Commit 0c645fdc authored by Ahriben Gonzalez's avatar Ahriben Gonzalez Committed by Tomasz Zawadzki
Browse files

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: default avatarAhriben Gonzalez <ahribeng@gmail.com>
Change-Id: I55a88a4f5ace5040f79c05edfc0b8559905bdd2e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10602


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent e45f78b8
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -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);
}
+6 −1
Original line number Diff line number Diff line
@@ -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}