[PATCH 5/6] brd: Split bio if needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If a bio is submitted to the brd driver that does not satisfy the
requirements of this driver, split the bio.

Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx>
Cc: Jan Kara <jack@xxxxxxx>
Cc: Christoph Hellwig <hch@xxxxxx>
Cc: Mike Snitzer <snitzer@xxxxxxxxxx>
Cc: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
Cc: Dmitry Monakhov <dmonakhov@xxxxxxxxxx>
---
 block/blk-merge.c   | 2 +-
 drivers/block/brd.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/blk-merge.c b/block/blk-merge.c
index 2ce5a78..c158577 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -39,7 +39,7 @@ static struct bio *blk_bio_discard_split(struct request_queue *q,
 		if (end == end_r && bio_sectors(bio) == end_r - start)
 			return NULL;
 		return bio_split(bio, end_r - start, GFP_NOIO, bs);
-	} else if (q->limits.discard_zeroes_data) {
+	} else if (q->limits.discard_zeroes_data && start < end) {
 		end = min(end, start_r + granularity);
 		wr = bio_alloc_bioset(GFP_NOIO, end - start, bs);
 		if (WARN_ON_ONCE(!wr))
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 1914c63..7e0a54e 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -336,6 +336,8 @@ static blk_qc_t brd_make_request(struct request_queue *q, struct bio *bio)
 	if (bio_end_sector(bio) > get_capacity(bdev->bd_disk))
 		goto io_error;
 
+	blk_queue_split(q, &bio, q->bio_split);
+
 	if (unlikely(bio->bi_rw & REQ_DISCARD)) {
 		if (sector & ((PAGE_SIZE >> SECTOR_SHIFT) - 1) ||
 		    bio->bi_iter.bi_size & ~PAGE_MASK)
-- 
2.1.4

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel



[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux