From: Shaohua Li <shli@kernel.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: NeilBrown <neilb@suse.de>, Shaohua Li <shli@fusionio.com>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] block: makes bio_split support bio without data
Date: Fri, 28 Sep 2012 15:36:55 +0800 [thread overview]
Message-ID: <20120928073655.GA24681@kernel.org> (raw)
In-Reply-To: <5061A8EA.6040702@kernel.dk>
On Tue, Sep 25, 2012 at 02:51:54PM +0200, Jens Axboe wrote:
> On 09/24/2012 06:56 AM, NeilBrown wrote:
> >
> > 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?
>
> It should go through my tree, especially since we've got conflicts with
> other changes. In other words, your patch does not apply to for-3.7/core
> as-is...
>
> Shaohua, could you resend an updated variant?
Here is the one applied to for-3.7/core
Subject: 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>
---
fs/bio.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
Index: linux/fs/bio.c
===================================================================
--- linux.orig/fs/bio.c 2012-09-28 15:09:38.000000000 +0800
+++ linux/fs/bio.c 2012-09-28 15:25:38.955252846 +0800
@@ -1475,7 +1475,7 @@ struct bio_pair *bio_split(struct bio *b
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;
@@ -1485,20 +1485,22 @@ struct bio_pair *bio_split(struct bio *b
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];
+ if (bi->bi_vcnt != 0) {
+ bp->bv1 = bi->bi_io_vec[0];
+ bp->bv2 = bi->bi_io_vec[0];
+
+ if (bio_is_rw(bi)) {
+ bp->bv2.bv_offset += first_sectors << 9;
+ bp->bv2.bv_len -= first_sectors << 9;
+ bp->bv1.bv_len = first_sectors << 9;
+ }
- if (bio_is_rw(bi)) {
- 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;
next prev parent reply other threads:[~2012-09-28 7:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-24 4:56 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 [this message]
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
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=20120928073655.GA24681@kernel.org \
--to=shli@kernel.org \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@suse.de \
--cc=shli@fusionio.com \
/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
Powered by JetHome