diff options
author | Dan Mick <dan.mick@inktank.com> | 2013-01-10 18:44:44 -0800 |
---|---|---|
committer | Dan Mick <dan.mick@inktank.com> | 2013-01-11 14:28:50 -0800 |
commit | 15bb00cafc31305cacf3c4684a429c2c9ee6f804 (patch) | |
tree | 458488cedea12373d6033b2fa5725f3ea680708f /src/rbd.cc | |
parent | 66eb93b83648b4561b77ee6aab5b484e6dba4771 (diff) | |
download | ceph-15bb00cafc31305cacf3c4684a429c2c9ee6f804.tar.gz |
rbd: call udevadm settle on map/unmap
When we map/unmap devices, udev gets called to manage device nodes;
this will allow the command to wait for those manipulations to complete,
particularly for test runs, so that the device tree is stable by the
time the command exits.
--no-settle is also provided to avoid this behavior if desired (say,
for a series of 'map' commands, perhaps the user wants to wait for
settling only on the last of the series).
Fixes: #3635
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Alex Elder <elder@inktank.com>
Diffstat (limited to 'src/rbd.cc')
-rw-r--r-- | src/rbd.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/rbd.cc b/src/rbd.cc index 9aaca568208..c2c61811ce7 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -64,6 +64,8 @@ static string dir_oid = RBD_DIRECTORY; static string dir_info_oid = RBD_INFO; +bool udevadm_settle = true; + void usage() { cout << @@ -127,7 +129,8 @@ void usage() " format 2 supports cloning\n" " --id <username> rados user (without 'client.' prefix) to authenticate as\n" " --keyfile <path> file containing secret key for use with cephx\n" -" --shared <tag> take a shared (rather than exclusive) lock\n"; +" --shared <tag> take a shared (rather than exclusive) lock\n" +" --no-settle do not wait for udevadm to settle on map/unmap\n"; } static string feature_str(uint64_t features) @@ -1206,6 +1209,10 @@ static int do_kernel_add(const char *poolname, const char *imgname, const char * r = safe_write(fd, add.c_str(), add.size()); close(fd); + // let udevadm do its job before we return + if (udevadm_settle) + system("/sbin/udevadm settle"); + return r; } @@ -1397,6 +1404,11 @@ static int do_kernel_rm(const char *dev) } r = close(fd); + + // let udevadm finish, if present + if (udevadm_settle) + system("/sbin/udevadm settle"); + if (r < 0) r = -errno; return r; @@ -1620,6 +1632,8 @@ int main(int argc, const char **argv) imgname = strdup(val.c_str()); } else if (ceph_argparse_witharg(args, i, &val, "--shared", (char *)NULL)) { lock_tag = strdup(val.c_str()); + } else if (ceph_argparse_flag(args, i, "--no-settle", (char *)NULL)) { + udevadm_settle = false; } else { ++i; } |