summaryrefslogtreecommitdiffstats
path: root/util.c
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright dates and remove references to @cse.unsw.edu.auNeilBrown2009-06-021-7/+2
| | | | | | Also removed 'paper' addresses. Signed-off-by: NeilBrown <neilb@suse.de>
* map_dev: prefer names in /dev/md/NeilBrown2009-05-111-14/+13
| | | | | | | | Rather than preferring non-standard names (of which there are many, like /dev/block/9:1), prefer names in /dev/md/ when finding the name of an md device. Signed-off-by: NeilBrown <neilb@suse.de>
* util: fix test for text_versionNeilBrown2009-05-111-1/+4
| | | | | | | | as text_version is a char array (not a pointer), testing the address against NULL is the wrong thing to do. Test the content instead. Signed-off-by: NeilBrown <neilb@suse.de>
* incremental_container: preserve 'in_sync' flag when adding to existing array.NeilBrown2009-04-141-1/+2
| | | | | | | | | | | When building container members with -IR, we need to ensure that devices added to an active array preserve the 'in_sync' status so they don't needlessly get rebuilt. So allow sysfs_add_disk to do this (only works in kernels since 2.6.30) and pass the relevant flag down. Signed-off-by: NeilBrown <neilb@suse.de>
* wait_for improvement.NeilBrown2009-04-071-2/+9
| | | | | | | | wait not only for the name to appear, but for it to refer to the correct device. Sometimes old symlinks left lying around can be confusing. Signed-off-by: NeilBrown <neilb@suse.de>
* util.c: use correct range for minor numbers when finding free device.NeilBrown2009-04-061-1/+1
| | | | | | Minor numbers are 20 bits, not 22. So when looking for a free, high minor number, try (1<<20)-1, not (1<<22)-1.
* mdmon: pass symbolic name to mdmon instead of device name.NeilBrown2008-11-201-3/+10
| | | | | | | | | | | | | Now that names in /dev are usually created (eventually) by udev, it isn't really safe to rely in finding a name in /dev to pass to mdmon to identify which array to monitor. And it isn't really necessary to have a name in /dev. So just pass the symbolic name, e.g. md127 or md123. Change util.c to pass that name, and change mdmon to process the name sensibly. Signed-off-by: NeilBrown <neilb@suse.de>
* fix add_dev() handling of broken linksDan Williams2008-11-101-1/+3
| | | | | | | | | | Resolves issues like: mdadm -Ss mdadm: unable to open /dev/md/r1: No such file or directory ...where /dev/md/r1 points to a removed device. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* Wait for name to appear after create/assemble etc.NeilBrown2008-11-041-0/+12
| | | | | | | We don't really want mdadm to exit until udev has created the names in /dev. So wait. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: allow members of containers to be assembled and auto-assembled.NeilBrown2008-11-041-0/+14
| | | | | | | | | | 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>
* Assemble: revert preliminary -As supportDan Williams2008-11-041-9/+0
| | | | | | I have seen the light. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* util: make env checking more genericNeilBrown2008-11-041-3/+3
| | | | | | | Change the "env_check_mdmon" function to be more generic, accepting and environment variable name, as soon we will have a new use for it. Signed-off-by: NeilBrown <neilb@suse.de>
* Move recently merged /sys/dev/ lookup into stat2devnum.NeilBrown2008-11-041-4/+25
| | | | | | | | But sysfs_init and stat2devnum try to convert stat information into an md devnum. Combine all the value of both pieces of code into stat2devnum and have sysfs_init call that. Signed-off-by: NeilBrown <neilb@suse.de>
* Merge branch 'master' into devel-3.0NeilBrown2008-10-301-1/+1
|\ | | | | | | | | | | | | | | Conflicts: Incremental.c super0.c super1.c
| * Fix --incremental assembly of partitions arrays.NeilBrown2008-10-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If incremental assembly finds an array mentioned in mdadm.conf, with a 'standard partitioned' name like /dev/md_d0 or /dev/md/d0, it will not create a partitioned array like it should. This is because it mishandled the 'devnum' returned by is_standard. That is a devnum that does not have the partition-or-not encoded into it. So we need to check the actual return value of is_standard and encode the partition-or-not info into the devnum. Also fix a couple of comments. Signed-off-by: NeilBrown <neilb@suse.de>
* | Preliminary -As support for container member arraysDan Williams2008-10-281-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | Given an mdadm.conf like the following allow /dev/imsm and /dev/md/r1 to be created by "mdadm -As". DEVICES partitions ARRAY /dev/imsm metadata=imsm auto=md UUID=b98f5dbe-aa859e7b-0e369b89-a80986d4 ARRAY /dev/md/r1 container=/dev/imsm member=0 auto=mdp UUID=3538e39c-b397c2e9-1aa031f9-2bc0eca4 spares=1 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Merge branch 'master' into devel-3.0NeilBrown2008-10-171-0/+17
|\| | | | | | | | | | | Conflicts: Manage.c
| * Improve reporting of layout for raid10.NeilBrown2008-10-131-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | Showing e.g. near=1, far=2 for the 'far2' layout of raid10 is confusing even though there is a sense in which is it correct. Make it less confusing by only printing whichever number is not 1. If both are 1, make that clear too (i.e. no redundancy).
* | Allow a uuid of all f's to always matchDan Williams2008-10-151-0/+5
| | | | | | | | | | | | | | The uuid returned for an imsm spare device will never match the uuid of an active disk. So make mdadm interpret a uuid of all f's as "match any". Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | fname_as_uuid: print uuids msb firstDan Williams2008-10-151-5/+9
| | | | | | | | | | | | | | | | The sha1 routines store the uuids in little endian byte-order, so always print from msb to lsb. This allows imsm containers to be assembled with -As. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Report uuid in --detail --brief for ddf and intelNeilBrown2008-09-181-5/+3
| | | | | | | | The uuid is slightly fictitious but needed for array matching.
* | Use uuid as /dev name when assembling array of uncertain origin.NeilBrown2008-09-181-0/+19
| | | | | | | | | | If we aren't sure that the array belongs to 'this' host, use the uuid to choose a name to avoid any conflict.
* | Move calls to SET_ARRAY_INFO to common helper.NeilBrown2008-09-181-4/+34
| | | | | | | | | | | | | | | | | | | | When we assemble an array, there are three different approaches depending on whether metadata is internal or external, and on kernel version. Move all this to a common helper instead of duplicating in 3 places. Signed-off-by: NeilBrown <neilb@suse.de>
* | Factor out add-disk codeNeilBrown2008-09-181-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | The variety of approaches to 'add_disk' are factored out into a separate function, and Incremental mode benefits by being closer to supporting the assembly of containers. Also remove the adding-to-array-data-structure out of sysfs_add_disk and into add_disk. And add some tests for --incremental mode to make sure we don't break it. Signed-off-by: NeilBrown <neilb@suse.de>
* | Compile fixes, particularly moving more stuff under MDASSEMBLENeilBrown2008-09-181-5/+3
| | | | | | | | Now 'make everything' works again.
* | Add ping_monitor() to mdadm --waitDan Williams2008-09-151-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The action we are waiting for may not be complete until the monitor has had a chance to take action on the result. The following script can now remove the device on the first attempt, versus a few attempts with the original Wait(): #!/bin/bash #export MDADM_NO_MDMON=1 export IMSM_DEVNAME_AS_SERIAL=1 ./mdadm -Ss ./mdadm --zero-superblock /dev/loop[0-3] echo 2 > /proc/sys/dev/raid/speed_limit_max ./mdadm --create /dev/imsm /dev/loop[0-3] -n 4 -e imsm -a md ./mdadm --create /dev/md/r1 /dev/loop[0-3] -n 4 -l 5 --force -a mdp ./mdadm --fail /dev/md/r1 /dev/loop3 ./mdadm --wait /dev/md/r1 x=0 while ! ./mdadm --remove /dev/imsm /dev/loop3 > /dev/null 2>&1 do x=$((x+1)) done echo "removed after $x attempts" ./mdadm --add /dev/imsm /dev/loop3 Include 2 small cleanups: * remove the almost open coded fd2devnum() in Wait() by introducing a new utility routine stat2devnum() * teach connect_monitor() to parse the container device from a subarray string Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Factor out test for subarray version string.NeilBrown2008-08-191-1/+1
| | | | | | | | | | | | | | We are about to change the syntax of the version string for 'subarray's. So factor out the test into a single function. Signed-off-by: NeilBrown <neilb@suse.de>
* | mdmon: fork and run as a daemon.NeilBrown2008-07-181-1/+7
| | | | | | | | | | | | | | start_mdmon now waits for mdmon to complete initialisation and, importantly, listen on the socket, before continuing. Signed-off-by: Neil Brown <neilb@suse.de>
* | Don't assume that mdmon is in the current directory.NeilBrown2008-07-181-4/+27
| | | | | | | | | | | | | | Rather, assume that it is in the same directory from which mdadm was run. If not, then maybe /sbin or current directory. Signed-off-by: Neil Brown <neilb@suse.de>
* | Factor common code into new "start_mdmon".NeilBrown2008-07-181-0/+25
| | | | | | | | Signed-off-by: Neil Brown <neilb@suse.de>
* | mdadm: add an environment variable to prevent auto-launching mdmonDan Williams2008-07-141-0/+10
| | | | | | | | | | | | Useful for attaching gdb to mdmon before any action is taken on the array. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Introduce devname2devnumNeil Brown2008-07-121-4/+12
| | | | | | | | and use it instead of opencoding.
* | Use O_DIRECT for all IO to devices.Neil Brown2008-07-121-2/+2
| | | | | | | | | | | | | | | | Using buffered IO risks non-atomic updates to parts of the device that we don't actually want to write to. This isn't in general safe. So switch to O_DIRECT for all that IO and make sure we have properly aligned buffers.
* | Create arrays via metadata-updateNeil Brown2008-07-121-0/+43
| | | | | | | | | | Support creating arrays inside an active ddf container by sending a metadata update over a pipe to mdmon.
* | Remove getinfo_super_n and do some other cleaning up.Neil Brown2008-07-121-0/+2
| | | | | | | | | | Getting close to a sensible description of what some of the superswitch methods are supposed to do!
* | Add subarray field to supertype.Neil Brown2008-07-121-8/+29
| | | | | | | | | | | | | | | | | | When loading the metadata for a subarray (super_by_fd), we set ->subarray to be the name read from md/metadata_version so that getinfo_super can return info about the correct array. With this we can differentiate between a container and an array within the container by looking at ->subarray[0].
* | Always initialise a struct super_type to zeroNeil Brown2008-07-121-3/+3
| |
* | Remove st->text_version in favour of info->text_versionNeil Brown2008-05-271-20/+9
| | | | | | | | | | | | | | I want the metadata handler to have more control over the 'version', particularly for arrays which are members of containers. So discard st->text_version and instead use info->text_version which getinfo_super can initialise.
* | auto-start mdmon on --createNeil Brown2008-05-271-15/+60
| | | | | | | | | | | | FIXME uses sill hardcoded path. Need --assemble too.
* | Remember to close directories when we are finished with them.Neil Brown2008-05-271-0/+1
| |
* | Alway use a unique file name for opendevNeil Brown2008-05-271-1/+2
| | | | | | | | Else mdadm and mdmon running in parallel can tread on each other.
* | handle Manage_subdevs() for 'external' arraysDan Williams2008-05-151-2/+8
| | | | | | | | | | | | | | | | | | From: Dan Williams <dan.j.williams@intel.com> 1/ Block attempts to add/remove devices from container members 2/ Forward add/remove requests to containers Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | imsm: initial Intel(R) Matrix Storage Manager supportDan Williams2008-05-151-1/+1
| | | | | | | | | | | | | | | | | | | | From: Dan Williams <dan.j.williams@intel.com> The following now work: --examine --examine --brief Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Create a container memberNeil Brown2008-05-151-0/+23
| | | | | | | | From: Neil Brown <neilb@suse.de>
* | Can now mostly assemble DDF arraysNeil Brown2008-05-151-0/+3
| |
* | more ddf stuffNeil Brown2008-05-151-0/+17
| | | | | | | | | | | | Create a BVD in a DDF Do not actually assemble it yet...
* | Initial DDF support code.Dan Williams2008-05-151-1/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Create a ddf array by naming the device /dev/ddf* or specifying metadata 'ddf'. If ddf is specified with no level, assume a container (indeed, anything else would be wrong). **Need to use text_Version to set external metadata... More ddf support Load a ddf container. Now --examine /dev/ddf works. super-ddf: fix compile warning From: Dan Williams <dan.j.williams@intel.com> super-ddf.c:723: format %lu expects type long unsigned int, but argument 3 has type unsigned int Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Some support for external metadata.Neil Brown2008-05-151-1/+3
|/ | | | Allow specifying metadata type when creating arrays etc.
* Compiple fixes for mdassemble and diet-libcNeil Brown2008-05-151-39/+41
|
* Fix support for --update=swapsuperNeil Brown2008-05-151-1/+2
| | | | The user of dup_super broke it.