From 7083fa3e351afab7c000cc7e7c5a001088d76af5 Mon Sep 17 00:00:00 2001 From: Wojciech Malikowski Date: Fri, 6 Sep 2019 05:29:54 -0400 Subject: [PATCH] lib/ftl: Remove group from ftl physical address ftl_ppa address do not need to expose group information when FTL will move to zones API. Change-Id: Iece1b32f9bcd8985260668c953089eb9951f13cc Signed-off-by: Wojciech Malikowski Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467603 Community-CI: SPDK CI Jenkins Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Reviewed-by: Mateusz Kozlowski Reviewed-by: Konrad Sztyber --- lib/ftl/ftl_band.c | 5 +---- lib/ftl/ftl_core.c | 4 ++-- lib/ftl/ftl_core.h | 16 ++++++++-------- lib/ftl/ftl_debug.h | 4 ++-- lib/ftl/ftl_init.c | 7 ++++--- lib/ftl/ftl_ppa.h | 3 +-- test/unit/lib/ftl/common/utils.c | 3 +-- test/unit/lib/ftl/ftl_band.c/ftl_band_ut.c | 3 +-- test/unit/lib/ftl/ftl_ppa/ftl_ppa_ut.c | 7 +------ test/unit/lib/ftl/ftl_reloc.c/ftl_reloc_ut.c | 3 +-- 10 files changed, 22 insertions(+), 33 deletions(-) diff --git a/lib/ftl/ftl_band.c b/lib/ftl/ftl_band.c index b8def6ce3..707ddaa2b 100644 --- a/lib/ftl/ftl_band.c +++ b/lib/ftl/ftl_band.c @@ -407,7 +407,6 @@ ftl_band_tail_md_ppa(struct ftl_band *band) ppa.lbk = (num_req / band->num_zones) * xfer_size; ppa.chk = band->id; ppa.pu = zone->punit->start_ppa.pu; - ppa.grp = zone->punit->start_ppa.grp; return ppa; } @@ -589,7 +588,6 @@ ftl_band_next_xfer_ppa(struct ftl_band *band, struct ftl_ppa ppa, size_t num_lbk zone = ftl_band_next_operational_zone(band, zone); assert(zone); - ppa.grp = zone->start_ppa.grp; ppa.pu = zone->start_ppa.pu; num_lbks -= dev->xfer_size; @@ -639,8 +637,7 @@ ftl_band_ppa_from_lbkoff(struct ftl_band *band, uint64_t lbkoff) ppa.lbk = lbkoff % ftl_dev_lbks_in_zone(dev); ppa.chk = band->id; - ppa.pu = punit / dev->geo.num_grp; - ppa.grp = punit % dev->geo.num_grp; + ppa.pu = punit; return ppa; } diff --git a/lib/ftl/ftl_core.c b/lib/ftl/ftl_core.c index 217a1a3c1..791c084f1 100644 --- a/lib/ftl/ftl_core.c +++ b/lib/ftl/ftl_core.c @@ -585,8 +585,8 @@ ftl_wptr_advance(struct ftl_wptr *wptr, size_t xfer_size) assert(!ftl_ppa_invalid(wptr->ppa)); - SPDK_DEBUGLOG(SPDK_LOG_FTL_CORE, "wptr: grp:%d, pu:%d zone:%d, lbk:%u\n", - wptr->ppa.grp, wptr->ppa.pu, wptr->ppa.chk, wptr->ppa.lbk); + SPDK_DEBUGLOG(SPDK_LOG_FTL_CORE, "wptr: pu:%d zone:%d, lbk:%u\n", + wptr->ppa.pu, wptr->ppa.chk, wptr->ppa.lbk); if (wptr->offset >= next_thld && !dev->next_band) { dev->next_band = ftl_next_write_band(dev); diff --git a/lib/ftl/ftl_core.h b/lib/ftl/ftl_core.h index 2b0dc41de..69651c35b 100644 --- a/lib/ftl/ftl_core.h +++ b/lib/ftl/ftl_core.h @@ -358,8 +358,8 @@ ftl_ppa_addr_pack(const struct spdk_ftl_dev *dev, struct ftl_ppa ppa) lbk = ppa.lbk; chk = ppa.chk; - pu = ppa.pu; - grp = ppa.grp; + pu = ppa.pu / dev->geo.num_grp; + grp = ppa.pu % dev->geo.num_grp; return (lbk << dev->ppaf.lbk_offset) | (chk << dev->ppaf.chk_offset) | @@ -371,11 +371,13 @@ static inline struct ftl_ppa ftl_ppa_addr_unpack(const struct spdk_ftl_dev *dev, uint64_t ppa) { struct ftl_ppa res = {}; + unsigned int pu, grp; res.lbk = (ppa >> dev->ppaf.lbk_offset) & dev->ppaf.lbk_mask; res.chk = (ppa >> dev->ppaf.chk_offset) & dev->ppaf.chk_mask; - res.pu = (ppa >> dev->ppaf.pu_offset) & dev->ppaf.pu_mask; - res.grp = (ppa >> dev->ppaf.grp_offset) & dev->ppaf.grp_mask; + pu = (ppa >> dev->ppaf.pu_offset) & dev->ppaf.pu_mask; + grp = (ppa >> dev->ppaf.grp_offset) & dev->ppaf.grp_mask; + res.pu = grp * dev->geo.num_pu + pu; return res; } @@ -417,15 +419,13 @@ ftl_ppa_from_packed(const struct spdk_ftl_dev *dev, struct ftl_ppa p) static inline unsigned int ftl_ppa_flatten_punit(const struct spdk_ftl_dev *dev, struct ftl_ppa ppa) { - return ppa.pu * dev->geo.num_grp + ppa.grp - dev->range.begin; + return ppa.pu - dev->range.begin; } static inline int ftl_ppa_in_range(const struct spdk_ftl_dev *dev, struct ftl_ppa ppa) { - unsigned int punit = ftl_ppa_flatten_punit(dev, ppa) + dev->range.begin; - - if (punit >= dev->range.begin && punit <= dev->range.end) { + if (ppa.pu >= dev->range.begin && ppa.pu <= dev->range.end) { return 1; } diff --git a/lib/ftl/ftl_debug.h b/lib/ftl/ftl_debug.h index 086f8040d..6feb15cf7 100644 --- a/lib/ftl/ftl_debug.h +++ b/lib/ftl/ftl_debug.h @@ -53,8 +53,8 @@ static inline const char * ftl_ppa2str(struct ftl_ppa ppa, char *buf, size_t size) { - snprintf(buf, size, "(grp: %u, pu: %u, chk: %u, lbk: %u)", - ppa.grp, ppa.pu, ppa.chk, ppa.lbk); + snprintf(buf, size, "(pu: %u, chk: %u, lbk: %u)", + ppa.pu, ppa.chk, ppa.lbk); return buf; } diff --git a/lib/ftl/ftl_init.c b/lib/ftl/ftl_init.c index fee88edbd..76e04d9e9 100644 --- a/lib/ftl/ftl_init.c +++ b/lib/ftl/ftl_init.c @@ -209,7 +209,9 @@ ftl_retrieve_chunk_info(struct spdk_ftl_dev *dev, struct ftl_ppa ppa, { volatile struct ftl_admin_cmpl cmpl = {}; uint32_t nsid = spdk_nvme_ns_get_id(dev->ns); - uint64_t offset = (ppa.grp * dev->geo.num_pu + ppa.pu) * + unsigned int grp = ppa.pu % dev->geo.num_grp; + unsigned int punit = ppa.pu / dev->geo.num_grp; + uint64_t offset = (grp * dev->geo.num_pu + punit) * dev->geo.num_chk + ppa.chk; int rc; @@ -411,8 +413,7 @@ ftl_dev_init_punits(struct spdk_ftl_dev *dev) punit = dev->range.begin + i; dev->punits[i].start_ppa.ppa = 0; - dev->punits[i].start_ppa.grp = punit % dev->geo.num_grp; - dev->punits[i].start_ppa.pu = punit / dev->geo.num_grp; + dev->punits[i].start_ppa.pu = punit; } return 0; diff --git a/lib/ftl/ftl_ppa.h b/lib/ftl/ftl_ppa.h index 6c620ab75..305f524e4 100644 --- a/lib/ftl/ftl_ppa.h +++ b/lib/ftl/ftl_ppa.h @@ -55,8 +55,7 @@ struct ftl_ppa { struct { uint64_t lbk : 32; uint64_t chk : 16; - uint64_t pu : 8; - uint64_t grp : 7; + uint64_t pu : 15; uint64_t rsvd : 1; }; diff --git a/test/unit/lib/ftl/common/utils.c b/test/unit/lib/ftl/common/utils.c index 76e7b0525..b6736476d 100644 --- a/test/unit/lib/ftl/common/utils.c +++ b/test/unit/lib/ftl/common/utils.c @@ -73,8 +73,7 @@ test_init_ftl_dev(const struct spdk_ocssd_geometry_data *geo, for (size_t i = 0; i < ftl_dev_num_punits(dev); ++i) { punit = range->begin + i; dev->punits[i].dev = dev; - dev->punits[i].start_ppa.grp = punit % geo->num_grp; - dev->punits[i].start_ppa.pu = punit / geo->num_grp; + dev->punits[i].start_ppa.pu = punit; } LIST_INIT(&dev->free_bands); diff --git a/test/unit/lib/ftl/ftl_band.c/ftl_band_ut.c b/test/unit/lib/ftl/ftl_band.c/ftl_band_ut.c index 61e400d03..2399f44a9 100644 --- a/test/unit/lib/ftl/ftl_band.c/ftl_band_ut.c +++ b/test/unit/lib/ftl/ftl_band.c/ftl_band_ut.c @@ -83,8 +83,7 @@ ppa_from_punit(uint64_t punit) { struct ftl_ppa ppa = {}; - ppa.grp = punit % g_geo.num_grp; - ppa.pu = punit / g_geo.num_grp; + ppa.pu = punit; return ppa; } diff --git a/test/unit/lib/ftl/ftl_ppa/ftl_ppa_ut.c b/test/unit/lib/ftl/ftl_ppa/ftl_ppa_ut.c index 96262cb49..6d651620a 100644 --- a/test/unit/lib/ftl/ftl_ppa/ftl_ppa_ut.c +++ b/test/unit/lib/ftl/ftl_ppa/ftl_ppa_ut.c @@ -51,6 +51,7 @@ test_alloc_dev(size_t size) dev->num_lbas = L2P_TABLE_SIZE; dev->l2p = calloc(L2P_TABLE_SIZE, size); + dev->geo.num_grp = 1; return dev; } @@ -120,7 +121,6 @@ test_ppa_pack32(void) orig.lbk = 4; orig.chk = 3; orig.pu = 2; - orig.grp = 1; ppa = ftl_ppa_to_packed(g_dev, orig); CU_ASSERT_TRUE(ppa.ppa <= UINT32_MAX); CU_ASSERT_FALSE(ppa.pack.cached); @@ -156,7 +156,6 @@ test_ppa_pack64(void) orig.lbk = 4; orig.chk = 3; orig.pu = 2; - orig.grp = 1; /* Check valid address transformation */ ppa.ppa = ftl_ppa_addr_pack(g_dev, orig); @@ -167,7 +166,6 @@ test_ppa_pack64(void) orig.lbk = 0x7ea0be0f; orig.chk = 0x6; orig.pu = 0x4; - orig.grp = 0x2; ppa.ppa = ftl_ppa_addr_pack(g_dev, orig); ppa = ftl_ppa_addr_unpack(g_dev, ppa.ppa); @@ -178,7 +176,6 @@ test_ppa_pack64(void) orig.lbk = 0x7fffffff; orig.chk = 0xf; orig.pu = 0x7; - orig.grp = 0x3; ppa.ppa = ftl_ppa_addr_pack(g_dev, orig); ppa = ftl_ppa_addr_unpack(g_dev, ppa.ppa); @@ -197,7 +194,6 @@ test_ppa_trans(void) ppa.lbk = i % (g_dev->ppaf.lbk_mask + 1); ppa.chk = i % (g_dev->ppaf.chk_mask + 1); ppa.pu = i % (g_dev->ppaf.pu_mask + 1); - ppa.grp = i % (g_dev->ppaf.grp_mask + 1); ftl_l2p_set(g_dev, i, ppa); } @@ -205,7 +201,6 @@ test_ppa_trans(void) orig.lbk = i % (g_dev->ppaf.lbk_mask + 1); orig.chk = i % (g_dev->ppaf.chk_mask + 1); orig.pu = i % (g_dev->ppaf.pu_mask + 1); - orig.grp = i % (g_dev->ppaf.grp_mask + 1); ppa = ftl_l2p_get(g_dev, i); CU_ASSERT_EQUAL(ppa.ppa, orig.ppa); } diff --git a/test/unit/lib/ftl/ftl_reloc.c/ftl_reloc_ut.c b/test/unit/lib/ftl/ftl_reloc.c/ftl_reloc_ut.c index 01c42b9d7..ca2644897 100644 --- a/test/unit/lib/ftl/ftl_reloc.c/ftl_reloc_ut.c +++ b/test/unit/lib/ftl/ftl_reloc.c/ftl_reloc_ut.c @@ -120,8 +120,7 @@ ftl_band_ppa_from_lbkoff(struct ftl_band *band, uint64_t lbkoff) ppa.lbk = lbkoff % ftl_dev_lbks_in_zone(dev); ppa.chk = band->id; - ppa.pu = punit / dev->geo.num_grp; - ppa.grp = punit % dev->geo.num_grp; + ppa.pu = punit; return ppa; }