nvme/cuse: fix nblocks and block_size in rw path
nblocks is zero based, so read path was missing the increment. NVMe device that cuse represents can be of any block_size, so rather than hardcoding 512 - actually verify it. Both paths didn't request enough of a buffer from cuse. Reported-by: Niklas Cassel Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I228dc2572bc94ecbcb913e950d912a7ab5be9434 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4037 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
ef3f0d97ab
commit
ccdbd2ed51
@ -407,7 +407,7 @@ cuse_nvme_submit_io_read(struct cuse_device *cuse_device, fuse_req_t req, int cm
|
||||
|
||||
ctx->req = req;
|
||||
ctx->lba = user_io->slba;
|
||||
ctx->lba_count = user_io->nblocks;
|
||||
ctx->lba_count = user_io->nblocks + 1;
|
||||
|
||||
ctx->data_len = ctx->lba_count * block_size;
|
||||
ctx->data = spdk_zmalloc(ctx->data_len, 0x1000, NULL, SPDK_ENV_SOCKET_ID_ANY,
|
||||
@ -454,7 +454,7 @@ cuse_nvme_submit_io(fuse_req_t req, int cmd, void *arg,
|
||||
switch (user_io->opcode) {
|
||||
case SPDK_NVME_OPC_READ:
|
||||
out_iov.iov_base = (void *)user_io->addr;
|
||||
out_iov.iov_len = (user_io->nblocks + 1) * 512;
|
||||
out_iov.iov_len = (user_io->nblocks + 1) * block_size;
|
||||
if (out_bufsz == 0) {
|
||||
fuse_reply_ioctl_retry(req, in_iov, 1, &out_iov, 1);
|
||||
return;
|
||||
@ -465,7 +465,7 @@ cuse_nvme_submit_io(fuse_req_t req, int cmd, void *arg,
|
||||
break;
|
||||
case SPDK_NVME_OPC_WRITE:
|
||||
in_iov[1].iov_base = (void *)user_io->addr;
|
||||
in_iov[1].iov_len = (user_io->nblocks + 1) * 512;
|
||||
in_iov[1].iov_len = (user_io->nblocks + 1) * block_size;
|
||||
if (in_bufsz == sizeof(*user_io)) {
|
||||
fuse_reply_ioctl_retry(req, in_iov, 2, NULL, 0);
|
||||
return;
|
||||
|
@ -89,6 +89,13 @@ done
|
||||
|
||||
rm -Rf $testdir/match_files
|
||||
|
||||
# Verify read/write path
|
||||
tr < /dev/urandom -dc "a-zA-Z0-9" | fold -w 512 | head -n 1 > $testdir/write_file
|
||||
${NVME_CMD} write $ns --data-size=512 --data=$testdir/write_file
|
||||
${NVME_CMD} read $ns --data-size=512 --data=$testdir/read_file
|
||||
diff --ignore-trailing-space $testdir/write_file $testdir/read_file
|
||||
rm -f $testdir/write_file $testdir/read_file
|
||||
|
||||
# Verify admin cmd when no data is transferred,
|
||||
# by creating and deleting completion queue.
|
||||
${NVME_CMD} admin-passthru $ctrlr -o 5 --cdw10=0x3ff0003 --cdw11=0x1 -r
|
||||
|
Loading…
Reference in New Issue
Block a user