From: Ilya Dryomov Date: Wed, 11 Mar 2015 17:13:50 +0000 (+0300) Subject: rbd: fix rw option skipping logic X-Git-Tag: v9.0.0~182^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F3979%2Fhead;p=ceph.git 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 --- 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);