From: Pan Liu Date: Tue, 14 Mar 2017 12:38:40 +0000 (+0800) Subject: rbd-nbd: should set read_only when --readonly is set. X-Git-Tag: v12.0.1~60^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=957ba78bb8c185cafbaca9bba5b5d06608f72cac;p=ceph.git rbd-nbd: should set read_only when --readonly is set. Signed-off-by: Pan Liu --- diff --git a/src/tools/rbd_nbd/rbd-nbd.cc b/src/tools/rbd_nbd/rbd-nbd.cc index 32bd6da7e9e..c16df03e23a 100644 --- a/src/tools/rbd_nbd/rbd-nbd.cc +++ b/src/tools/rbd_nbd/rbd-nbd.cc @@ -514,7 +514,7 @@ static int do_map(int argc, const char *argv[]) librados::IoCtx io_ctx; librbd::Image image; - int read_only; + int read_only = 0; unsigned long flags; unsigned long size; @@ -608,8 +608,10 @@ static int do_map(int argc, const char *argv[]) } flags = NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_TRIM | NBD_FLAG_HAS_FLAGS; - if (!snapname.empty() || readonly) + if (!snapname.empty() || readonly) { flags |= NBD_FLAG_READ_ONLY; + read_only = 1; + } r = rados.init_with_context(g_ceph_context); if (r < 0) @@ -674,7 +676,6 @@ static int do_map(int argc, const char *argv[]) ioctl(nbd, NBD_SET_FLAGS, flags); - read_only = snapname.empty() ? 0 : 1; r = ioctl(nbd, BLKROSET, (unsigned long) &read_only); if (r < 0) { r = -errno;