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")
Unified · Split
| @@ -24,6 +24,16 @@ u32 nvmet_get_log_page_len(struct nvme_command *cmd) · 23 unmodified lines | |||
| 24 | return len; | 24 | return len; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 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 | |||
| 27 | u64 nvmet_get_log_page_offset(struct nvme_command *cmd) | 37 | u64 nvmet_get_log_page_offset(struct nvme_command *cmd) |
| 28 | { | 38 | { |
| 29 | return le64_to_cpu(cmd->get_log_page.lpo); | 39 | 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 | |||
| 778 | u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); | 788 | u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); |
| 779 | u16 status = 0; | 789 | u16 status = 0; |
| 780 | 790 | ||
| 781 | if (!nvmet_check_data_len(req, 0)) | 791 | if (!nvmet_check_data_len(req, nvmet_feat_data_len(req, cdw10))) |
| 782 | return; | 792 | return; |
| 783 | 793 | ||
| 784 | switch (cdw10 & 0xff) { | 794 | switch (cdw10 & 0xff) { |