summaryrefslogtreecommitdiffstats
path: root/mdstat.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* add checking of return status on fstat callsNigel Croxon2024-05-211-1/+2
| | | | | | | | There are a few places we don't check the return status when calling fstat for success. Clean up the calls by adding a check before continuing. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* Modify mdstat parsing for volumes with the bitmapJakub Radtke2021-03-091-0/+6
| | | | | | | | | Current mdstat read functionality is not working correctly for the volumes with the write-intent bitmap. It affects rebuild and reshape use cases. Signed-off-by: Jakub Radtke <jakub.radtke@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdmonitor: set small delay onceBlazej Kucman2020-10-141-3/+15
| | | | | | | | | If mdmonitor is awakened by event, set small delay once to deal with udev and mdadm. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Monitor: refresh mdstat fd after selectMariusz Tkaczyk2020-10-141-2/+2
| | | | | | | | | | | | | After 52209d6ee118 ("Monitor: release /proc/mdstat fd when no arrays present") mdstat fd is closed if mdstat is empty or cannot be opened. It causes that monitor is not able to select on mdstat. Select doesn't fail because it gets valid descriptor to a different resource. As a result any new event will be unnoticed until timeout (delay). Refresh mdstat after wake up, don't poll on wrong resource. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: adding sync status for cluster deviceLidong Zhong2020-04-271-0/+2
| | | | | | | | | | | | | | | | | | | On the node with /proc/mdstat is Personalities : [raid1] md0 : active raid1 sdb[4] sdc[3] sdd[2] 1046528 blocks super 1.2 [3/2] [UU_] recover=REMOTE bitmap: 1/1 pages [4KB], 65536KB chunk Let's change the 'State' of 'mdadm -Q -D' accordingly State : clean, degraded With this patch, it will be State : clean, degraded, recovering (REMOTE) Signed-off-by: Lidong Zhong <lidong.zhong@suse.com> Acked-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/mdstat: correct the strncmp number 4 as 6Zhilong Liu2017-10-101-1/+1
| | | | | | | mdstat: it should be corrected as 6 when strncmp 'resync'. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/mdstat: fixup a number of '==' broken formattingZhilong Liu2017-10-101-19/+20
| | | | | | | | This commit doesn't change any codes, just tidy up the code formatting. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: Fixup more broken logical operator formattingJes Sorensen2017-05-161-4/+6
| | | | Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Monitor: release /proc/mdstat fd when no arrays presentTomasz Majchrzak2016-07-211-1/+5
| | | | | | | | | | | | | | | | | | | | If md kernel module is reloaded, /proc/mdstat cannot be accessed ("cat: /proc/mdstat: No such file or directory"). The reason is mdadm monitor still holds a file descriptor to previous /proc/mdstat instance. It leads to really confusing outcome of the following operations - mdadm seems to run without errors, however some udev rules don't get executed and new array doesn't work. Add a check if lseek was successful as it fails if md kernel module has been unloaded - close a file descriptor then. The problem is mdadm monitor doesn't always do it before next operation takes place. To prevent it monitor always releases /proc/mdstat descriptor when there are no arrays to be monitored, just in case driver unload happens in a moment. Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com> Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* mdstat: discard 'dev' field, just use 'devnm'NeilBrown2015-07-021-3/+1
| | | | | | | | These both have the same value, and have done since the 'devnm' concept was introduced. So discard the pointless duplicate. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: use mdstat_wait to wait for delayed reshape.NeilBrown2013-07-101-0/+7
| | | | | | | | | | Having a fix time for a wait is clumsy and can make us wait much too long. So use mdstat_wait and keep the mdstat_fd open. This requires an 'mdstat_close' so it doesn't stay open forever. Signed-off-by: NeilBrown <neilb@suse.de>
* Discard devnum in favour of devnmNeilBrown2013-02-211-39/+30
| | | | | | | | | | | | | | We widely use a "devnum" which is 0 or +ve for md%d devices and -ve for md_d%d devices. But I want to be able to use md_%s device names. So get rid of devnum (a number) and use devnm (a 32char string). eg. md0 md_d2 md_home Signed-off-by: NeilBrown <neilb@suse.de>
* Remove scattered checks for malloc success.NeilBrown2012-07-091-11/+6
| | | | | | | | | | | | | | 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>
* Introduce pr_err for printing error messages.NeilBrown2012-07-091-2/+2
| | | | | | | 'pr_err("' is a lot shorter than 'fprintf(stderr, Name ": ' cont_err() is also available. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: fix inconsistencies in values for ->percentNeilBrown2012-06-041-6/+6
| | | | | | | | | | | | | ->percent sometimes stores negative values recording states like 'pending' or 'delayed'. The value '-2' means both 'delayed' and in Monitor, 'unknown'. Also, '-1' has a meaning but not #define. So change the #defines to be prefixed with "RESYNC_", instead of "PROCESS_", add new "_NONE" and "_UNKNOWN", and use correct value in each location. Signed-off-by: NeilBrown <neilb@suse.de>
* mdstat_read(): Check return value of dup() before using file descriptorJes Sorensen2011-11-021-1/+6
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Show DELAYED, PENDING status of resync process in "--detail"Krzysztof Wojcik2011-06-231-4/+4
| | | | | | | | | | | | | | | | Initially there is no proper translation mdstat's DELAYED/PENDING processes to "--detail" output. For example, if we have recover=DELAYED in mdstat, "--detail" shows "State: recovering" and "Rebuild Status = 0%". It was incorrect in case of process waiting on checkpoint different than 0%. In fact rebuild status is differnt than 0% and user is misled. The patch fix the problem. Current "--detail" command shows in the exampe: "State: recovering (DELAYED)" and no information about precentage. Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* FIX: Position calculation in mdstat_by_subdevKrzysztof Wojcik2011-01-061-2/+2
| | | | | Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: Prepare reshape_update in mdadmNeilBrown2010-12-161-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | During Online Capacity Expansion metadata has to be updated to show array changes and allow for future assembly of array. To do this mdadm prepares and sends reshape_update metadata update to mdmon. The update contains the old and new number of raid disks, and the indices of the spare disks that will be used to fill the spaces. This works as follows: 1. reshape_super() prepares metadata update. 2. mdadm discovers the spares and adds them to the array 3. mdadm sends the update to mdmon 4. managemon in prepare_update() allocates required memory for bigger device object 5. monitor in process_update() updates the metadata to record the new sizes and the newly assigned devices. 6. mdadm initiates the reshape Based on code From: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com> Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* fix: mdstat_read() incorrectly translates value of mdstat_ent->reshape for ↵Hawrylewicz Czarnowski, Przemyslaw2010-12-081-1/+1
| | | | | | | | | | recovering it results in wrong output of mdadm --detail (shows reshaping instead of recovering) Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* mdmon: don't copy an invalid chunk_sizeNeilBrown2010-11-301-1/+0
| | | | | | | | | As chunk_size in mdstat_ent is never set, we shouldn't copy it into a->info.array. In fact, it is safest to get rid of the field altogether. Reported-by: "Kwolek, Adam" <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* detail/wait: better handling of monitoring sync action.NeilBrown2010-11-221-3/+19
| | | | | | | Detail: report reshape and check as well as resync and recovery Wait: if the resync is pending or delayed, wait for that too. Signed-off-by: NeilBrown <neilb@suse.de>
* Fix the count of member devices in mdstat_read function.Marcin Labun2010-07-061-4/+5
| | | | | | | | | | Correction of the number of container or volume member devices (devcnt in struct mdstat_ent). The number after the last devices was counted towards member of devices. Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Add mdstat_by_componentNeilBrown2010-06-301-4/+60
| | | | | | | | | | | | | This allows finding the array which contains a given component. Components are named using the kernel-internal string name such as "sda1" or "hdb". Don't return member arrays, only the contain that contains them. Also tidy up the parsing of 'inactive' arrays in /proc/mdstat. If we see 'inactive' we need to set 'in_devs' immediately as there is no level coming. Signed-off-by: NeilBrown <neilb@suse.de>
* Fix parsing of inactive arrays in /proc/mdstatJeff DeFouw2010-06-291-2/+3
| | | | | | | They don't have a level, so we should not expect one, and should expect devices instead. Signed-off-by: NeilBrown <neilb@suse.de>
* mdmon: don't monitor /proc/mounts to decide when to create .pid file.NeilBrown2010-02-081-7/+2
| | | | | | | | | | | Monitoring /proc/mounts and creating a .pid file as soon as /var/run is writable is racy. Most distros clean all non-directories from /var/run early in boot and if mdmon races with this it could lose the files as soon as they are created. Instead require that "mdmon --takeover" be run after /var is writable. Signed-off-by: NeilBrown <neilb@suse.de>
* mdmon: allow pid to be stored in different directory.NeilBrown2010-02-041-3/+13
| | | | | | | | /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>
* 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>
* Wait for POLLPRI on /proc or /sys files.NeilBrown2009-04-141-2/+12
| | | | | | | | | | | | | 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>
* mdmon: recreate socket/pid file on SIGHUPDan Williams2008-09-161-1/+2
| | | | | | | | | | Allow mdmon to start while /var/run/mdadm is readonly. Later a SIGHUP can trigger mdmon to drop its pid and socket once /var/run/mdadm is writable. Of course one needs the pid to send a HUP, that can be stored in a distribution specific rw-init directory... For now, rely on a killall -HUP mdmon to get the files dumped. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* Fix mdstat_wait_fdNeilBrown2008-08-191-3/+9
| | | | | | It didn't necessarily wait for the fd. Signed-off-by: NeilBrown <neilb@suse.de>
* Introduce devname2devnumNeil Brown2008-07-121-5/+1
| | | | and use it instead of opencoding.
* Remove stopped arrays.Neil Brown2008-05-271-2/+3
| | | | | | When an array becomes inactive, clean up and forget it. This involves signalling the manager.
* close some memory leaksDan Williams2008-05-151-0/+1
| | | | | | From: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* Merge mdmonNeil Brown2008-05-151-16/+44
|
* Remove spaces/tabs from ends of lines.Neil Brown2007-12-141-2/+2
|
* Mark some files FD_CLOEXEC to protect sendmail from them.Doug Ledford2007-07-091-1/+5
| | | | | | | | | | | 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.
* Add new mode: --incrementalNeil Brown2006-12-211-0/+12
| | | | | --incremental allows arrays to be assembled one device at a time. This is expected to be used with udev.
* Minor man page and comment fixesNeil Brown2006-10-091-2/+2
| | | | Thanks To: "Scott Weikart" <Scott.W@Benetech.org>
* Just updaqte copyright dates and email addressNeil Brown2006-05-191-1/+1
| | | | Signed-off-by: Neil Brown <neilb@suse.de>
* Sort mdstat entries so that composites are well-ordered.Neil Brown2006-01-311-7/+46
| | | | | | | This means that "-Ds" lists arrays in an approprate order for assembly. Signed-off-by: Neil Brown <neilb@suse.de>
* mdadm-1.7.0mdadm-1.7.0Neil Brown2004-08-111-0/+6
|
* mdadm-1.6.0mdadm-1.6.0Neil Brown2004-06-041-4/+23
|
* mdadm-1.5.0mdadm-1.5.0Neil Brown2004-01-221-4/+13
|
* mdadm-0.8mdadm-0.8Neil Brown2002-04-041-0/+180