]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
krbd: check device node accessibility only if we actually mapped 39968/head
authorIlya Dryomov <idryomov@gmail.com>
Mon, 15 Mar 2021 19:30:07 +0000 (20:30 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 17 Mar 2021 19:26:34 +0000 (20:26 +0100)
Fix a braino that came with commit f6854ac65d2a ("krbd: make sure the
device node is accessible after the mapping").

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 8330c9fa4e27204c768777afe45af0eeb273c835)

src/krbd.cc

index 88a50b38d5461d037f3b5c6fbd4aae282f739b6a..1318512d6ca1afc5c013fe082a941b94e97f6ffe 100644 (file)
@@ -495,6 +495,9 @@ static int do_map(krbd_ctx *ctx, const krbd_spec& spec, const string& buf,
   close(fds[0]);
   close(fds[1]);
 
+  if (r < 0)
+    return r;
+
   /*
    * Make sure our device node is there.  This is intended to help
    * diagnose environments where "rbd map" is run from a container with
@@ -504,6 +507,7 @@ static int do_map(krbd_ctx *ctx, const krbd_spec& spec, const string& buf,
    * and in some cases can even lead to data loss, depending on higher
    * level logic and orchestration layers involved.
    */
+  ceph_assert(mapped);
   if (stat(pname->c_str(), &sb) < 0 || !S_ISBLK(sb.st_mode)) {
     std::cerr << "rbd: mapping succeeded but " << *pname
               << " is not accessible, is host /dev mounted?" << std::endl;
@@ -518,7 +522,7 @@ static int do_map(krbd_ctx *ctx, const krbd_spec& spec, const string& buf,
     return -EINVAL;
   }
 
-  return r;
+  return 0;
 }
 
 static int map_image(struct krbd_ctx *ctx, const krbd_spec& spec,