Skip to content

Commit e17016f

Browse files
Amit Engelaxboe
authored andcommitted
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 e9061c3 ("nvmet: Remove the data_len field from the nvmet_req struct") Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Amit Engel <[email protected]> [endiness, naming, and kernel style fixes] Signed-off-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Keith Busch <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 35038bf commit e17016f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/nvme/target/admin-cmd.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ u32 nvmet_get_log_page_len(struct nvme_command *cmd)
2424
return len;
2525
}
2626

27+
static u32 nvmet_feat_data_len(struct nvmet_req *req, u32 cdw10)
28+
{
29+
switch (cdw10 & 0xff) {
30+
case NVME_FEAT_HOST_ID:
31+
return sizeof(req->sq->ctrl->hostid);
32+
default:
33+
return 0;
34+
}
35+
}
36+
2737
u64 nvmet_get_log_page_offset(struct nvme_command *cmd)
2838
{
2939
return le64_to_cpu(cmd->get_log_page.lpo);
@@ -778,7 +788,7 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
778788
u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
779789
u16 status = 0;
780790

781-
if (!nvmet_check_data_len(req, 0))
791+
if (!nvmet_check_data_len(req, nvmet_feat_data_len(req, cdw10)))
782792
return;
783793

784794
switch (cdw10 & 0xff) {

0 commit comments

Comments
 (0)