From: Daniel Wagner Date: Wed, 6 Mar 2024 09:18:10 +0000 (+0100) Subject: ioctl: remove incomplete debug logging infrastructure X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d74d2c0945231632549d85bc1fa6941d09280481;p=users%2Fsagi%2Flibnvme.git ioctl: remove incomplete debug logging infrastructure Do not clutter the code base with debugging code. Because the low level passthru functions are now exposed as weak symbol, the user application can do it by itself. Signed-off-by: Daniel Wagner --- diff --git a/src/nvme/ioctl.c b/src/nvme/ioctl.c index 42b614c3..66cb8ab1 100644 --- a/src/nvme/ioctl.c +++ b/src/nvme/ioctl.c @@ -90,53 +90,14 @@ int nvme_submit_passthru64(int fd, unsigned long ioctl_cmd, return err; } -static void nvme_show_command(struct nvme_passthru_cmd *cmd, int err, struct timeval start, - struct timeval end) -{ - printf("opcode : %02x\n", cmd->opcode); - printf("flags : %02x\n", cmd->flags); - printf("rsvd1 : %04x\n", cmd->rsvd1); - printf("nsid : %08x\n", cmd->nsid); - printf("cdw2 : %08x\n", cmd->cdw2); - printf("cdw3 : %08x\n", cmd->cdw3); - printf("data_len : %08x\n", cmd->data_len); - printf("metadata_len : %08x\n", cmd->metadata_len); - printf("addr : %"PRIx64"\n", (uint64_t)(uintptr_t)cmd->addr); - printf("metadata : %"PRIx64"\n", (uint64_t)(uintptr_t)cmd->metadata); - printf("cdw10 : %08x\n", cmd->cdw10); - printf("cdw11 : %08x\n", cmd->cdw11); - printf("cdw12 : %08x\n", cmd->cdw12); - printf("cdw13 : %08x\n", cmd->cdw13); - printf("cdw14 : %08x\n", cmd->cdw14); - printf("cdw15 : %08x\n", cmd->cdw15); - printf("timeout_ms : %08x\n", cmd->timeout_ms); - printf("result : %08x\n", cmd->result); - printf("err : %d\n", err); - printf("latency : %lu us\n", - (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec)); -} - __attribute__((weak)) int nvme_submit_passthru(int fd, unsigned long ioctl_cmd, struct nvme_passthru_cmd *cmd, __u32 *result) { - struct timeval start; - struct timeval end; - int err; - - if (nvme_get_debug()) - gettimeofday(&start, NULL); - - err = ioctl(fd, ioctl_cmd, cmd); - - if (nvme_get_debug()) { - gettimeofday(&end, NULL); - nvme_show_command(cmd, err, start, end); - } + int err = ioctl(fd, ioctl_cmd, cmd); if (err >= 0 && result) *result = cmd->result; - return err; } diff --git a/src/nvme/log.c b/src/nvme/log.c index f1a7eaee..5a18bb97 100644 --- a/src/nvme/log.c +++ b/src/nvme/log.c @@ -27,7 +27,6 @@ #endif static nvme_root_t root; -static bool nvme_debug; void __attribute__((format(printf, 4, 5))) __nvme_msg(nvme_root_t r, int lvl, @@ -107,10 +106,10 @@ void nvme_set_root(nvme_root_t r) void nvme_set_debug(bool debug) { - nvme_debug = debug; + root->log_level = debug ? LOG_DEBUG : DEFAULT_LOGLEVEL; } bool nvme_get_debug(void) { - return nvme_debug; + return root->log_level == LOG_DEBUG; } diff --git a/src/nvme/log.h b/src/nvme/log.h index dea94290..829b76ab 100644 --- a/src/nvme/log.h +++ b/src/nvme/log.h @@ -51,12 +51,16 @@ void nvme_set_root(nvme_root_t r); /** * nvme_set_debug - Set NVMe command debugging output * @debug: true to enable or false to disable + * + * Don't use it, it's debricated. */ void nvme_set_debug(bool debug); /** * nvme_get_debug - Get NVMe command debugging output * + * Don't use it, it's debricated. + * * Return: false if disabled or true if enabled. */ bool nvme_get_debug(void);