summaryrefslogtreecommitdiff
path: root/Detail.c
Commit message (Collapse)AuthorAge
* Detail: Avoid dereferencing some NULL pointers.NeilBrown2014-08-06
| | | | | | | | | | | | | | dm devices which only have a single underlying md device will respond to md ioctls as though they were that md device. This can confuse mdadm and lead it to violating its segments. So add tests for NULL where appropriate. You might not get exactly the right answer when you "mdadm -D" a dm device, but at least it won't crash now. Reported-by: Willy Weisz <Willy.Weisz@univie.ac.at> Resolves: https://bugzilla.novell.com/show_bug.cgi?id=887821 Signed-off-by: NeilBrown <neilb@suse.de>
* Release mdadm-3.3NeilBrown2013-09-03
| | | | | | (and various cosmetic fixes) Signed-off-by: NeilBrown <neilb@suse.de>
* Detail: Factor out add_device()Martin Wilck2013-07-02
| | | | | | | Makes the code a little more readable. Signed-off-by: Martin Wilck <mwilck@arcor.de> Signed-off-by: NeilBrown <neilb@suse.de>
* Detail: deterministic ordering in --brief --verbosemwilck@arcor.de2013-06-24
| | | | | | | | | | | | | | | | Have mdadm --Detail --brief --verbose print the list of devices in alphabetical order. This is useful for debugging purposes. E.g. the test script 10ddf-create compares the output of two mdadm -Dbv calls which may be different if the order is not deterministic. (I confess: I use a modified "test" script that always runs "mdadm --verbose" rather than "mdadm --quiet", otherwise this wouldn't happen in 10ddf-create). Signed-off-by: Martin Wilck <mwilck@arcor.de> Signed-off-by: NeilBrown <neilb@suse.de>
* Detail: add device information to --detail --exportNeilBrown2013-06-19
| | | | | | | We may well want more per-device information here, but this is a start. Signed-off-by: NeilBrown <neilb@suse.de>
* Detail: report on inactive arrays.NeilBrown2013-05-13
| | | | | | | | Array can be inactive when e.g. -I is in the process of assembling them. This change allows --detail to report limited information about these arrays. Signed-off-by: NeilBrown <neilb@suse.de>
* Detail: fix --brief --verboseNeilBrown2013-05-13
| | | | | | | | This pair of options should give a --brief listing including devices= information. But recent changes to flag passing broke this. So fix it. Signed-off-by: NeilBrown <neilb@suse.de>
* Detail.c: call load_container for container subarraysmwilck@arcor.de2013-03-04
| | | | | | | | | | | | Without calling load_container at this point, the info structure may be missing some important information. In particular, information about secondary DDF RAID levels may be wrong if information is only read from a single disk. If this fails, fall back to the previous code. Signed-off-by: Martin Wilck <mwilck@arcor.de> Signed-off-by: NeilBrown <neilb@suse.de>
* Discard devnum in favour of devnmNeilBrown2013-02-21
| | | | | | | | | | | | | | We widely use a "devnum" which is 0 or +ve for md%d devices and -ve for md_d%d devices. But I want to be able to use md_%s device names. So get rid of devnum (a number) and use devnm (a 32char string). eg. md0 md_d2 md_home Signed-off-by: NeilBrown <neilb@suse.de>
* Detail: print correct size for large external-metadata arrays.NeilBrown2013-02-05
| | | | | | | | If externally menaged metadata is in use, array.major_version will be zero, so the test here to consider using get_component_size() is wrong. So if sra is present, use the major_version from there. Signed-off-by: NeilBrown <neilb@suse.de>
* Report replacement devices correctly with --detail and --examineNeilBrown2012-10-23
| | | | | | | | --detail needs to be read to report 2 devices in each slot, and --examine need to report if the device is the original or the replacement. Signed-off-by: NeilBrown <neilb@suse.de>
* Detail: don't report a faulty device as 'spare' or 'rebuilding'.NeilBrown2012-10-22
| | | | | | | | If a device is faulty, then that is all there is too it. Even if it isn't 'removed' yet, it shouldn't be reported as 'spare' or 'rebuilding'. Signed-off-by: NeilBrown <neilb@suse.de>
* Handles spaces in array names better.NeilBrown2012-10-04
| | | | | | | | | | | | 1/ When printing the "name=" entry for --brief output, enclose name in quotes if it contains spaces etc. Quotes are already supported for reading mdadm.conf 2/ When a name is used as a device name, translate spaces and tabs to '_', as well as the current translation of '/' to '-'. Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: Allow to specify controller for --detail-platform.Maciej Naruszewicz2012-10-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Usually, 'mdadm --detail-platform -e imsm' scans all the controllers looking for IMSM capabilities. This patch provides the possibility to specify a controller to scan, enabling custom usage by other processes - especially with the --export switch. $ mdadm --detail-platform Platform : Intel(R) Matrix Storage Manager Version : 9.5.0.1037 RAID Levels : raid0 raid1 raid10 raid5 Chunk Sizes : 4k 8k 16k 32k 64k 128k 2TB volumes : supported 2TB disks : not supported Max Disks : 7 Max Volumes : 2 per array, 4 per controller I/O Controller : /sys/devices/pci0000:00/0000:00:1f.2 (SATA) $ mdadm --detail-platform /sys/devices/pci0000:00/0000:00:1f.2 Platform : Intel(R) Matrix Storage Manager Version : 9.5.0.1037 RAID Levels : raid0 raid1 raid10 raid5 Chunk Sizes : 4k 8k 16k 32k 64k 128k 2TB volumes : supported 2TB disks : not supported Max Disks : 7 Max Volumes : 2 per array, 4 per controller I/O Controller : /sys/devices/pci0000:00/0000:00:1f.2 (SATA) $ mdadm --detail-platform /sys/devices/pci0000:00/0000:00:1f.2 --export MD_FIRMWARE_TYPE=imsm IMSM_VERSION=9.5.0.1037 IMSM_SUPPORTED_RAID_LEVELS=raid0 raid1 raid10 raid5 IMSM_SUPPORTED_CHUNK_SIZES=4k 8k 16k 32k 64k 128k IMSM_2TB_VOLUMES=yes IMSM_2TB_DISKS=no IMSM_MAX_DISKS=7 IMSM_MAX_VOLUMES_PER_ARRAY=2 IMSM_MAX_VOLUMES_PER_CONTROLLER=4 $ mdadm --detail-platform /sys/devices/pci0000:00/0000:00:1f.0 # This isn't an IMSM-capable controller mdadm: no active Intel(R) RAID controller found under /sys/devices/pci0000:00/0000:00:1f.0 Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Detail/raid10: don't report 'set' names for 'far' and 'offset' raid10.NeilBrown2012-10-03
| | | | | | | The 'set' concept is only meaningful for 'near' arrays, so only use it there. Signed-off-by: NeilBrown <neilb@suse.de>
* Fix return code for --detail-platformMaciej Naruszewicz2012-10-02
| | | | | | | | Variable 'err' is initially set to 1, so changing its value with '|=' won't set it to 0 even if the operation is successful. Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: Add --export option for --detail-platformMaciej Naruszewicz2012-10-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This option will provide most of information we can get via mdadm --detail-platform [-e format] in the key=value format. Example output: $ mdadm --detail-platform Platform : Intel(R) Matrix Storage Manager Version : 9.5.0.1037 RAID Levels : raid0 raid1 raid10 raid5 Chunk Sizes : 4k 8k 16k 32k 64k 128k 2TB volumes : supported 2TB disks : not supported Max Disks : 7 Max Volumes : 2 per array, 4 per controller I/O Controller : /sys/devices/pci0000:00/0000:00:1f.2 (SATA) $ mdadm --detail-platform --export MD_FIRMWARE_TYPE=imsm IMSM_VERSION=9.5.0.1037 IMSM_SUPPORTED_RAID_LEVELS=raid0 raid1 raid10 raid5 IMSM_SUPPORTED_CHUNK_SIZES=4k 8k 16k 32k 64k 128k IMSM_2TB_VOLUMES=yes IMSM_2TB_DISKS=no IMSM_MAX_DISKS=7 IMSM_MAX_VOLUMES_PER_ARRAY=2 IMSM_MAX_VOLUMES_PER_CONTROLLER=4 Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* fix segfaults in Detail()Lukasz Dorau2012-09-20
| | | | | | | | If disk has been removed, 'st' and 'info' can be NULL. It causes segfault. 'st' and 'info' should be checked against being NULL before being used. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Minor cosmetic fixes in various files.NeilBrown2012-08-13
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Change Detail and misc_scan to take a struct contextNeilBrown2012-07-09
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Change name of 'c' variable in DetailNeilBrown2012-07-09
| | | | | | | I want to use 'c' uniformly as a 'struct context', so in Detail change 'c' to 'str'. Signed-off-by: NeilBrown <neilb@suse.de>
* Convert 'quiet' to 'not verbose' in various places.NeilBrown2012-07-09
| | | | | | | | If we change some functions to accept 'verbose', where <0 means to be quiet, in place of 'quiet', then we will be able to merge 'quiet' and 'verbose' together for simplicity. Signed-off-by: NeilBrown <neilb@suse.de>
* Remove scattered checks for malloc success.NeilBrown2012-07-09
| | | | | | | | | | | | | | malloc should never fail, and if it does it is unlikely that anything else useful can be done. Best approach is to abort and let some super-daemon restart. So define xmalloc, xcalloc, xrealloc, xstrdup which don't fail but just print a message and exit. Then use those removing all the tests for failure. Also replace all "malloc;memset" sequences with 'xcalloc'. Signed-off-by: NeilBrown <neilb@suse.de>
* Introduce pr_err for printing error messages.NeilBrown2012-07-09
| | | | | | | 'pr_err("' is a lot shorter than 'fprintf(stderr, Name ": ' cont_err() is also available. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: fix inconsistencies in values for ->percentNeilBrown2012-06-04
| | | | | | | | | | | | | ->percent sometimes stores negative values recording states like 'pending' or 'delayed'. The value '-2' means both 'delayed' and in Monitor, 'unknown'. Also, '-1' has a meaning but not #define. So change the #defines to be prefixed with "RESYNC_", instead of "PROCESS_", add new "_NONE" and "_UNKNOWN", and use correct value in each location. Signed-off-by: NeilBrown <neilb@suse.de>
* Detail: show which 'set' each device in a RAID10 belongs toNeilBrown2012-05-30
| | | | | | | | | | | | | | | A RAID10 can be though of as having 2 sets of devices (if there are 2 copies and an even number of devices in total). With this patch "mdadm --detail" shows which 'set' each device belongs to - set-A or set-B. If there are more than 3 copies, there can be more than 3 sets. If the number of copies does not evenly divide the number of devices, there are not distinct 'sets' so none are reported. Signed-off-by: NeilBrown <neilb@suse.de>
* Add --prefer option for --detail and --monitorNeilBrown2012-04-18
| | | | | | | | | | | | | | | | | Both --detail and --monitor can report the names of member devices on an array, and do so by searching /dev and finding the shortest name that matches. If --prefer=foo is given, they will instead prefer a name that contain /foo/. So mdadm --detail /dev/md0 --prefer=by-path will list the component devices via their /dev/disk/by-path/xxx names. Signed-off-by: NeilBrown <neilb@suse.de>
* Remove avail_disks arg from 'enough'.NeilBrown2012-02-07
| | | | | | | | It can easily be calculated from 'avail' and 'raid_disks', and we will soon have a case where we don't have it easily available to pass in. Signed-off-by: NeilBrown <neilb@suse.de>
* Detail(): Remember to free 'avail'Jes Sorensen2011-11-02
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Fix memory leakJes Sorensen2011-11-01
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Show DELAYED, PENDING status of resync process in "--detail"Krzysztof Wojcik2011-06-23
| | | | | | | | | | | | | | | | Initially there is no proper translation mdstat's DELAYED/PENDING processes to "--detail" output. For example, if we have recover=DELAYED in mdstat, "--detail" shows "State: recovering" and "Rebuild Status = 0%". It was incorrect in case of process waiting on checkpoint different than 0%. In fact rebuild status is differnt than 0% and user is misled. The patch fix the problem. Current "--detail" command shows in the exampe: "State: recovering (DELAYED)" and no information about precentage. Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* mdadm --detail was incorrect for shrinking reshapesAndrew Burgess2011-06-23
| | | | | | | | Since info->delta_disks is signed it doesn't need to be special-cased. This allowed my 9->8 reshape to display correctly instead of as 8->7 Signed-off-by: NeilBrown <neilb@suse.de>
* Detail: report subarrays of a container properly.NeilBrown2011-03-09
| | | | | | | Due to the wrong variable being used, this part of --detail wasn't working at all. Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: set imsm spare uuid to 0Anna Czarnowska2010-12-26
| | | | | | | | | | uuid_match_any is replaced by uuid_zero for imsm spares. Function fixup_container_spare_uuid not needed as it gives unwanted uuid to spares. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Initialize st->devnum and st->container_dev in super_by_fdDan Williams2010-11-23
| | | | | | | | 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>
* Use new container_content rather than passing subarray to load_super.NeilBrown2010-11-22
| | | | | | | | 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>
* super_by_fd: return subarray info explicitly.NeilBrown2010-11-22
| | | | | | | | | 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>
* get_info_super: report which other devices are thought to be working/failed.NeilBrown2010-11-22
| | | | | | | | | | | | | | 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/wait: better handling of monitoring sync action.NeilBrown2010-11-22
| | | | | | | 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>
* Compile with -Wextra by defaultNeilBrown2010-08-05
| | | | | | This produced lots of warning, some of which pointed to actual bugs. Signed-off-by: NeilBrown <neilb@suse.de>
* Detail: clean up handing of the 'info' we load from superblock.NeilBrown2010-08-05
| | | | | | | | | | 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>
* Cast to long long before left-shifting too much.NeilBrown2010-07-22
| | | | | | | | | | | | | 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>
* Detail: Report state of FAILED when an array has too few devices to work.NeilBrown2010-01-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Don't use %02d as a metadata format specifier for metadata numbers.Doug Ledford2010-01-19
| | | | | | | It confuses us when we read the output back later Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Detail: report new-layout for RAID6 arraysNeilBrown2009-10-29
| | | | | | We were only reporting it for RAID5 and RAID10. Signed-off-by: NeilBrown <neilb@suse.de>
* Merge branch 'master' into devel-3.1NeilBrown2009-10-22
|\
| * Free some malloced memory that wasn't being freed.NeilBrown2009-10-22
| | | | | | | | | | | | | | | | | | | | 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>
| * Merge git://github.com/djbw/mdadmNeilBrown2009-10-19
| |\
| | * Detail: export MD_UUID from mapfileDan Williams2009-10-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Merge branch 'master' into devel-3.1NeilBrown2009-10-01
|\| | | | | | | | | | | | | | Conflicts: mdadm.8