]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: fix probe of source when block device
authorSage Weil <sage@newdream.net>
Tue, 17 Apr 2012 20:12:50 +0000 (13:12 -0700)
committerSage Weil <sage@newdream.net>
Tue, 17 Apr 2012 20:12:50 +0000 (13:12 -0700)
Fixes: #2304
Signed-off-by: Sage Weil <sage@newdream.net>
src/common/fiemap.cc
src/rbd.cc

index dd239058a00e49d64c9a3143419b4be3ad959de5..0df12d6e8fd1e2ac11fe1864261ef11464d1efe1 100644 (file)
@@ -58,7 +58,6 @@ struct fiemap *read_fiemap(int fd)
   /* Find out how many extents there are */
   r = ioctl(fd, FS_IOC_FIEMAP, fiemap);
   if (r < 0) {
-    fprintf(stderr, "fiemap ioctl() failed\n");
     goto done_err;
   }
 
index 48f13dd5b805d418a0735c42c719f69639a2b8a4..cb82f9cc70fe64938d8a01a6627ef1ffd7986e95 100644 (file)
@@ -28,6 +28,7 @@
 #include "include/intarith.h"
 
 #include "include/compat.h"
+#include "common/blkdev.h"
 
 #include <dirent.h>
 #include <errno.h>
@@ -405,7 +406,7 @@ static int do_import(librbd::RBD &rbd, librados::IoCtx& io_ctx,
 {
   int fd = open(path, O_RDONLY);
   int r;
-  uint64_t size;
+  int64_t size = 0;
   struct stat stat_buf;
   string md_oid;
   struct fiemap *fiemap;
@@ -424,6 +425,13 @@ static int do_import(librbd::RBD &rbd, librados::IoCtx& io_ctx,
     return r;
   }
   size = (uint64_t)stat_buf.st_size;
+  if (!size) {
+    r = get_block_device_size(fd, &size);
+    if (r < 0) {
+      cerr << "unable to get size of file/block device: " << cpp_strerror(r) << std::endl;
+      return r;
+    }
+  }
 
   assert(imgname);