From: NeilBrown <nfbrown@novell.com>
To: Chris Dunlop <chris@onthe.net.au>
Cc: Wols Lists <antlists@youngman.org.uk>,
Brad Campbell <lists2009@fnarfbargle.com>,
linux-raid@vger.kernel.org
Subject: Re: Rewrite md raid1 member
Date: Sat, 20 Aug 2016 16:52:46 +1000 [thread overview]
Message-ID: <87h9aggce9.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20160820015708.GB30642@onthe.net.au>
[-- Attachment #1: Type: text/plain, Size: 3011 bytes --]
On Sat, Aug 20 2016, Chris Dunlop wrote:
> Hi Neil,
>
> Nice work on the Bus1 article!
Thanks :-)
>
> On Sat, Aug 20, 2016 at 07:26:27AM +1000, NeilBrown wrote:
>> On Fri, Aug 19 2016, Chris Dunlop wrote:
>>> In my case, I want it to write everything.
>>>
>>> If I do my 'dd' to write everything as previously described, with the window
>>> of opportunity for stale data to end up on the written disk, one option
>>> would to run a scrub / repair to check the data is the same - but if I'm
>>> unlucky with my dd and the data isn't the same for some sector[s], I want to
>>> ensure the correct data is copied over the stale data and not the other way
>>> around, e.g. to specify "in the event of a mismatch, use the data from sda
>>> and overwrite the data on sdb".
>>>
>>> Unfortunately I don't know how that can be done.
>>>
>>> Does anyone know?
>>
>> If it is the second device in the array (as listed by mdadm --detail)
>> then you can stop the array and re-assemble with --update=resync.
>
> That's nearly there - except in this specific case it's my root filesystem
> so I can't stop the array without booting into a recovery disk etc. Of
> course I could do that, but the point of the exercise is to see if it can
> be done live, safely.
Well... you could
cd /sys/block/mdXX/md
echo frozen > sync_action
echo 0 > resync_start
echo idle > sync_action
that should start a resync on a live array.
Still, only works for non-first device in RAID1
>
>> If it is the first device I can only suggest that you
>> fail the device and add it again:
>>
>> mdadm /dev/mdXX --fail /dev/sdYY
>> mdadm /dev/mdXX --remove /dev/sdYY
>> mdadm /dev/mdYY --add /dev/sdYY
>>
>> If the "good" drive fails during the rewrite it might be a little bit
>> fiddley getting the array working again, but all the data will certainly
>> be there on the device you are re-writing, so you won't lose anything.
>
> OK, that sounds good. What would the process be if the good drive fails,
> either completely, or a few specific sectors?
If you think there is a serious risk of that happening, then it's best
to skip this option.
You would need to boot from a rescue disk and re-create the array using
just the working device - and make sure the same data-offset and size
are used. Certainly possible, but not at all straightforward.
Another thing you could do, particularly if you know what region of the
device needs to be over-written, is to write sector numbers to
suspend_lo and suspend_hi. This will suspend all IO through the
/dev/mdXX device to that range of array sectors.
Then you could read from/write to the raw device with dd or whatever.
raid6check.c does this on a raid6 to correct errors that can be detected
with the raid6 syndrome, even while the array is online. A similar
thing could be done to allow individual blocks to be rewritten.
Care is needed to map between array addresses and device addresses.
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
prev parent reply other threads:[~2016-08-20 6:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-18 3:04 Rewrite md raid1 member Chris Dunlop
2016-08-18 3:27 ` Brad Campbell
2016-08-18 4:01 ` Chris Dunlop
2016-08-19 11:52 ` Wols Lists
2016-08-19 12:46 ` Chris Dunlop
2016-08-19 16:10 ` Chris Murphy
2016-08-20 1:43 ` Chris Dunlop
2016-08-20 10:44 ` Wols Lists
2016-08-19 21:26 ` NeilBrown
2016-08-20 1:57 ` Chris Dunlop
2016-08-20 6:52 ` NeilBrown [this message]
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=87h9aggce9.fsf@notabene.neil.brown.name \
--to=nfbrown@novell.com \
--cc=antlists@youngman.org.uk \
--cc=chris@onthe.net.au \
--cc=linux-raid@vger.kernel.org \
--cc=lists2009@fnarfbargle.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;
as well as URLs for NNTP newsgroup(s).