From: Adrian Hunter <adrian.hunter@nokia.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel Mailing List <linux-kernel@vger.kernel.org>,
Adrian Hunter <adrian.hunter@nokia.com>
Subject: [PATCH] block: prevent merges of discard and write requests
Date: Sat, 25 Sep 2010 13:36:42 +0300 [thread overview]
Message-ID: <1285411002-22924-1-git-send-email-adrian.hunter@nokia.com> (raw)
Add logic to prevent two I/O requests being merged if
only one of them is a discard. Ditto secure discard.
Without this fix, it is possible for write requests
to transform into discard requests. For example:
Submit bio 1 to discard 8 sectors from sector n
Submit bio 2 to write 8 sectors from sector n + 16
Submit bio 3 to write 8 sectors from sector n + 8
Bio 1 becomes request 1. Bio 2 becomes request 2.
Bio 3 is merged with request 2, and then subsequently
request 2 is merged with request 1 resulting in just
one I/O request which discards all 24 sectors.
Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
---
block/blk-merge.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 6a72546..3d88c1f 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -375,6 +375,18 @@ static int attempt_merge(struct request_queue *q, struct request *req,
if (blk_rq_pos(req) + blk_rq_sectors(req) != blk_rq_pos(next))
return 0;
+ /*
+ * Don't merge file system requests and discard requests
+ */
+ if ((req->cmd_flags & REQ_DISCARD) != (next->cmd_flags & REQ_DISCARD))
+ return 0;
+
+ /*
+ * Don't merge discard requests and secure discard requests
+ */
+ if ((req->cmd_flags & REQ_SECURE) != (next->cmd_flags & REQ_SECURE))
+ return 0;
+
if (rq_data_dir(req) != rq_data_dir(next)
|| req->rq_disk != next->rq_disk
|| next->special)
--
1.7.0.4
next reply other threads:[~2010-09-25 10:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-25 10:36 Adrian Hunter [this message]
2010-09-25 10:40 ` Jens Axboe
2010-09-27 3:30 ` Kyle McMartin
2010-09-27 4:59 ` Jens Axboe
2010-09-27 5:02 ` Kyle McMartin
2010-09-27 5:12 ` Mike Snitzer
2010-09-27 5:26 ` Mike Snitzer
2010-09-27 6:08 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1285411002-22924-1-git-send-email-adrian.hunter@nokia.com \
--to=adrian.hunter@nokia.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®