All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: makes bio_split support bio without data
@ 2012-09-24  4:56 NeilBrown
  2012-09-24  8:35 ` Namhyung Kim
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: NeilBrown @ 2012-09-24  4:56 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Shaohua Li, lkml

[-- Attachment #1: Type: text/plain, Size: 2072 bytes --]


Hi Jens,
 this patch has been sitting in my -next tree for a little while and I was
 hoping for it to go in for the next merge window.
 It simply allows bio_split() to be used on bios without a payload, such as
 'discard'.
 Are you happy with it going in though my 'md' tree, or would you rather take
 it though your 'block' tree?

Thanks,
NeilBrown


From: Shaohua Li <shli@fusionio.com>
Date: Thu, 20 Sep 2012 09:36:03 +1000
Subject: [PATCH] block: makes bio_split support bio without data

discard bio hasn't data attached. We hit a BUG_ON with such bio. This makes
bio_split works for such bio.

Signed-off-by: Shaohua Li <shli@fusionio.com>
Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/fs/bio.c b/fs/bio.c
index 71072ab..dbb7a6c 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1501,7 +1501,7 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors)
 	trace_block_split(bdev_get_queue(bi->bi_bdev), bi,
 				bi->bi_sector + first_sectors);
 
-	BUG_ON(bi->bi_vcnt != 1);
+	BUG_ON(bi->bi_vcnt != 1 && bi->bi_vcnt != 0);
 	BUG_ON(bi->bi_idx != 0);
 	atomic_set(&bp->cnt, 3);
 	bp->error = 0;
@@ -1511,17 +1511,19 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors)
 	bp->bio2.bi_size -= first_sectors << 9;
 	bp->bio1.bi_size = first_sectors << 9;
 
-	bp->bv1 = bi->bi_io_vec[0];
-	bp->bv2 = bi->bi_io_vec[0];
-	bp->bv2.bv_offset += first_sectors << 9;
-	bp->bv2.bv_len -= first_sectors << 9;
-	bp->bv1.bv_len = first_sectors << 9;
+	if (bi->bi_vcnt != 0) {
+		bp->bv1 = bi->bi_io_vec[0];
+		bp->bv2 = bi->bi_io_vec[0];
+		bp->bv2.bv_offset += first_sectors << 9;
+		bp->bv2.bv_len -= first_sectors << 9;
+		bp->bv1.bv_len = first_sectors << 9;
 
-	bp->bio1.bi_io_vec = &bp->bv1;
-	bp->bio2.bi_io_vec = &bp->bv2;
+		bp->bio1.bi_io_vec = &bp->bv1;
+		bp->bio2.bi_io_vec = &bp->bv2;
 
-	bp->bio1.bi_max_vecs = 1;
-	bp->bio2.bi_max_vecs = 1;
+		bp->bio1.bi_max_vecs = 1;
+		bp->bio2.bi_max_vecs = 1;
+	}
 
 	bp->bio1.bi_end_io = bio_pair_end_1;
 	bp->bio2.bi_end_io = bio_pair_end_2;

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-10-03 16:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-24  4:56 [PATCH] block: makes bio_split support bio without data NeilBrown
2012-09-24  8:35 ` Namhyung Kim
2012-09-24 23:37   ` NeilBrown
2012-09-25 12:51 ` Jens Axboe
2012-09-28  7:36   ` Shaohua Li
2012-09-28  8:39     ` Jens Axboe
2012-09-28 16:23 ` Kent Overstreet
2012-10-02  6:22   ` NeilBrown
2012-10-02 21:09     ` Kent Overstreet
2012-10-03  3:30       ` NeilBrown
2012-10-03  3:42         ` Kent Overstreet
2012-10-03 16:22           ` Martin K. Petersen

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.