Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions src/nvme/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,22 @@ int nvme_get_log(struct nvme_get_log_args *args)
return nvme_submit_admin_passthru(args->fd, &cmd, args->result);
}

static bool force_4k;

__attribute__((constructor))
static void nvme_init_env(void)
{
char *val;

val = getenv("LIBNVME_FORCE_4K");
if (!val)
return;
if (!strcmp(val, "1") ||
!strcasecmp(val, "true") ||
!strncasecmp(val, "enable", 6))
force_4k = true;
}

#ifdef CONFIG_LIBURING
enum {
IO_URING_NOT_AVAILABLE,
Expand Down Expand Up @@ -449,6 +465,9 @@ int nvme_get_log_page(int fd, __u32 xfer_len, struct nvme_get_log_args *args)

args->fd = fd;

if (force_4k)
xfer_len = NVME_LOG_PAGE_PDU_SIZE;

#ifdef CONFIG_LIBURING
int n = 0;
struct io_uring ring;
Expand All @@ -469,9 +488,13 @@ int nvme_get_log_page(int fd, __u32 xfer_len, struct nvme_get_log_args *args)
* avoids having to check the MDTS value of the controller.
*/
do {
xfer = data_len - offset;
if (xfer > xfer_len)
xfer = xfer_len;
if (!force_4k) {
xfer = data_len - offset;
if (xfer > xfer_len)
xfer = xfer_len;
} else {
xfer = NVME_LOG_PAGE_PDU_SIZE;
}

/*
* Always retain regardless of the RAE parameter until the very
Expand Down