summaryrefslogtreecommitdiffstats
path: root/mdadm.c
AgeCommit message (Collapse)AuthorFilesLines
2021-08-02Add monitor delay parameter to mdadm.confoshchirs1-4/+2
Add possibility to configure delay for mdadm in monitoring mode using mdadm.conf. --delay command line argument takes precedence over config file. Signed-off-by: Oleksandr Shchirskyi <oleksandr.shchirskyi@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2021-05-06Prevent user from using --stop with ambiguous argsNorbert Szulc1-0/+5
When both --scan and device name is passed to --stop action, then is executed only for given device. Scan is ignored. Block the operation when both --scan and device name are passed. Signed-off-by: Norbert Szulc <norbert.szulc@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2021-03-09Add "bitmap" to allowed command-line valuesJakub Radtke1-1/+3
Currently, the sysfs interface allows bitmap setup only when volume is in an inactive state. For external metadata to add bitmap to existing volume instead of GROW, the UPDATE operation can be done. The patch adds a "bitmap" argument to the allowed values for UPDATE. Signed-off-by: Jakub Radtke <jakub.radtke@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2020-10-14Super1: allow RAID0 layout setting to be removed.NeilBrown1-2/+3
Once the RAID0 layout has been set, the RAID0 array cannot be assembled on an older kernel which doesn't understand layouts. This is an intentional safety feature, but sometimes people need the ability to roll-back to a previously working configuration. So add "--update=layout-unspecified" to remove RAID0 layout information from the superblock. Running "--assemble --update=layout-unspecified" will cause the assembly the fail when run on a newer kernel, but will allow it to work on an older kernel. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2020-08-07Specify nodes number when updating cluster nodesXiao Ni1-0/+5
Now it allows updating cluster nodes without specify --nodes. It can write superblock with zero nodes. It can break the current cluster. Add this check to avoid this problem. v2: It needs check c.update first to avoid NULL pointer reference v3: Wol points the typo error Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2020-01-21imsm: fill working_disks according to metadata.Blazej Kucman1-3/+6
Imsm tracks as "working_disk" each visible drive. Assemble routine expects that the value will return count of active member drives recorded in metadata. As a side effect "--no-degraded" doesn't work correctly for imsm. Align this field to others. Added check, if the option --no-degraded is called with --scan. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2019-12-02Assemble: add support for RAID0 layouts.NeilBrown1-0/+4
If you have a RAID0 array with varying sized devices on a kernel before 5.4, you cannot assembling it on 5.4 or later without explicitly setting the layout. This is now possible with --update=layout-original (For 3.13 and earlier kernels) or --update=layout-alternate (for 3.14 and later kernels) Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2019-12-02Create: add support for RAID0 layouts.NeilBrown1-0/+8
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>
2019-08-12mdadm: add --no-devices to avoid component devices detail informationColy Li1-0/+4
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>
2018-09-27mdadm.c: Fix error handling for --zero-superblockMariusz Tkaczyk1-1/+1
When Kill() cannot open device or find superblock it return the same error and mdadm ignores it. Change error handling in Kill() function. Return error if device is busy, ignore it only when superblock doesn't exist- assume that metadata is zeroed. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-06-11Free map to avoid resource leak issuesGuoqing Jiang1-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>
2018-03-08mdadm: improve the dlm locking mechanism for clustered raidGuoqing Jiang1-0/+20
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>
2018-01-21mdadm: allow clustered raid10 to be created with default layoutGuoqing Jiang1-1/+1
Since the default layout of raid10 is n2, so we should allow the behavior. Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-11-21Monitor/msg: Don't print error message if mdmon doesn't runMariusz Tkaczyk1-2/+2
Commit 4515fb28a53a ("Add detail information when can not connect monitor") was added to warn about failed connection to monitor in WaitClean function (see link below). Mdmon runs for IMSM containers when they have array with redundancy so if mdmon doesn't run, mdadm prints this error. This is misleading and unnecessary. Just print it in WaitClean function. The sock in WaitClean is deprecated so it is removed. Link: https://bugzilla.redhat.com/show_bug.cgi?id=1375002 Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-11-09To support clustered raid10Guoqing Jiang1-2/+7
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>
2017-10-02Close mdfd before returning main functionXiao Ni1-0/+2
Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-08-16Don't use exit(ERANGE)NeilBrown1-1/+1
mdadm uses smaller exit codes like 0,1,2,3,4. Using ERANGE is inconsistent and not helpful. So change it to a more consistent number. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-16mdadm: Fixup a large number of bad formatting of logical operatorsJes Sorensen1-2/+1
Logical oprators never belong at the beginning of a line. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-24Don't use UnSet with consistency_policyArtur Paszkiewicz1-6/+6
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>
2017-04-11mdadm.c:fix compile warning "mdfd is uninitialized"Zhilong Liu1-1/+1
Initialized the mdfd as -1 to prevent compile error of some compilers. For example, gcc version 4.8.5(SUSE Linux). Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-06mdadm: Fail for kernels older than 2.6.15Jes Sorensen1-0/+5
With the removal of old kernel API support, mdadm will no longer run on kernels older than 2.6.15. Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-30sysfs: Make sysfs_init() return an error codeJes Sorensen1-3/+8
Rather than have the caller inspect the returned content, return an error code from sysfs_init(). In addition make all callers actually check it. Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-30mdadm.c: fix compile error "switch condition has boolean value"Gioh Kim1-8/+6
Remove a boolean expression in switch condition to prevent compile error of some compilers, for example, gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2). Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29mdadm: Fixup a number of whitespace inconsistency casesJes Sorensen1-26/+25
Lots of code lacked whitespaces in assignments, and in other places had them in the wrong place. Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29mdadm: Clean up some ugly multiple actions on single lineJes Sorensen1-10/+20
'foo(); continue;' on the same line within a switch statement is always wrong. Get rid of some of it. Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29Grow: support consistency policy changeArtur Paszkiewicz1-0/+3
Extend the --consistency-policy parameter to work also in Grow mode. Using it changes the currently active consistency policy in the kernel driver and updates the metadata to make this change permanent. Currently this supports only changing between "ppl" and "resync" policies, that is enabling or disabling PPL at runtime. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29Add 'ppl' and 'no-ppl' options for --update=Artur Paszkiewicz1-1/+5
This can be used with --assemble for super1 and with --update-subarray for imsm to enable or disable PPL in the metadata. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29Generic support for --consistency-policy and PPLArtur Paszkiewicz1-3/+52
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>
2017-03-27mdadm:it doesn't make sense to set --bitmap twiceZhilong Liu1-0/+4
mdadm.c: it doesn't make sense to set --bitmap twice. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-07mdadm:add checking clustered bitmap in assemble modeZhilong Liu1-2/+4
mdadm:Both clustered and internal array don't need to specify --bitmap when assembling array. Signed-off-by: Zhilong Liu <zlliu@suse.com> Acked-by: Coly Li <colyli@suse.de> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-06mdadm:check the nodes when operate clustered arrayZhilong Liu1-2/+2
It doesn't make sense to write_bitmap with less than 2 nodes, in order to avoid 'write_bitmap' received invalid nodes number, it would be better to do checking nodes in getopt operations. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-06mdadm:fix typo in commentZhilong Liu1-1/+1
Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-01-29Fix oddity where mdadm did not recognise a relative pathWol1-6/+6
mdadm assumed that a pathname started with a "/", while an array name didn't. This alters the logic so that if the first character is not a "/" it tries to open an array, and if that fails it drops through to the pathname code rather than terminating immediately with an error. Signed-off-by: Wol <anthony@youngman.org.uk> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2016-11-29Introduce enum flag_mode for setting and clearing flags.NeilBrown1-6/+6
We currently use '1' to indicate that a flag (writemostly or failfast) needs to be set, and '2' to indicate that it needs to be cleared. Using magic number like this is not a best-practice. So replaced them with values from a enum. No functional change. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
2016-11-28Add failfast support.NeilBrown1-0/+11
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>
2016-08-02mdadm:add 'clustered' in typo prompt when specify wrong param for bitmapZhilong Liu1-1/+1
mdadm: 'clustered' bitmap has already supported, thus add the prompt if users specify wrong value for bitmap param. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
2016-03-29mdadm:Add '--nodes' option in GROW modezhilong1-0/+1
mdadm:add '--nodes' option in GROW mode, because 'Cluster nodes' is set 4 by default if the nodes parameter is not specified when switch bitmap from none to clustered. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
2016-03-22mdadm: Cleanup conditionalsJes Sorensen1-51/+52
Be more consistent in the formatting of conditionals. Don't split on multiple lines if not needed, don't overflow the 80 character line length, put the condition operator at the end of the line of multi-line conditionals, etc. This should be purely cosmetic.... famous last words! Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
2015-12-21Add --update=force-no-bbl.NeilBrown1-2/+5
This forcibly removed the bad-block log. There can be situations where it is hard to remove bad blocks by writing to them - partiularly on RAID5. Signed-off-by: NeilBrown <neilb@suse.com>
2015-12-16recreate journal in mdadmSong Liu1-0/+8
This patch tries recreates missing/faulty journal in mdadm. Example: ./mdadm --fail /dev/md1 /dev/sdb2 mdadm: set /dev/sdb2 faulty in /dev/md1 ./mdadm --stop /dev/md1 mdadm: stopped /dev/md1 ./mdadm -A --scan --force mdadm: Journal is missing or stale, starting array read only. mdadm: /dev/md/1 has been started with 15 drives. ./mdadm --add-journal /dev/md1 /dev/sdb2 mdadm: added /dev/sdb2 Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: NeilBrown <neilb@suse.com>
2015-10-21Make cmap_* also has same policy as dlm_*Guoqing Jiang1-2/+3
Let libcmap lib and related funs also only need one-time setup during mdadm running period. Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.com>
2015-10-21Safeguard against writing to an active device of another nodeGuoqing Jiang1-0/+2
Modifying an exiting device's superblock or creating a new superblock on an existing device needs to be checked because the device could be in use by another node in another array. So, we check this by taking all superblock locks in userspace so that we don't step onto an active device used by another node and safeguard against accidental edits. After the edit is complete, we release all locks and the lockspace so that it can be used by the kernel space. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.com>
2015-10-19Enable create array with write journal (--write-journal DEVICE).Song Liu1-0/+23
Specify the write journal device with --write-journal DEVICE ./mdadm --create -f /dev/md0 --assume-clean -c 32 --raid-devices=4 --level=5 /dev/sd[c-f] --write-journal /dev/sdb1 mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md0 started. Only one journal device is allowed. If multiple --write-journal are given, mdadm will use the first and ignore others ./mdadm --create -f /dev/md0 --assume-clean -c 32 --raid-devices=4 --level=5 /dev/sd[c-f] --write-journal /dev/sdb1 --write-journal /dev/sdx mdadm: Please specify only one journal device for the array. mdadm: Ignoring --write-journal /dev/sdx... mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md0 started. Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: NeilBrown <neilb@suse.com>
2015-10-01Merge branch 'fix' of git://github.com/ldzhong/mdadmNeilBrown1-2/+0
2015-09-28Increment version for clustered bitmapsGoldwyn Rodrigues1-2/+3
Add BITMAP_MAJOR_CLUSTERED as 5, in order to prevent older kernels to assemble a clustered device. In order to maximize compatibility, the major version is set to BITMAP_MAJOR_CLUSTERED *only* if the bitmap is clustered. Also, added MD_FEATURE_CLUSTERED in order to return error for older kernels which would assemble MD in case bitmap is corrupted. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: NeilBrown <neilb@suse.com>
2015-08-26mdadm: remove duplicate logic when c.delay is 0Lidong Zhong1-2/+0
2015-08-05main: remove use of uninitialized 'rv'.NeilBrown1-2/+2
If c.homecluster was not NULL, might get an error anyway. Signed-off-by: NeilBrown <neilb@suse.com>
2015-07-27Merge branch 'cluster'NeilBrown1-3/+61
Now that 3.3.3 is out, it is time to include the cluster-support code. Signed-off-by: NeilBrown <neilb@suse.com>
2015-07-24Assemble: extend --homehost='<ignore>' to allow --name= to ignore homehostNeilBrown1-1/+1
Also make --homehost='<ignore>' work properly. Signed-off-by: NeilBrown <neilb@suse.com>
2015-07-02mdstat: discard 'dev' field, just use 'devnm'NeilBrown1-2/+2
These both have the same value, and have done since the 'devnm' concept was introduced. So discard the pointless duplicate. Signed-off-by: NeilBrown <neilb@suse.de>
2015-06-17mdadm: change the num of cluster nodeGuoqing Jiang1-1/+4
This extends nodes option for assemble mode, make the num of cluster node could be change by user. Before that, it is necessary to ensure there are enough space for those nodes, calc_bitmap_size is introduced to calculate the bitmap size of each node. Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.de>
2015-06-17mdadm: add the ability to change cluster nameGuoqing Jiang1-1/+4
To support change the cluster name, the commit do the followings: 1. extend original write_bitmap function for new scenario. 2. add the scenarion to handle the modification of cluster's name in write_bitmap1. 3. let the cluster name also show in examine_super1 and detail_super1 Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.de>
2015-06-17Add a new clustered diskGuoqing Jiang1-0/+4
A clustered disk is added by the traditional --add sequence. However, other nodes need to acknowledge that they can "see" the device. This is done by --cluster-confirm: --cluster-confirm SLOTNUM:/dev/whatever (if disk is found) or --cluster-confirm SLOTNUM:missing (if disk is not found) The node initiating the --add, has the disk state tagged with MD_DISK_CLUSTER_ADD and the one confirming tag the disk with MD_DISK_CANDIDATE. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.de>
2015-06-17Set home-cluster while creating an arrayGuoqing Jiang1-0/+17
The home-cluster is stored in the bitmap super block of the array. The device can be assembled on a cluster with the cluster name same as the one recorded in the bitmap. If home-cluster is not specified, this is auto-detected using dlopen corosync cmap library. neilb: allow code to compile when corosync-devel is not installed. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.de>
2015-06-17Add nodes option while creating mdGuoqing Jiang1-1/+32
Specifies the maximum number of nodes in the cluster that may use this device simultaneously. This is equivalent to the number of bitmaps created in the internal superblock (patches to follow). Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.de>
2015-02-12Don't break long strings onto multiple lines.NeilBrown1-63/+31
It is best to keep strings all together so that they are easier to search for in the source code. If a string is so long that it looks ugly one line, them maybe it should be broken into multiple lines for display too. Only strings which contain a newline can be broken into multiple lines: "It is OK to\n" "break this string\n" Signed-off-by: NeilBrown <neilb@suse.de>
2015-02-12Consistently print program Name and __func__ in debug messages.NeilBrown1-3/+1
make dprintf() print program name and __func__, so that this messaging is consistent. Also remove all __func__ messages from pr_err(). We shouldn't leak that internal data in error message. If we really want function name there, we new pr_XXX might be wanted. Signed-off-by: NeilBrown <neilb@suse.de>
2015-02-12Change way of printing name of a processPawel Baldysiak1-3/+4
Sometimes mdadm prints messages with wrong name "mdmon", and vice versa. This patch solves this problem by changing method of determining process name. Now "Name" will be set in const at start of a program, previously was hardcoded as #define. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
2014-08-27--update: add 'bbl' and 'no-bbl' to the list of known updates.NeilBrown1-1/+3
so "mdadm -A --update=?" mentions them. Reported-by: Peter Hoeg <peter@hoeg.com> Signed-off-by: NeilBrown <neilb@suse.de>
2014-05-22MISC: add --action option to set or abort check/repair.NeilBrown1-0/+43
Signed-off-by: NeilBrown <neilb@suse.de>
2013-12-03Incremental: improve support for "DEVICE" based restriction in mdadm.confNeilBrown1-8/+8
--incremental currently fails if the device name passed does not textually match the names permitted by the DEVICE line in mdadm.conf. This is problematic when "mdadm -I" is run by udev as the name given can be a temp name. This patch makes two improvements: 1/ We generate a list of all existing devices that match the names in mdadm.conf, and allow rdev based matching 2/ We allows extra aliases to be provided on the command line, and perform textual matching on those. This is particularly suitable for udev usages as ${DEVLINKS} can be provided even though the links make not yet be created. Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-31Add support for --add-spareNeilBrown1-0/+4
--add-spare is like --add, but a --re-add is never attempted. So it is equivalent to two separate commands: --zero-metadata --add Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-15Give error if --incremental --scan also has a device name given.NeilBrown1-0/+5
Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-13Make -IRs and --run work properly for containers.NeilBrown1-3/+4
We really need to make sure assemble_container_content() gets called to finished the assembly of these. Reported-by: Francis Moreau <francis.moro@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-03Release mdadm-3.3mdadm-3.3NeilBrown1-1/+1
(and various cosmetic fixes) Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-26Change "mdadm --run" to use the same code as "mdadm --IRs".NeilBrown1-1/+1
Current "mdadm --run /dev/mdX" will not handle external metadata properly. mdmon won't be started etc. So use the code from "mdadm -IRs" instead - that already does all the right things. Reported-by: Francis Moreau <francis.moro@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-01Don't lie to systemd about mdadm's status.NeilBrown1-7/+0
Telling systemd that mdadm was started from the initrd is often a lie and never necessary. Now that the reshape monitoring thread handles SIGTERM gracefully it is OK for system to kill and mdadm that it finds running. mdmon still have a bit of a question mark over it so I won't remove the '@' from there just yet. Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-24Grow: allow "--add" with "--grow --level=??"NeilBrown1-1/+1
This is useful for reshaping a RAID0 to a higher level. The recovery will happen at the same time as the reshape. Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-24test/00names: use appropriate mdadm.confNeilBrown1-0/+1
Using non-numeric names needs an mdadm.conf setting, so make sure we have one. Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-19Remove lots of unnecessary white space.NeilBrown1-4/+1
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>
2013-06-19Manage: allow "--stop" on kernel names.NeilBrown1-1/+7
e.g. mdadm --stop md4 This works even if udev has become confused or killed. Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-19Manage: split Manage_runstop into Manage_run and Manage_stopNeilBrown1-5/+7
The two branches have virtually nothing in common, so it is simpler if they are separate. Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-28Assemble: allow --update=revert-reshapeNeilBrown1-1/+3
This will cause a reshape to start going backwards.
2013-05-28Assemble: --update=metadata converts v0.90 to v1.0NeilBrown1-1/+3
This allows the smooth conversion of legacy 0.90 arrays to 1.0 metadata. Old metadata is likely to remain but will be ignored. It can be removed with mdadm --zero-superblock --metadata=0.90 /dev/whatever Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-22Grow: allow a reshape which only changes --data-offsetNeilBrown1-1/+2
Sometimes, that is all we want to do. Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-22Grow: --backup-file and --data-offset are incompatible.NeilBrown1-0/+5
So report if both are given, and if --backup-file is given, don't try to update data-offset. Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21Change some fprintf(stderrs to cont_err()NeilBrown1-1/+1
Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-21Change some "fprintf(stderr,"s to pr_err.NeilBrown1-2/+2
They just keep slipping in.. Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-16Add --dump / --restore functionality.NeilBrown1-2/+24
This allows the metadata on a device to be saved and later restored. This can be useful before experimenting on an array that is misbehaving. Suggested-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-13misc_scan: don't trust the mapping file too much for device names.NeilBrown1-2/+4
misc_scan assumes that any device name found in the 'mapping' file is usable. Usually it is but sometimes not, such as for inactive devices. Depending on it isn't really robust, when a name is found, check that it exists. If not, fall back on map_dev. This will allow "--detail --scan" to notice inactive devices. Signed-off-by: NeilBrown <neilb@suse.de>
2013-03-05Create: default to bitmap=internal for large arrays.NeilBrown1-6/+0
Here, "large" means components are 100G or more. It is usually beneficial to have write-intent bitmaps on such arrays. They can be suppressed with --bitmap=none Signed-off-by: NeilBrown <neilb@suse.de>
2013-02-21Discard devnum in favour of devnmNeilBrown1-4/+4
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>
2013-02-05Remove --offroot argument and default to always setting argv[0] to @Jes Sorensen1-7/+8
We still allow --offroot to be given - for compatibility with scripts - but ignore it. The whole point of --offroot is to get systemd to not auto-kill mdmon, and we always want that. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
2012-12-05MISC: Add --examine-badblocks optionNeilBrown1-0/+4
This will list the contents of the bad-blocks log, if one is present. Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-23Add support for --replace and --withNeilBrown1-0/+14
--replace can be used to replace a device without completely failing it. Once the replacement completes the device will be failed. --with can indicate which of several spares to use. Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-04Allow data-offset to be specified per-device for createNeilBrown1-1/+5
mdadm --create /dev/md0 .... /dev/sda1:1024 /dev/sdb1:2048 ... The size is in K unless a suffix: K M G is given. The suffix 's' means sectors. Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-04Add --data-offset flag for Create and GrowNeilBrown1-2/+19
This can be used to over-ride the automatic assignment of data offset. For --create, it is useful to re-create old arrays where different defaults applied. For --grow it may be able to force a reshape in the reverse direction. Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-04Allow parse_size to return 0.NeilBrown1-4/+8
We will shortly introduce --data-offset= which is allowed to be zero. We will want to use parse_size() so it needs to be able to return '0' without it being an error. So define INVALID_SECTORS to be an impossible value (currently '1') and return and test for it consistently. Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-04imsm: Allow to specify controller for --detail-platform.Maciej Naruszewicz1-2/+11
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>
2012-10-03Allow --update to add or remove space for a bad block list.NeilBrown1-2/+8
--update=bbl will add a bad block list to each device. --update=no-bblk will remove the bad block list providing that it is empty. Signed-off-by: NeilBrown <neilb@suse.de>
2012-10-02imsm: Add --export option for --detail-platformMaciej Naruszewicz1-1/+1
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>
2012-07-09Use new struct context and struct shape for Grow_addbitmapNeilBrown1-2/+1
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Use new struct context and struct shape in Grow_reshapeNeilBrown1-4/+2
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Use new 'struct shape' to pass args to CreateNeilBrown1-5/+3
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Use new 'struct shape' to pass args to BuildNeilBrown1-4/+1
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Create new 'struct shape' to pass around array details.NeilBrown1-90/+84
This collects to together many of the args given to create/build/grow Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09change array_size to be unsigned and use the new MAX_SIZENeilBrown1-6/+6
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Change the values for "max size" from -1 to 1.NeilBrown1-7/+7
Both are impossible, and '1' allows size to be unsigned, which is neater. Also #define MAX_SIZE to be '1' to make it all more explicit. Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Change Incremental and related functions to take struct contextNeilBrown1-4/+1
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Change Monitor to take a struct contextNeilBrown1-3/+5
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Change Detail and misc_scan to take a struct contextNeilBrown1-14/+6
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09change Examine to take a struct contextNeilBrown1-3/+1
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Examine: split 'verbose' out from 'brief'.NeilBrown1-3/+5
The value of 'verbose' is sometimes mixed into 'brief', particularly for Examine. This is messy and confusing. So keep them separate. 'brief' still gets assumed when 'scan' is set, unless we are very verbose. Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Change Create to take a struct contextNeilBrown1-4/+4
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Change Build to take a struct contextNeilBrown1-1/+1
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Change misc_list to take struct contextNeilBrown1-25/+18
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Convert Assemble() to take a context rather than a list of options.NeilBrown1-49/+15
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Discard 'quiet' context variable.NeilBrown1-18/+18
Just use negative verbose, now that we are ready for that. Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Convert 'quiet' to 'not verbose' in various places.NeilBrown1-25/+25
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>
2012-07-09Create 'struct context' for ad hoc context option.NeilBrown1-168/+152
Rather than passing a long list of little flags etc to various functions we will soon pass a small collection of structures. This first step combines a collection of variables local to 'main' into a single structure. Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Create parse_num() function.NeilBrown1-12/+10
Instead of open-coding this several times, just do it once. The frees up the name 'c' which I'm about to use. Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Create: support --readonly flag.NeilBrown1-1/+2
Allow array to be created read-only Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Assemble: allow arrays to be assembled read-only.NeilBrown1-0/+6
The option was there, but never used. Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Remove scattered checks for malloc success.NeilBrown1-10/+2
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>
2012-07-09Remove re_add flag in favour of new disposition.NeilBrown1-7/+2
Instead of disposition == 'a' re_add == 1 use disposition == 'A' to record that a re-add was requested. Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Introduce pr_err for printing error messages.NeilBrown1-132/+124
'pr_err("' is a lot shorter than 'fprintf(stderr, Name ": ' cont_err() is also available. Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Help: use an array to choose which help matches which mode.NeilBrown1-11/+4
Looks cleaner than a big switch statement. Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09main: extract more functions.NeilBrown1-162/+206
extract misc_scan stop_scan misc_list from main to try to make main() a little more manageable. Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09main: split scan_assemble into a separate functionNeilBrown1-92/+117
main is too big. This makes it a little more manageable. Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09mdadm.c: various minor clean-upsNeilBrown1-20/+30
Signed-off-by: NeilBrown <neilb@suse.de>
2012-07-09Use explicit non-char opt for --zero-superNeilBrown1-3/+3
As we don't allow '-K' for '--zero-super' there is no point using it internally. Just define a 'KillOpt' like with other options. Signed-off-by: NeilBrown <neilb@suse.de>
2012-04-18Add --prefer option for --detail and --monitorNeilBrown1-3/+12
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>
2012-04-04parse_size: distinguish between 0 and error.NeilBrown1-3/+2
It isn't sufficient to use '0' for 'error' as well will later have fields that can validly be '0'. So return "-1" on error. Also fix parsing of --bitmap_check so that '0' is treated as an error: we don't support 512B anyway. Signed-off-by: NeilBrown <neilb@suse.de>
2012-01-30Spawn mdmon with --offroot if mdadm was launched with --offrootJes Sorensen1-0/+1
Acked-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
2012-01-30Add --offroot argument to mdadmJes Sorensen1-0/+9
When --offroot is specified, mdadm will change the first character of argv[0] to '@'. This is used to signal to systemd that mdadm was launched from initramfs and should not be shut down before returning to the initramfs. Acked-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
2011-12-23allow --monitor to be run by non-privileged use.NeilBrown1-1/+2
Providing --no-sharing is given, monitoring should be permitted. Unfortunately the kernel current rejects GET_DISK_INFO and GET_ARRAY_INFO for non-privileged users which is unjustified. The info is available in sysfs and we could get it from there, but for now, require the kernel to be fixed. Reported-by: Raphael Hertzog <hertzog@debian.org> Signed-off-by: NeilBrown <neilb@suse.de>
2011-11-07fix: Allowed to assemble 2 volumes with the same names from config file.Lukasz Orlowski1-0/+7
mdadm allowes to assemble 2 volumes with the same names based on the config file. The issue is fixed by iterating over the list of md device identifiers and comparing the names of md devices against each other, detecting identical names and blocking the assembly should the same names be found. Now having detected duplicate names, mdadm terminates without assembling the container, displaying appropriate prompt. Signed-off-by: Lukasz Orlowski <lukasz.orlowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
2011-11-03mdadm: Rearrange option parsing for KillSubarray and UpdateSubarrayJes Sorensen1-12/+22
Extracting the 'subarray' arg for these options was being done at the wrong place which lead to the code being a bit confusing and looking wrong. So reformat that code a bit better and move the extraction of 'subarray' down to the main parsing of these options rather than the mode setting. Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-22Hold the map lock while performing Assemble to avoid races with udevJes Sorensen1-0/+6
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-03Add continue option to grow commandAdam Kwolek1-1/+11
To allow for reshape continuation '--continue' option is added to grow command. Function that will be executed in grow-continue case doesn't require information about reshape geometry. All required information are read from metadata. For external metadata reshape can be run for monitored array/container only. In case when array/container is not monitored run mdmon for it. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
2011-10-03Do not continue reshape during initrd phaseAdam Kwolek1-9/+24
During initrd phase continuing reshape will cause file system context lost. This blocks ability to control reshape using checkpoints. To avoid this, during initrd phase assemble has to be executed with '--freeze-reshape' option. This causes that mdadm restores reshape critical section only. Reshape can be continued later after system full boot. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
2011-09-19Monitor: --oneshot must imply --no-sharingNeilBrown1-0/+1
Moving spares is not the purpose of '--oneshot' and without currently --oneshot doesn't work as the check against multiple spare-sharers prevents it. So make --oneshot imply --no-sharing. This is sensible and allows --oneshot to work again. Reported-by: Jamie Heilman <jamie@audible.transient.net> Resolves-Debian-Bug: 641886 Signed-off-by: NeilBrown <neilb@suse.de>
2011-09-08Discourage large devices from being added to 0.90 arrays.NeilBrown1-1/+2
0.90 arrays can only use up to 4TB per device. So when a larger device is added, complain a bit. Still allow it if --force is given as there could be a valid use. Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-16Grow: accept --assume-clean with --grow --sizeNeilBrown1-1/+2
When an array is resized to have larger members, --assume-clean will disable any resync if the kernel supports it (2.6.40 and later). Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-10Create: allow chunksize to be non-power-of-2.NeilBrown1-2/+2
RAID0 has accepted chunksizes that are not a power of 2 since 2.6.30. So it time mdadm allowed that to be used. Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-10Give suitable error for mdadm /dev/md0 --stopNeilBrown1-0/+6
Options like --stop must come before the device that is being stopped. If (in --misc mode) a device does not have an option, nothing will be done to it, which can be confusing. So report an error in this case. Signed-off-by: NeilBrown <neilb@suse.de>
2011-05-10config: restore the possibility of a NULL homehostNeilBrown1-1/+5
As homehost defaults to the system name it is not possible to specify a NULL homehost. This patch restored this ability with either --homehost="" or --homehost="<none>". This allows the creation of v1.x arrays without a "hostname:" prefix in the name. Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-27Finally remove auto-home-hostNeilBrown1-35/+0
This was #if-ed out for 3.0, but it really should go. Gcc 4.6.0 complains that auto_update_home is set but not used (which is true). Reported-by: Tobias Powalowski <t.powa@gmx.de>
2011-03-15Fix regression when using 'grow' to add a bitmap.NeilBrown1-1/+1
When we allowed a devlist to accompany some --grow modes - but not --bitmap - we made --bitmap always fail, in stead of fail of a device was given to add. As 'devs_found' includes the md device, we need to compare against '1'. Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-10Grow: support reshape of RAID0 arrays.NeilBrown1-7/+12
This is done via conversion to RAID4 and back. To grow the array, extra devices will be needed which cannot already be present as spares - so allow a list of new devices to be included in grow request which changed the number of devices. Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-27Dynamic hot-plug udev rules for policiesLabun, Marcin1-0/+18
Neil, Please consider this patch that once was discussed and I think agreed with in general direction. It was sent a while ago but somehow did not merged into your devel3-2. This patch enables hot-plug of so called bare devices (as understand by domain policies rules in mdadm.conf). Without this patch we do NOT serve hot-plug of bare devices at all. Thanks, Marcin Labun Subject was: FW: Autorebuild, new dynamic udev rules for hot-plugs >>From c0aecd4dd96691e8bfa6f2dc187261ec8bb2c5a2 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Date: Thu, 23 Dec 2010 16:35:01 +0100 Subject: [PATCH] Dynamic hot-plug udev rules for policies Cc: linux-raid@vger.kernel.org, Williams, Dan J <dan.j.williams@intel.com>, Ciechanowski, Ed <ed.ciechanowski@intel.com> When introducing policies, new hot-plug rules were added to support bare disks. Mdadm was started for each hot plugged block device to determine if it could be used as spare or as a replacement member for degraded array. This patch introduces limitation of range of devices that are handled by mdadm. It limits them to the ones specified in domains associated with the actions: spare-same-port, spare and spare-force. In order to enable hot-plug for bare disks one must update udev rules with command mdadm --activate-domains[=filename] Above command writes udev rule configuration to stdout. If 'filename' is given output is written to the file provided as parameter. It is up to system administrator what should be done later. To make such rule permanent (i.e. remain after reboot) rule should be writen to /lib/udev/rules.d directory. Other cases will just need to write it to /dev/.udev/rules.d directory where temporary rules lies. One should be aware of the meaning of names/priorities of the udev rules. After mdadm.conf is changed one is obliged to re-run "mdadm --activate-domains" command in order to bring the system configuration up to date. All hot-plugged disks containing metadata are still handled by existing rules. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-09Allow --update=devicesize with --re-addNeilBrown1-6/+34
This is useful with 1.1 and 1.2 metadata to update the metadata if the device size has changed. The same functionality can be achieved by writing to the device size in sysfs after re-adding normally, but in some cases this might be easier. Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-09Grow: warn if growing an array will make it degraded.NeilBrown1-1/+2
Growing an array when there aren't enough spares can make the array degraded. This works but might not be what is wanted. So warn the user in this case and require a --force to go ahead with the reshape. Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-01Create/grow: improve checks on number of devices.NeilBrown1-14/+0
Check on upper limit of number of devices was in the wrong place. Result was could not create array with more than 27 devices without explicitly setting metadata, even though default metadata allows more. Fixed, and also perform check when growing an array. Signed-off-by: NeilBrown <neilb@suse.de>
2010-12-01Assemble: allow an array undergoing reshape to be started without backup fileNeilBrown1-11/+22
Though not having the proper backup file can cause data corruption, it is not enough to justify not being able to start the array at all. So allow "--invalid-backup" to be specified which says "just continue even if a backup cannot be restored". Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-30Assemble: add --update=no-bitmapNeilBrown1-1/+4
This allows an array with a corrupt internal bitmap to be assembled without the bitmap. Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-30Allow K,M,G suffix on chunk sizes as well as device/array sizes.NeilBrown1-9/+12
We already allow K,M,G suffixes for --size and --array-size. Allow it for --chunk and --bitmap-chunk as well. Also add this info to man page, and remove the duplication of info about --array-size. Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-25Improve opt parsing, and distinguish long from short.NeilBrown1-24/+72
In several cases, two different long options map to the same short option. So e.g. you could give '--brief' and it would be interpreted as '--bitmap'. That isn't really good. So for every shared short option, define an option number and return that for the long option instead. Then always check for both the short and long options. Also give some bugs like " mode == 'G'" which should be '== GROW'. Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-23fix a get_linux_version() comparison typoDan Williams1-1/+1
Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22mdadm: added --no-sharing option for Monitor modeAnna Czarnowska1-2/+6
--no-sharing option disables moving spares between arrays/containers. Without the option spares are moved if needed according to config rules. We only allow one process moving spares started with --scan option. If there is such process running and another instance of Monitor is starting without --scan, then we issue a warning but allow it to continue. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22added --path <path_id> to give the information on the 'path-id' of removed ↵Przemyslaw Czarnowski1-6/+11
device <path-id> allows to identify the port to which given device is plugged in. In case of hot-removal, udev can pass this information for future use (eg. write this name as 'cookie' allowing to detect the fact of reinserting device to the same port). --path <path-id> parameter has been added to device removal handle (and char *path has been added to IncrementalRemove() to pass this value) in order to pass path-id to this handler. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22Remove content from mddev_devNeilBrown1-2/+0
Now that the next_member loop is much smaller it is easy to just use 'content' rather than stashing it in 'tmpdev->content'. So we can remove the 'content' field from 'struct mddev_dev'. Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22Improve type names for mddev_devNeilBrown1-5/+5
Remove the _t pointer typedef and remove the _s suffix for the structure, These things do not help readability. Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22Improve mddev_ident type definitions.NeilBrown1-4/+4
Remove the _t typedef and remove the _s suffix from the struct name. These things do not help readability. Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-12Incremental: accept '--no-degraded' as a deprecated optionDan Williams1-0/+2
Commit 3288b419 (Revert "Incremental: honor --no-degraded to delay assembly") killed the --no-degraded flag since commit 97b4d0e9 (Incremental: honor an 'enough' flag from external handlers) made this the default behavior of -I, and brought -I usage for external/container formats in line with native metadata. However, this breaks existing usages of '-I --no-degraded', so allow it as a deprecated option. Starting a degraded container, like the native metadata case, requires -R. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Reported-by: Ignacy Kasperowicz <ignacy.kasperowicz@intel.com>
2010-07-06Merge branch 'master' of git://github.com/djbw/mdadmNeilBrown1-2/+45
2010-07-06Add --test option to --re-add and similarNeilBrown1-1/+4
--test can be given in Manage mode. This can be used when there is an attempt to fail or remove 'faulty', 'failed' or 'detached' devices, or to re-add 'missing' devices. If no devices were failed, removed, or re-added, then mdadm will exit with status '2'. Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-01Merge branch 'fixes' into for-neilDan Williams1-1/+0
2010-06-30Add -fail support to --incrementalNeilBrown1-0/+12
This can be used for hot-unplug. When a device has been remove, udev can call mdadm --incremental --fail sda and mdadm will find the array holding sda and remove sda from the array. Based on code from Doug Ledford <dledford@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
2010-06-22Rename subarray v2Dan Williams1-3/+38
Allow the name of the array stored in the metadata to be updated. In some cases the metadata format may not be able to support this rename without modifying the UUID. In these cases the request will be blocked. Otherwise we allow the rename to take place, even for active arrays. This assumes that the user understands the difference between the kernel node name, the device node symlink name, and the metadata specific name. Anticipating further need to modify subarrays in-place, introduce the ->update_subarray() superswitch method. A future potential use case is setting storage pool (spare-group) identifiers. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-06-15Kill subarray v2Dan Williams1-0/+8
Support for deleting a subarray out of a container. When all subarrays are deleted the component devices are converted back into spares, a --zero-superblock is still needed to kill the remaining metadata at this point. This operation is blocked when the subarray is active and may also be blocked by the metadata handler when deleting the subarray might change the uuid of other active subarrays. For example, with imsm, deleting subarray 'n' may change the uuid of subarrays with indexes > n. Deleting a subarray needs to be a container wide event to ensure disks that record the modified subarray list perceive other disks that did not receive this change as out of date. Notes: The st->subarray parsing in super-intel.c and super-ddf.c is updated to be more strict now that we are reading user supplied subarray values. Offline container modification shares actions that mdmon typically handles so promote is_container_member() and version_to_superswitch() (formerly find_metadata_methods()) to generic utility functions for the cases where mdadm performs the operation. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-05-26Revert "Incremental: honor --no-degraded to delay assembly"Dan Williams1-1/+0
This reverts commit fdb482f99b9ad2ef8cd1724902fdfeedaa8796a1. Now that containers can report state for ->container_enough we can automatically determine when the array can be started, and no longer need the --no-degraded hammer. Conflicts: Incremental.c Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-02-24Assemble: Handle assembling from config file which is out of order.NeilBrown1-15/+33
Currently "mdadm -As" will process the entries in the config file in order. If any array is a component or member of a preceding array, that array will not be assembled. So if there are any failures during assembly, retry those arrays, and look until everything is assembled, or nothing more can be assembled. Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-01Add test for "are we running as root".NeilBrown1-0/+6
Most operations require root access. Rather than ensure we generate the right error message when something fails because we aren't root, check early. Note that "--examine" does not necessarily require root, so test for that first. Resolves-Debian-bug: 396570 Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-29Kill: fix when zeroing busy devices.Artur Wojcik1-1/+1
mdadm should not wait indefinitely when it trys to reset superblock on device which is busy (cannot be opened). Acked-by: Andre Noll <maan@systemlinux.org> Signed-off-by: Artur Wojcik <artur.wojcik@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-29Tidy up some argument parsing, particularly for -bNeilBrown1-7/+6
-b only means --brief in MISC mode, elsewhere it is --bitmap. Resolves-debian-bug: 427777 Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-24Various fixes for --killNeilBrown1-1/+10
- When --kill-superblock is used with --metadata, find every different superblock if there are several and kill them all. - When creating a new array, kill off any old metadata. The code to do this was already present but has become broken over time. Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-06Grow: do not allow size changes with other changes.NeilBrown1-0/+9
A change the reduces the size of an array always happens before any other change. So it can cause data to be lost. By themselves these changes are reversible. But once another change has started, the data would be permanently lost. So recommend data integrity be checked between a size change and any other change. Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-22Merge branch 'master' into devel-3.1NeilBrown1-3/+20
2009-10-19Detail: list containers before members.NeilBrown1-0/+8
To allow "--assemble --scan" to have a chance, list containers before members in --detail --scan output. Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-19Monitor: add option to specify rebuild incrementsZdenek Behan1-1/+10
ie. the percent increments after which RebuildNN event is generated This is particulary useful when using --program option, rather than (only) syslog for alerts. Signed-off-by: Zdenek Behan <rain@matfyz.cz> Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-13mdmon: preserve socket over chrootDan Williams1-2/+2
Connect to the monitor in the old namespace and use that connection for WaitClean requests when stopping the victim mdmon instance. This allows ping_monitor() to work post chroot(). Cc: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-10-01Merge branch 'master' into devel-3.1NeilBrown1-8/+17
Conflicts: mdadm.8
2009-08-11Handle extra 'grow' variations.NeilBrown1-12/+16
UNFINISHED
2009-07-14Grow: --size improvements.NeilBrown1-2/+4
1/ allow --size to be given with 'G' or 'T' suffix. 2/ allow size to exceed 32bits, and in that case write through sysfs. Signed-off-by: NeilBrown <neilb@suse.de>
2009-07-14Grow: pass layout as a string rather than a number.NeilBrown1-7/+18
This allows the layout to be parsed after the current level of the array is know, so that the level doesn't need to be given (otherwise pointlessly) on the command line. Signed-off-by: NeilBrown <neilb@suse.de>
2009-07-14Remove Manage_reconfing in favour of Grow_reshapeNeilBrown1-3/+1
Bother Manage_reconfig and Grow_reshape provide for changing the 'layout' of a faulty array. This is no necessary. So discard Manage_reconfig and just use Grow_reshape Signed-off-by: NeilBrown <neilb@suse.de>
2009-07-14main: factor out code to parse layout for raid10 and faulty.NeilBrown1-22/+5
This will soon be called from multiple places. Signed-off-by: NeilBrown <neilb@suse.de>
2009-07-13Grow: support --array-size changesNeilBrown1-1/+42
With 2.6.30 it is possible to tell the md driver to clip an array to a size smaller than the real size of the array. This option gives access to that feature. The size change does not persist across restarts. Signed-off-by: NeilBrown <neilb@suse.de>
2009-06-02Update copyright dates and remove references to @cse.unsw.edu.auNeilBrown1-7/+2
Also removed 'paper' addresses. Signed-off-by: NeilBrown <neilb@suse.de>
2009-06-02Monitor: reduce default poll interval if mdstat is pollable.NeilBrown1-0/+7
Since 2.6.16, mdstat responds to select/poll. So in that case, increase the default poll interval to about 15 minutes. This ensures that the background load is insignificant. Signed-off-by: NeilBrown <neilb@suse.de>
2009-06-02mdadm.8: Man page updatesNeilBrown1-1/+8
General review and update of mdadm.8
2009-05-11Merge branch 'master' into devel-3.0NeilBrown1-2/+3
Conflicts: Build.c mdadm.c mdadm.h super1.c
2009-05-11mapfile: allow the path name to the device to be empty.NeilBrown1-1/+2
Allowing an empty name and coping with it is less confusing than seeing "/empty" appear. Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11Allow homehost to be largely ignored when assembling arrays.NeilBrown1-9/+25
If mdadm.conf contains HOMEHOST <ignore> or commandline contains --homehost=<ignore> then the check that array metadata mentions the given homehost is replace by a check that the name recorded in the metadata is not already used by some other array mentioned in mdadm.conf. This allows more arrays to use their native name rather than having an _NN suffix added. This should only be used during boot time if all arrays required for normal boot are listed in mdadm.conf. If auto-assembly is used to find all array during boot, then the HOMEHOST feature should be used to ensure there is no room for confusion in choosing array names, and so it should not be set to <ignore>. Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11config: support "ARRAY <ignore> ..." lines in mdadm.confNeilBrown1-0/+3
Sometimes we want to ensure particular arrays are never assembled automatically. This might include an array made of devices that are shared between hosts. To support this, allow ARRAY lines in mdadm.conf to use the word "ignore" rather than a device name. Arrays which match such lines are never automatically assembled (though they can still be assembled by explicitly giving identification information on the mdadm command line. Signed-off-by: NeilBrown <neilb@suse.de>
2009-04-21mdadm: allow build to use --sizePaul Clements1-2/+4
This patch enables the --size parameter for build operations. Without this, if you have a raid1, for instance, where the 2 disks are not the exact same size, and you need to build the array but one of the disks is not available right at the moment (maybe it's USB and it's unplugged, or maybe it's a network disk and it's unavailable), then you have to play some weird games to get the array to size correctly (that is, to the size of the smaller of the two components or less). There may be other uses for this too... -- Paul Signed-off-by: NeilBrown <neilb@suse.de>
2009-04-06Detail: use meaningful names with --scan.NeilBrown1-2/+9
When reporting "--detail --scan", use names like /dev/md/foo where available rather than /dev/md/127 This is particularly needed for containers where the member arrays will report "container=/dev/md/foo" and we want the container to have the same name. Signed-off-by: NeilBrown <neilb@suse.de>
2009-03-09Support new raid6 layouts needed for DDFNeilBrown1-1/+8
DDF raid6 layouts are subtly different from the standard 'md' layouts. From 2.6.30 the kernel knows about these. Teach mdadm about them, and also allow 'ddf' to set an appropriate default. Signed-off-by: NeilBrown <neilb@suse.de>
2009-02-24Incremental: honor --no-degraded to delay assemblyDan Williams1-0/+1
Currently Incremental_container is being called after adding each disk. In the imsm case where spares are not tracked in the raid_disks field we can use --no-degraded to block premature assembly. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-01-08Merge branch 'master' into scratch-3.0NeilBrown1-0/+2
Conflicts: Assemble.c config.c
2009-01-08Free mdstat data structures properly.NeilBrown1-0/+2
In one case we called 'free' instead of 'mdstat_free'. In others we didn't free at all. Signed-off-by: NeilBrown <neilb@suse.de>
2008-12-08introduce --detail-platform to display platform raid capabilitiesDan Williams1-0/+4
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>
2008-12-01Allow --config in --incremental mode.NeilBrown1-0/+1
2008-11-27Support --wait-clean --scanDan Williams1-4/+12
Its cumbersome to determine which devices to wait for in a system shutdown script, so hook up --scan. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-11-20Assemble: don't auto-assemble if any arrays are listed in mdadm.confNeilBrown1-2/+2
Auto-assembly and planned assembly don't really work well together, it can be confusing. In particular in mkinitrd or similar creates an mdadm.conf to assemble a particular array, we shouldn't go assembling any other arrays as well. If you want auto assembly, you need to give mdadm a config file with no ARRAY lines. mdadm -Ascpartitions can do this. Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04Assemble: allow members of containers to be assembled and auto-assembled.NeilBrown1-0/+3
Try to treat members of containers much like other arrays for assembly. We still look through the list of devices for a match (it will be the container), then find the relevant 'info' and try to assemble the array. Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04Always set 'homehost' if not specified.NeilBrown1-1/+1
The default for 'homehost' is now '<system>' rather than unspecified.
2008-11-04config: Don't require an array to have a device name.NeilBrown1-10/+0
i.e. in mdadm.conf you can have a line like ARRAY uuid=whatever and it will use auto-name-generation to give a name to the array at assemble-time. The is different from blind auto-assembly in that the array will be treated as 'local'.
2008-11-04Delay creation of array devices for assemble/build/createNeilBrown1-42/+61
We will shortly be feeding more information into the process of creating array devices, so delay the creation. Still open them early if the device already exists. This involves making sure the autof flag is in the right place so that it can be found at creation time. Also, Assemble, Build, and Create now always close 'mdfd'. Signed-off-by: NeilBrown <neilb@suse.de>