linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Johannes Thumshirn <jthumshirn@suse.de>
Subject: [PATCH 1/3] block: improve the gap check in __bio_add_pc_page
Date: Mon, 12 Aug 2019 17:39:56 +0200	[thread overview]
Message-ID: <20190812153958.29560-2-hch@lst.de> (raw)
In-Reply-To: <20190812153958.29560-1-hch@lst.de>

If we can add more data into an existing segment we do not create a gap
per definition, so move the check for a gap after the attempt to merge
into the segment.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 block/bio.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 24a496f5d2e2..9f80bf4531b3 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -710,18 +710,18 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
 			goto done;
 		}
 
-		/*
-		 * If the queue doesn't support SG gaps and adding this
-		 * offset would create a gap, disallow it.
-		 */
-		if (bvec_gap_to_prev(q, bvec, offset))
-			return 0;
-
 		if (page_is_mergeable(bvec, page, len, offset, &same_page) &&
 		    can_add_page_to_seg(q, bvec, page, len, offset)) {
 			bvec->bv_len += len;
 			goto done;
 		}
+
+		/*
+		 * If the queue doesn't support SG gaps and adding this segment
+		 * would create a gap, disallow it.
+		 */
+		if (bvec_gap_to_prev(q, bvec, offset))
+			return 0;
 	}
 
 	if (bio_full(bio, len))
-- 
2.20.1


  reply	other threads:[~2019-08-12 15:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-12 15:39 bio_add_pc_page cleanups Christoph Hellwig
2019-08-12 15:39 ` Christoph Hellwig [this message]
2019-08-12 15:39 ` [PATCH 2/3] block: create a bio_try_merge_pc_page helper Christoph Hellwig
2019-08-12 15:39 ` [PATCH 3/3] block: move same page handling from __bio_add_pc_page to the callers Christoph Hellwig
2019-08-22  1:00 ` bio_add_pc_page cleanups Christoph Hellwig
2019-08-22 13:15 ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2019-07-03 13:00 Christoph Hellwig
2019-07-03 13:00 ` [PATCH 1/3] block: improve the gap check in __bio_add_pc_page Christoph Hellwig
2019-07-03 14:40   ` Johannes Thumshirn

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=20190812153958.29560-2-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=jthumshirn@suse.de \
    --cc=linux-block@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;
as well as URLs for NNTP newsgroup(s).