]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
lightnvm: pblk: fix mapping issue on failed writes
authorHans Holmberg <hans.holmberg@cnexlabs.com>
Tue, 9 Oct 2018 11:11:59 +0000 (13:11 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 9 Oct 2018 14:25:07 +0000 (08:25 -0600)
On 1.2-devices, the mapping-out of remaning sectors in the
failed-write's block can result in an infinite loop,
stalling the write pipeline, fix this.

Fixes: 6a3abf5beef6 ("lightnvm: pblk: rework write error recovery path")
Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
Signed-off-by: Matias Bjørling <mb@lightnvm.io>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/lightnvm/pblk-write.c
include/linux/lightnvm.h

index 61fe22ccc7a1e2ef8c973f7080a2a146caa5d286..9554febee4805604d18f43336396caf61275fb87 100644 (file)
@@ -106,8 +106,6 @@ retry:
 /* Map remaining sectors in chunk, starting from ppa */
 static void pblk_map_remaining(struct pblk *pblk, struct ppa_addr *ppa)
 {
-       struct nvm_tgt_dev *dev = pblk->dev;
-       struct nvm_geo *geo = &dev->geo;
        struct pblk_line *line;
        struct ppa_addr map_ppa = *ppa;
        u64 paddr;
@@ -125,15 +123,7 @@ static void pblk_map_remaining(struct pblk *pblk, struct ppa_addr *ppa)
                if (!test_and_set_bit(paddr, line->invalid_bitmap))
                        le32_add_cpu(line->vsc, -1);
 
-               if (geo->version == NVM_OCSSD_SPEC_12) {
-                       map_ppa.ppa++;
-                       if (map_ppa.g.pg == geo->num_pg)
-                               done = 1;
-               } else {
-                       map_ppa.m.sec++;
-                       if (map_ppa.m.sec == geo->clba)
-                               done = 1;
-               }
+               done = nvm_next_ppa_in_chk(pblk->dev, &map_ppa);
        }
 
        line->w_err_gc->has_write_err = 1;
index eb7300c20f24504827e7f88d69246f1ae7550d1b..2fdeac1a420d68f204ee73eab288ce0b33cacaff 100644 (file)
@@ -593,6 +593,42 @@ static inline u32 nvm_ppa64_to_ppa32(struct nvm_dev *dev,
        return ppa32;
 }
 
+static inline int nvm_next_ppa_in_chk(struct nvm_tgt_dev *dev,
+                                     struct ppa_addr *ppa)
+{
+       struct nvm_geo *geo = &dev->geo;
+       int last = 0;
+
+       if (geo->version == NVM_OCSSD_SPEC_12) {
+               int sec = ppa->g.sec;
+
+               sec++;
+               if (sec == geo->ws_min) {
+                       int pg = ppa->g.pg;
+
+                       sec = 0;
+                       pg++;
+                       if (pg == geo->num_pg) {
+                               int pl = ppa->g.pl;
+
+                               pg = 0;
+                               pl++;
+                               if (pl == geo->num_pln)
+                                       last = 1;
+
+                               ppa->g.pl = pl;
+                       }
+                       ppa->g.pg = pg;
+               }
+               ppa->g.sec = sec;
+       } else {
+               ppa->m.sec++;
+               if (ppa->m.sec == geo->clba)
+                       last = 1;
+       }
+
+       return last;
+}
 
 typedef blk_qc_t (nvm_tgt_make_rq_fn)(struct request_queue *, struct bio *);
 typedef sector_t (nvm_tgt_capacity_fn)(void *);