nvmf: treat DSM attribute as bitfield

The Dataset Management command allows several operations to be specified
at once; the virtual controller only supports deallocate for now, but it
should just ignore the other bits in order to be spec compliant: "If the
Dataset Management command is supported, all combinations of attributes
[...] may be set".

The spec also explicitly states that it is acceptable for controllers to
choose to take no action based on information provided, so not
implementing the other attributes is fine.

Change-Id: Ia989dc1faa9c852660bf1299ea18fa8e7bdf4053
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2016-08-26 12:43:24 -07:00
parent 3e9ddce6f3
commit a1d83c72bc

View File

@ -446,10 +446,11 @@ nvmf_virtual_ctrlr_dsm_cmd(struct spdk_bdev *bdev, struct spdk_nvmf_request *req
struct spdk_scsi_unmap_bdesc *unmap;
struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd;
struct spdk_nvme_cpl *response = &req->rsp->nvme_cpl;
bool async = false;
nr = ((cmd->cdw10 & 0x000000ff) + 1);
attribute = cmd->cdw11 & 0x00000007;
if (attribute == SPDK_NVME_DSM_ATTR_DEALLOCATE) {
if (attribute & SPDK_NVME_DSM_ATTR_DEALLOCATE) {
struct spdk_nvme_dsm_range *dsm_range = (struct spdk_nvme_dsm_range *)req->data;
unmap = calloc(nr, sizeof(*unmap));
if (unmap == NULL) {
@ -467,12 +468,14 @@ nvmf_virtual_ctrlr_dsm_cmd(struct spdk_bdev *bdev, struct spdk_nvmf_request *req
response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
} else {
SPDK_ERRLOG("dsm attribute:%x does not supported yet\n", attribute);
response->status.sc = SPDK_NVME_SC_INVALID_OPCODE;
async = true;
}
if (async) {
return SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS;
}
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
static int
nvmf_virtual_ctrlr_process_io_cmd(struct spdk_nvmf_request *req)