summaryrefslogtreecommitdiffstats
path: root/util.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* mdadm: drop auto= supportMariusz Tkaczyk2024-11-051-36/+0
| | | | | | | | | | | | According to author (and what was described in man): "With mdadm 3.0, device creation is normally left up to udev so this is option is unlikely to be needed" This was a workaround for kernel 2.6 family issues (partitionable and non-partitionable arrays hell) and I believe we are far away from it now. I'm not aware of any usage of it, hence it is removed. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* util: use only /dev directory in open_dev()Kinga Stefaniuk2024-10-161-11/+0
| | | | | | | | | Previously, open_dev() tried to open device in two ways - using /dev and /tmp directory. This method could be used by users which have no access to /tmp directory (e.g. udev) and dev_open() fails which may affect many processes. Remove try to open in /tmp directory. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* util: fix sys_hot_remove_disk()Mariusz Tkaczyk2024-10-041-1/+1
| | | | | | | Instead of "remove", "faulty" was called. Fixes: d95edceb362a ("sysfs: add function for writing to sysfs fd") Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* 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>
* sysfs: add function for writing to sysfs fdMariusz Tkaczyk2024-09-271-5/+14
| | | | | | | | | | Proposed function sysfs_wrte_descriptor() unifies error handling for write() done to sysfs files. Main purpose is to use it with MD sysfs file but it can be used elsewhere. No functional changes. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Detail.c: Fix divide_by_zero issueAnna Sztukowska2024-09-231-6/+9
| | | | | | | | Fix divide_by_zero issue reported by SAST analysis in Detail.c when calling enough() from util.c. Also add missing spaces for better code readability. Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
* mdadm: Increase number limit in md device name to 1024.Shminderjit Singh2024-09-041-1/+1
| | | | | | | | | | Updated the maximum device number in md device names from 127 to 1024. The previous limit was causing issues in the automation framework. This change ensures backward compatibility and allows for future scalability. Fixes: 25aa7329141c ("mdadm: numbered names verification") Signed-off-by: Shminderjit Singh <shminderjit.singh@oracle.com>
* mdadm: util.c fix coverity issuesNigel Croxon2024-08-131-16/+25
| | | | | | | | | | | | | | | | | | Fixing the following coding errors the coverity tools found: * Event check_return: Calling "open" without checking return value * Event check_return: Calling "lseek(fd, sector_size, 0)" without checking return value. * Event leaked_handle: Handle variable "fd" going out of scope leaks the handle. * Event leaked_storage: Variable "dir" going out of scope leaks the storage it points to. * Event fixed_size_dest: You might overrun the 32-character fixed-size string "st->devnm" by copying "_devnm" without checking the length. * Event fixed_size_dest: You might overrun the 32-character fixed-size string "container" by copying "dev" without checking the length. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* mdstat: Rework mdstat external arrays handlingMariusz Tkaczyk2024-07-301-10/+0
| | | | | | | | | | | | To avoid repeating mdstat_read() in IncrementalRemove(), new function mdstat_find_by_member_name() has been proposed. With that, IncrementalRemove() handles own copy of mdstat content and there is no need to repeat reading for external stop. Additionally, It proposed few helper to avoid repeating mdstat_ent->metadata_version checks across code. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Fix socket connection failure when mdmon runs in foreground mode.Shminderjit Singh2024-07-021-0/+45
| | | | | | | | | | | | | | | | | | | | While creating an IMSM RAID, mdadm will wait for the mdmon main process to finish if mdmon runs in forking mode. This is because with "Type=forking" in the mdmon service unit file, "systemctl start service" will block until the main process of mdmon exits. At that moment, mdmon has already created the socket, so the subsequent socket connect from mdadm will succeed. However, when mdmon runs in foreground mode (without "Type=forking" in the service unit file), "systemctl start service" will return once the mdmon process starts. This causes mdadm and mdmon to run in parallel, which may lead to a socket connection failure since mdmon has not yet initialized the socket when mdadm tries to connect. If the next instruction/command is to access this device and try to write to it, a permission error will occur since mdmon has not yet set the array to RW mode. Signed-off-by: Shminderjit Singh <shminderjit.singh@oracle.com>
* Change some error messages to info levelXiao Ni2024-05-241-2/+2
| | | | | | | These logs are not error logs. Change them to info level. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Wait for mdmon when it is stared via systemdKinga Stefaniuk2024-05-141-0/+29
| | | | | | | | | When mdmon is being started it may need few seconds to start. For now, we didn't wait for it. Introduce wait_for_mdmon() function, which waits up to 5 seconds for mdmon to start completely. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* util.c: change devnm to const in mdmon functionsKinga Stefaniuk2024-05-141-2/+2
| | | | | | | | Devnm shall not be changed inside mdmon_running() and mdmon_pid() functions, change this parameter to const. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: support RAID 10 with more than 4 drivesMateusz Kusiak2024-05-071-14/+25
| | | | | | | | | | | | | | | | | VROC UEFI driver does not support RAID 10 with more than 4 drives. Add user prompts if such layout is being created and for R0->R10 reshapes. Refactor ask() function: - simplify the code, - remove dialog reattempts, - do no pass '?' sign on function calls, - highlight default option on output. This patch completes adding support for R10D4+ to IMSM. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* sysfs: remove vers parameter from sysfs_set_arrayMateusz Kusiak2024-03-221-2/+1
| | | | | | | | | | | 9003 was passed directly to sysfs_set_array() since md_get_version() always returned this value. md_get_version() was removed long ago. Remove dead version check from sysfs_set_array(). Remove "vers" argument and fix function calls. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Fix native --detail --exportMariusz Tkaczyk2024-03-221-11/+13
| | | | | | | | | | | | | | | | 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>
* util.c: add limits.h include for NAME_MAX definitionAlexander Kanavin2024-03-121-1/+1
| | | | | | | Add limits.h include for NAME_MAX definition. Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Monitor, Incremental: use device policiesMariusz Tkaczyk2024-03-111-4/+9
| | | | | | | | | | | | | spare_criteria is expanded to contain policies which will be generated by handler's get_spare_criteria() function. It provides a way to test device for metadata specific policies earlier than during add_do_super(), when device is already removed from previous array/container for Monitor. For Incremental, it ensures that all criteria are tested when trying spare. It is not tested when device contains valid metadata. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Add functions for spare criteria verificationMariusz Tkaczyk2024-03-111-53/+59
| | | | | | | | | | | | | | | | | It is done similar way in few places. As a result, two almost identical functions (dev_size_from_id() and dev_sector_size_from_id()) are removed. Now, it uses same file descriptor to send two ioctls. Two extern functions are added, in next patches disk_fd_matches_criteria() is used. Next optimization is inline zeroing struct spare_criteria. With that, we don't need to reset values in get_spare_criteria_imsm(). Dedicated boolean field for checking if criteria are filled is added. We don't need to execute the code if it is not set. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Replace "none" with macroMateusz Kusiak2024-01-241-1/+1
| | | | | | | | | | | String "none" is used many times throughout the code. Replace "none" strings with predefined macro. Add str_is_none() for comparing strings with "none". Replace str(n)cmp calls with function. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: numbered names verificationMariusz Tkaczyk2023-05-081-0/+44
| | | | | | | | New functions added to remove literals and make the code reusable. Use parse_num() instead of is_numer(). Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdmon: Improve switchroot interactions.NeilBrown2023-03-191-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need a new mdmon@mdfoo instance to run in the root filesystem after switch root, as /sys and /dev are removed from the initrd. systemd will not start a new unit with the same name running while the old unit is still active, and we want the two mdmon processes to overlap in time to avoid any risk of deadlock, which can happen when a write is attempted with no mdmon running. So we need a different unit name in the initrd than in the root. Apart from the name, everything else should be the same. This is easily achieved using a different instance name as the mdmon@.service unit file already supports multiple instances (for different arrays). So start "mdmon@mdfoo.service" from root, but "mdmon@initrd-mdfoo.service" from the initrd. udev can tell which circumstance is the case by looking for /etc/initrd-release. continue_from_systemd() is enhanced so that the "initrd-" prefix can be requested. Teach mdmon that a container name like "initrd/foo" should be treated just like "foo". Note that systemd passes the instance name "initrd-foo" as "initrd/foo". We don't need a similar mechanism at shutdown because dracut runs "mdmon --takeover --all" when appropriate. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Use existence of /etc/initrd-release to detect initrd.NeilBrown2023-03-191-9/+1
| | | | | | | | | | Since v183, systemd has used the existence of /etc/initrd-release to detect if it is running in an initrd, rather than looking at the magic number of the root filesystem's device. It is time for mdadm to do the same. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* util.c: fix memleak in parse_layout_faulty()Wu Guanghao2023-03-081-0/+2
| | | | | | | | | | char *m is allocated by xstrdup but not free() before return, will cause a 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>
* util.c: reorder code lines in parse_layout_faulty()Coly Li2023-03-081-3/+6
| | | | | | | | | Resort the code lines in parse_layout_faulty() to make it more comfortable, no logic change. Signed-off-by: Coly Li <colyli@suse.de> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Add helpers to determine whether directories or files are soft linksMateusz Grzonka2023-03-021-0/+45
| | | | | | Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Acked-by: Coly Li <colyli@suse.de> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Fix NULL dereference in super_by_fdLi Xiao Keng2023-02-281-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | When we create 100 partitions (major is 259 not 254) in a raid device, mdadm may coredump: Core was generated by `/usr/sbin/mdadm --detail --export /dev/md1p7'. Program terminated with signal SIGSEGV, Segmentation fault. #0 __strlen_avx2_rtm () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:74 74 VPCMPEQ (%rdi), %ymm0, %ymm1 (gdb) bt #0 __strlen_avx2_rtm () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:74 #1 0x00007fbb9a7e4139 in __strcpy_chk (dest=dest@entry=0x55d55d6a13ac "", src=0x0, destlen=destlen@entry=32) at strcpy_chk.c:28 #2 0x000055d55ba1766d in strcpy (__src=<optimized out>, __dest=0x55d55d6a13ac "") at /usr/include/bits/string_fortified.h:79 #3 super_by_fd (fd=fd@entry=3, subarrayp=subarrayp@entry=0x7fff44dfcc48) at util.c:1289 #4 0x000055d55ba273a6 in Detail (dev=0x7fff44dfef0b "/dev/md1p7", c=0x7fff44dfe440) at Detail.c:101 #5 0x000055d55ba0de61 in misc_list (c=<optimized out>, ss=<optimized out>, dump_directory=<optimized out>, ident=<optimized out>, devlist=<optimized out>) at mdadm.c:1959 #6 main (argc=<optimized out>, argv=<optimized out>) at mdadm.c:1629 The direct cause is fd2devnm returning NULL, so add a check. Signed-off-by: Li Xiao Keng <lixiaokeng@huawei.com> Signed-off-by: Wu Guang Hao <wuguanghao3@huawei.com> Acked-by: Coly Li <colyli@suse.de> Acked-by: Coly Li <colyli@suse.de <mailto:colyli@suse.de>> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* util: remove obsolete code from get_md_nameMateusz Kusiak2023-01-041-34/+17
| | | | | | | | | | get_md_name() is used only with mdstat entries. Remove dead code and simplyfy function. Remove redundadnt checks from mdmon.c Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Grow: Split Grow_reshape into helper functionMateusz Kusiak2022-08-241-0/+14
| | | | | | | | | | Grow_reshape should be split into helper functions given its size. - Add helper function for preparing reshape on external metadata. - Close cfd file descriptor. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Acked-by: Coly Li <colyli@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: Replace obsolete usleep with nanosleepMateusz Grzonka2022-08-221-9/+33
| | | | | | | | | According to POSIX.1-2001, usleep is considered obsolete. Replace it with a wrapper that uses nanosleep, as recommended in man. Add handy macros for conversions between msec, usec and nsec. Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* util: replace ioctl use with functionKinga Tanska2022-06-241-1/+1
| | | | | | | | | Replace using of ioctl calling to get md array info with special function prepared to it. Signed-off-by: Kinga Tanska <kinga.tanska@intel.com> Acked-by: Coly Li <colyli@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Replace error prone signal() with sigaction()Lukasz Florczak2022-04-041-1/+0
| | | | | | | | | | | | Up to this date signal() was used which implementation could vary [1]. Sigaction() call is preferred. This commit introduces replacement from signal() to sigaction() by the use of signal_s() wrapper. Also remove redundant signal.h header includes. [1] https://man7.org/linux/man-pages/man2/signal.2.html Signed-off-by: Lukasz Florczak <lukasz.florczak@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Refactor parse_num and use it to parse optarg.Mateusz Grzonka2021-10-081-11/+2
| | | | | | | | Use parse_num instead of atoi to parse optarg. Replace atoi by strtol. Move inst to int conversion into manage_new. Add better error handling. Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Utils: Change sprintf to snprintfMateusz Kusiak2021-08-131-2/+2
| | | | | | | Using sprintf can cause segmentation fault by exceeding the size of buffer array. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: Fix building errorsXiao Ni2021-07-161-1/+1
| | | | | | | | | | | | | In util.c, there is a building error: '/md/metadata_version' directive writing 20 bytes into a region of size between 0 and 255 [-Werror=format-overflow=] In mapfile.c It declares the fouth argument as 'int *' in map_update, but in mdadm.h it's previously declared as an array 'int[4]' Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: Unify forks behaviourMariusz Tkaczyk2020-11-261-44/+80
| | | | | | | | | | | | | | If mdadm is run by udev or systemd, it gets a pipe as each stream. Forks in the background may run after an event or service has been processed when udev is detached from pipe. As a result process fails quietly if any message is written. To prevent from it, each fork has to close all parent streams. Leave stderr and stdout opened only for debug purposes. Unify it across all forks. Introduce other descriptors detection by scanning /proc/self/fd directory. Add generic method for managing systemd services. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
* uuid.c: split uuid stuffs from util.cGuoqing Jiang2020-05-191-87/+0
| | | | | | | | | | | | | | | | | | | | Currently, 'make raid6check' is build broken since commit b06815989 ("mdadm: load default sysfs attributes after assemblation"). /usr/bin/ld: sysfs.o: in function `sysfsline': sysfs.c:(.text+0x2707): undefined reference to `parse_uuid' /usr/bin/ld: sysfs.c:(.text+0x271a): undefined reference to `uuid_zero' /usr/bin/ld: sysfs.c:(.text+0x2721): undefined reference to `uuid_zero' Apparently, the compile of mdadm or raid6check are coupled with uuid functions inside util.c. However, we can't just add util.o to CHECK_OBJS which raid6check is needed, because it caused other worse problems. So, let's introduce a uuid.c file which is indenpended file to fix the problem, all the contents are splitted from util.c. Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Add support for TebibytesKinga Tanska2020-01-211-14/+33
| | | | | | | | | Adding support for Tebibytes enables display size of volumes in Tebibytes and Terabytes when they are bigger than 2048 GiB (or GB). Signed-off-by: Kinga Tanska <kinga.tanska@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: force a uuid swap on big endianNigel Croxon2019-09-301-0/+4
| | | | | | | | | | | | | | The code path for metadata 0.90 calls a common routine fname_from_uuid that uses metadata 1.2. The code expects member swapuuid to be setup and usable. But it is only setup when using metadata 1.2. Since the metadata 0.90 did not create swapuuid and set it. The test (st->ss == &super1) ? 1 : st->ss->swapuuid fails. The swapuuid is set at compile time based on byte order. Any call based on metadata 0.90 and on big endian processors, the --export uuid will be incorrect. Signed-Off-by: Nigel Croxon <ncroxon@redhat.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: Do not require MDADM_EXPERIMENTAL flag anymoreMichal Zylowski2018-05-311-10/+0
| | | | | | | | | | | | | | Grow feature for IMSM metadata is currently fully supported and tested. Reshape operation is not in experimental state anymore, so usage of this flag is unnecessary. Do not require MDADM_EXPERIMENTAL flag and remove obsolete information from manual. Signed-off-by: Michal Zylowski <michal.zylowski@intel.com> Acked-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com> Acked-by: Roman Sobanski <roman.sobanski@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: improve the dlm locking mechanism for clustered raidGuoqing Jiang2018-03-081-14/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the dlm locking only protects several functions which writes to superblock (update_super, add_to_super and store_super), and we missed other funcs such as add_internal_bitmap. We also need to call the funcs which read superblock under the locking protection to avoid consistent issue. So let's remove the dlm stuffs from super1.c, and provide the locking mechanism to the main() except assemble mode which will be handled in next commit. And since we can identify it is a clustered raid or not based on check the different conditions of each mode, so the change should not have effect on native array. And we improve the existed locking stuffs as follows: 1. replace ls_unlock with ls_unlock_wait since we should return when unlock operation is complete. 2. inspired by lvm, let's also try to use the existed lockspace first before creat a lockspace blindly if the lockspace not released for some reason. 3. try more times before quit if EAGAIN happened for locking. Note: for MANAGE mode, we do not need to get lock if node just want to confirm device change, otherwise we can't add a disk to cluster since all nodes are compete for the lock. Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* To support clustered raid10Guoqing Jiang2017-11-091-0/+11
| | | | | | | | | | We are now considering to extend clustered raid to support raid10. But only near layout is supported, so make the check when create the array or switch the bitmap from internal to clustered. Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Zeroout whole ppl space during creation/force assemblePawel Baldysiak2017-10-021-0/+49
| | | | | | | | | | | PPL area should be cleared before creation/force assemble. If the drive was used in other RAID array, it might contains PPL from it. There is a risk that mdadm recognizes those PPLs and refuses to assemble the RAID due to PPL conflict with created array. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* util: Code is 80 characters wideJes Sorensen2017-09-301-12/+21
| | | | | | Lets not make things uglier than they need to be. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: correct output for active arraysMariusz Tkaczyk2017-08-161-6/+9
| | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | 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: Fixup more broken logical operator formattingJes Sorensen2017-05-161-2/+1
| | | | Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: Fixup a large number of bad formatting of logical operatorsJes Sorensen2017-05-161-12/+8
| | | | | | Logical oprators never belong at the beginning of a line. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Add sector size as spare selection criterionAlexey Obitotskiy2017-05-091-1/+30
| | | | | | | | | | | Add sector size as new spare selection criterion. Assume that 0 means there is no requirement for the sector size in the array. Skip disks with unsuitable sector size when looking for a spare to move across containers. Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com> Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Allow more spare selection criteriaAlexey Obitotskiy2017-05-091-3/+3
| | | | | | | | | | | | | | Disks can be moved across containers in order to be used as a spare drive for reubild. At the moment the only requirement checked for such disk is its size (if it matches donor expectations). In order to introduce more criteria rename corresponding superswitch method to more generic name and move function parameter to a structure. This change is a big edit but it doesn't introduce any changes in code logic, it just updates function naming and parameters. Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com> Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>