From c6cfb616a846959a2cd1c0e540b14668c61a2afd Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 7 Sep 2016 11:49:26 -0400 Subject: [PATCH] rbd-nbd: mask out-of-bounds IO errors caused by image shrink Signed-off-by: Jason Dillaman --- src/tools/rbd_nbd/rbd-nbd.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tools/rbd_nbd/rbd-nbd.cc b/src/tools/rbd_nbd/rbd-nbd.cc index 4f70db42403c1..2db9dfacb9a7b 100644 --- a/src/tools/rbd_nbd/rbd-nbd.cc +++ b/src/tools/rbd_nbd/rbd-nbd.cc @@ -185,13 +185,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(ctx->request.len)) { int pad_byte_count = static_cast (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 { -- 2.39.5