diff options
author | Hans Holmberg <hans.holmberg@cnexlabs.com> | 2018-10-09 07:11:46 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-10-09 10:25:07 -0400 |
commit | d68a9344041b6dd304ff382d0c7805869f09944f (patch) | |
tree | a14d5b06c1e0ab5e9d58693ae44cfbd18c5dd156 /include/linux/lightnvm.h | |
parent | 9cc85bc761f83da41935cdd6edcdb7c122bc90bf (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 'include/linux/lightnvm.h')
-rw-r--r-- | include/linux/lightnvm.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 77743a02ec0d..50ac5b21297c 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h | |||
@@ -320,6 +320,11 @@ static inline void *nvm_rq_to_pdu(struct nvm_rq *rqdata) | |||
320 | return rqdata + 1; | 320 | return rqdata + 1; |
321 | } | 321 | } |
322 | 322 | ||
323 | static inline struct ppa_addr *nvm_rq_to_ppa_list(struct nvm_rq *rqd) | ||
324 | { | ||
325 | return (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr; | ||
326 | } | ||
327 | |||
323 | enum { | 328 | enum { |
324 | NVM_BLK_ST_FREE = 0x1, /* Free block */ | 329 | NVM_BLK_ST_FREE = 0x1, /* Free block */ |
325 | NVM_BLK_ST_TGT = 0x2, /* Block in use by target */ | 330 | NVM_BLK_ST_TGT = 0x2, /* Block in use by target */ |