#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
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);
}