aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm
diff options
context:
space:
mode:
authorMatias Bjørling <mb@lightnvm.io>2018-10-09 07:11:51 -0400
committerJens Axboe <axboe@kernel.dk>2018-10-09 10:25:07 -0400
commit43241cfe470850a590913a86e590fd4ad9939d59 (patch)
tree2de5e0eeed63f296fd2457a8acf3f72e718c4ddd /drivers/lightnvm
parent765462fa4c4d0fd3eb718f2ba14cb04c35219854 (diff)
lightnvm: pblk: remove debug from pblk_[down/up]_page
Remove the debug only iteration within __pblk_down_page, which then allows us to reduce the number of arguments down to pblk and the parallel unit from the functions that calls it. Simplifying the callers logic considerably. Also, rename the functions pblk_[down/up]_page to pblk_[down/up]_chunk, to communicate that it manages the write pointer of the chunk. Note that it also protects the parallel unit such that at most one chunk is active per parallel unit. Signed-off-by: Matias Bjørling <mb@lightnvm.io> Reviewed-by: Javier González <javier@cnexlabs.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm')
-rw-r--r--drivers/lightnvm/pblk-core.c34
-rw-r--r--drivers/lightnvm/pblk-map.c2
-rw-r--r--drivers/lightnvm/pblk-recovery.c6
-rw-r--r--drivers/lightnvm/pblk-write.c6
-rw-r--r--drivers/lightnvm/pblk.h6
5 files changed, 19 insertions, 35 deletions
diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index bb1a7cc24cbb..968597d10cc2 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -1861,8 +1861,7 @@ void pblk_gen_run_ws(struct pblk *pblk, struct pblk_line *line, void *priv,
1861 queue_work(wq, &line_ws->ws); 1861 queue_work(wq, &line_ws->ws);
1862} 1862}
1863 1863
1864static void __pblk_down_page(struct pblk *pblk, struct ppa_addr *ppa_list, 1864static void __pblk_down_chunk(struct pblk *pblk, int pos)
1865 int nr_ppas, int pos)
1866{ 1865{
1867 struct pblk_lun *rlun = &pblk->luns[pos]; 1866 struct pblk_lun *rlun = &pblk->luns[pos];
1868 int ret; 1867 int ret;
@@ -1871,13 +1870,6 @@ static void __pblk_down_page(struct pblk *pblk, struct ppa_addr *ppa_list,
1871 * Only send one inflight I/O per LUN. Since we map at a page 1870 * Only send one inflight I/O per LUN. Since we map at a page
1872 * granurality, all ppas in the I/O will map to the same LUN 1871 * granurality, all ppas in the I/O will map to the same LUN
1873 */ 1872 */
1874#ifdef CONFIG_NVM_PBLK_DEBUG
1875 int i;
1876
1877 for (i = 1; i < nr_ppas; i++)
1878 WARN_ON(ppa_list[0].a.lun != ppa_list[i].a.lun ||
1879 ppa_list[0].a.ch != ppa_list[i].a.ch);
1880#endif
1881 1873
1882 ret = down_timeout(&rlun->wr_sem, msecs_to_jiffies(30000)); 1874 ret = down_timeout(&rlun->wr_sem, msecs_to_jiffies(30000));
1883 if (ret == -ETIME || ret == -EINTR) 1875 if (ret == -ETIME || ret == -EINTR)
@@ -1885,21 +1877,21 @@ static void __pblk_down_page(struct pblk *pblk, struct ppa_addr *ppa_list,
1885 -ret); 1877 -ret);
1886} 1878}
1887 1879
1888void pblk_down_page(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas) 1880void pblk_down_chunk(struct pblk *pblk, struct ppa_addr ppa)
1889{ 1881{
1890 struct nvm_tgt_dev *dev = pblk->dev; 1882 struct nvm_tgt_dev *dev = pblk->dev;
1891 struct nvm_geo *geo = &dev->geo; 1883 struct nvm_geo *geo = &dev->geo;
1892 int pos = pblk_ppa_to_pos(geo, ppa_list[0]); 1884 int pos = pblk_ppa_to_pos(geo, ppa);
1893 1885
1894 __pblk_down_page(pblk, ppa_list, nr_ppas, pos); 1886 __pblk_down_chunk(pblk, pos);
1895} 1887}
1896 1888
1897void pblk_down_rq(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas, 1889void pblk_down_rq(struct pblk *pblk, struct ppa_addr ppa,
1898 unsigned long *lun_bitmap) 1890 unsigned long *lun_bitmap)
1899{ 1891{
1900 struct nvm_tgt_dev *dev = pblk->dev; 1892 struct nvm_tgt_dev *dev = pblk->dev;
1901 struct nvm_geo *geo = &dev->geo; 1893 struct nvm_geo *geo = &dev->geo;
1902 int pos = pblk_ppa_to_pos(geo, ppa_list[0]); 1894 int pos = pblk_ppa_to_pos(geo, ppa);
1903 1895
1904 /* If the LUN has been locked for this same request, do no attempt to 1896 /* If the LUN has been locked for this same request, do no attempt to
1905 * lock it again 1897 * lock it again
@@ -1907,23 +1899,15 @@ void pblk_down_rq(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas,
1907 if (test_and_set_bit(pos, lun_bitmap)) 1899 if (test_and_set_bit(pos, lun_bitmap))
1908 return; 1900 return;
1909 1901
1910 __pblk_down_page(pblk, ppa_list, nr_ppas, pos); 1902 __pblk_down_chunk(pblk, pos);
1911} 1903}
1912 1904
1913void pblk_up_page(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas) 1905void pblk_up_chunk(struct pblk *pblk, struct ppa_addr ppa)
1914{ 1906{
1915 struct nvm_tgt_dev *dev = pblk->dev; 1907 struct nvm_tgt_dev *dev = pblk->dev;
1916 struct nvm_geo *geo = &dev->geo; 1908 struct nvm_geo *geo = &dev->geo;
1917 struct pblk_lun *rlun; 1909 struct pblk_lun *rlun;
1918 int pos = pblk_ppa_to_pos(geo, ppa_list[0]); 1910 int pos = pblk_ppa_to_pos(geo, ppa);
1919
1920#ifdef CONFIG_NVM_PBLK_DEBUG
1921 int i;
1922
1923 for (i = 1; i < nr_ppas; i++)
1924 WARN_ON(ppa_list[0].a.lun != ppa_list[i].a.lun ||
1925 ppa_list[0].a.ch != ppa_list[i].a.ch);
1926#endif
1927 1911
1928 rlun = &pblk->luns[pos]; 1912 rlun = &pblk->luns[pos];
1929 up(&rlun->wr_sem); 1913 up(&rlun->wr_sem);
diff --git a/drivers/lightnvm/pblk-map.c b/drivers/lightnvm/pblk-map.c
index dc0efb852475..ff677ca6e4e1 100644
--- a/drivers/lightnvm/pblk-map.c
+++ b/drivers/lightnvm/pblk-map.c
@@ -79,7 +79,7 @@ static int pblk_map_page_data(struct pblk *pblk, unsigned int sentry,
79 } 79 }
80 } 80 }
81 81
82 pblk_down_rq(pblk, ppa_list, nr_secs, lun_bitmap); 82 pblk_down_rq(pblk, ppa_list[0], lun_bitmap);
83 return 0; 83 return 0;
84} 84}
85 85
diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c
index eea901d7cebc..cbcc0828517e 100644
--- a/drivers/lightnvm/pblk-recovery.c
+++ b/drivers/lightnvm/pblk-recovery.c
@@ -227,7 +227,7 @@ static void pblk_end_io_recov(struct nvm_rq *rqd)
227 struct pblk_pad_rq *pad_rq = rqd->private; 227 struct pblk_pad_rq *pad_rq = rqd->private;
228 struct pblk *pblk = pad_rq->pblk; 228 struct pblk *pblk = pad_rq->pblk;
229 229
230 pblk_up_page(pblk, ppa_list, rqd->nr_ppas); 230 pblk_up_chunk(pblk, ppa_list[0]);
231 231
232 pblk_free_rqd(pblk, rqd, PBLK_WRITE_INT); 232 pblk_free_rqd(pblk, rqd, PBLK_WRITE_INT);
233 233
@@ -339,12 +339,12 @@ next_pad_rq:
339 } 339 }
340 340
341 kref_get(&pad_rq->ref); 341 kref_get(&pad_rq->ref);
342 pblk_down_page(pblk, rqd->ppa_list, rqd->nr_ppas); 342 pblk_down_chunk(pblk, rqd->ppa_list[0]);
343 343
344 ret = pblk_submit_io(pblk, rqd); 344 ret = pblk_submit_io(pblk, rqd);
345 if (ret) { 345 if (ret) {
346 pblk_err(pblk, "I/O submission failed: %d\n", ret); 346 pblk_err(pblk, "I/O submission failed: %d\n", ret);
347 pblk_up_page(pblk, rqd->ppa_list, rqd->nr_ppas); 347 pblk_up_chunk(pblk, rqd->ppa_list[0]);
348 goto fail_free_bio; 348 goto fail_free_bio;
349 } 349 }
350 350
diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c
index cd579b440b56..674ba4d1a9f4 100644
--- a/drivers/lightnvm/pblk-write.c
+++ b/drivers/lightnvm/pblk-write.c
@@ -270,7 +270,7 @@ static void pblk_end_io_write_meta(struct nvm_rq *rqd)
270 struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd); 270 struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd);
271 int sync; 271 int sync;
272 272
273 pblk_up_page(pblk, ppa_list, rqd->nr_ppas); 273 pblk_up_chunk(pblk, ppa_list[0]);
274 274
275 if (rqd->error) { 275 if (rqd->error) {
276 pblk_log_write_err(pblk, rqd); 276 pblk_log_write_err(pblk, rqd);
@@ -420,7 +420,7 @@ int pblk_submit_meta_io(struct pblk *pblk, struct pblk_line *meta_line)
420 list_del(&meta_line->list); 420 list_del(&meta_line->list);
421 spin_unlock(&l_mg->close_lock); 421 spin_unlock(&l_mg->close_lock);
422 422
423 pblk_down_page(pblk, ppa_list, rqd->nr_ppas); 423 pblk_down_chunk(pblk, ppa_list[0]);
424 424
425 ret = pblk_submit_io(pblk, rqd); 425 ret = pblk_submit_io(pblk, rqd);
426 if (ret) { 426 if (ret) {
@@ -431,7 +431,7 @@ int pblk_submit_meta_io(struct pblk *pblk, struct pblk_line *meta_line)
431 return NVM_IO_OK; 431 return NVM_IO_OK;
432 432
433fail_rollback: 433fail_rollback:
434 pblk_up_page(pblk, ppa_list, rqd->nr_ppas); 434 pblk_up_chunk(pblk, ppa_list[0]);
435 spin_lock(&l_mg->close_lock); 435 spin_lock(&l_mg->close_lock);
436 pblk_dealloc_page(pblk, meta_line, rq_ppas); 436 pblk_dealloc_page(pblk, meta_line, rq_ppas);
437 list_add(&meta_line->list, &meta_line->list); 437 list_add(&meta_line->list, &meta_line->list);
diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
index 0ca67e8f99d5..429347bcd1fa 100644
--- a/drivers/lightnvm/pblk.h
+++ b/drivers/lightnvm/pblk.h
@@ -823,10 +823,10 @@ u64 pblk_alloc_page(struct pblk *pblk, struct pblk_line *line, int nr_secs);
823u64 __pblk_alloc_page(struct pblk *pblk, struct pblk_line *line, int nr_secs); 823u64 __pblk_alloc_page(struct pblk *pblk, struct pblk_line *line, int nr_secs);
824int pblk_calc_secs(struct pblk *pblk, unsigned long secs_avail, 824int pblk_calc_secs(struct pblk *pblk, unsigned long secs_avail,
825 unsigned long secs_to_flush); 825 unsigned long secs_to_flush);
826void pblk_up_page(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas); 826void pblk_down_rq(struct pblk *pblk, struct ppa_addr ppa,
827void pblk_down_rq(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas,
828 unsigned long *lun_bitmap); 827 unsigned long *lun_bitmap);
829void pblk_down_page(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas); 828void pblk_down_chunk(struct pblk *pblk, struct ppa_addr ppa);
829void pblk_up_chunk(struct pblk *pblk, struct ppa_addr ppa);
830void pblk_up_rq(struct pblk *pblk, unsigned long *lun_bitmap); 830void pblk_up_rq(struct pblk *pblk, unsigned long *lun_bitmap);
831int pblk_bio_add_pages(struct pblk *pblk, struct bio *bio, gfp_t flags, 831int pblk_bio_add_pages(struct pblk *pblk, struct bio *bio, gfp_t flags,
832 int nr_pages); 832 int nr_pages);