diff options
author | Dan Williams <dan.j.williams@intel.com> | 2008-09-16 05:58:42 +0200 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2008-09-16 05:58:42 +0200 |
commit | c94709e83f662c4780aa9c6917b03c774747eca5 (patch) | |
tree | 46d8a1c6e4ecd5dbca24d092af28910f92b01547 /msg.c | |
parent | monitor: don't mark dirty on resync complete (diff) | |
download | mdadm-c94709e83f662c4780aa9c6917b03c774747eca5.tar.xz mdadm-c94709e83f662c4780aa9c6917b03c774747eca5.zip |
Add ping_monitor() to mdadm --wait
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>
Diffstat (limited to 'msg.c')
-rw-r--r-- | msg.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -144,8 +144,21 @@ int connect_monitor(char *devname) int sfd; long fl; struct sockaddr_un addr; + int pos; + char *c; + + pos = sprintf(path, "/var/run/mdadm/"); + if (is_subarray(devname)) { + devname++; + c = strchr(devname, '/'); + if (!c) + return -1; + snprintf(&path[pos], c - devname + 1, "%s", devname); + pos += c - devname; + } else + pos += sprintf(&path[pos], "%s", devname); + sprintf(&path[pos], ".sock"); - sprintf(path, "/var/run/mdadm/%s.sock", devname); sfd = socket(PF_LOCAL, SOCK_STREAM, 0); if (sfd < 0) return -1; |