]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
ioctl: Use nvme_get_log_page() in helpers
authorDaniel Wagner <dwagner@suse.de>
Mon, 7 Nov 2022 09:31:20 +0000 (10:31 +0100)
committerDaniel Wagner <dwagner@suse.de>
Mon, 7 Nov 2022 09:31:20 +0000 (10:31 +0100)
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 <dwagner@suse.de>
src/nvme/ioctl.h

index 41cd9a05b5c272f44e2da501d7db278bb79e1773..42a791fc223c93c0299e3c43d93309abb92c5d61 100644 (file)
 /* '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);
 }
 
 /**