Commit 40681adc authored by Jacek Kalwas's avatar Jacek Kalwas Committed by Tomasz Zawadzki
Browse files

nvmf: improve write zeroes input validation



By current design of nvmf and bdev layers write zeroes command with
deallocate is not supported. See that spdk_nvmf_ctrlr_identify_ns and
nvmf_bdev_ctrlr_identify_ns don't set any dlfeat bits.

Without that check Write Zeroes command with DEAC bit set passes
through nvmf/bdev/nvme and can reach out remote target which might
actually support it and return the success.

Adding proper support for that requires more work between nvmf, bdev
and nvme layers hence just improve input validation by adding explicit
check and terminate such command early.

Change-Id: Ie9dccdfb8a706cb58caf04c1368c5c8f48084fc9
Signed-off-by: default avatarJacek Kalwas <jacek.kalwas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22376


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
parent 8f9fdf2d
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -1322,6 +1322,24 @@ union spdk_nvme_cmd_cdw12 {
		uint32_t lr        : 1;
	} copy;

	struct {
		/* Number of Logical Blocks */
		uint32_t nlb       : 16;
		uint32_t reserved  : 8;
		/* Storage Tag Check */
		uint32_t stc       : 1;
		/* Deallocate */
		uint32_t deac      : 1;
		/* Protection Information Check */
		uint32_t prchk     : 3;
		/* Protection Information Action */
		uint32_t pract     : 1;
		/* Force Unit Access */
		uint32_t fua       : 1;
		/* Limited Retry */
		uint32_t lr        : 1;
	} write_zeroes;

	union spdk_nvme_feat_fdp_cdw12 feat_fdp_cdw12;
	union spdk_nvme_feat_fdp_events_cdw12 feat_fdp_events_cdw12;
};
+7 −0
Original line number Diff line number Diff line
@@ -498,6 +498,13 @@ nvmf_bdev_ctrlr_write_zeroes_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *
		return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
	}

	if (spdk_unlikely(cmd->cdw12_bits.write_zeroes.deac)) {
		SPDK_ERRLOG("Write Zeroes Deallocate is not supported\n");
		rsp->status.sct = SPDK_NVME_SCT_GENERIC;
		rsp->status.sc = SPDK_NVME_SC_INVALID_FIELD;
		return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
	}

	rc = spdk_bdev_write_zeroes_blocks(desc, ch, start_lba, num_blocks,
					   nvmf_bdev_ctrlr_complete_cmd, req);
	if (spdk_unlikely(rc)) {