Message ID | 20180201195212.GD24417@localhost.localdomain (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 2/1/18 12:52 PM, Keith Busch wrote: > On Thu, Feb 01, 2018 at 10:58:23AM -0700, Jens Axboe wrote: >> I was able to reproduce on a test box, pretty trivially in fact: >> >> # echo mq-deadline > /sys/block/nvme2n1/queue/scheduler >> # mkfs.ext4 /dev/nvme2n1 >> # mount /dev/nvme2n1 /data -o discard >> # dd if=/dev/zero of=/data/10g bs=1M count=10k >> # sync >> # rm /data/10g >> # sync <- triggered >> >> Your patch still doesn't work, but mainly because we init the segments >> to 0 when setting up a discard. The below works for me, and cleans up >> the merge path a bit, since your patch was missing various adjustments >> on both the merged and freed request. > > I'm still finding cases not accounted even your patch. I had to use the > following on top of that, and this pattern looks like it needs to be > repeated for all schedulers: > > --- > diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c > index 55c0a745b427..25c14c58385c 100644 > --- a/block/blk-mq-sched.c > +++ b/block/blk-mq-sched.c > @@ -259,6 +259,8 @@ bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio, > if (!*merged_request) > elv_merged_request(q, rq, ELEVATOR_FRONT_MERGE); > return true; > + case ELEVATOR_DISCARD_MERGE: > + return bio_attempt_discard_merge(q, rq, bio); Yes, we need this to enable the bio-to-request merging. > diff --git a/block/mq-deadline.c b/block/mq-deadline.c > index c56f211c8440..a0f5752b6858 100644 > --- a/block/mq-deadline.c > +++ b/block/mq-deadline.c > @@ -451,7 +451,7 @@ static int dd_request_merge(struct request_queue *q, struct request **rq, > > if (elv_bio_merge_ok(__rq, bio)) { > *rq = __rq; > - return ELEVATOR_FRONT_MERGE; > + return blk_try_merge(__rq, bio); This isn't needed. We already know it's a front merge at this point, and it can only be a normal read/write request.
diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index 55c0a745b427..25c14c58385c 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -259,6 +259,8 @@ bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio, if (!*merged_request) elv_merged_request(q, rq, ELEVATOR_FRONT_MERGE); return true; + case ELEVATOR_DISCARD_MERGE: + return bio_attempt_discard_merge(q, rq, bio); default: return false; } diff --git a/block/mq-deadline.c b/block/mq-deadline.c index c56f211c8440..a0f5752b6858 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -451,7 +451,7 @@ static int dd_request_merge(struct request_queue *q, struct request **rq, if (elv_bio_merge_ok(__rq, bio)) { *rq = __rq; - return ELEVATOR_FRONT_MERGE; + return blk_try_merge(__rq, bio); } }