summaryrefslogtreecommitdiffstats
path: root/Detail.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* mdadm: add xmalloc.hMariusz Tkaczyk2024-09-271-0/+2
| | | | | | | | | | Move memory declaration helpers outside mdadm.h. They seems to be useful so keep them but include separatelly. Rework them to not reffer to Name[] declared internally in mdadm/mdmon. This is first step to start decomplexing mdadm.h. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Change displaying of devices in --detailAnna Sztukowska2024-08-301-10/+4
| | | | | | | | | | The counts of active, working, failed and spare devices were not printed when the number was zero. Refactor the code to always display the counts of all device types, regardless of their number. This way, it is more reliable for users. Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
* Detail: fix --detail --export for uuid_zeroKinga Stefaniuk2024-07-241-1/+1
| | | | | | | | | | | | | | Mentioned commit (see Fixes) causes that devices with UUID equal to uuid_zero was not recognized properly. For few devices the first one was taken always, and the same information was printed. It caused regression, when few containers were created, symlinks were generated only for the first one. Add checking if uuid is uuid_zero and, if yes, use devname to differentiate devices. Fixes: 60c19530dd7c ("Detail: remove duplicated code") Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* mdadm: Fix native --detail --exportMariusz Tkaczyk2024-03-221-1/+25
| | | | | | | | | | | | | | | | Mentioned commit (see Fixes) causes that UUID is not swapped as expected for native superblock. Fix this problem. For detail, we should avoid superblock calls, we can have information about supertype from map, use that. Simplify fname_from_uuid() by removing dependencies to metadata handler, it is not needed. Decision is taken at compile time, expect super1 but this function is not used by super1. Add warning about that. Remove separator, it is always ':'. Fixes: 60c19530dd7c ("Detail: remove duplicated code") Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Detail: remove duplicated codeKinga Tanska2024-03-061-20/+13
| | | | | | | | | Remove duplicated code from Detail(), where MD_UUID and MD_DEVNAME are being set. Superblock is no longer required to print system properties. Now it tries to obtain map in two ways. Signed-off-by: Kinga Tanska <kinga.tanska@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Remove all "if zeros"Mateusz Kusiak2023-12-191-7/+0
| | | | | | | | No more random encounters of "if zeros". Remove all "if 0" code blocks. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Follow POSIX Portable Character SetMariusz Tkaczyk2023-10-261-11/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the user creates a device with a name that contains whitespace, mdadm timeouts and throws an error. This issue is caused by udev, which truncates /dev/md link until the first whitespace. This patch introduces prohibition of characters other than A-Za-z0-9.-_ in the device name. Also, it prohibits using leading "-" in device name, so name won't be confused with cli parameter. Set of allowed characters is taken from POSIX 3.280 Portable Character Set. Also, device name length now is limited to NAME_MAX. In some places, there are other requirements for string length (e.g. size up to MD_NAME_MAX for device name). This routine is made to follow POSIX and other, more strict limitations should be checked separately. We are aware of the risk of regression in exceptional cases (as escape_devname function is removed) that should be fixed by updating the array name. The POSIX validation is added for: - 'name' parameter in every mode. - first devlist entry, for Build, Create, Assemble, Manage, Grow. - config entries, both devname and "name=". Additionally, some manual cleanups are made. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: define DEV_MD_DIRMariusz Tkaczyk2023-05-081-5/+4
| | | | | | | | It is used many times. Additionally define _LEN to avoid repeated strlen() calls when length is needed. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Detail.c: fix memleak in Detail()Wu Guanghao2023-03-081-0/+1
| | | | | | | | | | char *sysdev = xstrdup() but not free() in for loop, will cause memory leak Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com> Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Acked-by: Coly Li <colyli@suse.de> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: add map_num_s()Mariusz Tkaczyk2022-04-051-2/+2
| | | | | | | | | | | | | | map_num() returns NULL if key is not defined. This patch adds alternative, non NULL version for cases where NULL is not expected. There are many printf() calls where map_num() is called on variable without NULL verification. It works, even if NULL is passed because gcc is able to ignore NULL argument quietly but the behavior is undefined. For safety reasons such usages will use map_num_s() now. It is a potential point of regression. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/Detail: Can't show container name correctly when unpluging disksXiao Ni2021-11-021-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The test case is: 1. create one imsm container 2. create a raid5 device from the container 3. unplug two disks 4. mdadm --detail /dev/md126 [root@rhel85 ~]# mdadm -D /dev/md126 /dev/md126: Container : ��, member 0 The Detail function first gets container name by function map_dev_preferred. Then it tries to find which disks are available. In patch db5377883fef(It should be FAILED..) uses map_dev_preferred to find which disks are under /dev. But now, the major/minor information comes from kernel space. map_dev_preferred malloc memory and init a device list when first be called by Detail. It can't find the device in the list by the major/minor. It free the memory and reinit the list. The container name now points to an area tha has been freed. So the containt is a mess. This patch replaces map_dev_preferred with access. Fixes: db5377883fef (It should be FAILED when raid has) Signed-off-by: Xiao Ni <xni@redhat.com> Reported-by: Fine Fan <ffan@redhat.com> Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Fix memory leak after "mdadm --detail"Mateusz Grzonka2021-08-021-11/+9
| | | | | Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Remove Spare drives line from details for external metadataOleksandr Shchirskyi2021-07-161-1/+2
| | | | | | | | | | | Arrays with external metadata do not have spare disks directly assigned to volumes; spare disks belong to containers and are moved to arrays when the array is degraded/reshaping. Thus, the display of zero spare disks in volume details is incorrect and can be confusing. Signed-off-by: Oleksandr Shchirskyi <oleksandr.shchirskyi@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* It should be FAILED when raid has not enough active disksXiao Ni2021-03-081-4/+10
| | | | | | | | | It can't remove the disk if there are not enough disks. For example, raid5 can't remove the second disk. If the second disk is unplug from machine, it's better show missing and the raid should be FAILED. It's better for administrator to monitor the raid. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/Detail: show correct state for clustered arrayZhao Heming2020-11-261-1/+19
| | | | | | | | | | | | After kernel md module commit 480523feae581, in clustered env, mddev->in_sync always zero, it will make array.state never set up MD_SB_CLEAN. it causes "mdadm -D /dev/mdX" show state 'active' all the time. bitmap.c: add a new API IsBitmapDirty() to support inquiry bitmap dirty or clean. Signed-off-by: Zhao Heming <heming.zhao@suse.com>
* Detail: fix segfault during IMSM raid creationLidong Zhong2020-11-261-1/+1
| | | | | | | | | | | It can be reproduced with non IMSM hardware and IMSM_NO_PLATFORM environmental variable set. The array state is inactive when creating an IMSM container. And the structure info is NULL because load_super() always fails since no intel HBA information could be obtained. Signed-off-by: Lidong Zhong <lidong.zhong@suse.com> Reported-by: Tkaczyk Mariusz <mariusz.tkaczyk@intel.com> Fixes: 64bf4dff3430 (Detail: show correct raid level when the array is inactive)
* Detail: show correct raid level when the array is inactiveLidong Zhong2020-10-141-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes the raid level in the output of `mdadm -D /dev/mdX` is misleading when the array is in inactive state. Here is a testcase for introduction. 1\ creating a raid1 device with two disks. Specify a different hostname rather than the real one for later verfication. node1:~ # mdadm --create /dev/md0 --homehost TESTARRAY -o -l 1 -n 2 /dev/sdb /dev/sdc 2\ remove one of the devices and reboot 3\ show the detail of raid1 device node1:~ # mdadm -D /dev/md127 /dev/md127: Version : 1.2 Raid Level : raid0 Total Devices : 1 Persistence : Superblock is persistent State : inactive Working Devices : 1 You can see that the "Raid Level" in /dev/md127 is raid0 now. After step 2\ is done, the degraded raid1 device is recognized as a "foreign" array in 64-md-raid-assembly.rules. And thus the timer to activate the raid1 device is not triggered. The array level returned from GET_ARRAY_INFO ioctl is 0. And the string shown for "Raid Level" is str = map_num(pers, array.level); And the definition of pers is mapping_t pers[] = { { "linear", LEVEL_LINEAR}, { "raid0", 0}, { "0", 0} ... So the misleading "raid0" is shown in this testcase. Changelog: v1: don't show "Raid Level" when array is inactive Signed-off-by: Lidong Zhong <lidong.zhong@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: adding sync status for cluster deviceLidong Zhong2020-04-271-3/+6
| | | | | | | | | | | | | | | | | | | On the node with /proc/mdstat is Personalities : [raid1] md0 : active raid1 sdb[4] sdc[3] sdd[2] 1046528 blocks super 1.2 [3/2] [UU_] recover=REMOTE bitmap: 1/1 pages [4KB], 65536KB chunk Let's change the 'State' of 'mdadm -Q -D' accordingly State : clean, degraded With this patch, it will be State : clean, degraded, recovering (REMOTE) Signed-off-by: Lidong Zhong <lidong.zhong@suse.com> Acked-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: show correct bitmap info for cluster raid deviceLidong Zhong2020-03-161-1/+3
| | | | | Signed-off-by: Lidong Zhong <lidong.zhong@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Create: add support for RAID0 layouts.NeilBrown2019-12-021-0/+5
| | | | | | | | | | | | | | Since Linux 5.4 a layout is needed for RAID0 arrays with varying device sizes. This patch makes the layout of an array visible (via --examine) and sets the layout on newly created arrays. --layout=dangerous can be used to avoid setting a layout so that they array can be used on older kernels. Tested-by: dann frazier <dann.frazier@canonical.com> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: return correct uuid for volume in detailBlazej Kucman2019-12-021-2/+2
| | | | | | | | | | | Fixes the side effect of the patch b6180160f ("imsm: save current_vol number") - wrong UUID is printed in detail for each volume. New parameter "subarray" is added to determine what info should be extracted from metadata (subarray or container). The parameter affects only IMSM metadata. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: Introduce new array state 'broken' for raid0/linearGuilherme G. Piccoli2019-09-301-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently if a md raid0/linear array gets one or more members removed while being mounted, kernel keeps showing state 'clean' in the 'array_state' sysfs attribute. Despite udev signaling the member device is gone, 'mdadm' cannot issue the STOP_ARRAY ioctl successfully, given the array is mounted. Nothing else hints that something is wrong (except that the removed devices don't show properly in the output of mdadm 'detail' command). There is no other property to be checked, and if user is not performing reads/writes to the array, even kernel log is quiet and doesn't give a clue about the missing member. This patch is the mdadm counterpart of kernel new array state 'broken'. The 'broken' state mimics the state 'clean' in every aspect, being useful only to distinguish if an array has some member missing. All necessary paths in mdadm were changed to deal with 'broken' state, and in case the tool runs in a kernel that is not updated, it'll work normally, i.e., it doesn't require the 'broken' state in order to work. Also, this patch changes the way the array state is showed in the 'detail' command (for raid0/linear only) - now it takes the 'array_state' sysfs attribute into account instead of only rely in the MD_SB_CLEAN flag. Cc: Jes Sorensen <jes.sorensen@gmail.com> Cc: NeilBrown <neilb@suse.de> Cc: Song Liu <songliubraving@fb.com> Signed-off-by: Guilherme G. Piccoli <gpiccoli@canonical.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: add --no-devices to avoid component devices detail informationColy Li2019-08-121-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When people assemble a md raid device with a large number of component deivces (e.g. 1500 DASD disks), the raid device detail information generated by 'mdadm --detail --export $devnode' is very large. It is because the detail information contains information of all the component disks (even the missing/failed ones). In such condition, when udev-md-raid-arrays.rules is triggered and internally calls "mdadm --detail --no-devices --export $devnode", user may observe systemd error message ""invalid message length". It is because the following on-stack raw message buffer in systemd code is not big enough, systemd/src/libudev/libudev-monitor.c _public_ struct udev_device *udev_monito ... struct ucred *cred; union { struct udev_monitor_netlink_header nlh; char raw[8192]; } buf; Even change size of raw[] from 8KB to larger size, it may still be not enough for detail message of a md raid device with much larger number of component devices. To fix this problem, an extra option '--no-devices' is added (the original idea is proposed by Neil Brown). When printing detailed information of a md raid device, if '--no-devices' is specified, then all component devices information will not be printed, then the output message size can be restricted to a small number, even with the systemd only has 8KB on-disk raw buffer, the md raid array udev rules can work correctly without failure message. Signed-off-by: Coly Li <colyli@suse.de> Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail.c: do not skip first character when calling xstrdup in Detail()Coly Li2019-02-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 'Commit b9c9bd9bacaa ("Detail: ensure --export names are acceptable as shell variables")' duplicates mdi->sys_name to sysdev string by, char *sysdev = xstrdup(mdi->sys_name + 1); which skips the first character of mdi->sys_name. Then when running mdadm --detail <md device> --export, the output looks like, MD_DEVICE_ev_sda2_ROLE=1 MD_DEVICE_ev_sda2_DEV=/dev/sda2 The first character of md device (between MD_DEVICE and _ROLE/_DEV) is dropped. The expected output should be, MD_DEVICE_dev_sda2_ROLE=1 MD_DEVICE_dev_sda2_DEV=/dev/sda2 This patch removes the '+ 1' from calling xstrdup() in Detail(), which gets the dropped first character back. Reported-by: Arvin Schnell <aschnell@suse.com> Fixes: b9c9bd9bacaa ("Detail: ensure --export names are acceptable as 4 shell variables") Signed-off-by: Coly Li <colyli@suse.de> Cc: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Free map to avoid resource leak issuesGuoqing Jiang2018-06-111-0/+2
| | | | | | | | | | | | | | | | | | | | | | | 1. There are some places which didn't free map as discovered by coverity. CID 289661 (#1 of 1): Resource leak (RESOURCE_LEAK)12. leaked_storage: Variable mapl going out of scope leaks the storage it points to. CID 289619 (#3 of 3): Resource leak (RESOURCE_LEAK)63. leaked_storage: Variable map going out of scope leaks the storage it points to. CID 289618 (#1 of 1): Resource leak (RESOURCE_LEAK)26. leaked_storage: Variable map going out of scope leaks the storage it points to. CID 289607 (#1 of 1): Resource leak (RESOURCE_LEAK)41. leaked_storage: Variable map going out of scope leaks the storage it points to. 2. If we call map_by_* inside a loop, then map_free should be called in the same loop, and it is better to set map to NULL after free. 3. And map_unlock is always called with map_lock, if we don't call map_remove before map_unlock, then the memory (allocated by map_lock -> map_read -> map_add -> xmalloc) could be leaked. So we need to free it in map_unlock as well. Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: fix use-after-free after free_mdstatZhipeng Xie2018-04-101-1/+2
| | | | | | | e->percent access the mdstat_ent which was already freed in free_mdstat Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: differentiate between container and inactive arraysMariusz Tkaczyk2017-08-231-5/+11
| | | | | | | | | | | | Containers used to be handled as active arrays because GET_ARRAY_INFO ioctl returns valid structure for them. As containers appear as inactive in sysfs, the output for detail command has changed. Stop relying on inactive state for containers. Make the output look the same as in mdadm 4.0. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: correct output for active arraysMariusz Tkaczyk2017-08-161-8/+7
| | | | | | | | | | | | The check for inactive array is incorrect as it compares it against active array. Introduce a new function md_is_array_active so the check is consistent across the code. As the output contains list of disks in the array include this information in sysfs read. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: don't exit if ioctl has been successfulTomasz Majchrzak2017-05-241-12/+15
| | | | | | | | | | | When GET_ARRAY_INFO ioctl is successful, mdadm exits with an error. It breaks udev and no links in /dev/md are created. Also change debug print to error print in the message indicating lack of the link to facilitate debugging similar issues in the future. Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: Fix '==' broken formattingJes Sorensen2017-05-161-3/+3
| | | | Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: Reinstate support for not having sysfsJes Sorensen2017-04-251-3/+5
| | | | | | | | While sysfs support will hopefully go away eventually, lets not break it unnecessarily for now. Fixes: 901d5ee ("Detail: Stop bothering about md drivers older than 0.90.00") Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: Respect code lines are 80 character wideJes Sorensen2017-04-251-101/+138
| | | | | | In addition apply spaces and don'f do 'if () action()' on the same line. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: determine array state from sysfsJes Sorensen2017-04-251-5/+4
| | | | | | | | | | This is easily obtained from sysfs as part of the existing call to sysfs_read() and it simplifies the code a little too. Another small step in the process of getting rid of the GET_ARRAY_STATE ioctl. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: ensure --export names are acceptable as shell variables.NeilBrown2017-04-201-3/+9
| | | | | | | | | | | | | | | | | | | | | If an array contains a device which has a name that contains something other than alphnumerics and underscores, then some values reported by "mdadm --detail --export" will not be valid as variable assignment of the shell. This particularly affects dm devices. e.g. MD_DEVICE_dm-4_ROLE=1 MD_DEVICE_dm-4_DEV=/dev/dm-4 As it is particularly useful to be able to work with these in a shell script, and as the precise name is not important, change all non-alphanumerics to '_'. MD_DEVICE_dm_4_ROLE=1 MD_DEVICE_dm_4_DEV=/dev/dm-4 Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: Fixup ugly if () foo() abuseJes Sorensen2017-04-121-3/+5
| | | | | | Cosmetic change only Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: Remove pre-2.6 code for printing info on rebuildingJes Sorensen2017-04-121-16/+3
| | | | | | | Since we no longer support anything pre-2.6.15, there is no point in keeping this around. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: Stop bothering about md drivers older than 0.90.00Jes Sorensen2017-04-051-20/+7
| | | | | | Remove further handling of md driver version older than 0.90.00 Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* util: Introduce md_get_disk_info()Jes Sorensen2017-03-291-5/+3
| | | | | | | This removes all the inline ioctl calls for GET_DISK_INFO, allowing us to switch to sysfs in one place, and improves type checking. Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* util: Introduce md_get_array_info()Jes Sorensen2017-03-291-1/+1
| | | | | | | | | | | Remove most direct ioctl calls for GET_ARRAY_INFO, except for one, which will be addressed in the next patch. This is the start of the effort to clean up the use of ioctl calls and introduce a more structured API, which will use sysfs and fall back to ioctl for backup. Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* Detail: show consistency policyArtur Paszkiewicz2017-03-291-36/+54
| | | | | | | | | Show the currently enabled consistency policy in the output from --detail. Add 3 spaces to all existing items in Detail output to align with "Consistency Policy : ". Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* Detail: handle non-existent arrays better.NeilBrown2017-03-281-0/+8
| | | | | | | | | | | | | | | | If you call "mdadm --detail" with a device file for an array which doesn't exist, such as by mknod /dev/md57 b 9 57 mdadm --detail /dev/md57 you get an unhelpful message about and inactive RAID0, and return status is '0'. This is confusing. So catch this possibility and print a more useful message, and return a non-zero status. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* mdadm: Specify enough length when write to bufferXiao Ni2017-03-171-1/+1
| | | | | | | | | | | | | | | | | | | | | In Detail.c the buffer path in function Detail is defined as path[200], in fact the max lenth of content which needs to write to the buffer is 287. Because the length of dname of struct dirent is 255. During building it reports error: error: ‘%s’ directive writing up to 255 bytes into a region of size 189 [-Werror=format-overflow=] In function examine_super0 there is a buffer nb with length 5. But it need to show a int type argument. The lenght of max number of int is 10. So the buffer length should be 11. In human_size function the length of buf is 30. During building there is a error: output between 20 and 47 bytes into a destination of size 30. Change the length to 47. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* Add failfast support.NeilBrown2016-11-281-0/+1
| | | | | | | | | | | | | Allow per-device "failfast" flag to be set when creating an array or adding devices to an array. When re-adding a device which had the failfast flag, it can be removed using --nofailfast. failfast status is printed in --detail and --examine output. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* mdadm: put journal device in right place of --detailSong Liu2016-08-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When there is failed HDDs, journal device showed in wrong place of --detail: Number Major Minor RaidDevice State 4 8 24 - journal /dev/sdb8 1 8 18 1 active sync /dev/sdb2 2 8 19 2 active sync /dev/sdb3 3 8 21 3 active sync /dev/sdb5 0 8 17 - faulty /dev/sdb1 This patch fixed the output as: Number Major Minor RaidDevice State - 0 0 0 removed 1 8 18 1 active sync /dev/sdb2 2 8 19 2 active sync /dev/sdb3 3 8 21 3 active sync /dev/sdb5 0 8 17 - faulty /dev/sdb1 4 8 24 - journal /dev/sdb8 Reported-by: Yi Zhang <yizhan@redhat.com> Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* Use dev_t for devnm2devid and devid2devnmMike Lovell2016-06-031-2/+2
| | | | | | | | | | | | | | | | | | | Commit 4dd2df0966ec added a trip through makedev(), major(), and minor() for device major and minor numbers. This would cause mdadm to fail in operating on a device with a minor number bigger than (2^19)-1 due to it changing from dev_t to a signed int and back. Where this was found as a problem was when a array was created with a device specified as a name like /dev/md/raidname and there were already 128 arrays on the system. In this case, mdadm would chose 1048575 ((2^20)-1) for the array and minor number. This would cause the major and minor number to become negative when generated from devnm2devid() and passed to major() and minor() in open_dev_excl(). open_dev_excl() would then call dev_open() which would detect the negative minor number and call open() on the *char containing the major:minor pair which isn't a valid file. Signed-off-by: Mike Lovell <mlovell@bluehost.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* load_sys(): Add a buffer size argumentJes Sorensen2016-03-091-1/+1
| | | | | | | | | | | | | This adds a buffer size argument to load_sys(), rather than relying on a hard coded buffer size. The old behavior was safe because we knew the kernel would never return strings overrunning the buffers, however it was ugly, and would cause code checking tools to spit out warnings. This caused a Coverity warning over the read into sra->sysfs_array_state which is only 20 bytes. Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* super0: Fix reporting of devices between 2GB and 4GBNeilBrown2016-01-281-2/+3
| | | | | | | | v0.90 metadata can handle devices between 2GB and 4GB, but we need to treat the 'size' and unsigned. In a couple of places we don't. URL: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809447 Signed-off-by: NeilBrown <neilb@suse.com>
* Detail: fix wrong condition in recent change.NeilBrown2015-12-231-1/+1
| | | | | | | | | Now that we can print device details with a specific raid_disk but not disk.number, the condition for "print either disk.number or disk.raid_disk" must be make more specific. Reported-by: Coly Li <colyli@suse.com> Signed-off-by: NeilBrown <neilb@suse.com>
* move journal to end of --detail listSong Liu2015-12-211-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | As we give journal device raid_disk of 0, the output of --detail is: Number Major Minor RaidDevice State 0 8 17 0 active sync /dev/sdb1 5 8 24 0 journal /dev/sdb8 1 8 18 1 active sync /dev/sdb2 2 8 19 2 active sync /dev/sdb3 3 8 21 3 active sync /dev/sdb5 4 8 23 - spare /dev/sdb7 This patch makes it back to: Number Major Minor RaidDevice State 0 8 17 0 active sync /dev/sdb1 1 8 18 1 active sync /dev/sdb2 2 8 19 2 active sync /dev/sdb3 3 8 21 3 active sync /dev/sdb5 4 8 23 - spare /dev/sdb7 5 8 24 - journal /dev/sdb8 Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: NeilBrown <neilb@suse.com>
* Merge https://github.com/makelinux/mdadmNeilBrown2015-12-211-4/+2
|\ | | | | | | Fixes https://github.com/neilbrown/mdadm/issues/17