lib/ftl: Rename ftl_num_band_lbks() to ftl_get_num_blocks_in_band()
This patch is part of name refactoring associated with moving FTL to work with zone bdev API. Change-Id: I09781323b2ee25dbcee61eecf95ce7eca703ab93 Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479672 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
This commit is contained in:
parent
2ff623b504
commit
3725b4484a
@ -101,7 +101,7 @@ ftl_vld_map_num_lbks(const struct spdk_ftl_dev *dev)
|
||||
size_t
|
||||
ftl_lba_map_num_lbks(const struct spdk_ftl_dev *dev)
|
||||
{
|
||||
return spdk_divide_round_up(ftl_num_band_lbks(dev) * sizeof(uint64_t), FTL_BLOCK_SIZE);
|
||||
return spdk_divide_round_up(ftl_get_num_blocks_in_band(dev) * sizeof(uint64_t), FTL_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -139,7 +139,7 @@ ftl_band_write_failed(struct ftl_band *band)
|
||||
|
||||
band->high_prio = 1;
|
||||
|
||||
ftl_reloc_add(dev->reloc, band, 0, ftl_num_band_lbks(dev), 1, true);
|
||||
ftl_reloc_add(dev->reloc, band, 0, ftl_get_num_blocks_in_band(dev), 1, true);
|
||||
ftl_band_set_state(band, FTL_BAND_STATE_CLOSED);
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ ftl_pack_tail_md(struct ftl_band *band)
|
||||
|
||||
/* Clear out the buffer */
|
||||
memset(tail, 0, ftl_tail_md_hdr_num_lbks() * FTL_BLOCK_SIZE);
|
||||
tail->num_lbks = ftl_num_band_lbks(dev);
|
||||
tail->num_lbks = ftl_get_num_blocks_in_band(dev);
|
||||
|
||||
pthread_spin_lock(&lba_map->lock);
|
||||
spdk_bit_array_store_mask(lba_map->vld, vld_offset);
|
||||
@ -343,7 +343,7 @@ ftl_unpack_tail_md(struct ftl_band *band)
|
||||
return FTL_MD_NO_MD;
|
||||
}
|
||||
|
||||
if (tail->num_lbks != ftl_num_band_lbks(dev)) {
|
||||
if (tail->num_lbks != ftl_get_num_blocks_in_band(dev)) {
|
||||
return FTL_MD_INVALID_SIZE;
|
||||
}
|
||||
|
||||
@ -1147,7 +1147,7 @@ ftl_band_clear_lba_map(struct ftl_band *band)
|
||||
|
||||
/* For open band all lba map segments are already cached */
|
||||
assert(band->state == FTL_BAND_STATE_PREP);
|
||||
num_segments = spdk_divide_round_up(ftl_num_band_lbks(band->dev), FTL_NUM_LBA_IN_BLOCK);
|
||||
num_segments = spdk_divide_round_up(ftl_get_num_blocks_in_band(band->dev), FTL_NUM_LBA_IN_BLOCK);
|
||||
ftl_lba_map_set_segment_state(&band->lba_map, 0, num_segments, FTL_LBA_MAP_SEG_CACHED);
|
||||
|
||||
lba_map->num_vld = 0;
|
||||
@ -1158,5 +1158,5 @@ ftl_lba_map_pool_elem_size(struct spdk_ftl_dev *dev)
|
||||
{
|
||||
/* Map pool element holds the whole tail md + segments map */
|
||||
return ftl_tail_md_num_lbks(dev) * FTL_BLOCK_SIZE +
|
||||
spdk_divide_round_up(ftl_num_band_lbks(dev), FTL_NUM_LBA_IN_BLOCK);
|
||||
spdk_divide_round_up(ftl_get_num_blocks_in_band(dev), FTL_NUM_LBA_IN_BLOCK);
|
||||
}
|
||||
|
@ -1866,7 +1866,7 @@ ftl_process_relocs(struct spdk_ftl_dev *dev)
|
||||
if (ftl_dev_needs_defrag(dev)) {
|
||||
band = ftl_select_defrag_band(dev);
|
||||
if (band) {
|
||||
ftl_reloc_add(dev->reloc, band, 0, ftl_num_band_lbks(dev), 0, true);
|
||||
ftl_reloc_add(dev->reloc, band, 0, ftl_get_num_blocks_in_band(dev), 0, true);
|
||||
ftl_trace_defrag_band(dev, band);
|
||||
}
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ ftl_dev_num_punits(const struct spdk_ftl_dev *dev)
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
ftl_num_band_lbks(const struct spdk_ftl_dev *dev)
|
||||
ftl_get_num_blocks_in_band(const struct spdk_ftl_dev *dev)
|
||||
{
|
||||
return ftl_dev_num_punits(dev) * ftl_dev_lbks_in_zone(dev);
|
||||
}
|
||||
@ -477,7 +477,7 @@ ftl_num_band_lbks(const struct spdk_ftl_dev *dev)
|
||||
static inline size_t
|
||||
ftl_vld_map_size(const struct spdk_ftl_dev *dev)
|
||||
{
|
||||
return (size_t)spdk_divide_round_up(ftl_num_band_lbks(dev), CHAR_BIT);
|
||||
return (size_t)spdk_divide_round_up(ftl_get_num_blocks_in_band(dev), CHAR_BIT);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
|
@ -59,7 +59,7 @@ ftl_band_validate_md(struct ftl_band *band)
|
||||
size_t i, size, seg_off;
|
||||
bool valid = true;
|
||||
|
||||
size = ftl_num_band_lbks(dev);
|
||||
size = ftl_get_num_blocks_in_band(dev);
|
||||
|
||||
pthread_spin_lock(&lba_map->lock);
|
||||
for (i = 0; i < size; ++i) {
|
||||
|
@ -119,7 +119,7 @@ ftl_band_init_md(struct ftl_band *band)
|
||||
{
|
||||
struct ftl_lba_map *lba_map = &band->lba_map;
|
||||
|
||||
lba_map->vld = spdk_bit_array_create(ftl_num_band_lbks(band->dev));
|
||||
lba_map->vld = spdk_bit_array_create(ftl_get_num_blocks_in_band(band->dev));
|
||||
if (!lba_map->vld) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -474,10 +474,10 @@ ftl_dev_init_nv_cache(struct spdk_ftl_dev *dev, struct spdk_bdev_desc *bdev_desc
|
||||
* inside the cache can be overwritten, the band it's stored on has to be closed. Plus one
|
||||
* extra block is needed to store the header.
|
||||
*/
|
||||
if (spdk_bdev_get_num_blocks(bdev) < ftl_num_band_lbks(dev) * 2 + 1) {
|
||||
if (spdk_bdev_get_num_blocks(bdev) < ftl_get_num_blocks_in_band(dev) * 2 + 1) {
|
||||
SPDK_ERRLOG("Insufficient number of blocks for write buffer cache (available: %"
|
||||
PRIu64", required: %"PRIu64")\n", spdk_bdev_get_num_blocks(bdev),
|
||||
ftl_num_band_lbks(dev) * 2 + 1);
|
||||
ftl_get_num_blocks_in_band(dev) * 2 + 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -529,7 +529,7 @@ ftl_lba_map_request_ctor(struct spdk_mempool *mp, void *opaque, void *obj, unsig
|
||||
struct spdk_ftl_dev *dev = opaque;
|
||||
|
||||
request->segments = spdk_bit_array_create(spdk_divide_round_up(
|
||||
ftl_num_band_lbks(dev), FTL_NUM_LBA_IN_BLOCK));
|
||||
ftl_get_num_blocks_in_band(dev), FTL_NUM_LBA_IN_BLOCK));
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -611,7 +611,7 @@ ftl_band_reloc_init(struct ftl_reloc *reloc, struct ftl_band_reloc *breloc,
|
||||
breloc->band = band;
|
||||
breloc->parent = reloc;
|
||||
|
||||
breloc->reloc_map = spdk_bit_array_create(ftl_num_band_lbks(reloc->dev));
|
||||
breloc->reloc_map = spdk_bit_array_create(ftl_get_num_blocks_in_band(reloc->dev));
|
||||
if (!breloc->reloc_map) {
|
||||
SPDK_ERRLOG("Failed to initialize reloc map");
|
||||
return -1;
|
||||
@ -822,7 +822,7 @@ ftl_reloc_add(struct ftl_reloc *reloc, struct ftl_band *band, size_t offset,
|
||||
|
||||
/* If the band is coming from the defrag process, mark it appropriately */
|
||||
if (is_defrag) {
|
||||
assert(offset == 0 && num_lbks == ftl_num_band_lbks(band->dev));
|
||||
assert(offset == 0 && num_lbks == ftl_get_num_blocks_in_band(band->dev));
|
||||
reloc->num_defrag_bands++;
|
||||
breloc->defrag = true;
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ ftl_restore_l2p(struct ftl_band *band)
|
||||
uint64_t lba;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < ftl_num_band_lbks(band->dev); ++i) {
|
||||
for (i = 0; i < ftl_get_num_blocks_in_band(band->dev); ++i) {
|
||||
if (!spdk_bit_array_get(band->lba_map.vld, i)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ test_init_ftl_band(struct spdk_ftl_dev *dev, size_t id)
|
||||
LIST_INSERT_HEAD(&dev->shut_bands, band, list_entry);
|
||||
CIRCLEQ_INIT(&band->zones);
|
||||
|
||||
band->lba_map.vld = spdk_bit_array_create(ftl_num_band_lbks(dev));
|
||||
band->lba_map.vld = spdk_bit_array_create(ftl_get_num_blocks_in_band(dev));
|
||||
SPDK_CU_ASSERT_FATAL(band->lba_map.vld != NULL);
|
||||
|
||||
band->zone_buf = calloc(ftl_dev_num_punits(dev), sizeof(*band->zone_buf));
|
||||
|
@ -87,7 +87,7 @@ ftl_band_acquire_lba_map(struct ftl_band *band)
|
||||
size_t
|
||||
ftl_lba_map_num_lbks(const struct spdk_ftl_dev *dev)
|
||||
{
|
||||
return spdk_divide_round_up(ftl_num_band_lbks(dev) * sizeof(uint64_t), FTL_BLOCK_SIZE);
|
||||
return spdk_divide_round_up(ftl_get_num_blocks_in_band(dev) * sizeof(uint64_t), FTL_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
int
|
||||
@ -270,11 +270,11 @@ test_reloc_iter_full(void)
|
||||
breloc = &reloc->brelocs[0];
|
||||
band = breloc->band;
|
||||
|
||||
set_band_valid_map(band, 0, ftl_num_band_lbks(dev));
|
||||
set_band_valid_map(band, 0, ftl_get_num_blocks_in_band(dev));
|
||||
|
||||
ftl_reloc_add(reloc, band, 0, ftl_num_band_lbks(dev), 0, true);
|
||||
ftl_reloc_add(reloc, band, 0, ftl_get_num_blocks_in_band(dev), 0, true);
|
||||
|
||||
CU_ASSERT_EQUAL(breloc->num_lbks, ftl_num_band_lbks(dev));
|
||||
CU_ASSERT_EQUAL(breloc->num_lbks, ftl_get_num_blocks_in_band(dev));
|
||||
|
||||
num_iters = ftl_dev_num_punits(dev) *
|
||||
(ftl_dev_lbks_in_zone(dev) / reloc->xfer_size);
|
||||
@ -297,7 +297,7 @@ test_reloc_iter_full(void)
|
||||
}
|
||||
|
||||
/* num_lbks should remain intact since all the blocks are valid */
|
||||
CU_ASSERT_EQUAL(breloc->num_lbks, ftl_num_band_lbks(dev));
|
||||
CU_ASSERT_EQUAL(breloc->num_lbks, ftl_get_num_blocks_in_band(dev));
|
||||
breloc->state = FTL_BAND_RELOC_STATE_INACTIVE;
|
||||
|
||||
cleanup_reloc(dev, reloc);
|
||||
@ -316,7 +316,7 @@ test_reloc_empty_band(void)
|
||||
breloc = &reloc->brelocs[0];
|
||||
band = breloc->band;
|
||||
|
||||
ftl_reloc_add(reloc, band, 0, ftl_num_band_lbks(dev), 0, true);
|
||||
ftl_reloc_add(reloc, band, 0, ftl_get_num_blocks_in_band(dev), 0, true);
|
||||
|
||||
CU_ASSERT_EQUAL(breloc->num_lbks, 0);
|
||||
|
||||
@ -337,20 +337,20 @@ test_reloc_full_band(void)
|
||||
breloc = &reloc->brelocs[0];
|
||||
band = breloc->band;
|
||||
num_moves = MAX_RELOC_QDEPTH * reloc->xfer_size;
|
||||
num_iters = ftl_num_band_lbks(dev) / num_moves;
|
||||
num_iters = ftl_get_num_blocks_in_band(dev) / num_moves;
|
||||
|
||||
set_band_valid_map(band, 0, ftl_num_band_lbks(dev));
|
||||
set_band_valid_map(band, 0, ftl_get_num_blocks_in_band(dev));
|
||||
|
||||
ftl_reloc_add(reloc, band, 0, ftl_num_band_lbks(dev), 0, true);
|
||||
ftl_reloc_add(reloc, band, 0, ftl_get_num_blocks_in_band(dev), 0, true);
|
||||
|
||||
CU_ASSERT_EQUAL(breloc->num_lbks, ftl_num_band_lbks(dev));
|
||||
CU_ASSERT_EQUAL(breloc->num_lbks, ftl_get_num_blocks_in_band(dev));
|
||||
|
||||
ftl_reloc_prep(breloc);
|
||||
add_to_active_queue(reloc, breloc);
|
||||
|
||||
for (i = 1; i <= num_iters; ++i) {
|
||||
single_reloc_move(breloc);
|
||||
num_lbk = ftl_num_band_lbks(dev) - (i * num_moves);
|
||||
num_lbk = ftl_get_num_blocks_in_band(dev) - (i * num_moves);
|
||||
CU_ASSERT_EQUAL(breloc->num_lbks, num_lbk);
|
||||
|
||||
}
|
||||
@ -380,19 +380,19 @@ test_reloc_scatter_band(void)
|
||||
|
||||
breloc = &reloc->brelocs[0];
|
||||
band = breloc->band;
|
||||
num_iters = spdk_divide_round_up(ftl_num_band_lbks(dev), MAX_RELOC_QDEPTH * 2);
|
||||
num_iters = spdk_divide_round_up(ftl_get_num_blocks_in_band(dev), MAX_RELOC_QDEPTH * 2);
|
||||
|
||||
for (i = 0; i < ftl_num_band_lbks(dev); ++i) {
|
||||
for (i = 0; i < ftl_get_num_blocks_in_band(dev); ++i) {
|
||||
if (i % 2) {
|
||||
set_band_valid_map(band, i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
ftl_reloc_add(reloc, band, 0, ftl_num_band_lbks(dev), 0, true);
|
||||
ftl_reloc_add(reloc, band, 0, ftl_get_num_blocks_in_band(dev), 0, true);
|
||||
ftl_reloc_prep(breloc);
|
||||
add_to_active_queue(reloc, breloc);
|
||||
|
||||
CU_ASSERT_EQUAL(breloc->num_lbks, ftl_num_band_lbks(dev));
|
||||
CU_ASSERT_EQUAL(breloc->num_lbks, ftl_get_num_blocks_in_band(dev));
|
||||
|
||||
for (i = 0; i < num_iters ; ++i) {
|
||||
single_reloc_move(breloc);
|
||||
@ -424,7 +424,7 @@ test_reloc_zone(void)
|
||||
num_io = MAX_RELOC_QDEPTH * reloc->xfer_size;
|
||||
num_iters = ftl_dev_lbks_in_zone(dev) / num_io;
|
||||
|
||||
set_band_valid_map(band, 0, ftl_num_band_lbks(dev));
|
||||
set_band_valid_map(band, 0, ftl_get_num_blocks_in_band(dev));
|
||||
|
||||
ftl_reloc_add(reloc, band, ftl_dev_lbks_in_zone(dev) * 3,
|
||||
ftl_dev_lbks_in_zone(dev), 1, false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user