]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-nbd: set reply error properly
authorMykola Golub <mgolub@mirantis.com>
Tue, 5 Jan 2016 14:15:08 +0000 (16:15 +0200)
committerMykola Golub <mgolub@mirantis.com>
Wed, 6 Jan 2016 10:48:01 +0000 (12:48 +0200)
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/tools/rbd_nbd/rbd-nbd.cc

index 0afa444387ddb5f30e6dcd6680fdc7d67b75b053..ff12f91d772f5ca043aeb54146307a68a96470e5 100644 (file)
@@ -170,9 +170,15 @@ private:
 
     dout(20) << __func__ << ": " << *ctx << dendl;
 
-    if (ret > 0)
-      ret = 0;
-    ctx->reply.error = htonl(ret);
+    if (ret < 0) {
+      ctx->reply.error = htonl(-ret);
+    } else if (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 {
+      ctx->reply.error = htonl(0);
+    }
     ctx->server->io_finish(ctx);
 
     aio_completion->release();