Skip to content

Commit

Permalink
Fix RBD-NBD aio_callback error handling
Browse files Browse the repository at this point in the history
Tracker-Id: ceph#15604

Signed-off-by: Chang-Yi Lee <cy.l@inwinstack.com>
  • Loading branch information
cy.l@inwinstack.com committed Apr 30, 2016
1 parent 25c2f5a commit f8f6c1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions qa/workunits/rbd/rbd-nbd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions src/tools/rbd_nbd/rbd-nbd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,12 @@ class NBDServer

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);
}
Expand Down

0 comments on commit f8f6c1d

Please sign in to comment.