summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-08-12 17:39:56 +0200
committerJens Axboe <axboe@kernel.dk>2019-08-22 15:14:36 +0200
commit320ea869a12cec206756207c6ca5f817ec45c7f2 (patch)
treef47241df847ce8a065edf328cf94794e8f4694c0 /block
parentnbd: fix max number of supported devs (diff)
downloadlinux-320ea869a12cec206756207c6ca5f817ec45c7f2.tar.xz
linux-320ea869a12cec206756207c6ca5f817ec45c7f2.zip
block: improve the gap check in __bio_add_pc_page
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> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/bio.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/block/bio.c b/block/bio.c
index 54769659a434..537d71a30e56 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))