]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-nbd: mask out-of-bounds IO errors caused by image shrink
authorJason Dillaman <dillaman@redhat.com>
Wed, 7 Sep 2016 15:49:26 +0000 (11:49 -0400)
committerLoic Dachary <ldachary@redhat.com>
Fri, 21 Oct 2016 10:16:44 +0000 (12:16 +0200)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit c6cfb616a846959a2cd1c0e540b14668c61a2afd)

src/tools/rbd_nbd/rbd-nbd.cc

index d6dae2073f69a0be5f924f527b2ff1af2c264d11..49cbeecf19d1fbbb5ece0dc5ddcece199fbdd8e4 100644 (file)
@@ -184,13 +184,21 @@ private:
 
     dout(20) << __func__ << ": " << *ctx << dendl;
 
+    if (ret == -EINVAL) {
+      // if shrinking an image, a pagecache writeback might reference
+      // extents outside of the range of the new image extents
+      dout(5) << __func__ << ": masking IO out-of-bounds error" << dendl;
+      ctx->data.clear();
+      ret = 0;
+    }
+
     if (ret < 0) {
       ctx->reply.error = htonl(-ret);
     } 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_zero(pad_byte_count);
-      dout(20) << __func__ << ": " << *ctx << ": Pad byte count: " 
+      dout(20) << __func__ << ": " << *ctx << ": Pad byte count: "
                << pad_byte_count << dendl;
       ctx->reply.error = 0;
     } else {