lightnvm: pblk: delete redundant buffer pointer
authorJavier González <jg@lightnvm.io>
Mon, 26 Jun 2017 09:57:19 +0000 (11:57 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 26 Jun 2017 22:27:39 +0000 (16:27 -0600)
After refactoring the metadata path, the backpointer controlling
synced I/Os in a line becomes unnecessary; metadata is scheduled
on the write thread, thus we know when the end of the line is reached
and act on it directly.

Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/lightnvm/pblk-core.c
drivers/lightnvm/pblk-init.c
drivers/lightnvm/pblk-map.c
drivers/lightnvm/pblk-recovery.c
drivers/lightnvm/pblk-sysfs.c
drivers/lightnvm/pblk-write.c
drivers/lightnvm/pblk.h

index 6e4b06f841e71db1972b20bca36815ea889b2bc4..beae1618483fd71fc82a4c85be36e1dff644802d 100644 (file)
@@ -65,8 +65,8 @@ static void pblk_end_io_erase(struct nvm_rq *rqd)
        mempool_free(rqd, pblk->g_rq_pool);
 }
 
-static void __pblk_map_invalidate(struct pblk *pblk, struct pblk_line *line,
-                                 u64 paddr)
+void __pblk_map_invalidate(struct pblk *pblk, struct pblk_line *line,
+                          u64 paddr)
 {
        struct pblk_line_mgmt *l_mg = &pblk->l_mg;
        struct list_head *move_list = NULL;
@@ -129,18 +129,6 @@ void pblk_map_invalidate(struct pblk *pblk, struct ppa_addr ppa)
        __pblk_map_invalidate(pblk, line, paddr);
 }
 
-void pblk_map_pad_invalidate(struct pblk *pblk, struct pblk_line *line,
-                            u64 paddr)
-{
-       __pblk_map_invalidate(pblk, line, paddr);
-
-       pblk_rb_sync_init(&pblk->rwb, NULL);
-       line->left_ssecs--;
-       if (!line->left_ssecs)
-               pblk_line_run_ws(pblk, line, NULL, pblk_line_close_ws);
-       pblk_rb_sync_end(&pblk->rwb, NULL);
-}
-
 static void pblk_invalidate_range(struct pblk *pblk, sector_t slba,
                                  unsigned int nr_secs)
 {
@@ -1057,7 +1045,7 @@ retry_smeta:
        line->sec_in_line -= lm->emeta_sec[0];
        line->emeta_ssec = off;
        line->nr_valid_lbas = 0;
-       line->left_ssecs = line->left_msecs = line->sec_in_line;
+       line->left_msecs = line->sec_in_line;
        *line->vsc = cpu_to_le32(line->sec_in_line);
 
        if (lm->sec_per_line - line->sec_in_line !=
index 54e03c3e79621e28174e5b890026aaca08a18324..cd10f2d74cf9fada3966df065ae70fb3c1ef2a56 100644 (file)
@@ -890,7 +890,6 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
        atomic_long_set(&pblk->req_writes, 0);
        atomic_long_set(&pblk->sub_writes, 0);
        atomic_long_set(&pblk->sync_writes, 0);
-       atomic_long_set(&pblk->compl_writes, 0);
        atomic_long_set(&pblk->inflight_reads, 0);
        atomic_long_set(&pblk->cache_reads, 0);
        atomic_long_set(&pblk->sync_reads, 0);
index 08580a649499ff376a658eeb29480e348558a288..9942d9bc7b3a5efd432ee99931147c1c64440746 100644 (file)
@@ -56,7 +56,7 @@ static void pblk_map_page_data(struct pblk *pblk, unsigned int sentry,
                        u64 addr_empty = cpu_to_le64(ADDR_EMPTY);
 
                        lba_list[paddr] = meta_list[i].lba = addr_empty;
-                       pblk_map_pad_invalidate(pblk, line, paddr);
+                       __pblk_map_invalidate(pblk, line, paddr);
                }
        }
 
index ba02d0bc3e459b68e79a2daf6eb7e92bdaeee24a..7b0ace2f49574b718b4ecb4873fb64fd49660603 100644 (file)
@@ -553,7 +553,6 @@ next_rq:
                if (ret)
                        pr_err("pblk: OOB read failed (err:%d)\n", ret);
 
-               line->left_ssecs = line->left_msecs;
                left_ppas = 0;
        }
 
@@ -659,7 +658,6 @@ next_rq:
                /* Roll back failed sectors */
                line->cur_sec -= nr_error_bits;
                line->left_msecs += nr_error_bits;
-               line->left_ssecs = line->left_msecs;
                bitmap_clear(line->map_bitmap, line->cur_sec, nr_error_bits);
 
                left_ppas = 0;
index 3d9a77646a3d881a7688a7b9e61932539739474d..e1e92c9498a92fde53c7d5baf999e9966d37f752 100644 (file)
@@ -154,7 +154,7 @@ static ssize_t pblk_sysfs_lines(struct pblk *pblk, char *page)
        int d_line_cnt = 0, l_line_cnt = 0;
        int gc_full = 0, gc_high = 0, gc_mid = 0, gc_low = 0, gc_empty = 0;
        int bad = 0, cor = 0;
-       int msecs = 0, ssecs = 0, cur_sec = 0, vsc = 0, sec_in_line = 0;
+       int msecs = 0, cur_sec = 0, vsc = 0, sec_in_line = 0;
        int map_weight = 0, meta_weight = 0;
 
        spin_lock(&l_mg->free_lock);
