History

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 e9061c397839 ("nvmet: Remove the data_len field from the nvmet_req struct")

Amit Engel committed 6 years ago

Commit e17016f1 parent 35038bf1 file · +11 −1Browse files

Unified · Split

drivers/nvme/target/admin-cmd.c+11−1
@@ -24,6 +24,16 @@ u32 nvmet_get_log_page_len(struct nvme_command *cmd) · 23 unmodified lines
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) · 748 unmodified lines
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) {