summaryrefslogtreecommitdiff
path: root/util.c
Commit message (Collapse)AuthorAge
* Manage: be more careful about --add attempts.NeilBrown2010-11-22
| | | | | | | | | If an --add is requested and a re-add looks promising but fails or cannot possibly succeed, then don't try the add. This avoids inadvertently turning devices into spares when an array is failed but the devices seem to actually work. Signed-off-by: NeilBrown <neilb@suse.de>
* Add guess_super_typeNeilBrown2010-09-06
| | | | | | | This can select to only guess array types, or only guess partition types. Signed-off-by: NeilBrown <neilb@suse.de>
* Add gpt pseudo-metadataNeilBrown2010-09-06
| | | | | | This allows mdadm to work with gpt metadata to a limited extent. Signed-off-by: NeilBrown <neilb@suse.de>
* Add mbr pseudo metadata handler.NeilBrown2010-09-06
| | | | | | | | | | | | To support incorpating a new bare device into a collection of arrays - one partition each - mdadm needs a modest understanding of partition tables. The main needs to be able to recognise a partition table on one device and copy it onto another. This will be done using pseudo metadata types 'mbr' and 'gpt'. Signed-off-by: NeilBrown <neilb@suse.de>
* Allow dev_open to work on read-only /devNeilBrown2010-08-30
| | | | | | | | | | /dev could be read-only in which case we cannot make devices there. So dev_open should first try to use an existing device name, and if that doesn't work try creating a node in /dev or /tmp. Reported-by: Paweł Sikora <pluto@agmk.net> Signed-off-by: NeilBrown <neilb@suse.de>
* Compile with -Wextra by defaultNeilBrown2010-08-05
| | | | | | This produced lots of warning, some of which pointed to actual bugs. Signed-off-by: NeilBrown <neilb@suse.de>
* Fix all the confusion over directories once and for all.Doug Ledford2010-07-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We now have 3 directory definitions: mdmon directory for its pid and sock files (compile time define, not changable at run time), mdmonitor directory which is for the mdadm monitor mode pid file (can only be passed in via command line at the time mdadm is invoked in monitor mode), and the directory for the mdadm incremental assembly map file (compile time define, not changable at run time). Only the mdadm map file still hunts multiple locations, and the number of locations has been reduced to /var/run and the compile time specified location. Re-use of similar sounding defines that actually didn't denote their actual usage at compile time made it more difficult for a person to know what affect changing the compile time defines would have on the resulting programs. This patch renames the various defines to clearly identify which item the define affects. It also reduces the number of various directories which will be searched for these files as this has lead to confusion in mdadm and mdmon in terms of which files should take precedence when files exist in multiple locations, etc. It's best if the person compiling the program intentionally and with planning selects the right directories to be used for the various purposes. Which directory is right depends on which items you are talking about and what boot loader your system uses and what initramfs generation program your system uses. Because of the inter-dependency of all these items it would typically be up to the distribution that mdadm is being integrated into to select the correct values for these defines. Signed-off-by: Doug Ledford <dledford@redhat.com>
* Incremental: restore assembly for inactive containers, block activeDan Williams2010-07-19
| | | | | | | GET_ARRAY_INFO always succeeds on an inactive container, so we need to be a bit more diligent about adding a disk to an active container. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* Merge branch 'fixes' into for-neilDan Williams2010-07-01
|\
| * fix: memory leak in mdmon_pid()Przemyslaw Hawrylewicz Czarnowski2010-05-17
| | | | | | | | | | | | | | | | devnum2devname() returns pointer to memory allocated with strdup. It must be released to prevent memory leak. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Kill subarray v2Dan Williams2010-06-15
|/ | | | | | | | | | | | | | | | | | | | | | | | | 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>
* IMSM/DDF: don't recognised these metadata on partitions.NeilBrown2010-04-29
| | | | | | | | | | | These metadata are not expected on partitions, and they have no way of differentiation whether which is correct if they are found both on the device and on the last partition. So if the device is a partition, refuse to read the metadata. Signed-off-by: NeilBrown <neilb@suse.de>
* (no commit message)NeilBrown2010-03-24
|
* Improve partition table code.NeilBrown2010-03-09
| | | | | | | | | | Code to check partition tables used some needless casts and was broken, using a u8 when a u32 was wanted. So create structure describing the tables rather than using offset, and read into those tables instead. Signed-off-by: NeilBrown <neilb@suse.de>
* fix mdmon takeoverLuca Berra2010-03-03
| | | | | | | | | | | - when we waited for the old mdmon to exit, we didn't look for the socket in the right place - when we failed to find a pid file, we returned the wrong value (code expected <0, but got ==0). Signed-off-by: Luca Berra <bluca@comedia.it> Signed-off-by: NeilBrown <neilb@suse.de>
* fix gcc warnings about strict-aliasing rulesNeilBrown2010-03-03
| | | | | Original-by: Luca Berra <bluca@comedia.it> Signed-off-by: NeilBrown <neilb@suse.de>
* mdmon: allow pid to be stored in different directory.NeilBrown2010-02-04
| | | | | | | | /var/run probably doesn't persist from early boot. So if necessary, store in in /lib/init/rw or somewhere else that does persist. Signed-off-by: NeilBrown <neilb@suse.de>
* Having single function to read mdmon pid file.NeilBrown2010-02-04
| | | | | | | We don't need three. One (signal_mdmon) wasn't even being used. Signed-off-by: NeilBrown <neilb@suse.de>
* Merge branch 'master' of git://github.com/djbw/mdadmNeilBrown2009-12-30
|\
| * imsm: add support for checkpointing via 'curr_migr_unit'Dan Williams2009-12-21
| | | | | | | | | | | | | | | | Unlike native md checkpointing some data about the geometry and type of the migration process is coded into curr_migr_unit. Provide logic to convert between md/{resync_start|recovery_start} and imsm/curr_migr_unit. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
| * Support external metadata recovery-resumeDan Williams2009-12-21
| | | | | | | | | | | | | | | | | | Minimal changes needed to permit reassembling partially recovered external metadata arrays. The biggest logical change is that ->container_content() can now surface partially rebuilt members rather than omitting them from the disk list. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
| * Teach sysfs_add_disk() callers to use ->recovery_start versus 'insync' parameterDan Williams2009-12-21
| | | | | | | | | | | | Also fixup 'in_sync' versus 'insync' typo. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
| * util: fix devnum2devname for devnum == 0Dan Williams2009-12-12
| | | | | | | | | | | | devnum 0 is md0 no md_d-1 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Check partition tables when creating array.Trela, Maciej2009-12-08
|/ | | | | | | When creating an array, check if the devices have partition tables and print a warning if the table or the partitions might be destroyed by array creation. Signed-off-by: NeilBrown <neilb@suse.de>
* Replace all relevant occurrences of -4 with LEVEL_MULTIPATHNeilBrown2009-11-17
| | | | | | Also -1 -> LEVEL_LINEAR. Signed-off-by: NeilBrown <neilb@suse.de>
* Merge branch 'master' into devel-3.1NeilBrown2009-10-22
|\
| * Detail: export MD_UUID from mapfileDan Williams2009-10-13
| | | | | | | | | | | | | | | | | | | | | | | | The load_super() from an mdadm --detail call may race against an mdmon update. When this happens the load_super sees an inconsistent metadata block and returns an error. The fallback path to use the map file contents lacks uuid reporting, so provide __fname_from_uuid for generically printing a uuid. Reported-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Compile fixes for mdassembleNeilBrown2009-10-20
| | | | | | | | Signed-off-by: NeilBrown <neilb@suse.de>
* | Merge branch 'master' into devel-3.1NeilBrown2009-10-01
|\| | | | | | | | | Conflicts: mdadm.8
| * Detail: fix for an imsm container with a spareDan Williams2009-09-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Spares for imsm arrays do not have any info about the container in their metadata records. If Detail() inadvertantly picks such a device for ->get_array_info() it will end up with less than useful info for the container. So, continue to read from the disks until a non-spare device is found. This bug was found by timeouts waiting for udev to create the user-friendly container name. To detect future UUID reporting problems and a debug print to the timeout case in wait_for(). Signed-off-by: Dan Williams <dan.j.williams@intel.com>
| * imsm: fix family number handlingDan Williams2009-07-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The family_number field can change. The option-rom will change the family number when it starts a rebuild process (flags a container for rebuild). This was not seen previously as mdadm would usually start the rebuild process, preserving the family number. This is the mechanism that helps to prevent a prodigal array member from being returned to its original system and cause a rebuild to go in the wrong direction. With the change we will end up with a container that will fail to assemble unless the device with the incompatible family number is left out of the assembly. So, take several actions: 1/ Convert uuid generation to use orig_family_num, being careful to preserve the existing uuid in the case where orig_family_num is not set (i.e. previous mdadm created imsm arrays) 2/ Set orig_family_num at Create. For arrays created by mdadm prior to this release orig_family_num will be zero, so set it to family_num at the first metadata write. 3/ Add checks for orig_family_num to compare_super_imsm 4/ Update the family number when initiating rebuild 5/ The option-rom mixes some random data into the family number, add this functionality to the mdadm implementation. Reported-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
| * Update copyright dates and remove references to @cse.unsw.edu.auNeilBrown2009-06-02
| | | | | | | | | | | | Also removed 'paper' addresses. Signed-off-by: NeilBrown <neilb@suse.de>
* | main: factor out code to parse layout for raid10 and faulty.NeilBrown2009-07-14
| | | | | | | | | | | | This will soon be called from multiple places. Signed-off-by: NeilBrown <neilb@suse.de>
* | Grow: support --array-size changesNeilBrown2009-07-13
|/ | | | | | | | | 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>
* map_dev: prefer names in /dev/md/NeilBrown2009-05-11
| | | | | | | | 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-11
| | | | | | | | 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-14
| | | | | | | | | | | 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-07
| | | | | | | | 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-06
| | | | | | 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-20
| | | | | | | | | | | | | 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-10
| | | | | | | | | | 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-04
| | | | | | | 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-04
| | | | | | | | | | 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-04
| | | | | | I have seen the light. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* util: make env checking more genericNeilBrown2008-11-04
| | | | | | | 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-04
| | | | | | | | 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-30
|\ | | | | | | | | | | | | | | Conflicts: Incremental.c super0.c super1.c
| * Fix --incremental assembly of partitions arrays.NeilBrown2008-10-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-28
| | | | | | | | | | | | | | | | | | | | | | | | 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-17
|\| | | | | | | | | | | Conflicts: Manage.c