@@ -227,7 +227,6 @@ static ssize_t pblk_sysfs_lines(struct pblk *pblk, char *page)
        if (l_mg->data_line) {
                cur_sec = l_mg->data_line->cur_sec;
                msecs = l_mg->data_line->left_msecs;
-               ssecs = l_mg->data_line->left_ssecs;
                vsc = le32_to_cpu(*l_mg->data_line->vsc);
                sec_in_line = l_mg->data_line->sec_in_line;
                meta_weight = bitmap_weight(&l_mg->meta_bitmap,
@@ -259,8 +258,8 @@ static ssize_t pblk_sysfs_lines(struct pblk *pblk, char *page)
                        atomic_read(&pblk->gc.inflight_gc));
 
        sz += snprintf(page + sz, PAGE_SIZE - sz,
-               "data (%d) cur:%d, left:%d/%d, vsc:%d, s:%d, map:%d/%d (%d)\n",
-                       cur_data, cur_sec, msecs, ssecs, vsc, sec_in_line,
+               "data (%d) cur:%d, left:%d, vsc:%d, s:%d, map:%d/%d (%d)\n",
+                       cur_data, cur_sec, msecs, vsc, sec_in_line,
                        map_weight, lm->sec_per_line, meta_weight);
 
        return sz;
@@ -303,7 +302,7 @@ static ssize_t pblk_sysfs_get_sec_per_write(struct pblk *pblk, char *page)
 static ssize_t pblk_sysfs_stats_debug(struct pblk *pblk, char *page)
 {
        return snprintf(page, PAGE_SIZE,
-               "%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\n",
+               "%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\n",
                        atomic_long_read(&pblk->inflight_writes),
                        atomic_long_read(&pblk->inflight_reads),
                        atomic_long_read(&pblk->req_writes),
@@ -312,7 +311,6 @@ static ssize_t pblk_sysfs_stats_debug(struct pblk *pblk, char *page)
                        atomic_long_read(&pblk->padded_wb),
                        atomic_long_read(&pblk->sub_writes),
                        atomic_long_read(&pblk->sync_writes),
-                       atomic_long_read(&pblk->compl_writes),
                        atomic_long_read(&pblk->recov_writes),
                        atomic_long_read(&pblk->recov_gc_writes),
                        atomic_long_read(&pblk->recov_gc_reads),
index 1739c970692ea7f3b1273fee9663a79f8f8203a7..a29a34786ac564a62c1441bfe36fe9d1060576a1 100644 (file)
 
 #include "pblk.h"
 
-static void pblk_sync_line(struct pblk *pblk, struct pblk_line *line)
-{
-#ifdef CONFIG_NVM_DEBUG
-       atomic_long_inc(&pblk->sync_writes);
-#endif
-
-       /* Counter protected by rb sync lock */
-       line->left_ssecs--;
-}
-
 static unsigned long pblk_end_w_bio(struct pblk *pblk, struct nvm_rq *rqd,
                                    struct pblk_c_ctx *c_ctx)
 {
@@ -44,14 +34,13 @@ static unsigned long pblk_end_w_bio(struct pblk *pblk, struct nvm_rq *rqd,
 
                p = rqd->ppa_list[i];
                line = &pblk->lines[pblk_dev_ppa_to_line(p)];
-               pblk_sync_line(pblk, line);
 
                while ((original_bio = bio_list_pop(&w_ctx->bios)))
                        bio_endio(original_bio);
        }
 
 #ifdef CONFIG_NVM_DEBUG
-       atomic_long_add(c_ctx->nr_valid, &pblk->compl_writes);
+       atomic_long_add(c_ctx->nr_valid, &pblk->sync_writes);
 #endif
 
        ret = pblk_rb_sync_advance(&pblk->rwb, c_ctx->nr_valid);
index 07ae3c07d5632048f92dc4f7d40813d2ae7e16fa..50f30434718f7bd5dedeb096db39bcc0c5472fe9 100644 (file)
@@ -395,7 +395,6 @@ struct pblk_line {
        atomic_t left_seblks;           /* Blocks left for sync erasing */
 
        int left_msecs;                 /* Sectors left for mapping */
-       int left_ssecs;                 /* Sectors left to sync */
        unsigned int cur_sec;           /* Sector map pointer */
        unsigned int nr_valid_lbas;     /* Number of valid lbas in line */
 
@@ -555,7 +554,6 @@ struct pblk {
        atomic_long_t req_writes;       /* Sectors stored on write buffer */
        atomic_long_t sub_writes;       /* Sectors submitted from buffer */
        atomic_long_t sync_writes;      /* Sectors synced to media */
-       atomic_long_t compl_writes;     /* Sectors completed in write bio */
        atomic_long_t inflight_reads;   /* Inflight sector read requests */
        atomic_long_t cache_reads;      /* Read requests that hit the cache */
        atomic_long_t sync_reads;       /* Completed sector read requests */
@@ -706,11 +704,11 @@ void pblk_end_bio_sync(struct bio *bio);
 void pblk_end_io_sync(struct nvm_rq *rqd);
 int pblk_bio_add_pages(struct pblk *pblk, struct bio *bio, gfp_t flags,
                       int nr_pages);
-void pblk_map_pad_invalidate(struct pblk *pblk, struct pblk_line *line,
-                            u64 paddr);
 void pblk_bio_free_pages(struct pblk *pblk, struct bio *bio, int off,
                         int nr_pages);
 void pblk_map_invalidate(struct pblk *pblk, struct ppa_addr ppa);
+void __pblk_map_invalidate(struct pblk *pblk, struct pblk_line *line,
+                          u64 paddr);
 void pblk_update_map(struct pblk *pblk, sector_t lba, struct ppa_addr ppa);
 void pblk_update_map_cache(struct pblk *pblk, sector_t lba,
                           struct ppa_addr ppa);