]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-nbd: rescan partition table after image resize event
authorJason Dillaman <dillaman@redhat.com>
Wed, 15 Nov 2017 15:34:32 +0000 (10:34 -0500)
committerPrashant D <pdhange@redhat.com>
Tue, 21 Nov 2017 03:38:25 +0000 (22:38 -0500)
Fixes: http://tracker.ceph.com/issues/22131
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit db13e4757451b463e7fb65c43247e033f24d45e5)

src/tools/rbd_nbd/rbd-nbd.cc

index bf7477f4d394fd225e3e732714ad251ae3041926..f0443f69f826c2aa9fc0530efec758efa89d9e90 100644 (file)
@@ -474,13 +474,19 @@ public:
       unsigned long new_size = info.size;
 
       if (new_size != size) {
+        dout(5) << "resize detected" << dendl;
         if (ioctl(fd, BLKFLSBUF, NULL) < 0)
-            derr << "invalidate page cache failed: " << cpp_strerror(errno) << dendl;
+            derr << "invalidate page cache failed: " << cpp_strerror(errno)
+                 << dendl;
         if (ioctl(fd, NBD_SET_SIZE, new_size) < 0) {
             derr << "resize failed: " << cpp_strerror(errno) << dendl;
         } else {
           size = new_size;
         }
+        if (ioctl(fd, BLKRRPART, NULL) < 0) {
+          derr << "rescan of partition table failed: " << cpp_strerror(errno)
+               << dendl;
+        }
         if (image.invalidate_cache() < 0)
             derr << "invalidate rbd cache failed" << dendl;
       }