From: NeilBrown <neilb@suse.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Joe Lawrence <joe.lawrence@stratus.com>,
linux-raid@vger.kernel.org, kmo@daterainc.com
Subject: Re: [PATCH 1/2] block: add bio_rewind() to reset bio_vec
Date: Mon, 15 Jul 2013 09:40:43 +1000 [thread overview]
Message-ID: <20130715094043.7eea1ca1@notabene.brown> (raw)
In-Reply-To: <1373315114-16625-1-git-send-email-joe.lawrence@stratus.com>
[-- Attachment #1: Type: text/plain, Size: 2745 bytes --]
Hi Jens,
(I tried sending this a week ago but managed to not include your email - no
wonder I didn't get a reply!)
Are you OK with adding this to fs/bio.c?
The follow-on patch which uses it to fix a crash in md in 3.10 is at
http://marc.info/?l=linux-raid&m=137331514131503&w=2
If so: will you submit or should I? Both patches are in my "for-next" and
so should be in linux-next.
If not, I'll just do something local in raid1 to reset the bio before
calling bio_copy_data().
Thanks,
NeilBrown
On Mon, 8 Jul 2013 16:25:13 -0400 Joe Lawrence <joe.lawrence@stratus.com>
wrote:
> Provide a mechanism for drivers to "rewind" a bio, essentially undoing
> all bio_advance() calls on the bio. After the rewind, the bio idx will
> be 0, size and sector reset, and each bio_vec len and offset restored to
> their initial values.
>
> Suggested-by: NeilBrown <neilb@suse.de>
> Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com>
> ---
> fs/bio.c | 27 +++++++++++++++++++++++++++
> include/linux/bio.h | 1 +
> 2 files changed, 28 insertions(+)
>
> diff --git a/fs/bio.c b/fs/bio.c
> index 94bbc04..04309df 100644
> --- a/fs/bio.c
> +++ b/fs/bio.c
> @@ -833,6 +833,33 @@ void bio_advance(struct bio *bio, unsigned bytes)
> EXPORT_SYMBOL(bio_advance);
>
> /**
> + * bio_rewind - reset a bio to its start
> + * @bio: bio to rewind
> + *
> + * This resets bi_sector, bi_size and bi_idx; completely undoing all
> + * bio_advances on the @bio.
> + */
> +void bio_rewind(struct bio *bio)
> +{
> + int bytes = 0;
> +
> + if (bio->bi_idx < bio->bi_vcnt && bio_iovec(bio)->bv_offset > 0) {
> + bytes = bio_iovec(bio)->bv_offset;
> + bio_iovec(bio)->bv_offset -= bytes;
> + bio_iovec(bio)->bv_len += bytes;
> + }
> + while (bio->bi_idx) {
> + bio->bi_idx -= 1;
> + bio_iovec(bio)->bv_len += bio_iovec(bio)->bv_offset;
> + bio_iovec(bio)->bv_offset = 0;
> + bytes += bio_iovec(bio)->bv_len;
> + }
> + bio->bi_size += bytes;
> + bio->bi_sector -= bytes >> 9;
> +}
> +EXPORT_SYMBOL(bio_rewind);
> +
> +/**
> * bio_alloc_pages - allocates a single page for each bvec in a bio
> * @bio: bio to allocate pages for
> * @gfp_mask: flags for allocation
> diff --git a/include/linux/bio.h b/include/linux/bio.h
> index ef24466..e2082fb 100644
> --- a/include/linux/bio.h
> +++ b/include/linux/bio.h
> @@ -258,6 +258,7 @@ extern int bio_phys_segments(struct request_queue *, struct bio *);
>
> extern int submit_bio_wait(int rw, struct bio *bio);
> extern void bio_advance(struct bio *, unsigned);
> +extern void bio_rewind(struct bio *);
>
> extern void bio_init(struct bio *);
> extern void bio_reset(struct bio *);
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
next prev parent reply other threads:[~2013-07-14 23:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-02 1:20 RAID1 repair GPF crash w/3.10-rc7 Joe Lawrence
2013-07-03 21:49 ` Joe Lawrence
2013-07-04 0:53 ` NeilBrown
2013-07-08 20:06 ` Joe Lawrence
2013-07-08 20:25 ` [PATCH 1/2] block: add bio_rewind() to reset bio_vec Joe Lawrence
2013-07-14 23:40 ` NeilBrown [this message]
2013-07-08 20:25 ` [PATCH 2/2] md: raid1: use bio_rewind() before bio_copy_data() Joe Lawrence
2013-07-09 4:33 ` NeilBrown
2013-07-17 6:12 ` RAID1 repair GPF crash w/3.10-rc7 NeilBrown
2013-07-17 21:01 ` Joe Lawrence
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=20130715094043.7eea1ca1@notabene.brown \
--to=neilb@suse.de \
--cc=axboe@kernel.dk \
--cc=joe.lawrence@stratus.com \
--cc=kmo@daterainc.com \
--cc=linux-raid@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).