NeilBrown [Thu, 18 Dec 2008 05:23:46 +0000 (16:23 +1100)]
map: rebuild map if it doesn't exist.
It is possible for some arrays to be created e.g. by initrd, and so
not get mentioned in /var/run/mdadm/map.
As "-I" depends on things being listed in 'map', we create it by
scanning all devices if it doesn't exist.
NeilBrown [Thu, 18 Dec 2008 03:24:41 +0000 (14:24 +1100)]
Assemble: set stripe_cache_size properly when restarting a reshape.
Reshape with large chunk size can require a large stripe_cache.
We make this work when starting the reshape but not when
restarting at assemble time. So fix that.
NeilBrown [Thu, 18 Dec 2008 03:11:59 +0000 (14:11 +1100)]
Assemble: don't assume array is 'clean' unless all devices think it is.
This is only significant for --assemble --force where some old
devices might be included into the array. If anything looks like
it isn't clean, the kernel will not allow a degraded array to be started.
NeilBrown [Thu, 27 Nov 2008 04:46:51 +0000 (15:46 +1100)]
Assemble: allow --force to work even when event counts are 0.
If any superblocks in a confused array had an event count of 0,
"mdadm -Af" would not update the event counts to assemble the array.
I don't remember why that text is there, and it has caused at least
one situation to be difficult to recover from. So remove the
test. --force means --force!
NeilBrown [Sun, 2 Nov 2008 20:19:37 +0000 (07:19 +1100)]
mapfile: fix bug in testing for /var/run/mdadm/
There was a bug. If /var/run/mdadm/ did not exist as a directory,
the map file should have been created in /var/run/mdadm.map, but
due to bug it would never get created.
NeilBrown [Sun, 2 Nov 2008 19:39:02 +0000 (06:39 +1100)]
Incremental: change precedence order for autof setting.
It doesn't really make sense for the --auto setting to ever over-ride
the setting on an ARRAY line. That could cause failure if the
ARRAY line has a 'standard' now. So revert to the array line having
precedence over command line, then CREATE line last.
NeilBrown [Thu, 30 Oct 2008 05:37:29 +0000 (16:37 +1100)]
Adjust major number testing to allow for extended minor number in 2.6.28
From 2.6.28, normal md device will be able to have partitions. These
partitions will have a different major number. Sometimes mdadm tests
the major number and so can get confused.
Change these tests to test against get_mdp_major(). mdp does not use
extended minor number and so this test will always be accurate.
Also use /sys/dev links to map major/minor to devnum in sysfs.
NeilBrown [Wed, 29 Oct 2008 22:48:18 +0000 (09:48 +1100)]
Incremental: allow assembly of foreign array.
If a foreign (i.e. not known to be local) array is discovered
by --incremental assembly, we now assemble it. However we ignore
any name information in the array so as not to potentially create
a name that conflict with a 'local' array.
Also, foreign arrays are always assembled 'read-auto' to avoid writing
anything until the array is actually used.
NeilBrown [Wed, 29 Oct 2008 22:34:04 +0000 (09:34 +1100)]
Fix --incremental assembly of partitions arrays.
If incremental assembly finds an array mentioned in mdadm.conf,
with a 'standard partitioned' name like /dev/md_d0 or /dev/md/d0,
it will not create a partitioned array like it should.
This is because it mishandled the 'devnum' returned by
is_standard.
That is a devnum that does not have the partition-or-not encoded
into it. So we need to check the actual return value of
is_standard and encode the partition-or-not info into the devnum.
Doug Ledford [Wed, 29 Oct 2008 19:05:36 +0000 (15:05 -0400)]
Fix NULL pointer oops
RAID10 is the only raid level that uses the avail char array pointer
during the enough() operation, so it was the only one that saw this.
The code in incremental assumes unconditionally that count_active will
allocate the avail char array, that it might be used by enough, and that
it will need to be freed afterward. Once you make count_active actually
do that, then the oops goes away.
Doug Ledford [Wed, 29 Oct 2008 19:05:35 +0000 (15:05 -0400)]
Fix bad metadata formatting
Certain operations (Detail.c mainly) would print out the metadata of
an array in a format that the scan operation in super0.c and super1.c
would later reject as unknown when it was found in the mdadm.conf file.
Use a consistent format, but also modify the super0 and super1 match
methods to accept the other format without complaint.
NeilBrown [Sat, 25 Oct 2008 07:20:49 +0000 (18:20 +1100)]
Allow WRITEMOSTLY to be cleared on --readd using --readwrite.
Previously it was possible to set the WRITEMOSTLY flag when
adding a device to an array, but not to clear the flag when re-adding.
This is now possible with --readwrite.
NeilBrown [Fri, 17 Oct 2008 00:52:38 +0000 (11:52 +1100)]
Remove .UR .UE macros from man page because the don't do what we want.
.UR URL
text
.UE
is meant to create a hyperlink from the 'text' to the 'URL'.
But I wanted just to have the URL, so UR isn't really the right
tool - the URL gets displayed twice.
So just display the URL in bold and assume man2html etc can recognise
it and do the right thing.
NeilBrown [Wed, 15 Oct 2008 03:34:18 +0000 (14:34 +1100)]
Grow: Fix linear-growth when devices are not all the same size.
If we add a device to a linear array which is a difference size
to the other devices in the array then, for v1.x metadata, we need to
make sure the size is correctly reflected in the superblock.
NeilBrown [Mon, 13 Oct 2008 05:15:16 +0000 (16:15 +1100)]
Manage: allow adding device that is just large enough to v1.x array.
When adding a device to an array, we check that it is large enough.
Currently the check makes sure there is also room for a reasonably
sized bitmap. But if the array doesn't have a bitmap, then this test
might be too restrictive.
So when adding, only insist there is enough space for the current
bitmap.
When Creating, still require room for the standard sized bitmap.
Clean up usage of open()
Fix on call that passed an invalid mode to open
Don't pass a third arg unless we also pass O_CREAT
Use symbolic args for 2nd and 3rd args
Neil Brown [Wed, 25 Jun 2008 23:11:59 +0000 (09:11 +1000)]
Italic/bold fixes in man pages.
Two places that should have been .B or .I were .M, which of
course is an error.
So fix these and that the opportunity to be more consistent
with highlighting of "mdadm". Make it always italic except when
used as a literal example, then bold.
Neil Brown [Thu, 19 Jun 2008 06:30:36 +0000 (16:30 +1000)]
Fix an error when assembling arrays that are in the middle of a reshape.
It is important that dup_super always returns an 'st' with the same
->ss and ->minor_version as the st that was passed.
This wasn't happening for 0.91 metadata (i.e. in the middle of a reshape).
Neil Brown [Tue, 27 May 2008 07:23:16 +0000 (17:23 +1000)]
Avoid NULL reference calling free_super and elsewhere.
Since we made free_super a superswitch call, we need to be careful
that st is non NULL before calling st->ss->free_super(st).
Also when updating byteorder there is a chance of a similar NULL
deref.
Bill Nottingham [Mon, 5 May 2008 09:44:04 +0000 (19:44 +1000)]
Simplistig locking for --incremental.
From: Bill Nottingham <notting@redhat.com>
mdadm --incremental doesn't really do any locking. If you get multiple
events in parallel for the same device (that has not yet started), they
will all go down the path to create the array. One will succeed, the
rest will have SET_ARRAY_INFO die with -EBUSY (md: array mdX already has disks!)
and will exit without adding the disk.
Original bug report is: https://bugzilla.redhat.com/show_bug.cgi?id=433932
This is solved by adding very very rudimentary locking. Incremental() now
opens the device with O_EXCL to ensure only one invocation is frobbing the
array at once. A simple loop just tries to open 5 times a second for 5
seconds. If the array stays locked that long, you probably have bigger
issues.
Neil Brown [Mon, 28 Apr 2008 06:30:31 +0000 (16:30 +1000)]
Small improvements to --incremental for arrays that are in the middle of reshape
There is still a problem: If array is partially assembled and started
read-only, the last device doesn't get added properly. Probably a kernel
problem.
Neil Brown [Mon, 28 Apr 2008 06:30:09 +0000 (16:30 +1000)]
Allow creation of a RAID6 with a single missing device.
This did not work before as we couldn't mark it clean as there would
be some parity blocks out of sync, and raid6 will not assemble a
dirty degraded array.
So make such arrays doubly degraded (the last device becomes a spare)
and clean.
Neil Brown [Mon, 28 Apr 2008 06:29:37 +0000 (16:29 +1000)]
Fix problems with array.size overflowing on large arrays.
array.size is 32bits and counts K. So for arrays with
more than 4Terrabytes, it can overflow.
The correct number can be read from sysfs, but there are still
a few places that use array.size and risk truncation. What is worse.
they compare a number of kilobytes with a number of sectors !!
So use get_component_size() to read the sysfs information, and be
more consistent about units.
Neil Brown [Mon, 28 Apr 2008 06:29:12 +0000 (16:29 +1000)]
Fix for segfault when reading /proc/mdstat
Some kernel versions don't put a space between 'active' and '(auto-read-only)'
in /proc/mdstat. This causes a parsing problem leaving 'level' set to
NULL which causes a crash.
So synthesise a space there if it is missing, and check for 'level' to
be NULL and don't de-ref if it is.
Neil Brown [Tue, 16 Oct 2007 03:52:35 +0000 (13:52 +1000)]
Fix restarting of a reshaping array.
The last release broke the ability to assemble an array that
was in the middle of a reshape.
This patch adds code to test if the critical section needs
to be restored or not so that - if we have failed to restore it,
we know whether to fail or not.
martin f. krafft [Sun, 30 Sep 2007 12:22:56 +0000 (13:22 +0100)]
Fix segfault on assembly on amd64 with v1 superblocks
Commit a40b4fe introduced a temporary supertype variable tst, instead of
manipulating st directly. However, it was forgotton to pass &tst into the
recursive load_super1 call, causing an infinite recursion.
Signed-off-by: martin f. krafft <madduck@debian.org>