Precludes needing to deduce this information later, like in Detail.c and
soon in Grow.c.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Now that we can ask container_content for a specific subarray,
we don't need to pass the subarray name to load_super, and have it
secretly modify the returned state.
Signed-off-by: NeilBrown <neilb@suse.de>
Rather than hiding this in the 'st', return it explicitly.
In the one case we still need it, copy it into st where needed.
This will disappear in a future patch.
Signed-off-by: NeilBrown <neilb@suse.de>
To accurately detect when an array has been split and is now being
recombined, we need to track which other devices each thinks is
working.
We should never include a device in an array if it thinks that the
primary device has failed.
This patch just allows get_info_super to return a list of devices
and whether they are thought to be working or not.
Signed-off-by: NeilBrown <neilb@suse.de>
Detail: report reshape and check as well as resync and recovery
Wait: if the resync is pending or delayed, wait for that too.
Signed-off-by: NeilBrown <neilb@suse.de>
The loop for loading it was hard to follow, so restructure that
and avoid a theoretical use-before-set error.
Also there was a second 'info' structure which hid the first and was
pointless.
Signed-off-by: NeilBrown <neilb@suse.de>
When left-shifting we must be sure that the value being
shifted is large enough to not lose bits.
The 'chunkssize' in CreateBitmap is only 'long' so it
can overflow. So cast to 'long long' first.
Also fix a similar issue in Detail even though it isn't currently
being compiled.
Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: Tomasz Chmielewski <mangoo@wpkg.org>
We already have a call to 'enough' in Detail which is the check for
"do we have enough devices". We just need to calculate the required
data a bit earlier, then use the same 'enough' call to possibly
print FAILED.
This is motivated by Debian bug 495755.
The other request in that bug is not practical.
It would be very nice if output of `mdadm' is more clear in case of a
broken array.
Currently the only hint you get from `mdadm' that your array is broken
is this:
# mdadm -A /dev/md0 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1
mdadm: /dev/md0 assembled from 1 drive and 3 spares - not enough to start the
array.
It could say something like `Your array is broken, you can't use it anymore'
It is not valid to report that array as 'broken' if the user hasn't
listed all the devices, which could be the case here.
Resolves-Debian-Bug: 495755
Signed-off-by: NeilBrown <neilb@suse.de>
As mdadm is normally a short-lived program it isn't always necessary
to free memory that was allocated, as the 'exit()' call will
automatically free everything. But it is more obviously correct if
the 'free' is there.
So this patch add a few calls to 'free'
Signed-off-by: NeilBrown <neilb@suse.de>
The load_super() from an mdadm --detail call may race against an mdmon
update. When this happens the load_super sees an inconsistent metadata
block and returns an error. The fallback path to use the map file
contents lacks uuid reporting, so provide __fname_from_uuid for
generically printing a uuid.
Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Spares for imsm arrays do not have any info about the container in their
metadata records. If Detail() inadvertantly picks such a device for
->get_array_info() it will end up with less than useful info for the
container. So, continue to read from the disks until a non-spare device
is found.
This bug was found by timeouts waiting for udev to create the
user-friendly container name. To detect future UUID reporting problems
and a debug print to the timeout case in wait_for().
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Because ---examine --brief, or --detail --brief are
often used to create mdadm.conf, and because people don't want to
have to update their mdadm.conf unnecessarily, we don't want to
include information that might change.
And now that level changing is supported, that is almost everything
but UUID.
So move some more fields into the "Only print with --verbose" class.
Signed-off-by: NeilBrown <neilb@suse.de>
As get_component_size() returns the number of used sectors of a device
we need halve before pringing as K, and shift the value by 9, not 10,
before passing to human_size.
Thanks to Andre Noll <maan@systemlinux.org> for identifying problem
(and a slightly different version of this patch)
Signed-off-by: NeilBrown <neilb@suse.de>
If the metadata handler can not find its platform support components
then there is no way for it to verify that the raid configuration will
be supported by the option-rom. Provide a generic method for metadata
handlers to warn the user that the array they are about to create may
not work as intended with a given platform.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Metadata formats like imsm work in concert with platform firmware and
hardware, so provide a way for mdadm to display this info to the user.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
If there is no metadata (--build was used) then we need to lookup
by devnum, not by uuid, to get the map entry.
Signed-off-by: NeilBrown <neilb@suse.de>
MD_NAME is the name of the array extracted directly from the metadata.
MD_DEVNAME is the current working name of the array. It should appear
in /dev/md. It is possibly what the user gave when creating the
array.
We extract it from /var/run/mdadm/map.
Signed-off-by: NeilBrown <neilb@suse.de>
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.
Signed-off-by: NeilBrown <neilb@suse.de>
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.
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Showing e.g.
near=1, far=2
for the 'far2' layout of raid10 is confusing even though there is a
sense in which is it correct.
Make it less confusing by only printing whichever number is not 1.
If both are 1, make that clear too (i.e. no redundancy).
Make --detail on a container more useful by suppressing irrelevant
detail and adding useful detail like a list of member arrays.
Ditto for members of a container: report the name of the container
array.
Signed-off-by: NeilBrown <neilb@suse.de>
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
Signed-off-by: Doug Ledford <dledford@redhat.com>
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.
From: Tim Woods <timwoods@uklinux.net>
This patch fixes a NULL pointer dereference in Detail.c when running
'mdadm --detail --export' on a device with non-persistent super blocks.