summaryrefslogtreecommitdiff
path: root/msg.c
Commit message (Collapse)AuthorAge
* Flush mdmon before next reshape step during container operationAdam Kwolek2012-02-09
| | | | | | | | | | | Using takeover operation for grow purposes, mdadm has to be sure that mdmon processes all updates, and if necessary it will be closed at takeover to raid0 operation. If mdmon is late, next array in container is processed and due to race condition mdmon closes itself instead to monitor next reshape operation. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* unblock_monitor(): Check sra is valid before dereferencingJes Sorensen2011-11-03
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* ping_monitor(): check file descriptor is valid before using and closing itJes Sorensen2011-11-03
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Move code to check_mdmon_version() functionAdam Kwolek2011-10-03
| | | | | | | Move code to function for code reuse. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* FIX: ping_monitor() usage causes memory leaksAdam Kwolek2011-03-18
| | | | | | | | | | When for ping_monitor() input devnum2devname() is used, received string pointer should be passed to free() for memory release. It is not made in several places. This use case should have function to avoid memory leak. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Add block_subarray()Adam Kwolek2011-03-02
| | | | | | | | | | Put code for blocking subarray in to separate function. This little code/function will be used for blocking arrays from mdmon monitoring during assembly process. Arrays cannot wait for container assembly finish, because meanwhile monitor can enable arrays for writing. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Remove stray 'free' in block_monitor.NeilBrown2010-12-21
| | | | | | | | This value is passed in by caller so we should not be freeing it. Reported-by: "Wojcik, Krzysztof" <krzysztof.wojcik@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: be extra careful about races when freezing an arrayNeilBrown2010-12-16
| | | | | | | If any subarray has any spare devices, then something raced, and we should abort the reshape. Signed-off-by: NeilBrown <neilb@suse.de>
* FIX: Cannot exit monitor after takeoverAdam Kwolek2010-12-03
| | | | | | | | | | | When performing backward takeover to raid0 monitor cannot exit for single raid0 array configuration. Monitor is locked by communication (ping_manager()) after unfreeze() Do not ping manager for raid0 array as they shouldn't be monitored. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Improve comments for block_monitor.NeilBrown2010-11-29
| | | | | | | Also not that the leading '-' on the metadata names now simply means that mdmon must not reconfiure the array. Signed-off-by: NeilBrown <neilb@suse.de>
* block monitor: freeze spare assignment for external arraysDan Williams2010-11-23
| | | | | | | | | | | | | | | | | | | | | | | In order to support reshape and atomic removal of spares from containers we need to prevent mdmon from activating spares. In the reshape case we additionally need to freeze sync_action while the reshape transaction is initiated with the kernel and recorded in the metadata. When reshaping a raid0 array we need to freeze the array *before* it is transitioned to a redundant raid level. Since sync_action does not exist at this point we extend the '-' prefix of a subarray string to flag mdmon not to activate spares. Mdadm needs to be reasonably certain that the version of mdmon in the system honors this 'freeze' indication. If mdmon is not already active then we assume the version that gets started is the same as the mdadm version. Otherwise, we check the version of mdmon as returned by the extended ping_monitor() operation. This is to catch cases where mdadm is upgraded in the filesystem, but mdmon started in the initramfs is from a previous release. Signed-off-by: Dan Williams <dan.j.williams@intel.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>
* 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>
* 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>
* mdmon: preserve socket over chrootDan Williams2009-10-13
| | | | | | | | | | 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>
* ping_manager() to prevent 'add' before 'remove' completesDan Williams2008-09-15
| | | | | | | | | | | | It is currently possible to remove a device and re-add it without the manager noticing, i.e. without detecting a mdstat->devcnt container->devcnt mismatch. Introduce ping_manager() to arrange for mdmon to run manage_container() prior to mdadm dropping the exclusive open() on the container. Despite these precautions sysfs_read() may still fail. If this happens invalidate container->devcnt to ensure manage_container() runs at the next event. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* Add ping_monitor() to mdadm --waitDan Williams2008-09-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* msg: add a timeout to ping_monitorNeilBrown2008-07-18
| | | | | | | Though it should never bee needed, having a timeout in ping_monitor is a sensible safeguard. Signed-off-by: Neil Brown <neilb@suse.de>
* Revise message passing code.Neil Brown2008-07-12
| | | | More here
* Remove mgr_pipe for communicating from manage to monitor.Neil Brown2008-07-12
| | | | | Data is being passed in shared memory, so the pipe is only being use as a wakeup. This can more easily be done with a thread-signal.
* Handle device removal from containerNeil Brown2008-07-12
| | | | | | | This really should be done in mdadm, not mdmon. We ensure the device won't be suddenly commited as a hot-spare using O_EXCL, then check the 'holders' sysfs directory to make sure it is only in use once.
* handle Manage_subdevs() for 'external' arraysDan Williams2008-05-15
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>