From: Jim Paris <jim@jtan.com>
To: linux-raid@vger.kernel.org
Subject: Data corruption after resizing partition, when using bitmaps
Date: Tue, 19 May 2015 10:12:40 -0400 [thread overview]
Message-ID: <20150519141239.GA5309@psychosis.jim.sh> (raw)
[-- Attachment #1: Type: text/plain, Size: 1705 bytes --]
I had a raid1 mirror consisting of big partitions on two disks.
The first disk was 2TB, partitioned like this:
[--sda1(128M)--][-------sda2(~2T)--------------]
The second disk was 3TB, partitioned like this:
[--sdb1(128M)--][-------sdb2(~3T)------------------------------------]
sda2 and sdb2 were part of the array, which was only ~2TB in size due
to the smaller disk.
I realized that I needed to add a BIOS boot partition to the 3TB disk,
so I removed sdb2 from the array, and repartitioned sdb like this:
[--sdb1(128M)--][--sdb2(1M)--][-------sdb3(~3T)----------------------]
Then I added sdb3 to the array. And lost all my data. :(
What happened was that the last sector of the big partition did not
change location. So the metadata (0.90) at the end was still present.
Adding sdb3 to the array was considered a "re-add" because the UUID
and array sizes still matched the array, even though the partition
itself shrank. And the resync was thus guided by an out-of-date
bitmap, which caused very little data to actually be written to sdb3,
so half the reads from the array started returning junk. Once the
filesystem got involved, the result was rapid corruption.
If I had not been using write-intent bitmaps, everything would have
worked fine. I only recently started using bitmaps, and never had any
problems with adjusting partitions like this before that.
Perhaps mdadm can be more careful here -- for example, maybe checking
the actual device size and not just the "used dev size" when
determining whether to trust the bitmap.
I wrote a script (attached) to recreate what happened, using some loop
devices. It works fine if BITMAP=none, and fails with BITMAP=internal.
Jim
[-- Attachment #2: repro.sh --]
[-- Type: application/x-sh, Size: 3181 bytes --]
next reply other threads:[~2015-05-19 14:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-19 14:12 Jim Paris [this message]
2015-05-20 5:31 ` Data corruption after resizing partition, when using bitmaps NeilBrown
2015-05-20 6:31 ` Jim Paris
2015-05-21 0:24 ` NeilBrown
2015-05-21 5:58 ` Jim Paris
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=20150519141239.GA5309@psychosis.jim.sh \
--to=jim@jtan.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).