Commit 63dee3a6 authored by Javier González's avatar Javier González Committed by Jens Axboe

lightnvm: pblk: calculate line pad distance in helper

If a line is padded, calculate the pad distance directly on the helper
being used for this purpose.
Signed-off-by: default avatarJavier González <javier@cnexlabs.com>
Signed-off-by: default avatarMatias Bjørling <mb@lightnvm.io>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 7f985f9a
...@@ -380,6 +380,15 @@ static int pblk_recov_pad_oob(struct pblk *pblk, struct pblk_line *line, ...@@ -380,6 +380,15 @@ static int pblk_recov_pad_oob(struct pblk *pblk, struct pblk_line *line,
return ret; return ret;
} }
static int pblk_pad_distance(struct pblk *pblk, struct pblk_line *line)
{
struct nvm_tgt_dev *dev = pblk->dev;
struct nvm_geo *geo = &dev->geo;
int distance = geo->mw_cunits * geo->all_luns * geo->ws_opt;
return (distance > line->left_msecs) ? line->left_msecs : distance;
}
/* When this function is called, it means that not all upper pages have been /* When this function is called, it means that not all upper pages have been
* written in a page that contains valid data. In order to recover this data, we * written in a page that contains valid data. In order to recover this data, we
* first find the write pointer on the device, then we pad all necessary * first find the write pointer on the device, then we pad all necessary
...@@ -495,9 +504,7 @@ static int pblk_recov_scan_all_oob(struct pblk *pblk, struct pblk_line *line, ...@@ -495,9 +504,7 @@ static int pblk_recov_scan_all_oob(struct pblk *pblk, struct pblk_line *line,
line->left_msecs += nr_error_bits; line->left_msecs += nr_error_bits;
bitmap_clear(line->map_bitmap, line->cur_sec, nr_error_bits); bitmap_clear(line->map_bitmap, line->cur_sec, nr_error_bits);
pad_secs = pblk_pad_distance(pblk); pad_secs = pblk_pad_distance(pblk, line);
if (pad_secs > line->left_msecs)
pad_secs = line->left_msecs;
ret = pblk_recov_pad_oob(pblk, line, pad_secs); ret = pblk_recov_pad_oob(pblk, line, pad_secs);
if (ret) if (ret)
......
...@@ -986,14 +986,6 @@ static inline int pblk_line_vsc(struct pblk_line *line) ...@@ -986,14 +986,6 @@ static inline int pblk_line_vsc(struct pblk_line *line)
return le32_to_cpu(*line->vsc); return le32_to_cpu(*line->vsc);
} }
static inline int pblk_pad_distance(struct pblk *pblk)
{
struct nvm_tgt_dev *dev = pblk->dev;
struct nvm_geo *geo = &dev->geo;
return geo->mw_cunits * geo->all_luns * geo->ws_opt;
}
static inline int pblk_ppa_to_line_id(struct ppa_addr p) static inline int pblk_ppa_to_line_id(struct ppa_addr p)
{ {
return p.a.blk; return p.a.blk;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment