diff --git a/lib/nvme/nvme_cuse.c b/lib/nvme/nvme_cuse.c index eecb9c9dc..5644b3be1 100644 --- a/lib/nvme/nvme_cuse.c +++ b/lib/nvme/nvme_cuse.c @@ -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); } diff --git a/test/nvme/cuse/spdk_nvme_cli_cuse.sh b/test/nvme/cuse/spdk_nvme_cli_cuse.sh index 2648b1375..66b17f746 100755 --- a/test/nvme/cuse/spdk_nvme_cli_cuse.sh +++ b/test/nvme/cuse/spdk_nvme_cli_cuse.sh @@ -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}