aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm/pblk-init.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/lightnvm/pblk-init.c')
-rw-r--r--drivers/lightnvm/pblk-init.c47
1 files changed, 19 insertions, 28 deletions
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index e0df3de1ce83..1e227a08e54a 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -47,36 +47,10 @@ static struct pblk_global_caches pblk_caches = {
47 47
48struct bio_set pblk_bio_set; 48struct bio_set pblk_bio_set;
49 49
50static int pblk_rw_io(struct request_queue *q, struct pblk *pblk,
51 struct bio *bio)
52{
53 int ret;
54
55 /* Read requests must be <= 256kb due to NVMe's 64 bit completion bitmap
56 * constraint. Writes can be of arbitrary size.
57 */
58 if (bio_data_dir(bio) == READ) {
59 blk_queue_split(q, &bio);
60 ret = pblk_submit_read(pblk, bio);
61 if (ret == NVM_IO_DONE && bio_flagged(bio, BIO_CLONED))
62 bio_put(bio);
63
64 return ret;
65 }
66
67 /* Prevent deadlock in the case of a modest LUN configuration and large
68 * user I/Os. Unless stalled, the rate limiter leaves at least 256KB
69 * available for user I/O.
70 */
71 if (pblk_get_secs(bio) > pblk_rl_max_io(&pblk->rl))
72 blk_queue_split(q, &bio);
73
74 return pblk_write_to_cache(pblk, bio, PBLK_IOTYPE_USER);
75}
76
77static blk_qc_t pblk_make_rq(struct request_queue *q, struct bio *bio) 50static blk_qc_t pblk_make_rq(struct request_queue *q, struct bio *bio)
78{ 51{
79 struct pblk *pblk = q->queuedata; 52 struct pblk *pblk = q->queuedata;
53 int ret;
80 54
81 if (bio_op(bio) == REQ_OP_DISCARD) { 55 if (bio_op(bio) == REQ_OP_DISCARD) {
82 pblk_discard(pblk, bio); 56 pblk_discard(pblk, bio);
@@ -86,7 +60,24 @@ static blk_qc_t pblk_make_rq(struct request_queue *q, struct bio *bio)
86 } 60 }
87 } 61 }
88 62
89 switch (pblk_rw_io(q, pblk, bio)) { 63 /* Read requests must be <= 256kb due to NVMe's 64 bit completion bitmap
64 * constraint. Writes can be of arbitrary size.
65 */
66 if (bio_data_dir(bio) == READ) {
67 blk_queue_split(q, &bio);
68 ret = pblk_submit_read(pblk, bio);
69 } else {
70 /* Prevent deadlock in the case of a modest LUN configuration
71 * and large user I/Os. Unless stalled, the rate limiter
72 * leaves at least 256KB available for user I/O.
73 */
74 if (pblk_get_secs(bio) > pblk_rl_max_io(&pblk->rl))
75 blk_queue_split(q, &bio);
76
77 ret = pblk_write_to_cache(pblk, bio, PBLK_IOTYPE_USER);
78 }
79
80 switch (ret) {
90 case NVM_IO_ERR: 81 case NVM_IO_ERR:
91 bio_io_error(bio); 82 bio_io_error(bio);
92 break; 83 break;