[1/3] block: improve the gap check in __bio_add_pc_page
diff mbox series

Message ID 20190703130036.4105-2-hch@lst.de
State New
Headers show
Series
  • [1/3] block: improve the gap check in __bio_add_pc_page
Related show

Commit Message

hch@lst.de July 3, 2019, 1 p.m. UTC
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>
---
 block/bio.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Johannes Thumshirn July 3, 2019, 2:40 p.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>

Patch
diff mbox series

diff --git a/block/bio.c b/block/bio.c
index 29cd6cf4da51..6be22b8477ce 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -709,18 +709,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))