]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-nbd: relax size check for newer kernel versions 14976/head
authorMykola Golub <mgolub@mirantis.com>
Fri, 5 May 2017 13:59:44 +0000 (15:59 +0200)
committerMykola Golub <mgolub@mirantis.com>
Fri, 5 May 2017 14:44:51 +0000 (16:44 +0200)
Fixes: http://tracker.ceph.com/issues/19871
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/tools/rbd_nbd/rbd-nbd.cc

index 8ba83208b2e0a4fafbee6b7b9df1149df84d81d0..8b59ccd267e5130e86d8fd2bcab555149657c722 100644 (file)
@@ -500,6 +500,10 @@ static int open_device(const char* path, bool try_load_module = false)
 
 static int check_device_size(int nbd_index, unsigned long expected_size)
 {
+  // There are bugs with some older kernel versions that result in an
+  // overflow for large image sizes. This check is to ensure we are
+  // not affected.
+
   unsigned long size = 0;
   std::string path = "/sys/block/nbd" + stringify(nbd_index) + "/size";
   std::ifstream ifs;
@@ -511,6 +515,12 @@ static int check_device_size(int nbd_index, unsigned long expected_size)
   ifs >> size;
   size *= RBD_NBD_BLKSIZE;
 
+  if (size == 0) {
+    // Newer kernel versions will report real size only after nbd
+    // connect. Assume this is the case and return success.
+    return 0;
+  }
+
   if (size != expected_size) {
     cerr << "rbd-nbd: kernel reported invalid device size (" << size
          << ", expected " << expected_size << ")" << std::endl;