lightnvm: pblk: refactor put line fn on read completion
PATCH 1/1 lightnvm: pblk: refactor put line fn on read completion
The read completion path uses the put_line variable to decide whether the reference on a line should be released. The function name used for that is pblk_read_put_rqd_kref, which could lead one to believe that it is the rqd that is releasing the reference, while it is the line reference that is put.
Rename and also split the function in two to account for either rqd or single ppa callers.
--- drivers/lightnvm/pblk-read.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/lightnvm/pblk-read.c +13 -10
@@ -165,20 +165,23 @@ static void pblk_read_check_rand(struct pblk *pblk, struct nvm_rq *rqd,WARN_ONCE (j != rqd->nr_ppas,"pblk: corrupted random request\n" ); } -static void pblk_read_put_rqd_kref (struct pblk *pblk,struct nvm_rq *rqd) +static void __pblk_read_put_line (struct pblk *pblk,struct ppa_addr ppa) { -struct ppa_addr *ppa_list; -int i; - - ppa_list = (rqd->nr_ppas >1 ) ? rqd->ppa_list : &rqd->ppa_addr; - -for (i =0 ; i < rqd->nr_ppas; i++) { -struct ppa_addr ppa = ppa_list[i];struct pblk_line *line; line = &pblk->lines[pblk_ppa_to_line (ppa)];kref_put (&line->ref, pblk_line_put_wq); - } +} + +static void pblk_read_put_line (struct pblk *pblk,struct nvm_rq *rqd) +{ +struct ppa_addr *ppa_list; +int i; + + ppa_list = (rqd->nr_ppas >1 ) ? rqd->ppa_list : &rqd->ppa_addr; + +for (i =0 ; i < rqd->nr_ppas; i++) +__pblk_read_put_line (pblk, ppa_list[i]); }static void pblk_end_user_read (struct bio *bio)
@@ -208,7 +211,7 @@ static void __pblk_end_io_read(struct pblk *pblk, struct nvm_rq *rqd,bio_put (int_bio);if (put_line) -pblk_read_put_rqd_kref (pblk, rqd); +pblk_read_put_line (pblk, rqd);#ifdef CONFIG_NVM_PBLK_DEBUG atomic_long_add (rqd->nr_ppas, &pblk->sync_reads);
Signature · 1 line
2.11.0
Quoted 63 lines · Matias Bjørling
The read completion path uses the
put_linevariable to decide whether the reference on a line should be released. The function name used for that ispblk_read_put_rqd_kref, which could lead one to believe that it is the rqd that is releasing the reference, while it is the line reference that is put.Rename and also split the function in two to account for either rqd or single ppa callers.
Signed-off-by Matias Bjørling <[email protected]>---
drivers/lightnvm/pblk-read.c| 23 +++++++++++++----------1 file changed, 13 insertions(+), 10 deletions(-)drivers/lightnvm/pblk-read.c +13
-11@@ -165,20 +165,23 @@ static void pblk_read_check_rand(struct pblk *pblk, struct nvm_rq *rqd,WARN_ONCE (j != rqd->nr_ppas,"pblk: corrupted random request\n" ); } -static void pblk_read_put_rqd_kref (struct pblk *pblk,struct nvm_rq *rqd) +static void __pblk_read_put_line (struct pblk *pblk,struct ppa_addr ppa) { -struct ppa_addr *ppa_list; -int i; - - ppa_list = (rqd->nr_ppas >1 ) ? rqd->ppa_list : &rqd->ppa_addr; - -for (i =0 ; i < rqd->nr_ppas; i++) { -struct ppa_addr ppa = ppa_list[i];struct pblk_line *line; line = &pblk->lines[pblk_ppa_to_line (ppa)];kref_put (&line->ref, pblk_line_put_wq); - } +} + +static void pblk_read_put_line (struct pblk *pblk,struct nvm_rq *rqd) +{ +struct ppa_addr *ppa_list; +int i; + + ppa_list = (rqd->nr_ppas >1 ) ? rqd->ppa_list : &rqd->ppa_addr; + +for (i =0 ; i < rqd->nr_ppas; i++) +__pblk_read_put_line (pblk, ppa_list[i]); }static void pblk_end_user_read (struct bio *bio)@@ -208,7 +211,7 @@ static void __pblk_end_io_read(struct pblk *pblk, struct nvm_rq *rqd,bio_put (int_bio);if (put_line) -pblk_read_put_rqd_kref (pblk, rqd); +pblk_read_put_line (pblk, rqd);#ifdef CONFIG_NVM_PBLK_DEBUG atomic_long_add (rqd->nr_ppas, &pblk->sync_reads); --
Quoted 1 line
2.11.0
Looks good to me
A message that is not in the archive (sent off-list or not yet received): CAJbgVnWe0b03gvO2815rGeB=J4NOEst9FSPf_vyJ3iUSgBuQnw@mail.gmail.com
Quoted 65 lines · Heiner Litz
Consider removing the "
_read", make it non-static and move the function topblk-core.cas the function isn't read specific.Quoted 60 lines · Matias Bjørling
The read completion path uses the
put_linevariable to decide whether the reference on a line should be released. The function name used for that ispblk_read_put_rqd_kref, which could lead one to believe that it is the rqd that is releasing the reference, while it is the line reference that is put.Rename and also split the function in two to account for either rqd or single ppa callers.
Signed-off-by Matias Bjørling <[email protected]>--- drivers/lightnvm/pblk-read.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)drivers/lightnvm/pblk-read.c +12
-9@@ -165,20 +165,23 @@ static void pblk_read_check_rand(struct pblk *pblk, struct nvm_rq *rqd, WARN_ONCE(j != rqd->nr_ppas, "pblk: corrupted random request\n"); } -static void pblk_read_put_rqd_kref (struct pblk *pblk,struct nvm_rq *rqd) +static void __pblk_read_put_line (struct pblk *pblk,struct ppa_addr ppa) { -struct ppa_addr *ppa_list; -int i; - - ppa_list = (rqd->nr_ppas >1 ) ? rqd->ppa_list : &rqd->ppa_addr; - -for (i =0 ; i < rqd->nr_ppas; i++) { -struct ppa_addr ppa = ppa_list[i];struct pblk_line *line; line = &pblk->lines[pblk_ppa_to_line (ppa)];kref_put (&line->ref, pblk_line_put_wq); - } +} + +static void pblk_read_put_line (struct pblk *pblk,struct nvm_rq *rqd) +{ +struct ppa_addr *ppa_list; +int i; + + ppa_list = (rqd->nr_ppas >1 ) ? rqd->ppa_list : &rqd->ppa_addr; + +for (i =0 ; i < rqd->nr_ppas; i++) +__pblk_read_put_line (pblk, ppa_list[i]); }static void
pblk_end_user_read(struct bio *bio)drivers/lightnvm/pblk-read.c +1
-1@@ -208,7 +211,7 @@ static void __pblk_end_io_read(struct pblk *pblk,struct nvm_rq *rqd,bio_put (int_bio );if (put_line) -pblk_read_put_rqd_kref (pblk, rqd); +pblk_read_put_line (pblk, rqd);
Quoted 7 lines
Quoted 6 lines
drivers/lightnvm/pblk-read.c +0
-0#ifdef CONFIG_NVM_PBLK_DEBUG atomic_long_add(rqd->nr_ppas, &pblk->sync_reads);--
2.11.0
Thanks Heiner. I'll send a v2.