nvmet: fix per feat data len for get_feature
The existing implementation for the get_feature admin-cmd does not
use per-feature data len. This patch introduces a new helper function
nvmet_feat_data_len(), which is used to calculate per feature data len.
Right now we only set data len for fid 0x81 (NVME_FEAT_HOST_ID).
Fixes: commit e9061c3978
("nvmet: Remove the data_len field from the nvmet_req struct")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Amit Engel <amit.engel@dell.com>
[endiness, naming, and kernel style fixes]
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
35038bffa8
commit
e17016f6dc
|
@ -24,6 +24,16 @@ u32 nvmet_get_log_page_len(struct nvme_command *cmd)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static u32 nvmet_feat_data_len(struct nvmet_req *req, u32 cdw10)
|
||||||
|
{
|
||||||
|
switch (cdw10 & 0xff) {
|
||||||
|
case NVME_FEAT_HOST_ID:
|
||||||
|
return sizeof(req->sq->ctrl->hostid);
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
u64 nvmet_get_log_page_offset(struct nvme_command *cmd)
|
u64 nvmet_get_log_page_offset(struct nvme_command *cmd)
|
||||||
{
|
{
|
||||||
return le64_to_cpu(cmd->get_log_page.lpo);
|
return le64_to_cpu(cmd->get_log_page.lpo);
|
||||||
|
@ -778,7 +788,7 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
|
||||||
u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
|
u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
|
||||||
u16 status = 0;
|
u16 status = 0;
|
||||||
|
|
||||||
if (!nvmet_check_data_len(req, 0))
|
if (!nvmet_check_data_len(req, nvmet_feat_data_len(req, cdw10)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (cdw10 & 0xff) {
|
switch (cdw10 & 0xff) {
|
||||||
|
|
Loading…
Reference in New Issue