summaryrefslogtreecommitdiff
path: root/mapfile.c
Commit message (Collapse)AuthorAge
* Handles spaces in array names better.NeilBrown2012-10-04
| | | | | | | | | | | | 1/ When printing the "name=" entry for --brief output, enclose name in quotes if it contains spaces etc. Quotes are already supported for reading mdadm.conf 2/ When a name is used as a device name, translate spaces and tabs to '_', as well as the current translation of '/' to '-'. Signed-off-by: NeilBrown <neilb@suse.de>
* mapfile: fix mapfile rebuild for containersNeilBrown2012-08-20
| | | | | | | | When recreating the mapfile entry for a container we need to use ->getinfo_super, not ->container_content, just like we do in Detail(). Signed-off-by: NeilBrown <neilb@suse.de>
* Remove scattered checks for malloc success.NeilBrown2012-07-09
| | | | | | | | | | | | | | 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>
* RebuildMap: check that container_content returns a valid 'info'.NeilBrown2012-05-17
| | | | | | | If it doesn't, just skip that entry. Reported-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Adjust to new standard of /runNeilBrown2012-05-03
| | | | | | | | Now that /run seems to be a good standard, make that the default for storing various run-time files, rather than /var/run or /dev/.mdadm. Signed-off-by: NeilBrown <neilb@suse.de>
* Reset bad flag on map updateCzarnowska, Anna2012-03-08
| | | | | | | | | | | Map file may miss an entry if bad flag is not cleared on update. This happens for example when an old entry exists in map that has no mdstat counterpart and we create a new array with the same devnum. Newly created array will not appear in map if update doesnt clear bad flag. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Remove duplicated code: search_mdstat and conf_matchNeilBrown2011-11-01
| | | | | | | | | search_mdstat and conf_match are almost identical. Put all the functionality in conf_match, and remove search_mdstat. Reported-by: Jes.Sorensen@redhat.com Signed-off-by: NeilBrown <neilb@suse.de>
* fix: correct unlocking of map fileLukasz Dorau2011-10-03
| | | | | | | | 1. Three missing map_unlock() calls were added. 2. Map file must be unlocked on fork, else child will hold lock. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Various compile fixes.NeilBrown2011-02-01
| | | | | | | Make "make everything" succeed. This fixed some real bugs. Signed-off-by: NeilBrown <neilb@suse.de>
* Improve mddev_ident type definitions.NeilBrown2010-11-22
| | | | | | | | 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>
* Use new container_content rather than passing subarray to load_super.NeilBrown2010-11-22
| | | | | | | | Now that we can ask container_content for a specific subarray, we don't need to pass the subarray name to load_super, and have it secretly modify the returned state. Signed-off-by: NeilBrown <neilb@suse.de>
* mapinfo: simplify subarray handling.NeilBrown2010-11-22
| | | | | | | | | We don't need ->container_dev here, and we will soon be passing subarray as an explicit arg to load_super. So simplify extraction of subarray and move the strcpy close to ->load_super. Signed-off-by: NeilBrown <neilb@suse.de>
* get_info_super: report which other devices are thought to be working/failed.NeilBrown2010-11-22
| | | | | | | | | | | | | | To accurately detect when an array has been split and is now being recombined, we need to track which other devices each thinks is working. We should never include a device in an array if it thinks that the primary device has failed. This patch just allows get_info_super to return a list of devices and whether they are thought to be working or not. Signed-off-by: NeilBrown <neilb@suse.de>
* mapfile: just have one place to store the mapfileNeilBrown2010-08-06
| | | | | | | | | | | Having multiple possible locations and guessing where best to put the file is too messy, confusing and makes locking problematic. So just keep it in /dev/.mdadm/map. It is a horrible place but it is really all we have. System integrators can change this easily at build time. Signed-off-by: NeilBrown <neilb@suse.de>
* Some fixes to the mapfile code.NeilBrown2010-07-28
| | | | | | | | - Update the comments - use some defined names instead of magic numbers. - restore /var/run/mdadm/map to have priority over /dev/.mdadm/map Signed-off-by: NeilBrown <neilb@suse.de>
* Bugfix: mapfile locking is broken/racyNeilBrown2010-07-28
| | | | | | | | | | | | | | | | | | | | While we attempt to use a lockfile to grant exclusive access to the mapfile, our implementation is buggy. Specifically, we create a lockfile, then lock it, at which point new instances can open the lockfile and attempt to lock it, which will cause them to block. However, when we are ready to unlock it, we unlink the file. This causes existing lock waiters to get a lock on an unlinked inode while a different instance may now create a new lockfile and get an exclusive lock on it. There are several possible fixes. The chosen one is to test if ->s_nlink is zero after we get the lock and to retry if it isn't. This means: - failing to unlink a file doesn't leave a stale lock - we can block waiting to get a lock rather than busy-waiting - we don't need to leave a lock file permanently in place. Reported-by: Doug Ledford <dledford@redhat.com> 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>
* Always assume SKIP_GONE_DEVS behaviour and kill the flagDan Williams2010-06-16
| | | | | | | | | | | | | | | ...i.e. GET_DEVS == (GET_DEVS|SKIP_GONE_DEVS) A null pointer dereference in Incremental.c can be triggered by replugging a disk while the old name is in use. When mdadm -I is called on the new disk we fail the call to sysfs_read(). I audited all the locations that use GET_DEVS and it appears they can tolerate missing a drive. So just make SKIP_GONE_DEVS the default behaviour. Also fix up remaining unchecked usages of the sysfs_read() return value. Reported-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* Create: cleanup after failed create in duplicated array member caseDan Williams2010-04-19
| | | | | | | | | | | | | | | | mdadm prevents creation when device names are duplicated on the command line, but leaves the partially created array intact. Detect this case in the error code from add_to_super() and cleanup the partially created array. The imsm handler is updated to report this conflict in add_to_super_imsm_volume(). Note that since neither mdmon, nor userspace for that matter, ever saw an active array we only need to perform a subset of the cleanup actions. So call ioctl(STOP_ARRAY) directly and arrange for Create() to cleanup the map file rather than calling Manage_runstop(). Reported-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* Only signal a udev change event if we actually write a mapfile in RebuildMapDoug Ledford2010-03-24
| | | | Signed-off-by: Doug Ledford <dledford@redhat.com>
* mapfile: if we putting the mapfile in a custom location via ALT_RUN, allowDoug Ledford2010-03-24
| | | | | | a custom filename too. Signed-off-by: Doug Ledford <dledford@redhat.com>
* Create directory to contain mapfile (Assuming parent exists andDoug Ledford2010-03-24
| | | | | | | | filesystem is writable). This particularly keeps udev happy if VAR_RUN is set to /dev/md. Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* mapfile: use ALT_RUN as alternate place to store mapfileNeilBrown2010-02-08
| | | | | | This gives better consistency and fewer hidden '.' files. Signed-off-by: NeilBrown <neilb@suse.de>
* mapfile: fix locking.NeilBrown2010-01-29
| | | | | | | | | | | The current locking uses lockf, and is completely broken. When you hold a lockf lock, any close of any fd on that file will release the lock. So map_read() call which is made as soon as we get the lock, will immediately drop the lock. So change to flock locking which isn't so badly designed. Signed-off-by: NeilBrown <neilb@suse.de>
* Fix null-dereference in set_member_infoNeilBrown2009-10-01
| | | | | | | set_member_info would try to dereference ->metadata_version, without checking that it isn't NULL. Signed-off-by: NeilBrown <neilb@suse.de>
* fix RebuildMap() to retrieve 'subarray' infoDan Williams2009-07-31
| | | | | | | | | | | | | | | | | | RebuildMap falsely returns container info for member arrays. Retrieving the subarray and container_dev details prior to ->load_super() changes the result from: md127 imsm 082c6371:74b5ce03:64972e41:6b0860d5 /dev/md/imsm md126 imsm 082c6371:74b5ce03:64972e41:6b0860d5 /dev/md/vol0 ...to: md126 /md127/0 3e03aee2:78c3c593:1e8ecaf0:eefb53ed /dev/md/vol0 md127 imsm 082c6371:74b5ce03:64972e41:6b0860d5 /dev/md/imsm Reported-by: Ignacy Kasperowicz <ignacy.kasperowicz@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* mapfile - when rebuilding, choose an appropriate name is none is found.NeilBrown2009-05-11
| | | | | | | | When rebuilding the mapfile (mdadm -Ir), if not appropriate name is found in /dev/md/, try to find an appropriate name, either by looking in mdadm.conf or by using the name in the metadata. Signed-off-by: NeilBrown <neilb@suse.de>
* mapfile - Fix off-by-one error in RebuildMapNeilBrown2009-05-11
| | | | | | | "mdadm -Ir" would get the path for md0 wrong because it went looking for mdp(-1) by mistake. Signed-off-by NeilBrown <neilb@suse.de>
* mapfile: allow the path name to the device to be empty.NeilBrown2009-05-11
| | | | | | | Allowing an empty name and coping with it is less confusing than seeing "/empty" appear. Signed-off-by: NeilBrown <neilb@suse.de>
* Merge branch 'master' of git://github.com/djbw/mdadm into devel-3.0NeilBrown2009-04-14
|\ | | | | | | | | | | | | | | | | Conflicts: Grow.c mdadm.h sysfs.c Due to independent fixes for the "mdadm hangs if reshape finishes too quickly" problem.
| * RebuildMap: handle missing disksDan Williams2009-04-12
| | | | | | | | | | | | | | | | | | When rebuilding the map file tolerate missing/offline disks, otherwise we will segfault on the NULL return from sysfs_read. Reported-by: Jacek Danecki <jacek.danecki@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | mapfile: optionally store map file in /devNeilBrown2009-04-14
|/ | | | | | | | | | | During early boot, /var/run may not exist or be writable. If that happens, sore the mapfile (which is very important for incremental assembly) in /dev (which should exist for udev). Thanks to Doug Ledford <dledford@redhat.com> for identify this problem and suggesting a solution. Signed-off-by: NeilBrown <neilb@suse.de>
* Merge branch 'master' into scratch-3.0NeilBrown2009-01-08
|\ | | | | | | | | | | | | Conflicts: Assemble.c config.c
| * Free mdstat data structures properly.NeilBrown2009-01-08
| | | | | | | | | | | | | | 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>
* | Merge branch 'master' into devel-3.0NeilBrown2008-12-18
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Assemble.c Incremental.c Kill.c ReadMe.c inventory mapfile.c mdadm.8 mdadm.spec mdassemble.8
| * map: rebuild map if it doesn't exist.NeilBrown2008-12-18
| | | | | | | | | | | | | | | | | | It is possible for some arrays to be created e.g. by initrd, and so not get mentioned in /var/run/mdadm/map. As "-I" depends on things being listed in 'map', we create it by scanning all devices if it doesn't exist. Signed-off-by: NeilBrown <neilb@suse.de>
* | mapfile: validate entries before they are returned.NeilBrown2008-11-04
| | | | | | | | | | | | | | It is possible for the mapfile to become wrong, and that gets very confusing. So validate entries before returning them. Signed-off-by: NeilBrown <neilb@suse.de>
* | mdopen: use small sequence number for uniquifying array names.NeilBrown2008-11-04
| | | | | | | | | | | | | | | | | | Rather than appending the md minor number, we now append a small sequence number to make sure name in /dev/md/ that aren't LOCAL are unique. As the map file is locked while we do this, we are sure of no losing any races. Signed-off-by: NeilBrown <neilb@suse.de>
* | Incremental: lock against multiple concurrent additions to an array.NeilBrown2008-11-04
| | | | | | | | | | | | | | In two devices are added via -I to one array at the same time, mdadm can get badly confused. Signed-off-by: NeilBrown <neilb@suse.de>
* | Manage: when stopping an array, delete all names from /dev.NeilBrown2008-11-04
| | | | | | | | | | | | | | | | | | This only applies if udev isn't installed or is disabled by MDADM_NO_UDEV We try to remove partitions too. We find names to remove by looking in /var/run/mdadm/map Signed-off-by: NeilBrown <neilb@suse.de>
* | Always update mdadm/map when starting an array.NeilBrown2008-11-04
| | | | | | | | | | | | | | | | We previously only updated /var/run/mdadm/map when starting an array with --incremental. However we now make more use of that file (to pass the dev name to udev) so always update it. Signed-off-by: NeilBrown <neilb@suse.de>
* | Merge branch 'master' into scratch-3.0NeilBrown2008-11-03
|\|
| * mapfile: fix bug in testing for /var/run/mdadm/NeilBrown2008-11-03
| | | | | | | | | | | | | | | | There was a bug. If /var/run/mdadm/ did not exist as a directory, the map file should have been created in /var/run/mdadm.map, but due to bug it would never get created. Signed-off-by: NeilBrown <neilb@suse.de>
* | Lots of fixes to make incremental assembly of containers work.NeilBrown2008-09-18
| | | | | | | | | | | | | | | | So: mdadm -I /dev/whatever will (if appropriate) add whatever to a container, then start any arrays inside the container.
* | Use text_version in map_file rather than major.minor.Neil Brown2008-07-12
|/
* Add new mode: --incrementalNeil Brown2006-12-21
--incremental allows arrays to be assembled one device at a time. This is expected to be used with udev.