lib/ftl: Rename ftl_dev_lbks_in_zone() to ftl_get_num_blocks_in_zone()
This patch is part of name refactoring associated with moving FTL to work with zone bdev API. Change-Id: I09f671a9c6539cc259c297514b24978587c9b392 Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479673 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
3725b4484a
commit
3ff9d6e45b
@ -481,7 +481,7 @@ ftl_band_age(const struct ftl_band *band)
|
||||
size_t
|
||||
ftl_band_num_usable_lbks(const struct ftl_band *band)
|
||||
{
|
||||
return band->num_zones * ftl_dev_lbks_in_zone(band->dev);
|
||||
return band->num_zones * ftl_get_num_blocks_in_zone(band->dev);
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -527,7 +527,7 @@ ftl_band_lbkoff_from_addr(struct ftl_band *band, struct ftl_addr addr)
|
||||
{
|
||||
assert(addr.zone_id == band->id);
|
||||
assert(addr.pu < ftl_dev_num_punits(band->dev));
|
||||
return addr.pu * ftl_dev_lbks_in_zone(band->dev) + addr.offset;
|
||||
return addr.pu * ftl_get_num_blocks_in_zone(band->dev) + addr.offset;
|
||||
}
|
||||
|
||||
struct ftl_addr
|
||||
@ -560,7 +560,7 @@ ftl_band_next_xfer_addr(struct ftl_band *band, struct ftl_addr addr, size_t num_
|
||||
addr.offset += num_stripes * dev->xfer_size;
|
||||
num_lbks -= num_stripes * dev->xfer_size * band->num_zones;
|
||||
|
||||
if (addr.offset > ftl_dev_lbks_in_zone(dev)) {
|
||||
if (addr.offset > ftl_get_num_blocks_in_zone(dev)) {
|
||||
return ftl_to_addr(FTL_ADDR_INVALID);
|
||||
}
|
||||
|
||||
@ -570,7 +570,7 @@ ftl_band_next_xfer_addr(struct ftl_band *band, struct ftl_addr addr, size_t num_
|
||||
/* needs to be increased by xfer_size */
|
||||
if (ftl_band_zone_is_last(band, zone)) {
|
||||
addr.offset += dev->xfer_size;
|
||||
if (addr.offset > ftl_dev_lbks_in_zone(dev)) {
|
||||
if (addr.offset > ftl_get_num_blocks_in_zone(dev)) {
|
||||
return ftl_to_addr(FTL_ADDR_INVALID);
|
||||
}
|
||||
}
|
||||
@ -584,7 +584,7 @@ ftl_band_next_xfer_addr(struct ftl_band *band, struct ftl_addr addr, size_t num_
|
||||
|
||||
if (num_lbks) {
|
||||
addr.offset += num_lbks;
|
||||
if (addr.offset > ftl_dev_lbks_in_zone(dev)) {
|
||||
if (addr.offset > ftl_get_num_blocks_in_zone(dev)) {
|
||||
return ftl_to_addr(FTL_ADDR_INVALID);
|
||||
}
|
||||
}
|
||||
@ -622,9 +622,9 @@ ftl_band_addr_from_lbkoff(struct ftl_band *band, uint64_t lbkoff)
|
||||
struct spdk_ftl_dev *dev = band->dev;
|
||||
uint64_t punit;
|
||||
|
||||
punit = lbkoff / ftl_dev_lbks_in_zone(dev);
|
||||
punit = lbkoff / ftl_get_num_blocks_in_zone(dev);
|
||||
|
||||
addr.offset = lbkoff % ftl_dev_lbks_in_zone(dev);
|
||||
addr.offset = lbkoff % ftl_get_num_blocks_in_zone(dev);
|
||||
addr.zone_id = band->id;
|
||||
addr.pu = punit;
|
||||
|
||||
|
@ -457,7 +457,7 @@ ftl_dev_num_bands(const struct spdk_ftl_dev *dev)
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
ftl_dev_lbks_in_zone(const struct spdk_ftl_dev *dev)
|
||||
ftl_get_num_blocks_in_zone(const struct spdk_ftl_dev *dev)
|
||||
{
|
||||
return dev->geo.clba;
|
||||
}
|
||||
@ -471,7 +471,7 @@ ftl_dev_num_punits(const struct spdk_ftl_dev *dev)
|
||||
static inline uint64_t
|
||||
ftl_get_num_blocks_in_band(const struct spdk_ftl_dev *dev)
|
||||
{
|
||||
return ftl_dev_num_punits(dev) * ftl_dev_lbks_in_zone(dev);
|
||||
return ftl_dev_num_punits(dev) * ftl_get_num_blocks_in_zone(dev);
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
|
@ -330,7 +330,7 @@ ftl_dev_init_bands(struct spdk_ftl_dev *dev)
|
||||
zone->state = ftl_get_zone_state(&info[j]);
|
||||
zone->start_addr.pu = i;
|
||||
zone->start_addr.zone_id = band->id;
|
||||
zone->write_offset = ftl_dev_lbks_in_zone(dev);
|
||||
zone->write_offset = ftl_get_num_blocks_in_zone(dev);
|
||||
|
||||
if (zone->state != SPDK_BDEV_ZONE_STATE_OFFLINE) {
|
||||
band->num_zones++;
|
||||
|
@ -170,7 +170,7 @@ ftl_reloc_iter_zone_offset(struct ftl_band_reloc *breloc)
|
||||
static size_t
|
||||
ftl_reloc_iter_zone_done(struct ftl_band_reloc *breloc)
|
||||
{
|
||||
size_t num_lbks = ftl_dev_lbks_in_zone(breloc->parent->dev);
|
||||
size_t num_lbks = ftl_get_num_blocks_in_zone(breloc->parent->dev);
|
||||
|
||||
return ftl_reloc_iter_zone_offset(breloc) == num_lbks;
|
||||
}
|
||||
@ -306,7 +306,7 @@ ftl_reloc_iter_reset(struct ftl_band_reloc *breloc)
|
||||
static size_t
|
||||
ftl_reloc_iter_lbkoff(struct ftl_band_reloc *breloc)
|
||||
{
|
||||
size_t zone_offset = breloc->iter.zone_current * ftl_dev_lbks_in_zone(breloc->parent->dev);
|
||||
size_t zone_offset = breloc->iter.zone_current * ftl_get_num_blocks_in_zone(breloc->parent->dev);
|
||||
|
||||
return breloc->iter.zone_offset[breloc->iter.zone_current] + zone_offset;
|
||||
}
|
||||
@ -353,7 +353,7 @@ ftl_reloc_iter_next(struct ftl_band_reloc *breloc, size_t *lbkoff)
|
||||
static int
|
||||
ftl_reloc_first_valid_lbk(struct ftl_band_reloc *breloc, size_t *lbkoff)
|
||||
{
|
||||
size_t i, num_lbks = ftl_dev_lbks_in_zone(breloc->parent->dev);
|
||||
size_t i, num_lbks = ftl_get_num_blocks_in_zone(breloc->parent->dev);
|
||||
|
||||
for (i = ftl_reloc_iter_zone_offset(breloc); i < num_lbks; ++i) {
|
||||
if (ftl_reloc_iter_next(breloc, lbkoff)) {
|
||||
@ -369,7 +369,7 @@ ftl_reloc_iter_done(struct ftl_band_reloc *breloc)
|
||||
{
|
||||
size_t i;
|
||||
size_t num_zones = ftl_dev_num_punits(breloc->band->dev);
|
||||
size_t num_lbks = ftl_dev_lbks_in_zone(breloc->parent->dev);
|
||||
size_t num_lbks = ftl_get_num_blocks_in_zone(breloc->parent->dev);
|
||||
|
||||
for (i = 0; i < num_zones; ++i) {
|
||||
if (breloc->iter.zone_offset[i] != num_lbks) {
|
||||
|
@ -137,5 +137,5 @@ test_offset_from_addr(struct ftl_addr addr, struct ftl_band *band)
|
||||
|
||||
CU_ASSERT_EQUAL(addr.zone_id, band->id);
|
||||
|
||||
return addr.pu * ftl_dev_lbks_in_zone(dev) + addr.offset;
|
||||
return addr.pu * ftl_get_num_blocks_in_zone(dev) + addr.offset;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ test_band_lbkoff_from_addr_base(void)
|
||||
addr.zone_id = TEST_BAND_IDX;
|
||||
|
||||
offset = ftl_band_lbkoff_from_addr(g_band, addr);
|
||||
CU_ASSERT_EQUAL(offset, flat_lun * ftl_dev_lbks_in_zone(g_dev));
|
||||
CU_ASSERT_EQUAL(offset, flat_lun * ftl_get_num_blocks_in_zone(g_dev));
|
||||
flat_lun++;
|
||||
}
|
||||
cleanup_band();
|
||||
|
@ -111,9 +111,9 @@ ftl_band_addr_from_lbkoff(struct ftl_band *band, uint64_t lbkoff)
|
||||
struct spdk_ftl_dev *dev = band->dev;
|
||||
uint64_t punit;
|
||||
|
||||
punit = lbkoff / ftl_dev_lbks_in_zone(dev);
|
||||
punit = lbkoff / ftl_get_num_blocks_in_zone(dev);
|
||||
|
||||
addr.offset = lbkoff % ftl_dev_lbks_in_zone(dev);
|
||||
addr.offset = lbkoff % ftl_get_num_blocks_in_zone(dev);
|
||||
addr.zone_id = band->id;
|
||||
addr.pu = punit;
|
||||
|
||||
@ -277,7 +277,7 @@ test_reloc_iter_full(void)
|
||||
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);
|
||||
(ftl_get_num_blocks_in_zone(dev) / reloc->xfer_size);
|
||||
|
||||
for (i = 0; i < num_iters; i++) {
|
||||
num_lbks = ftl_reloc_next_lbks(breloc, &addr);
|
||||
@ -290,7 +290,7 @@ test_reloc_iter_full(void)
|
||||
/* contiguous valid logic blocks in zone, so we can end up */
|
||||
/* with some reminder if number of logical blocks in zone */
|
||||
/* is not divisible by xfer_size */
|
||||
reminder = ftl_dev_lbks_in_zone(dev) % reloc->xfer_size;
|
||||
reminder = ftl_get_num_blocks_in_zone(dev) % reloc->xfer_size;
|
||||
for (i = 0; i < num_iters; i++) {
|
||||
num_lbks = ftl_reloc_next_lbks(breloc, &addr);
|
||||
CU_ASSERT_EQUAL(reminder, num_lbks);
|
||||
@ -422,19 +422,19 @@ test_reloc_zone(void)
|
||||
band->high_prio = 1;
|
||||
ftl_band_alloc_lba_map(band);
|
||||
num_io = MAX_RELOC_QDEPTH * reloc->xfer_size;
|
||||
num_iters = ftl_dev_lbks_in_zone(dev) / num_io;
|
||||
num_iters = ftl_get_num_blocks_in_zone(dev) / num_io;
|
||||
|
||||
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);
|
||||
ftl_reloc_add(reloc, band, ftl_get_num_blocks_in_zone(dev) * 3,
|
||||
ftl_get_num_blocks_in_zone(dev), 1, false);
|
||||
add_to_active_queue(reloc, breloc);
|
||||
|
||||
CU_ASSERT_EQUAL(breloc->num_lbks, ftl_dev_lbks_in_zone(dev));
|
||||
CU_ASSERT_EQUAL(breloc->num_lbks, ftl_get_num_blocks_in_zone(dev));
|
||||
|
||||
for (i = 1; i <= num_iters ; ++i) {
|
||||
single_reloc_move(breloc);
|
||||
num_lbk = ftl_dev_lbks_in_zone(dev) - (i * num_io);
|
||||
num_lbk = ftl_get_num_blocks_in_zone(dev) - (i * num_io);
|
||||
|
||||
CU_ASSERT_EQUAL(breloc->num_lbks, num_lbk);
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ test_wptr(void)
|
||||
io.band = band;
|
||||
io.dev = dev;
|
||||
|
||||
for (lbk = 0, offset = 0; lbk < ftl_dev_lbks_in_zone(dev) / xfer_size; ++lbk) {
|
||||
for (lbk = 0, offset = 0; lbk < ftl_get_num_blocks_in_zone(dev) / xfer_size; ++lbk) {
|
||||
for (zone = 0; zone < band->num_zones; ++zone) {
|
||||
CU_ASSERT_EQUAL(wptr->addr.offset, (lbk * xfer_size));
|
||||
CU_ASSERT_EQUAL(wptr->offset, offset);
|
||||
@ -166,7 +166,7 @@ test_wptr(void)
|
||||
}
|
||||
|
||||
CU_ASSERT_EQUAL(band->state, FTL_BAND_STATE_FULL);
|
||||
CU_ASSERT_EQUAL(wptr->addr.offset, ftl_dev_lbks_in_zone(dev));
|
||||
CU_ASSERT_EQUAL(wptr->addr.offset, ftl_get_num_blocks_in_zone(dev));
|
||||
|
||||
ftl_band_set_state(band, FTL_BAND_STATE_CLOSING);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user