summaryrefslogtreecommitdiff
path: root/drivers/lightnvm/pblk-recovery.c
diff options
context:
space:
mode:
authorHans Holmberg <hans.holmberg@cnexlabs.com>2018-10-09 13:11:46 +0200
committerJens Axboe <axboe@kernel.dk>2018-10-09 08:25:07 -0600
commitd68a9344041b6dd304ff382d0c7805869f09944f (patch)
treea14d5b06c1e0ab5e9d58693ae44cfbd18c5dd156 /drivers/lightnvm/pblk-recovery.c
parent9cc85bc761f83da41935cdd6edcdb7c122bc90bf (diff)
lightnvm: introduce nvm_rq_to_ppa_list
There is a number of places in the lightnvm subsystem where the user iterates over the ppa list. Before iterating, the user must know if it is a single or multiple LBAs due to vector commands using either the nvm_rq ->ppa_addr or ->ppa_list fields on command submission, which leads to open-coding the if/else statement. Instead of having multiple if/else's, move it into a function that can be called by its users. A nice side effect of this cleanup is that this patch fixes up a bunch of cases where we don't consider the single-ppa case in pblk. 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>
Diffstat (limited to 'drivers/lightnvm/pblk-recovery.c')
-rw-r--r--drivers/lightnvm/pblk-recovery.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c
index cf629ab016ba..3bd2b6b0a359 100644
--- a/drivers/lightnvm/pblk-recovery.c
+++ b/drivers/lightnvm/pblk-recovery.c
@@ -161,6 +161,8 @@ next_read_rq:
if (pblk_io_aligned(pblk, rq_ppas))
rqd->is_seq = 1;
+ ppa_list = nvm_rq_to_ppa_list(rqd);
+
for (i = 0; i < rqd->nr_ppas; ) {
struct ppa_addr ppa;
int pos;
@@ -175,7 +177,7 @@ next_read_rq:
}
for (j = 0; j < pblk->min_write_pgs; j++, i++, r_ptr_int++)
- rqd->ppa_list[i] =
+ ppa_list[i] =
addr_to_gen_ppa(pblk, r_ptr_int, line->id);
}
@@ -202,7 +204,7 @@ next_read_rq:
if (lba == ADDR_EMPTY || lba > pblk->rl.nr_secs)
continue;
- pblk_update_map(pblk, lba, rqd->ppa_list[i]);
+ pblk_update_map(pblk, lba, ppa_list[i]);
}
left_ppas -= rq_ppas;
@@ -221,10 +223,11 @@ static void pblk_recov_complete(struct kref *ref)
static void pblk_end_io_recov(struct nvm_rq *rqd)
{
+ struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd);
struct pblk_pad_rq *pad_rq = rqd->private;
struct pblk *pblk = pad_rq->pblk;
- pblk_up_page(pblk, rqd->ppa_list, rqd->nr_ppas);
+ pblk_up_page(pblk, ppa_list, rqd->nr_ppas);
pblk_free_rqd(pblk, rqd, PBLK_WRITE_INT);