linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [md PATCH 0/6] Reduce the number of devices in RAID4/5/6
@ 2009-03-24  8:53 NeilBrown
  2009-03-24  8:53 ` [md PATCH 3/6] md: add explicit method to signal the end of a reshape NeilBrown
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: NeilBrown @ 2009-03-24  8:53 UTC (permalink / raw)
  To: linux-raid

Here is a set of patches I just finished that will be submitted for
2.6.30.
They make it possible to reduce the number of devices in a raid 4/5/6
array.

There is no support in mdadm for this yet so:
  a/ it has to be done by hand, writing to sysfs
  b/ there is no protection for the "critical section".
     So if you try this and your system crashes just before
     the reshape finishes, you lose data.

When reducing the number of device, you need to reduce the size of the
array first.  This can be done by writing to the "array_size"
attribute.
Alternately you can write the current size to the array_size
attribute, to pin it, then use "mdadm --grow --size=whatever" to use
more of the devices.  That is what the script below does.

When reducing the number of devices in an array, restriping starts at
the end of the devices and works towards the beginning.  When it gets
to the first few chunks it needs to over-write data that is currently
live.  This is perfectly safe unless the system crashes.  In that case
see the comment about "critical section" above.

The following script give some idea how to use this if you want to
experiment.  I kept and ext3 filesystem on md0 busy while this was
happening, and it fscked perfectly afterwards.

Note that the array starts degraded (I only have 5 test disks) and
ends degraded.  But then there are suddenly two spare devices, so it
start recovery straight away.

Comments or improvements, as always, very welcome.

NeilBrown

# test script for shrinking a raid5
# from 6 devices to 4
# don't worry about critical section
# make the devices larger first

mdadm -Ss
mdadm -CR /dev/md0 -l5 -n6 -z 2000000 missing /dev/sd[bcdef]
mdadm --wait /dev/md0
cat /proc/mdstat
echo 4 > /sys/block/md0/md/raid_disks
# freeze the array size at 5*2000000
echo 10000000 > /sys/block/md0/md/array_size
# make the individual devices bigger to 3333376
mdadm -G /dev/md0 --size 3333376
sleep 2
echo reshape > /sys/block/md0/md/sync_action
sleep 2
cat /proc/mdstat
mdadm --wait /dev/md0
echo default > /sys/block/md0/md/array_size
cat /proc/mdstat


---

NeilBrown (6):
      Documentation/md.txt update
      md: allow number of drives in raid5 to be reduced
      md/raid5: change reshape-progress measurement to cope with reshaping backwards.
      md: add explicit method to signal the end of a reshape.
      md/raid5: enhance raid5_size to work correctly with negative delta_disks
      md/raid5: drop qd_idx from r6_state


 Documentation/md.txt |   37 ++++++-
 drivers/md/md.c      |   11 +-
 drivers/md/md.h      |    2 
 drivers/md/raid5.c   |  259 ++++++++++++++++++++++++++++++++++----------------
 drivers/md/raid5.h   |   17 ++-
 5 files changed, 219 insertions(+), 107 deletions(-)



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2009-03-30  9:20 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-24  8:53 [md PATCH 0/6] Reduce the number of devices in RAID4/5/6 NeilBrown
2009-03-24  8:53 ` [md PATCH 3/6] md: add explicit method to signal the end of a reshape NeilBrown
2009-03-24  8:53 ` [md PATCH 2/6] md/raid5: enhance raid5_size to work correctly with negative delta_disks NeilBrown
2009-03-24  8:53 ` [md PATCH 4/6] md/raid5: change reshape-progress measurement to cope with reshaping backwards NeilBrown
2009-03-27 16:19   ` Andre Noll
2009-03-27 19:54     ` NeilBrown
2009-03-30  9:09       ` Andre Noll
     [not found]       ` <49CE1713.9070707@tmr.com>
2009-03-30  9:20         ` Andre Noll
2009-03-24  8:53 ` [md PATCH 6/6] Documentation/md.txt update NeilBrown
2009-03-27 16:19   ` Andre Noll
2009-03-27 19:43     ` NeilBrown
2009-03-24  8:53 ` [md PATCH 5/6] md: allow number of drives in raid5 to be reduced NeilBrown
2009-03-27 16:19   ` Andre Noll
2009-03-27 19:39     ` NeilBrown
2009-03-24  8:53 ` [md PATCH 1/6] md/raid5: drop qd_idx from r6_state NeilBrown

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).