summaryrefslogtreecommitdiff
path: root/Monitor.c
Commit message (Collapse)AuthorAge
...
* Monitor: teach spare migration about containersNeilBrown2010-11-22
| | | | | | | | | | When trying to move a spare, move to the container of a degraded array, not to the array itself. And don't try to move from a subarray, only from a native or container array. And don't move from a container which contains degraded subarrays. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: policy based spare migration.NeilBrown2010-11-22
| | | | | | | | | | | Rather than only migrating between arrays with the same spare_group, we now migrate based on domains set in the policy. In order for spare_group to continue to work, we treat it as a domain of the destination array, and a domain of any device we might remove from a source array. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: split out check_donorNeilBrown2010-11-22
| | | | | | | | Checking compatibility between arrays for spare migration is going to become a little more complicated, so split it out into a separate function. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: split out move_spare in spare migration.NeilBrown2010-11-22
| | | | | | This is a simple refactoring with no functionality change. Signed-off-by: NeilBrown <neilb@suse.de>
* Monior: create struct for holding alert info.NeilBrown2010-11-22
| | | | | | | Rather than passing mailaddr, mailfrom, cmd, dosyslog around in argument lists, create a structure to hold them all. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: use calloc rather than mallocNeilBrown2010-11-22
| | | | | | | calloc zeros the memory allocated, which is safer, particularly as we add more things to struct state. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: minor optimisation to spare migration.NeilBrown2010-11-22
| | | | | | | Only try spare migration if we know that at least one array is degraded. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: link containers with subarrays in statelistMarcin Labun2010-11-22
| | | | | | | | | Each containers has list of its subarrays. Each subarray has back link to its parent container. Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Break Monitor into smaller functions.NeilBrown2010-11-22
| | | | | | | Monitor() has become way too big. Break it up into multiple smaller functions that are all called from the main loop. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: track metadata type or parent/container of arrays.NeilBrown2010-11-22
| | | | | | | | | | For subarrays, record the devid of the parent. For others arrays, record the metadata type. This will be used in a subsequent patch to link related arrays together and allow spare migration between containers. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: include containers in scan modeAnna Czarnowska2010-11-22
| | | | | Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: avoid skipping checks on external arraysNeilBrown2010-11-22
| | | | | | | | utime is not correct for external metadata so we must not risk the observed time ever matching the old time. Reported-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* mdadm: added --no-sharing option for Monitor modeAnna Czarnowska2010-11-22
| | | | | | | | | | | | --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>
* Monitor: set err on arrays not in mdstatAnna Czarnowska2010-11-22
| | | | | | | | | | | | | | | mse can be NULL when the array was not in mdstat when we read it but existed in statelist and was recreated after reading mdstat. In this case we set err as we can't get full update on this array this time. If the same array is given twice in command line it appears twice in statelist. The first one will mark mse->devnum=INT_MAX so the second one can't find mse. We set err on the second one as it's not needed. Also if it becomes degraded we would look for spares twice for the same array. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Improve type names for mddev_devNeilBrown2010-11-22
| | | | | | | | | 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>
* 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>
* 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>
* Add --test option to --re-add and similarNeilBrown2010-07-06
| | | | | | | | | | --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>
* Monitor: don't report the disappearance of a faulty device as SpareActive.NeilBrown2010-05-18
| | | | | | | | | | | | Normally Monitor doesn't see faulty devices in active slots - they get moved away too quickly. But if it does, it reports the "faulty device disappeared" event (when it finally does get moved away) as SpareActive due to insufficient checking. So add a better check. Reported-by: Pierre Vignéras <pierre@vigneras.name>
* Monitor: add option to specify rebuild incrementsZdenek Behan2009-10-19
| | | | | | | | | | 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>
* Monitor: use pclose rather than fcloseNeilBrown2009-07-10
| | | | | | | | Using pclose is probably the right thing to do seeing that we used popen, but as there is no clear need to wait for sendmail to finish, it isn't really important. Signed-off-by: NeilBrown <neilb@suse.de>
* Merge branch 'master' into devel-3.0NeilBrown2009-06-02
|\ | | | | | | | | | | Conflicts: super0.c super1.c
| * Monitor: support spare-group manipulation for 1.x metadata.NeilBrown2009-05-12
| | | | | | | | | | | | | | | | | | The code for moving spares around a spare-group currently only works for 0.90 metadata. Generalise it for 1.x metadata as well. Reported-by: "Garth Snyder" <garth@grsweb.us> Signed-off-by NeilBrown <neilb@suse.de>
* | Move WaitClean from Monitor.c to sysfs.cNeilBrown2009-06-02
| | | | | | | | | | | | That way mdmon doesn't need to include Monitor.o Signed-off-by: NeilBrown <neilb@suse.de>
* | Update copyright dates and remove references to @cse.unsw.edu.auNeilBrown2009-06-02
| | | | | | | | | | | | Also removed 'paper' addresses. Signed-off-by: NeilBrown <neilb@suse.de>
* | Monitor: don't get confused if utime is never set.NeilBrown2009-06-02
| | | | | | | | | | | | | | | | | | | | | | externally managed arrays do not (currently) cause utime in GET_ARRAY_INFO to be updated. So if it is zero, just assume the current time. This will cause GET_DISK_INFO to be called more often, but as we do the scan only every 60 seconds normally, a few extra syscalls isn't going to make a big difference. Signed-off-by: NeilBrown <neilb@suse.de>
* | config: allow Array line to contain array name without /dev/md/ prefix.NeilBrown2009-05-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For consistency with --create and --assemble, allow the array name given in mdadm.conf to exclude the "/dev/md/" prefix. So e.g. ARRAY home uuid=whatever is treated like ARRAY /dev/md/home uuid=whatever Also exclude names which create_mddev will reject. Signed-off-by: NeilBrown <neilb@suse.de>
* | config: support "ARRAY <ignore> ..." lines in mdadm.confNeilBrown2009-05-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Wait for POLLPRI on /proc or /sys files.NeilBrown2009-04-14
| | | | | | | | | | | | | | | | | | | | | | | | | | From 2.6.30, /proc/mounts and various /sys files will probably always returns 'readable' to select, so we will need to wait on POLLPRI to get the 'new data is available' signal. When using select, this corresponds to an 'exception', so adjust calls to select accordingly. In one case we sometimes wait on a socket and sometime on /proc/mounts, so we need to test which. Signed-off-by: NeilBrown <neilb@suse.de>
* | Merge branch 'master' in devel-3.0NeilBrown2009-03-10
|\|
| * Monitor: send --test message for arrays in /proc/mdstat that aren't in ↵NeilBrown2009-02-05
| | | | | | | | | | | | | | | | | | | | | | | | | | mdadm.conf "mdadm --monitor --test --scan" currently only sends test messages for arrays listed on the command line or in /etc/mdadm.conf. With this patch it also reports on any active arrays, which is more in line with the description in the manpage. Thanks to Andrew Walrond <andrew@walrond.org> for reporting this error. 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>
* | fix ->metadata_version checking in Wait()Dan Williams2008-12-02
| | | | | | | | Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | config: Don't require an array to have a device name.NeilBrown2008-11-04
| | | | | | | | | | | | | | | | | | | | 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'.
* | quiet WaitClean()Dan Williams2008-10-15
| | | | | | | | Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Extend --wait-clean to checkpoint resyncDan Williams2008-10-15
| | | | | | | | | | | | | | | | | | Root file systems backed by external metadata arrays need to be explicitly checkpointed near the time the rootfs is marked readonly as userspace will not have an opportunity to react to the final shutdown of the array. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | --wait-clean: shorten timeoutDan Williams2008-10-15
| | | | | | | | | | | | | | | | | | | | | | | | Set the safemode timeout to a small value to get the array marked clean as soon as possible. We don't write 'clean' directly as it may cause mdmon to miss a 'write-pending' event. Include a couple fixes to sysfs_set_safemode(): 1/ 0 pad the milliseconds field 2/ workaround input truncation in the kernel Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | 'mdadm --wait-clean' wait for array to be marked cleanDan Williams2008-09-15
| | | | | | | | | | | | | | | | | | For use in distro shutdown scripts with a RAID root file system. Returns immediately if the array is 'readonly', or not an externally managed array. It is up to the distro's scripts to make sure no new writes hit the device after this returns 'true'. 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>
* Clean up usage of open()Doug Ledford2008-07-24
| | | | | | | | Fix on call that passed an invalid mode to open Don't pass a third arg unless we also pass O_CREAT Use symbolic args for 2nd and 3rd args Signed-off-by: Doug Ledford <dledford@redhat.com>
* Fix for segfault when reading /proc/mdstatNeil Brown2008-04-28
| | | | | | | | | Some kernel versions don't put a space between 'active' and '(auto-read-only)' in /proc/mdstat. This causes a parsing problem leaving 'level' set to NULL which causes a crash. So synthesise a space there if it is missing, and check for 'level' to be NULL and don't de-ref if it is.
* Replace sysarray with mdinfoNeil Brown2007-12-14
| | | | | Sure, mdinfo is bigger, but having a uniform structure for lots of things will make life easier.
* Remove spaces/tabs from ends of lines.Neil Brown2007-12-14
|
* Monitor.c s/MAXINT/INT_MAX/gmaximilian attems2007-09-27
| | | | | | | include limits.h directly instead of values.h Signed-off-by: maximilian attems <max@stro.at> Signed-off-by: Neil Brown <neilb@suse.de>
* Monitor.c include signal.h directlymaximilian attems2007-09-27
| | | | | | | another small step for better klibc support, glibc compile tested. Signed-off-by: maximilian attems <max@stro.at> Signed-off-by: Neil Brown <neilb@suse.de>
* Enhance raid4 support: --assemble and --monitor wasn't quite happy with it.Doug Ledford2007-07-09
| | | | | | | | | | | | | | | | | | | | | | | From: Doug Ledford <dledford@redhat.com> This one actually does a couple things. Mainly related to raid4, but kinda touches other raid levels some. When creating a raid4 array, treat it like a raid5 array in that we create it in degraded mode by default and add the last disk as a spare. Besides speeding things up, this has a second effect that it makes mdadm more consistent. In order to create a degraded raid5 array, you need only passing missing as one of the devices. For a degraded raid4 array, prior to this patch, you must pass assume-clean or else it refuses to create the array. Even force won't make it work without assume-clean. With the patch, raid4 behaves identical to raid5. Separate from that, the monitor functionality completely ignores raid4 arrays. That seems to stem from the code that checks to see if the array is part of a long list of types. It seems easier to check which array types *aren't* redundant instead of listing the ones that are redundant and missing some of them. This makes the monitor service actually watch raid4 arrays.
* Mark some files FD_CLOEXEC to protect sendmail from them.Doug Ledford2007-07-09
| | | | | | | | | | | From: Doug Ledford <dledford@redhat.com> When running with SELinux enabled and using mdadm to monitor devices, attempts to send emails to an admin will be blocked because mdadm is holding open /proc/mdstat without setting the FD_CLOEXEC flag. As a result, sendmail has an open descriptor to /proc/mdstat after the popen() call, which SELinux decides isn't really any of sendmail's business and so sendmail gets denied.
* Fix spare migration and other problems with --monitor.Neil Brown2007-07-09
| | | | | 2.6 broke --monitor in various ways, including spare migration stopped working. This fixes it.
* Fix a bug that was causing incorrect warning from --monitor.Neil Brown2007-02-22
|