All of lore.kernel.org
 help / color / mirror / Atom feed
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH for-4.4] block: split bios to max possible length
Date: Mon,  4 Jan 2016 11:24:55 -0700	[thread overview]
Message-ID: <1451931895-17474-1-git-send-email-keith.busch@intel.com> (raw)

This allows bio splits in the middle of a vector to form the largest
possible bio at the h/w's desired alignment, and guarantees the bio being
split will have some data. Previously, if the first vector's length was
greater than the allowable amount, the bio would split at a zero length
and hit a kernel BUG.

The length check is moved after the SG_GAPS check so that check doesn't
need to be duplicated in the split case.

Fixes: d3805611130af9b911e908af9f67a3f64f4f0914
bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=110231

Signed-off-by: Keith Busch <keith.busch at intel.com>
---
 block/blk-merge.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/block/blk-merge.c b/block/blk-merge.c
index e73846a..e886a7d 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -81,9 +81,6 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
 	struct bio *new = NULL;
 
 	bio_for_each_segment(bv, bio, iter) {
-		if (sectors + (bv.bv_len >> 9) > blk_max_size_offset(q, bio->bi_iter.bi_sector))
-			goto split;
-
 		/*
 		 * If the queue doesn't support SG gaps and adding this
 		 * offset would create a gap, disallow it.
@@ -91,6 +88,17 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
 		if (bvprvp && bvec_gap_to_prev(q, bvprvp, bv.bv_offset))
 			goto split;
 
+		if (sectors + (bv.bv_len >> 9) > blk_max_size_offset(q, bio->bi_iter.bi_sector)) {
+			/*
+			 * Consider this a new segment if we're taking any part
+			 * of this vector.
+			 */
+			if (sectors < blk_max_size_offset(q, bio->bi_iter.bi_sector))
+				++nsegs;
+			sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector);
+			goto split;
+		}
+
 		if (bvprvp && blk_queue_cluster(q)) {
 			if (seg_size + bv.bv_len > queue_max_segment_size(q))
 				goto new_segment;
-- 
2.6.2.307.g37023ba

             reply	other threads:[~2016-01-04 18:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-04 18:24 Keith Busch [this message]
2016-01-05  4:54 ` [PATCH for-4.4] block: split bios to max possible length Ming Lei
2016-01-05 15:09   ` Keith Busch
2016-01-06  2:17     ` Ming Lei
2016-01-06  5:51       ` Keith Busch
2016-01-06  6:29         ` Ming Lei
2016-01-06  6:53           ` Ming Lei
2016-01-06 15:18             ` Keith Busch
2016-01-06 15:43               ` Ming Lei
2016-01-06 16:21                 ` Keith Busch
2016-01-07  0:14                   ` Ming Lei
2016-01-07 10:46                   ` Kent Overstreet
2016-01-09 11:10                     ` Ming Lei
2016-01-06 15:29           ` Keith Busch
2016-01-06  9:46         ` Ming Lei

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=1451931895-17474-1-git-send-email-keith.busch@intel.com \
    --to=keith.busch@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.