lib/ftl: Keep DMA buffer for metadata as part of ftl_md structure
This patch is starting point for metadata refactor which is needed for efficient ANM events support. Change-Id: I81d864605e69008d8e3922fb61adf504187447a1 Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449328 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
9b025e17b3
commit
dd54dff78b
@ -174,7 +174,9 @@ ftl_band_free_md(struct ftl_band *band)
|
|||||||
}
|
}
|
||||||
|
|
||||||
spdk_mempool_put(dev->lba_pool, md->lba_map);
|
spdk_mempool_put(dev->lba_pool, md->lba_map);
|
||||||
|
spdk_dma_free(md->dma_buf);
|
||||||
md->lba_map = NULL;
|
md->lba_map = NULL;
|
||||||
|
md->dma_buf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -660,6 +662,13 @@ ftl_band_alloc_md(struct ftl_band *band)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
md->dma_buf = spdk_dma_zmalloc(ftl_tail_md_num_lbks(dev) * FTL_BLOCK_SIZE,
|
||||||
|
FTL_BLOCK_SIZE, NULL);
|
||||||
|
if (!md->dma_buf) {
|
||||||
|
spdk_mempool_put(dev->lba_pool, md->lba_map);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ftl_band_acquire_md(band);
|
ftl_band_acquire_md(band);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -100,8 +100,11 @@ struct ftl_md {
|
|||||||
/* Bitmap of valid LBAs */
|
/* Bitmap of valid LBAs */
|
||||||
struct spdk_bit_array *vld_map;
|
struct spdk_bit_array *vld_map;
|
||||||
|
|
||||||
/* LBA map (only valid for open bands) */
|
/* LBA map (only valid for open/relocating bands) */
|
||||||
uint64_t *lba_map;
|
uint64_t *lba_map;
|
||||||
|
|
||||||
|
/* Metadata DMA buffer (only valid for open/relocating bands) */
|
||||||
|
void *dma_buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ftl_band_state {
|
enum ftl_band_state {
|
||||||
|
@ -66,9 +66,6 @@ struct ftl_wptr {
|
|||||||
/* Current erase block */
|
/* Current erase block */
|
||||||
struct ftl_chunk *chunk;
|
struct ftl_chunk *chunk;
|
||||||
|
|
||||||
/* Metadata DMA buffer */
|
|
||||||
void *md_buf;
|
|
||||||
|
|
||||||
/* List link */
|
/* List link */
|
||||||
LIST_ENTRY(ftl_wptr) list_entry;
|
LIST_ENTRY(ftl_wptr) list_entry;
|
||||||
};
|
};
|
||||||
@ -114,7 +111,6 @@ ftl_wptr_free(struct ftl_wptr *wptr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
spdk_dma_free(wptr->md_buf);
|
|
||||||
free(wptr);
|
free(wptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,7 +249,7 @@ ftl_wptr_close_band(struct ftl_wptr *wptr)
|
|||||||
ftl_band_set_state(band, FTL_BAND_STATE_CLOSING);
|
ftl_band_set_state(band, FTL_BAND_STATE_CLOSING);
|
||||||
band->tail_md_ppa = wptr->ppa;
|
band->tail_md_ppa = wptr->ppa;
|
||||||
|
|
||||||
return ftl_band_write_tail_md(band, wptr->md_buf, ftl_md_write_cb);
|
return ftl_band_write_tail_md(band, band->md.dma_buf, ftl_md_write_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -269,7 +265,7 @@ ftl_wptr_open_band(struct ftl_wptr *wptr)
|
|||||||
assert(band->state == FTL_BAND_STATE_PREP);
|
assert(band->state == FTL_BAND_STATE_PREP);
|
||||||
ftl_band_set_state(band, FTL_BAND_STATE_OPENING);
|
ftl_band_set_state(band, FTL_BAND_STATE_OPENING);
|
||||||
|
|
||||||
return ftl_band_write_head_md(band, wptr->md_buf, ftl_md_write_cb);
|
return ftl_band_write_head_md(band, band->md.dma_buf, ftl_md_write_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -390,13 +386,6 @@ ftl_wptr_init(struct ftl_band *band)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wptr->md_buf = spdk_dma_zmalloc(ftl_tail_md_num_lbks(dev) * FTL_BLOCK_SIZE,
|
|
||||||
FTL_BLOCK_SIZE, NULL);
|
|
||||||
if (!wptr->md_buf) {
|
|
||||||
ftl_wptr_free(wptr);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wptr->dev = dev;
|
wptr->dev = dev;
|
||||||
wptr->band = band;
|
wptr->band = band;
|
||||||
wptr->chunk = CIRCLEQ_FIRST(&band->chunks);
|
wptr->chunk = CIRCLEQ_FIRST(&band->chunks);
|
||||||
|
@ -77,9 +77,6 @@ struct ftl_band_reloc {
|
|||||||
struct spdk_ring *write_queue;
|
struct spdk_ring *write_queue;
|
||||||
|
|
||||||
TAILQ_ENTRY(ftl_band_reloc) entry;
|
TAILQ_ENTRY(ftl_band_reloc) entry;
|
||||||
|
|
||||||
/* TODO: get rid of md_buf */
|
|
||||||
void *md_buf;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ftl_reloc {
|
struct ftl_reloc {
|
||||||
@ -172,7 +169,6 @@ ftl_reloc_read_lba_map_cb(void *arg, int status)
|
|||||||
struct ftl_band_reloc *breloc = ftl_io_get_band_reloc(io);
|
struct ftl_band_reloc *breloc = ftl_io_get_band_reloc(io);
|
||||||
|
|
||||||
assert(status == 0);
|
assert(status == 0);
|
||||||
spdk_dma_free(breloc->md_buf);
|
|
||||||
ftl_io_free(io);
|
ftl_io_free(io);
|
||||||
_ftl_reloc_prep(breloc);
|
_ftl_reloc_prep(breloc);
|
||||||
}
|
}
|
||||||
@ -189,17 +185,11 @@ ftl_reloc_read_lba_map(struct ftl_band_reloc *breloc)
|
|||||||
io->cb.ctx = io;
|
io->cb.ctx = io;
|
||||||
io->cb.fn = ftl_reloc_read_lba_map_cb;
|
io->cb.fn = ftl_reloc_read_lba_map_cb;
|
||||||
|
|
||||||
breloc->md_buf = spdk_dma_zmalloc(ftl_lba_map_num_lbks(dev) * FTL_BLOCK_SIZE,
|
|
||||||
FTL_BLOCK_SIZE, NULL);
|
|
||||||
if (!breloc->md_buf) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ftl_band_alloc_md(band)) {
|
if (ftl_band_alloc_md(band)) {
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ftl_band_read_lba_map(band, &band->md, breloc->md_buf, &io->cb);
|
return ftl_band_read_lba_map(band, &band->md, band->md.dma_buf, &io->cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -133,6 +133,7 @@ test_free_ftl_band(struct ftl_band *band)
|
|||||||
spdk_bit_array_free(&band->md.vld_map);
|
spdk_bit_array_free(&band->md.vld_map);
|
||||||
free(band->chunk_buf);
|
free(band->chunk_buf);
|
||||||
free(band->md.lba_map);
|
free(band->md.lba_map);
|
||||||
|
spdk_dma_free(band->md.dma_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
|
@ -63,7 +63,7 @@ setup_band(struct ftl_band **band, const struct spdk_ocssd_geometry_data *geo,
|
|||||||
dev = test_init_ftl_dev(geo, range);
|
dev = test_init_ftl_dev(geo, range);
|
||||||
*band = test_init_ftl_band(dev, 0);
|
*band = test_init_ftl_band(dev, 0);
|
||||||
rc = ftl_band_alloc_md(*band);
|
rc = ftl_band_alloc_md(*band);
|
||||||
CU_ASSERT_EQUAL_FATAL(rc, 0);
|
SPDK_CU_ASSERT_FATAL(rc == 0);
|
||||||
ftl_band_clear_md(*band);
|
ftl_band_clear_md(*band);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user