]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Fix RBD-NBD aio_callback error handling
authorcy.l@inwinstack.com <cy.l@inwinstack.com>
Wed, 27 Apr 2016 03:00:25 +0000 (11:00 +0800)
committercy.l@inwinstack.com <cy.l@inwinstack.com>
Sat, 30 Apr 2016 07:11:18 +0000 (15:11 +0800)
Tracker-Id: #15604

Signed-off-by: Chang-Yi Lee <cy.l@inwinstack.com>
qa/workunits/rbd/rbd-nbd.sh
src/tools/rbd_nbd/rbd-nbd.cc

index 3bc7d80d2800d026d9cb89d76569132560e99b12..46e8f3858d0189a8c4b034ecf6cc53101e47ccd8 100755 (executable)
@@ -81,8 +81,7 @@ ${SUDO} rbd-nbd list-mapped | grep "^${DEV}$"
 
 #write test
 dd if=/dev/urandom of=${DATA} bs=1M count=${SIZE}
-${SUDO} dd if=${DATA} of=${DEV} bs=1M
-sync
+${SUDO} dd if=${DATA} of=${DEV} bs=1M oflag=direct
 [ "`dd if=${DATA} bs=1M | md5sum`" = "`rbd -p ${POOL} --no-progress export ${IMAGE} - | md5sum`" ]
 
 #trim test
index e0c0284021c55c842da1b4dad47504e1fc7bfdde..60192b07eaf3ea235dbb29fba19b61eaa4b7311c 100644 (file)
@@ -186,11 +186,12 @@ private:
 
     if (ret < 0) {
       ctx->reply.error = htonl(-ret);
-    } else if ((ctx->command == NBD_CMD_WRITE || ctx->command == NBD_CMD_READ)
-              && ret != static_cast<int>(ctx->request.len)) {
-      derr << __func__ << ": " << *ctx << ": unexpected return value: " << ret
-          << " (" << ctx->request.len << " expected)" << dendl;
-      ctx->reply.error = htonl(EIO);
+    } else if ((ctx->command == NBD_CMD_READ) &&
+                ret < static_cast<int>(ctx->request.len)) {
+      int pad_byte_count = static_cast<int> (ctx->request.len) - ret;
+      ctx->data.append('\x0', pad_byte_count);
+      dout(20) << __func__ << ": " << *ctx << ": Pad byte count: " 
+               << pad_byte_count << dendl;
     } else {
       ctx->reply.error = htonl(0);
     }