linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Joe Lawrence <joe.lawrence@stratus.com>
Cc: linux-raid@vger.kernel.org
Subject: Re: RAID1 repair GPF crash w/3.10-rc7
Date: Thu, 4 Jul 2013 10:53:37 +1000	[thread overview]
Message-ID: <20130704105337.2a06cbfd@notabene.brown> (raw)
In-Reply-To: <alpine.DEB.2.02.1307031634440.9749@jlaw-desktop.mno.stratus.com>

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

On Wed, 3 Jul 2013 17:49:51 -0400 (EDT) Joe Lawrence
<joe.lawrence@stratus.com> wrote:

> On Mon, 1 Jul 2013, Joe Lawrence wrote:
> 
> > Hi Kent & Neil,
> > 
> > I've hit a crash in MD during RAID1 repair while running 3.10-rc7:
> >
> > [ ... snip ... ]
> 
> Hi Neil,
> 
> Looking through the MD source, I'm trying to understand part of the
> RAID1 repair path.  I came up with a few questions:
> 
> 1 - During user initiated RAID1 repair, is the loop at the bottom of
> sync_request(), under the bio_full label, responsible for submitting all
> of the initial read bios?

Yes.

> 
> 2 - Does process_checks() later find the first uptodate read bio and
> copy its data into the other r1_bio->bios[] for write repair to the
> other disks?

Yes.

> 
> If both are true, then perhaps the following applies to this crash...
> 
> Comments in commit f79ea416 "block: Refactor blk_update_request()" msg
> include:
> 
>     Note that req_bio_endio() now always calls bio_advance() - which
>     means it always loops over the biovec, not just on partial
>     completions.  Don't expect it to affect performance, but worth
>     noting.
> 
> Now that process_checks() has been further modified for immutable bio
> prep (commit d3b45c2 "raid1: use bio_copy_data()"), it calls
> bio_copy_data() to fill in the write repair bios... which starts
> indexing the bi_bio_vec[] from wherever bi_idx happens to be.
> 
> If this is indeed the case, I'm having trouble coming up with a good
> solution:
> 
>   - Immutable bios means drivers don't touch bi_idx.  So MD shouldn't
>     "re-wind" the source bi_idx before calling bio_copy_data().

But MD "owns" this bio.  It knows exactly how it was created, and can do
what ever it likes after it has been returned.

I would propose "bio_rewind" that exactly undoes any "bio_advance". 
Something like

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_bi_sector -= bytes >> 9;
}

Then call that on pbio at the same place we call bio_reset on sbio.

You could probably also call bio_rewind on sbio, and remove lots of that
code for setting the bio up again.
(or don't bother with bio_rewind, and use the same big lump of code on both
pbio and sbio).

Could you confirm that one of those works?

Thanks.

NeilBrown


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

  reply	other threads:[~2013-07-04  0:53 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 [this message]
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
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=20130704105337.2a06cbfd@notabene.brown \
    --to=neilb@suse.de \
    --cc=joe.lawrence@stratus.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).