From: Daniel Wagner Date: Mon, 7 Nov 2022 09:31:20 +0000 (+0100) Subject: ioctl: Use nvme_get_log_page() in helpers X-Git-Tag: v1.3~38^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=00c3b9d24fecb7fffc4d1aef8d8c6c2cb95b9454;p=users%2Fsagi%2Flibnvme.git ioctl: Use nvme_get_log_page() in helpers We use directly nvme_get_log() calls for many of the defined helpers (e.g. nvme_get_log_persistent_event()). Though when the size of the data is really large, nvme_get_log() is not able to transfer the data (size exceeds what the kernel driver fit in a request). Thus limit the transfer sizes in all helpers to 4k. Signed-off-by: Daniel Wagner --- diff --git a/src/nvme/ioctl.h b/src/nvme/ioctl.h index 41cd9a05..42a791fc 100644 --- a/src/nvme/ioctl.h +++ b/src/nvme/ioctl.h @@ -34,6 +34,12 @@ /* '0' is interpreted by the kernel to mean 'apply the default timeout' */ #define NVME_DEFAULT_IOCTL_TIMEOUT 0 +/* + * 4k is the smallest possible transfer unit, so restricting to 4k + * avoids having to check the MDTS value of the controller. + */ +#define NVME_LOG_PAGE_PDU_SIZE 4096 + /** * struct nvme_passthru_cmd - nvme passthrough command structure * @opcode: Operation code, see &enum nvme_io_opcodes and &enum nvme_admin_opcodes @@ -1259,7 +1265,7 @@ static inline int nvme_get_nsid_log(int fd, bool rae, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } static inline int nvme_get_log_simple(int fd, enum nvme_cmd_get_log_lid lid, @@ -1402,7 +1408,7 @@ static inline int nvme_get_log_cmd_effects(int fd, enum nvme_csi csi, .rae = false, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1452,7 +1458,7 @@ static inline int nvme_get_log_create_telemetry_host(int fd, .rae = false, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1488,7 +1494,7 @@ static inline int nvme_get_log_telemetry_host(int fd, __u64 offset, .rae = false, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1525,7 +1531,7 @@ static inline int nvme_get_log_telemetry_ctrl(int fd, bool rae, .rae = rae, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1564,7 +1570,7 @@ static inline int nvme_get_log_endurance_group(int fd, __u16 endgid, .rae = false, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1596,7 +1602,7 @@ static inline int nvme_get_log_predictable_lat_nvmset(int fd, __u16 nvmsetid, .rae = false, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1630,7 +1636,7 @@ static inline int nvme_get_log_predictable_lat_event(int fd, bool rae, .rae = rae, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1671,7 +1677,7 @@ static inline int nvme_get_log_ana(int fd, enum nvme_log_ana_lsp lsp, bool rae, .rae = false, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1724,7 +1730,7 @@ static inline int nvme_get_log_lba_status(int fd, bool rae, .rae = rae, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1758,7 +1764,7 @@ static inline int nvme_get_log_endurance_grp_evt(int fd, bool rae, .rae = rae, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1825,7 +1831,7 @@ static inline int nvme_get_log_boot_partition(int fd, bool rae, .rae = rae, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1862,7 +1868,7 @@ static inline int nvme_get_log_discovery(int fd, bool rae, .rae = rae, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1894,7 +1900,7 @@ static inline int nvme_get_log_media_unit_stat(int fd, __u16 domid, .rae = false, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1926,7 +1932,7 @@ static inline int nvme_get_log_support_cap_config_list(int fd, __u16 domid, .rae = false, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1996,7 +2002,7 @@ static inline int nvme_get_log_zns_changed_zones(int fd, __u32 nsid, bool rae, .rae = rae, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -2030,7 +2036,7 @@ static inline int nvme_get_log_persistent_event(int fd, .rae = false, .ot = false, }; - return nvme_get_log(&args); + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /**