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")

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>

authored by Amit Engel and committed by Jens Axboe e17016f6 35038bff

Changed files
+11 -1
drivers
nvme
target
+11 -1
drivers/nvme/target/admin-cmd.c
··· 24 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 37 u64 nvmet_get_log_page_offset(struct nvme_command *cmd) 28 38 { 29 39 return le64_to_cpu(cmd->get_log_page.lpo); ··· 788 778 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); 789 779 u16 status = 0; 790 780 791 - if (!nvmet_check_data_len(req, 0)) 781 + if (!nvmet_check_data_len(req, nvmet_feat_data_len(req, cdw10))) 792 782 return; 793 783 794 784 switch (cdw10 & 0xff) {