nvme: change cuse ioctl reply

-Change cuse ioctl reply from status code to whole status field.
-Add negative test for nvme cli cuse: Power Managment on Namespace

Signed-off-by: Ahriben Gonzalez <ahribeng@gmail.com>
Change-Id: I55a88a4f5ace5040f79c05edfc0b8559905bdd2e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10602
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Ahriben Gonzalez 2021-12-08 15:40:06 -08:00 committed by Keith Lucas
parent 472fa266b9
commit 19af48fca0
2 changed files with 14 additions and 6 deletions

View File

@ -99,10 +99,11 @@ cuse_nvme_passthru_cmd_cb(void *arg, const struct spdk_nvme_cpl *cpl)
struct cuse_io_ctx *ctx = arg;
struct iovec out_iov[2];
struct spdk_nvme_cpl _cpl;
uint16_t status_field = cpl->status_raw >> 1; /* Drop out phase bit */
if (ctx->data_transfer == SPDK_NVME_DATA_HOST_TO_CONTROLLER ||
ctx->data_transfer == SPDK_NVME_DATA_NONE) {
fuse_reply_ioctl_iov(ctx->req, cpl->status.sc, NULL, 0);
fuse_reply_ioctl_iov(ctx->req, status_field, NULL, 0);
} else {
memcpy(&_cpl, cpl, sizeof(struct spdk_nvme_cpl));
@ -112,9 +113,9 @@ cuse_nvme_passthru_cmd_cb(void *arg, const struct spdk_nvme_cpl *cpl)
if (ctx->data_len > 0) {
out_iov[1].iov_base = ctx->data;
out_iov[1].iov_len = ctx->data_len;
fuse_reply_ioctl_iov(ctx->req, cpl->status.sc, out_iov, 2);
fuse_reply_ioctl_iov(ctx->req, status_field, out_iov, 2);
} else {
fuse_reply_ioctl_iov(ctx->req, cpl->status.sc, out_iov, 1);
fuse_reply_ioctl_iov(ctx->req, status_field, out_iov, 1);
}
}
@ -349,8 +350,9 @@ static void
cuse_nvme_submit_io_write_done(void *ref, const struct spdk_nvme_cpl *cpl)
{
struct cuse_io_ctx *ctx = (struct cuse_io_ctx *)ref;
uint16_t status_field = cpl->status_raw >> 1; /* Drop out phase bit */
fuse_reply_ioctl_iov(ctx->req, cpl->status.sc, NULL, 0);
fuse_reply_ioctl_iov(ctx->req, status_field, NULL, 0);
cuse_io_ctx_free(ctx);
}
@ -421,11 +423,12 @@ cuse_nvme_submit_io_read_done(void *ref, const struct spdk_nvme_cpl *cpl)
{
struct cuse_io_ctx *ctx = (struct cuse_io_ctx *)ref;
struct iovec iov;
uint16_t status_field = cpl->status_raw >> 1; /* Drop out phase bit */
iov.iov_base = ctx->data;
iov.iov_len = ctx->data_len;
fuse_reply_ioctl_iov(ctx->req, cpl->status.sc, &iov, 1);
fuse_reply_ioctl_iov(ctx->req, status_field, &iov, 1);
cuse_io_ctx_free(ctx);
}

View File

@ -45,6 +45,10 @@ ${NVME_CMD} error-log $ctrlr > ${KERNEL_OUT}.7
${NVME_CMD} get-feature $ctrlr -f 1 -s 1 -l 100 > ${KERNEL_OUT}.8
${NVME_CMD} get-log $ctrlr -i 1 -l 100 > ${KERNEL_OUT}.9
${NVME_CMD} reset $ctrlr > ${KERNEL_OUT}.10
# Negative test to make sure status message is the same on failures
# FID 2 is power management. It should be constrained to the whole system
# Attempting to apply it to a namespace should result in a failure
${NVME_CMD} set-feature $ctrlr -n 1 -f 2 -v 0 2> ${KERNEL_OUT}.11 || true
$rootdir/scripts/setup.sh
@ -78,8 +82,9 @@ ${NVME_CMD} error-log $ctrlr > ${CUSE_OUT}.7
${NVME_CMD} get-feature $ctrlr -f 1 -s 1 -l 100 > ${CUSE_OUT}.8
${NVME_CMD} get-log $ctrlr -i 1 -l 100 > ${CUSE_OUT}.9
${NVME_CMD} reset $ctrlr > ${CUSE_OUT}.10
${NVME_CMD} set-feature $ctrlr -n 1 -f 2 -v 0 2> ${CUSE_OUT}.11 || true
for i in {1..10}; do
for i in {1..11}; do
if [ -f "${KERNEL_OUT}.${i}" ] && [ -f "${CUSE_OUT}.${i}" ]; then
sed -i "s/${nvme_name}/nvme0/g" ${KERNEL_OUT}.${i}
diff --suppress-common-lines ${KERNEL_OUT}.${i} ${CUSE_OUT}.${i}