From 6d9fbbe6f95cc2f4e12a6f46b8c0b7a967b4a108 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Wed, 11 Mar 2015 20:13:50 +0300 Subject: [PATCH] rbd: fix rw option skipping logic We slip in an extraneous comma if { "rw": "rw" } happens to be the first map_options pair: # ./rbd map -o rw,share foo /dev/rbd0 -> 127.0.0.1:6789 name=admin,key=client.admin,,share rbd foo - The kernel mount options parser can handle it, but fix it nonetheless. Signed-off-by: Ilya Dryomov --- src/rbd.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/rbd.cc b/src/rbd.cc index e7ed6369b820..0891afffddb0 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -2267,18 +2267,19 @@ static int do_kernel_map(const char *poolname, const char *imgname, if (r < 0) return r; - for (map::const_iterator it = map_options.begin(); - it != map_options.end(); - ++it) { + for (map::iterator it = map_options.begin(); + it != map_options.end(); ) { // for compatibility with < 3.7 kernels, assume that rw is on by // default and omit it even if it was specified by the user // (see ceph.git commit fb0f1986449b) - if (it->first == "rw" && it->second == "rw") - continue; - - if (it != map_options.begin()) - oss << ","; - oss << it->second; + if (it->first == "rw" && it->second == "rw") { + map_options.erase(it++); + } else { + if (it != map_options.begin()) + oss << ","; + oss << it->second; + ++it; + } } r = krbd_map(krbd, poolname, imgname, snapname, oss.str().c_str(), &devnode); -- 2.47.3