FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Device-mapper Development

 
 
LinkBack Thread Tools
 
Old 09-20-2012, 11:45 PM
Tejun Heo
 
Default block: Don't use bi_idx in bio_split() or require it to be 0

On Mon, Sep 10, 2012 at 05:22:18PM -0700, Kent Overstreet wrote:
> Prep work for immutable bio_vecs/efficient bio splitting: they require
> auditing and removing most uses of bi_idx.
>
> So here we convert bio_split() to respect the current value of bi_idx
> and use the bio_iovec() macro, instead of assuming bi_idx will be 0.

I find the description a bit cryptic.

> Signed-off-by: Kent Overstreet <koverstreet@google.com>
> CC: Jens Axboe <axboe@kernel.dk>
> ---
> drivers/block/drbd/drbd_req.c | 6 +++---
> drivers/md/raid0.c | 3 +--
> drivers/md/raid10.c | 3 +--
> fs/bio-integrity.c | 4 ++--
> fs/bio.c | 7 +++----
> 5 files changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
> index af69a96..57eb253 100644
> --- a/drivers/block/drbd/drbd_req.c
> +++ b/drivers/block/drbd/drbd_req.c
> @@ -1155,11 +1155,11 @@ void drbd_make_request(struct request_queue *q, struct bio *bio)
>
> /* can this bio be split generically?
> * Maybe add our own split-arbitrary-bios function. */
> - if (bio->bi_vcnt != 1 || bio->bi_idx != 0 || bio->bi_size > DRBD_MAX_BIO_SIZE) {
> + if (bio_segments(bio) != 1 || bio->bi_size > DRBD_MAX_BIO_SIZE) {
> /* rather error out here than BUG in bio_split */
> dev_err(DEV, "bio would need to, but cannot, be split: "
> - "(vcnt=%u,idx=%u,size=%u,sector=%llu)
",
> - bio->bi_vcnt, bio->bi_idx, bio->bi_size,
> + "(segments=%u,size=%u,sector=%llu)
",
> + bio_segments(bio), bio->bi_size,
> (unsigned long long)bio->bi_sector);
> bio_endio(bio, -EINVAL);
> } else {
> diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
> index 387cb89..0587450 100644
> --- a/drivers/md/raid0.c
> +++ b/drivers/md/raid0.c
> @@ -509,8 +509,7 @@ static void raid0_make_request(struct mddev *mddev, struct bio *bio)
> sector_t sector = bio->bi_sector;
> struct bio_pair *bp;
> /* Sanity check -- queue functions should prevent this happening */
> - if (bio->bi_vcnt != 1 ||
> - bio->bi_idx != 0)
> + if (bio_segments(bio) != 1)
> goto bad_map;
> /* This is a one page bio that upper layers
> * refuse to split for us, so we need to split it.
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 9715aaf..bbd08f5 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -1081,8 +1081,7 @@ static void make_request(struct mddev *mddev, struct bio * bio)
> || conf->prev.near_copies < conf->prev.raid_disks))) {
> struct bio_pair *bp;
> /* Sanity check -- queue functions should prevent this happening */
> - if (bio->bi_vcnt != 1 ||
> - bio->bi_idx != 0)
> + if (bio_segments(bio) != 1)
> goto bad_map;
> /* This is a one page bio that upper layers
> * refuse to split for us, so we need to split it.

And wonder how the description applies to the above.

> --- a/fs/bio.c
> +++ b/fs/bio.c
> @@ -1616,8 +1616,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_idx != 0);
> + BUG_ON(bio_segments(bi) != 1);
> atomic_set(&bp->cnt, 3);
> bp->error = 0;
> bp->bio1 = *bi;
> @@ -1626,8 +1625,8 @@ 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->bv1 = *bio_iovec(bi);
> + bp->bv2 = *bio_iovec(bi);

This conflicts with a recent commit from Martin. You probably wanna
rebase.

Thanks.

--
tejun

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 
Old 09-21-2012, 12:00 AM
Kent Overstreet
 
Default block: Don't use bi_idx in bio_split() or require it to be 0

On Thu, Sep 20, 2012 at 04:45:44PM -0700, Tejun Heo wrote:
> On Mon, Sep 10, 2012 at 05:22:18PM -0700, Kent Overstreet wrote:
> > Prep work for immutable bio_vecs/efficient bio splitting: they require
> > auditing and removing most uses of bi_idx.
> >
> > So here we convert bio_split() to respect the current value of bi_idx
> > and use the bio_iovec() macro, instead of assuming bi_idx will be 0.
>
> I find the description a bit cryptic.

Yeah, I wasn't able to come up with a better description at the time...
how's this:

Change bio_split() to respect the current value of bi_idx

In the current code bio_split() won't be seeing partially completed bios
so this doesn't change any behaviour, but this makes the code a bit
clearer as to what bio_split() actually requires.

The immediate purpose of the patch is removing unnecessary bi_idx
references, but the end goal is to allow partial completed bios to be
submitted, which along with immutable biovecs enables effecient bio
splitting.


>
> > Signed-off-by: Kent Overstreet <koverstreet@google.com>
> > CC: Jens Axboe <axboe@kernel.dk>
> > ---
> > drivers/block/drbd/drbd_req.c | 6 +++---
> > drivers/md/raid0.c | 3 +--
> > drivers/md/raid10.c | 3 +--
> > fs/bio-integrity.c | 4 ++--
> > fs/bio.c | 7 +++----
> > 5 files changed, 10 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
> > index af69a96..57eb253 100644
> > --- a/drivers/block/drbd/drbd_req.c
> > +++ b/drivers/block/drbd/drbd_req.c
> > @@ -1155,11 +1155,11 @@ void drbd_make_request(struct request_queue *q, struct bio *bio)
> >
> > /* can this bio be split generically?
> > * Maybe add our own split-arbitrary-bios function. */
> > - if (bio->bi_vcnt != 1 || bio->bi_idx != 0 || bio->bi_size > DRBD_MAX_BIO_SIZE) {
> > + if (bio_segments(bio) != 1 || bio->bi_size > DRBD_MAX_BIO_SIZE) {
> > /* rather error out here than BUG in bio_split */
> > dev_err(DEV, "bio would need to, but cannot, be split: "
> > - "(vcnt=%u,idx=%u,size=%u,sector=%llu)
",
> > - bio->bi_vcnt, bio->bi_idx, bio->bi_size,
> > + "(segments=%u,size=%u,sector=%llu)
",
> > + bio_segments(bio), bio->bi_size,
> > (unsigned long long)bio->bi_sector);
> > bio_endio(bio, -EINVAL);
> > } else {
> > diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
> > index 387cb89..0587450 100644
> > --- a/drivers/md/raid0.c
> > +++ b/drivers/md/raid0.c
> > @@ -509,8 +509,7 @@ static void raid0_make_request(struct mddev *mddev, struct bio *bio)
> > sector_t sector = bio->bi_sector;
> > struct bio_pair *bp;
> > /* Sanity check -- queue functions should prevent this happening */
> > - if (bio->bi_vcnt != 1 ||
> > - bio->bi_idx != 0)
> > + if (bio_segments(bio) != 1)
> > goto bad_map;
> > /* This is a one page bio that upper layers
> > * refuse to split for us, so we need to split it.
> > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> > index 9715aaf..bbd08f5 100644
> > --- a/drivers/md/raid10.c
> > +++ b/drivers/md/raid10.c
> > @@ -1081,8 +1081,7 @@ static void make_request(struct mddev *mddev, struct bio * bio)
> > || conf->prev.near_copies < conf->prev.raid_disks))) {
> > struct bio_pair *bp;
> > /* Sanity check -- queue functions should prevent this happening */
> > - if (bio->bi_vcnt != 1 ||
> > - bio->bi_idx != 0)
> > + if (bio_segments(bio) != 1)
> > goto bad_map;
> > /* This is a one page bio that upper layers
> > * refuse to split for us, so we need to split it.
>
> And wonder how the description applies to the above.
>
> > --- a/fs/bio.c
> > +++ b/fs/bio.c
> > @@ -1616,8 +1616,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_idx != 0);
> > + BUG_ON(bio_segments(bi) != 1);
> > atomic_set(&bp->cnt, 3);
> > bp->error = 0;
> > bp->bio1 = *bi;
> > @@ -1626,8 +1625,8 @@ 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->bv1 = *bio_iovec(bi);
> > + bp->bv2 = *bio_iovec(bi);
>
> This conflicts with a recent commit from Martin. You probably wanna
> rebase.
>
> Thanks.
>
> --
> tejun

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

Thread Tools




All times are GMT. The time now is 04:25 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org