summaryrefslogtreecommitdiffstats
path: root/maps.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Replace "none" with macroMateusz Kusiak2024-01-241-2/+2
| | | | | | | | | | | 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>
* Change update to enum in update_super and update_subarrayMateusz Kusiak2023-01-041-21/+0
| | | | | | | | | | Use already existing enum, change update_super and update_subarray update to enum globally. Refactor function references also. Remove code specific options from update_options. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Add code specific update options to enum.Mateusz Kusiak2023-01-041-0/+21
| | | | | | | | | Some of update options aren't taken from user input, but are hard-coded as strings. Include those options in enum. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: Add option validation for --update-subarrayMateusz Kusiak2023-01-041-0/+31
| | | | | | | | | Subset of options available for "--update" is not same as for "--update-subarray". Define maps and enum for update options and use them instead of direct comparisons. Add proper error message. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: add map_num_s()Mariusz Tkaczyk2022-04-051-0/+24
| | | | | | | | | | | | | | 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>
* Create: add support for RAID0 layouts.NeilBrown2019-12-021-0/+12
| | | | | | | | | | | | | | 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>
* mdadm: Introduce new array state 'broken' for raid0/linearGuilherme G. Piccoli2019-09-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Don't use UnSet with consistency_policyArtur Paszkiewicz2017-04-241-1/+1
| | | | | | | | | Use CONSISTENCY_POLICY_UNKNOWN instead. Simplify some checks because since 5e8e35fb7e17 ("maps: Use keyvalue for null terminator to indicate 'unset' value") map_name() can return this default directly. Suggested-by: Jes Sorensen <Jes.Sorensen@gmail.com> Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
* maps: Simplify implementation of map_name()Jes Sorensen2017-04-211-4/+1
| | | | | Reported-By: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* maps: Remove incorrect comment about strcmp()Jes Sorensen2017-04-211-4/+0
| | | | Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* maps: Use keyvalue for null terminator to indicate 'unset' valueJes Sorensen2017-04-201-8/+9
| | | | | | | This simplifies the code calling map_name() so it no longer has to manually check for UnSet and convert the value manually. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* maps: Terminate 'modes' map correctly.Jes Sorensen2017-04-201-0/+1
| | | | | | | While we are unlikely to fail here, terminate the modes map correctly to ensure we don't start running over undefined data. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* sysfs: Parse array_state in sysfs_read()Jes Sorensen2017-04-201-0/+17
| | | | | | | Rather than copying in the array_state string, parse it and use an enum to indicate the state. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Generic support for --consistency-policy and PPLArtur Paszkiewicz2017-03-291-0/+10
| | | | | | | | | | | | | Add a new parameter to mdadm: --consistency-policy=. It determines how the array maintains consistency in case of unexpected shutdown. This maps to the md sysfs attribute 'consistency_policy'. It can be used to create a raid5 array using PPL. Add the necessary plumbing to pass this option to metadata handlers. The write journal and bitmap functionalities are treated as different policies, which are implicitly selected when using --write-journal or --bitmap options. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* Remove lots of unnecessary white space.NeilBrown2013-06-191-3/+0
| | | | | | | Now that I am using white-space mode in Emacs I can see all of this, and I don't like it :-) Signed-off-by: NeilBrown <neilb@suse.de>
* split name/number maps into separate file.NeilBrown2011-04-051-0/+153
This reduced some interdependencies between files. Signed-off-by: NeilBrown <neilb@suse.de>