]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: check for all-zero buf in export, seek output if so
authorDan Mick <dan.mick@inktank.com>
Thu, 20 Dec 2012 22:00:12 +0000 (14:00 -0800)
committerDan Mick <dan.mick@inktank.com>
Sat, 22 Dec 2012 01:03:38 +0000 (17:03 -0800)
Use buf_is_zero in common/util.cc

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
src/Makefile.am
src/rbd.cc

index c04b262930ad455cbca288e83b3c94c1ed96754d..28386ad276207f8088958052d408e6f57a59fa82 100644 (file)
@@ -440,7 +440,7 @@ radosacl_SOURCES = radosacl.cc
 radosacl_LDADD = librados.la $(PTHREAD_LIBS) -lm $(CRYPTO_LIBS) $(EXTRALIBS)
 bin_DEBUGPROGRAMS += scratchtool scratchtoolpp radosacl
 
-rbd_SOURCES = rbd.cc common/fiemap.cc common/secret.c common/TextTable.cc
+rbd_SOURCES = rbd.cc common/fiemap.cc common/secret.c common/TextTable.cc common/util.cc
 rbd_CXXFLAGS = ${AM_CXXFLAGS}
 rbd_LDADD = libglobal.la librbd.la librados.la $(PTHREAD_LIBS) -lm -lkeyutils $(CRYPTO_LIBS) $(EXTRALIBS)
 if LINUX
index 3920d4b9d5520b03b43d78658daaa7de78c9a13a..f38a01e237d22dfd763055d5904f8b860ddb12ab 100644 (file)
@@ -46,6 +46,7 @@
 
 #include "include/rbd_types.h"
 #include "common/TextTable.h"
+#include "include/util.h"
 
 #if defined(__linux__)
 #include <linux/fs.h>
@@ -721,8 +722,10 @@ static int export_read_cb(uint64_t ofs, size_t len, const char *buf, void *arg)
       ret = write(fd, buf, len);
     }
   } else {             // not stdout
-    if (!buf) /* a hole */
+    if (!buf || buf_is_zero(buf, len)) {
+      /* a hole */
       return 0;
+    }
 
     ret = lseek64(fd, ofs, SEEK_SET);
     if (ret < 0)