mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-05 14:04:35 +00:00
lightnvm: pblk: fail gracefully on line alloc. failure
In the event of a line failing to allocate, fail gracefully and stop the pipeline to avoid more write failing in the same place. Signed-off-by: Javier González <javier@cnexlabs.com> Signed-off-by: Matias Bjørling <mb@lightnvm.io> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
84e92c131a
commit
2deeefc02d
2 changed files with 29 additions and 9 deletions
|
@ -1047,6 +1047,11 @@ static int pblk_lines_init(struct pblk *pblk)
|
||||||
nr_free_chks += pblk_setup_line_meta(pblk, line, chunk_meta, i);
|
nr_free_chks += pblk_setup_line_meta(pblk, line, chunk_meta, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!nr_free_chks) {
|
||||||
|
pr_err("pblk: too many bad blocks prevent for sane instance\n");
|
||||||
|
return -EINTR;
|
||||||
|
}
|
||||||
|
|
||||||
pblk_set_provision(pblk, nr_free_chks);
|
pblk_set_provision(pblk, nr_free_chks);
|
||||||
|
|
||||||
kfree(chunk_meta);
|
kfree(chunk_meta);
|
||||||
|
|
|
@ -18,11 +18,11 @@
|
||||||
|
|
||||||
#include "pblk.h"
|
#include "pblk.h"
|
||||||
|
|
||||||
static void pblk_map_page_data(struct pblk *pblk, unsigned int sentry,
|
static int pblk_map_page_data(struct pblk *pblk, unsigned int sentry,
|
||||||
struct ppa_addr *ppa_list,
|
struct ppa_addr *ppa_list,
|
||||||
unsigned long *lun_bitmap,
|
unsigned long *lun_bitmap,
|
||||||
struct pblk_sec_meta *meta_list,
|
struct pblk_sec_meta *meta_list,
|
||||||
unsigned int valid_secs)
|
unsigned int valid_secs)
|
||||||
{
|
{
|
||||||
struct pblk_line *line = pblk_line_get_data(pblk);
|
struct pblk_line *line = pblk_line_get_data(pblk);
|
||||||
struct pblk_emeta *emeta;
|
struct pblk_emeta *emeta;
|
||||||
|
@ -35,8 +35,14 @@ static void pblk_map_page_data(struct pblk *pblk, unsigned int sentry,
|
||||||
if (pblk_line_is_full(line)) {
|
if (pblk_line_is_full(line)) {
|
||||||
struct pblk_line *prev_line = line;
|
struct pblk_line *prev_line = line;
|
||||||
|
|
||||||
|
/* If we cannot allocate a new line, make sure to store metadata
|
||||||
|
* on current line and then fail
|
||||||
|
*/
|
||||||
line = pblk_line_replace_data(pblk);
|
line = pblk_line_replace_data(pblk);
|
||||||
pblk_line_close_meta(pblk, prev_line);
|
pblk_line_close_meta(pblk, prev_line);
|
||||||
|
|
||||||
|
if (!line)
|
||||||
|
return -EINTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
emeta = line->emeta;
|
emeta = line->emeta;
|
||||||
|
@ -74,6 +80,7 @@ static void pblk_map_page_data(struct pblk *pblk, unsigned int sentry,
|
||||||
}
|
}
|
||||||
|
|
||||||
pblk_down_rq(pblk, ppa_list, nr_secs, lun_bitmap);
|
pblk_down_rq(pblk, ppa_list, nr_secs, lun_bitmap);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry,
|
void pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry,
|
||||||
|
@ -87,8 +94,12 @@ void pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry,
|
||||||
|
|
||||||
for (i = off; i < rqd->nr_ppas; i += min) {
|
for (i = off; i < rqd->nr_ppas; i += min) {
|
||||||
map_secs = (i + min > valid_secs) ? (valid_secs % min) : min;
|
map_secs = (i + min > valid_secs) ? (valid_secs % min) : min;
|
||||||
pblk_map_page_data(pblk, sentry + i, &rqd->ppa_list[i],
|
if (pblk_map_page_data(pblk, sentry + i, &rqd->ppa_list[i],
|
||||||
lun_bitmap, &meta_list[i], map_secs);
|
lun_bitmap, &meta_list[i], map_secs)) {
|
||||||
|
bio_put(rqd->bio);
|
||||||
|
pblk_free_rqd(pblk, rqd, PBLK_WRITE);
|
||||||
|
pblk_pipeline_stop(pblk);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,8 +119,12 @@ void pblk_map_erase_rq(struct pblk *pblk, struct nvm_rq *rqd,
|
||||||
|
|
||||||
for (i = 0; i < rqd->nr_ppas; i += min) {
|
for (i = 0; i < rqd->nr_ppas; i += min) {
|
||||||
map_secs = (i + min > valid_secs) ? (valid_secs % min) : min;
|
map_secs = (i + min > valid_secs) ? (valid_secs % min) : min;
|
||||||
pblk_map_page_data(pblk, sentry + i, &rqd->ppa_list[i],
|
if (pblk_map_page_data(pblk, sentry + i, &rqd->ppa_list[i],
|
||||||
lun_bitmap, &meta_list[i], map_secs);
|
lun_bitmap, &meta_list[i], map_secs)) {
|
||||||
|
bio_put(rqd->bio);
|
||||||
|
pblk_free_rqd(pblk, rqd, PBLK_WRITE);
|
||||||
|
pblk_pipeline_stop(pblk);
|
||||||
|
}
|
||||||
|
|
||||||
erase_lun = pblk_ppa_to_pos(geo, rqd->ppa_list[i]);
|
erase_lun = pblk_ppa_to_pos(geo, rqd->ppa_list[i]);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue