Skip to contentSkip to conversation

dm vdo: remove sysfs parameters

PATCH New Matthew Sakai 1 participant 5 messages Mar 1, 2024

Subsystems (3)
lore
Share & tools
lore

Matthew Sakai

author maintainer
#0 lore raw

cover dm vdo: remove sysfs parameters

Ken Raeburn (1):
dm vdo: document log_level parameter

Mike Snitzer (3):
dm vdo: remove all sysfs interfaces
dm vdo: add 'log_level' module parameter
dm vdo logger: remove log level to string conversion code

 .../admin-guide/device-mapper/vdo.rst         |    7 +
 drivers/md/dm-vdo/Makefile                    |    4 -
 drivers/md/dm-vdo/dedupe.c                    |   70 +-
 drivers/md/dm-vdo/dedupe.h                    |    2 +-
 drivers/md/dm-vdo/dm-vdo-target.c             |   47 +-
 drivers/md/dm-vdo/logger.c                    |   64 +-
 drivers/md/dm-vdo/logger.h                    |   30 +-
 drivers/md/dm-vdo/pool-sysfs-stats.c          | 2063 -----------------
 drivers/md/dm-vdo/pool-sysfs.c                |  198 --
 drivers/md/dm-vdo/pool-sysfs.h                |   19 -
 drivers/md/dm-vdo/status-codes.c              |    1 -
 drivers/md/dm-vdo/status-codes.h              |    2 -
 drivers/md/dm-vdo/sysfs.c                     |   82 -
 drivers/md/dm-vdo/uds-sysfs.c                 |  187 --
 drivers/md/dm-vdo/uds-sysfs.h                 |   12 -
 drivers/md/dm-vdo/vdo.c                       |   54 +-
 drivers/md/dm-vdo/vdo.h                       |   13 -
 17 files changed, 41 insertions(+), 2814 deletions(-)
 delete mode 100644 drivers/md/dm-vdo/pool-sysfs-stats.c
 delete mode 100644 drivers/md/dm-vdo/pool-sysfs.c
 delete mode 100644 drivers/md/dm-vdo/pool-sysfs.h
 delete mode 100644 drivers/md/dm-vdo/sysfs.c
 delete mode 100644 drivers/md/dm-vdo/uds-sysfs.c
 delete mode 100644 drivers/md/dm-vdo/uds-sysfs.h
Signature · 1 line
2.42.0
author maintainer
#2 lore raw

PATCH 2/4 dm vdo: add 'log_level' module parameter

From: Mike Snitzer <[email protected]>

Expose control over dm-vdo's log-level in terms of a module param. It can be read and written via /sys/module/dm_vdo/parameters/log_level.

---
 drivers/md/dm-vdo/dm-vdo-target.c |  3 +++
 drivers/md/dm-vdo/logger.c        | 10 ++++++++--
 drivers/md/dm-vdo/logger.h        | 24 ++++++++++++++++--------
 3 files changed, 27 insertions(+), 10 deletions(-)
drivers/md/dm-vdo/dm-vdo-target.c +3 -0
index c6ee8161ba62..288e9b79bf16 100644
@@ -2905,6 +2905,9 @@ static void __exit vdo_exit(void)
 module_init(vdo_init);
 module_exit(vdo_exit);
 
+module_param_named(log_level, vdo_log_level, uint, 0644);
+MODULE_PARM_DESC(log_level, "Log level for log messages");
+
 MODULE_DESCRIPTION(DM_NAME " target for transparent deduplication");
 MODULE_AUTHOR("Red Hat, Inc.");
 MODULE_LICENSE("GPL");
drivers/md/dm-vdo/logger.c +8 -2
index bac28fff622d..5d27cd6483a9 100644
@@ -49,11 +49,17 @@ static const char *const PRIORITY_STRINGS[] = {
 	"DEBUG",
 };
 
-static int log_level = UDS_LOG_INFO;
+int vdo_log_level = UDS_LOG_DEFAULT;
 
 int uds_get_log_level(void)
 {
-	return log_level;
+	int log_level_latch = READ_ONCE(vdo_log_level);
+
+	if (unlikely(log_level_latch > UDS_LOG_MAX)) {
+		log_level_latch = UDS_LOG_DEFAULT;
+		WRITE_ONCE(vdo_log_level, log_level_latch);
+	}
+	return log_level_latch;
 }
 
 int uds_log_string_to_priority(const char *string)
drivers/md/dm-vdo/logger.h +16 -8
index ceb07aa3231f..095532afc9a3 100644
@@ -6,20 +6,28 @@
 #ifndef UDS_LOGGER_H
 #define UDS_LOGGER_H
 
+#include <linux/kern_levels.h>
 #include <linux/module.h>
 #include <linux/ratelimit.h>
 #include <linux/device-mapper.h>
 
 /* Custom logging utilities for UDS */
 
-#define UDS_LOG_EMERG 0
-#define UDS_LOG_ALERT 1
-#define UDS_LOG_CRIT 2
-#define UDS_LOG_ERR 3
-#define UDS_LOG_WARNING 4
-#define UDS_LOG_NOTICE 5
-#define UDS_LOG_INFO 6
-#define UDS_LOG_DEBUG 7
+enum {
+	UDS_LOG_EMERG = LOGLEVEL_EMERG,
+	UDS_LOG_ALERT = LOGLEVEL_ALERT,
+	UDS_LOG_CRIT = LOGLEVEL_CRIT,
+	UDS_LOG_ERR = LOGLEVEL_ERR,
+	UDS_LOG_WARNING = LOGLEVEL_WARNING,
+	UDS_LOG_NOTICE = LOGLEVEL_NOTICE,
+	UDS_LOG_INFO = LOGLEVEL_INFO,
+	UDS_LOG_DEBUG = LOGLEVEL_DEBUG,
+
+	UDS_LOG_MAX = UDS_LOG_DEBUG,
+	UDS_LOG_DEFAULT = UDS_LOG_INFO,
+};
+
+extern int vdo_log_level;
 
 #define DM_MSG_PREFIX "vdo"
 #define UDS_LOGGING_MODULE_NAME DM_NAME ": " DM_MSG_PREFIX
Signature · 1 line
2.42.0
author maintainer
#3 lore raw

PATCH 3/4 dm vdo: document log_level parameter

In reply to Matthew Sakai

From: Ken Raeburn <[email protected]>

---
 Documentation/admin-guide/device-mapper/vdo.rst | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/admin-guide/device-mapper/vdo.rst +7 -0
index a199009979d9..a3572582ead8 100644
@@ -315,6 +315,13 @@ GB of RAM per 1 TB of window. For sparse indexes, the index requires 1 GB
 of RAM per 10 TB of window. The index configuration is set when the target
 is formatted and may not be modified.
 
+Module Parameters
+=================
+
+The vdo driver has a numeric parameter 'log_level' which controls the
+verbosity of logging from the driver. The default setting is 6
+(LOGLEVEL_INFO and more severe messages).
+
 Run-time Usage
 ==============
 
Signature · 1 line
2.42.0
author maintainer
#4 lore raw

PATCH 4/4 dm vdo logger: remove log level to string conversion code

In reply to Matthew Sakai

From: Mike Snitzer <[email protected]>

Was only used by sysfs code, can be reinstated if/when needed.

---
 drivers/md/dm-vdo/logger.c | 53 --------------------------------------
 drivers/md/dm-vdo/logger.h |  4 ---
 2 files changed, 57 deletions(-)
drivers/md/dm-vdo/logger.c +0 -53
index 5d27cd6483a9..80f1e4c62ac6 100644
@@ -16,39 +16,6 @@
 #include "thread-device.h"
 #include "thread-utils.h"
 
-struct priority_name {
-	const char *name;
-	const int priority;
-};
-
-static const struct priority_name PRIORITIES[] = {
-	{ "ALERT", UDS_LOG_ALERT },
-	{ "CRITICAL", UDS_LOG_CRIT },
-	{ "CRIT", UDS_LOG_CRIT },
-	{ "DEBUG", UDS_LOG_DEBUG },
-	{ "EMERGENCY", UDS_LOG_EMERG },
-	{ "EMERG", UDS_LOG_EMERG },
-	{ "ERROR", UDS_LOG_ERR },
-	{ "ERR", UDS_LOG_ERR },
-	{ "INFO", UDS_LOG_INFO },
-	{ "NOTICE", UDS_LOG_NOTICE },
-	{ "PANIC", UDS_LOG_EMERG },
-	{ "WARN", UDS_LOG_WARNING },
-	{ "WARNING", UDS_LOG_WARNING },
-	{ NULL, -1 },
-};
-
-static const char *const PRIORITY_STRINGS[] = {
-	"EMERGENCY",
-	"ALERT",
-	"CRITICAL",
-	"ERROR",
-	"WARN",
-	"NOTICE",
-	"INFO",
-	"DEBUG",
-};
-
 int vdo_log_level = UDS_LOG_DEFAULT;
 
 int uds_get_log_level(void)
@@ -62,26 +29,6 @@ int uds_get_log_level(void)
 	return log_level_latch;
 }
 
-int uds_log_string_to_priority(const char *string)
-{
-	int i;
-
-	for (i = 0; PRIORITIES[i].name != NULL; i++) {
-		if (strcasecmp(string, PRIORITIES[i].name) == 0)
-			return PRIORITIES[i].priority;
-	}
-
-	return UDS_LOG_INFO;
-}
-
-const char *uds_log_priority_to_string(int priority)
-{
-	if ((priority < 0) || (priority >= (int) ARRAY_SIZE(PRIORITY_STRINGS)))
-		return "unknown";
-
-	return PRIORITY_STRINGS[priority];
-}
-
 static const char *get_current_interrupt_type(void)
 {
 	if (in_nmi())
drivers/md/dm-vdo/logger.h +0 -4
index 095532afc9a3..a8cdf46b6fc1 100644
@@ -45,10 +45,6 @@ extern int vdo_log_level;
 
 int uds_get_log_level(void);
 
-int uds_log_string_to_priority(const char *string);
-
-const char *uds_log_priority_to_string(int priority);
-
 void uds_log_embedded_message(int priority, const char *module, const char *prefix,
 			      const char *fmt1, va_list args1, const char *fmt2, ...)
 	__printf(4, 0) __printf(6, 7);
Signature · 1 line
2.42.0
author maintainer
#1 lore raw

PATCH 1/4 dm vdo: remove all sysfs interfaces

In reply to Matthew Sakai

From: Mike Snitzer <[email protected]>

Also update target major version number.

All info is (or will be) accessible through alternative interfaces (e.g. "dmsetup message", module params, etc).

---
 drivers/md/dm-vdo/Makefile           |    4 -
 drivers/md/dm-vdo/dedupe.c           |   70 +-
 drivers/md/dm-vdo/dedupe.h           |    2 +-
 drivers/md/dm-vdo/dm-vdo-target.c    |   44 +-
 drivers/md/dm-vdo/logger.c           |    5 -
 drivers/md/dm-vdo/logger.h           |    2 -
 drivers/md/dm-vdo/pool-sysfs-stats.c | 2063 --------------------------
 drivers/md/dm-vdo/pool-sysfs.c       |  198 ---
 drivers/md/dm-vdo/pool-sysfs.h       |   19 -
 drivers/md/dm-vdo/status-codes.c     |    1 -
 drivers/md/dm-vdo/status-codes.h     |    2 -
 drivers/md/dm-vdo/sysfs.c            |   82 -
 drivers/md/dm-vdo/uds-sysfs.c        |  187 ---
 drivers/md/dm-vdo/uds-sysfs.h        |   12 -
 drivers/md/dm-vdo/vdo.c              |   54 +-
 drivers/md/dm-vdo/vdo.h              |   13 -
 16 files changed, 9 insertions(+), 2749 deletions(-)
 delete mode 100644 drivers/md/dm-vdo/pool-sysfs-stats.c
 delete mode 100644 drivers/md/dm-vdo/pool-sysfs.c
 delete mode 100644 drivers/md/dm-vdo/pool-sysfs.h
 delete mode 100644 drivers/md/dm-vdo/sysfs.c
 delete mode 100644 drivers/md/dm-vdo/uds-sysfs.c
 delete mode 100644 drivers/md/dm-vdo/uds-sysfs.h
drivers/md/dm-vdo/Makefile +0 -4
index 502a7a0acbdb..33e09abc6acd 100644
@@ -28,19 +28,15 @@ dm-vdo-objs := \
 	packer.o \
 	permassert.o \
 	physical-zone.o \
-	pool-sysfs.o \
-	pool-sysfs-stats.o \
 	priority-table.o \
 	recovery-journal.o \
 	repair.o \
 	slab-depot.o \
 	status-codes.o \
 	string-utils.o \
-	sysfs.o \
 	thread-device.o \
 	thread-registry.o \
 	thread-utils.o \
-	uds-sysfs.o \
 	vdo.o \
 	vio.o \
 	wait-queue.o \
drivers/md/dm-vdo/dedupe.c +3 -67

107 lines not on this page · raw message

drivers/md/dm-vdo/dedupe.h +1 -1
index 1566fc972ea7..9000d6f3eece 100644
@@ -97,7 +97,7 @@ u64 vdo_get_dedupe_index_timeout_count(struct hash_zones *zones);
 
 int vdo_message_dedupe_index(struct hash_zones *zones, const char *name);
 
-int vdo_add_dedupe_index_sysfs(struct hash_zones *zones);
+void vdo_set_dedupe_state_normal(struct hash_zones *zones);
 
 void vdo_start_dedupe_index(struct hash_zones *zones, bool create_flag);
 
drivers/md/dm-vdo/dm-vdo-target.c +4 -40

105 lines not on this page · raw message

drivers/md/dm-vdo/logger.c +0 -5
index a50edb0331fc..bac28fff622d 100644
@@ -56,11 +56,6 @@ int uds_get_log_level(void)
 	return log_level;
 }
 
-void uds_set_log_level(int new_log_level)
-{
-	log_level = new_log_level;
-}
-
 int uds_log_string_to_priority(const char *string)
 {
 	int i;
drivers/md/dm-vdo/logger.h +0 -2
index 4e2f18042ba7..ceb07aa3231f 100644
@@ -37,8 +37,6 @@
 
 int uds_get_log_level(void);
 
-void uds_set_log_level(int new_log_level);
-
 int uds_log_string_to_priority(const char *string);
 
 const char *uds_log_priority_to_string(int priority);
drivers/md/dm-vdo/pool-sysfs-stats.c deleted +0 -2063

2,063 lines not on this page · raw message

drivers/md/dm-vdo/pool-sysfs.c deleted +0 -198

198 lines not on this page · raw message

drivers/md/dm-vdo/pool-sysfs.h deleted +0 -19
deleted file mode 100644
index 00e680924dc1..000000000000
@@ -1,19 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright 2023 Red Hat
- */
-
-#ifndef VDO_POOL_SYSFS_H
-#define VDO_POOL_SYSFS_H
-
-#include <linux/kobject.h>
-
-/* The kobj_type used for setting up the kernel layer kobject. */
-extern const struct kobj_type vdo_directory_type;
-
-/* The sysfs_ops used for the "statistics" subdirectory. */
-extern const struct sysfs_ops vdo_pool_stats_sysfs_ops;
-/* The attribute used for the "statistics" subdirectory. */
-extern struct attribute *vdo_pool_stats_attrs[];
-
-#endif /* VDO_POOL_SYSFS_H */
drivers/md/dm-vdo/status-codes.c +0 -1
index 92c42b8bbb8b..42e87b2344bc 100644
@@ -38,7 +38,6 @@ const struct error_info vdo_status_list[] = {
 	{ "VDO_BAD_NONCE", "Bad nonce" },
 	{ "VDO_JOURNAL_OVERFLOW", "Journal sequence number overflow" },
 	{ "VDO_INVALID_ADMIN_STATE", "Invalid operation for current state" },
-	{ "VDO_CANT_ADD_SYSFS_NODE", "Failed to add sysfs node" },
 };
 
 static atomic_t vdo_status_codes_registered = ATOMIC_INIT(0);
drivers/md/dm-vdo/status-codes.h +0 -2
index eb847def8eb4..72da04159f88 100644
@@ -72,8 +72,6 @@ enum vdo_status_codes {
 	VDO_JOURNAL_OVERFLOW,
 	/* the VDO is not in a state to perform an admin operation */
 	VDO_INVALID_ADMIN_STATE,
-	/* failure adding a sysfs node */
-	VDO_CANT_ADD_SYSFS_NODE,
 	/* one more than last error code */
 	VDO_STATUS_CODE_LAST,
 	VDO_STATUS_CODE_BLOCK_END = VDO_ERRORS_BLOCK_END
drivers/md/dm-vdo/sysfs.c deleted +0 -82

82 lines not on this page · raw message

drivers/md/dm-vdo/uds-sysfs.c deleted +0 -187

187 lines not on this page · raw message

drivers/md/dm-vdo/uds-sysfs.h deleted +0 -12
deleted file mode 100644
index c3d00a7187bd..000000000000
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright 2023 Red Hat
- */
-
-#ifndef UDS_SYSFS_H
-#define UDS_SYSFS_H
-
-int uds_init_sysfs(void);
-void uds_put_sysfs(void);
-
-#endif  /* UDS_SYSFS_H */
drivers/md/dm-vdo/vdo.c +1 -53

78 lines not on this page · raw message

drivers/md/dm-vdo/vdo.h +0 -13
index 01558fc67f24..483ae873e002 100644
@@ -10,7 +10,6 @@
 #include <linux/blk_types.h>
 #include <linux/completion.h>
 #include <linux/dm-kcopyd.h>
-#include <linux/kobject.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
 
@@ -248,11 +247,6 @@ struct vdo {
 	struct vdo_statistics stats_buffer;
 	/* Protects the stats_buffer */
 	struct mutex stats_mutex;
-	/* true if sysfs directory is set up */
-	bool sysfs_added;
-	/* Used when shutting down the sysfs statistics */
-	struct completion stats_shutdown;
-
 
 	/* A list of all device_configs referencing this vdo */
 	struct list_head device_config_list;
@@ -264,15 +258,10 @@ struct vdo {
 	u64 starting_sector_offset;
 	struct volume_geometry geometry;
 
-	/* For sysfs */
-	struct kobject vdo_directory;
-	struct kobject stats_directory;
-
 	/* N blobs of context data for LZ4 code, one per CPU thread. */
 	char **compression_context;
 };
 
-
 /**
  * vdo_uses_bio_ack_queue() - Indicate whether the vdo is configured to use a separate work queue
  *                            for acknowledging received and processed bios.
@@ -315,8 +304,6 @@ void vdo_destroy(struct vdo *vdo);
 
 void vdo_load_super_block(struct vdo *vdo, struct vdo_completion *parent);
 
-int __must_check vdo_add_sysfs_stats_dir(struct vdo *vdo);
-
 struct block_device * __must_check vdo_get_backing_device(const struct vdo *vdo);
 
 const char * __must_check vdo_get_device_name(const struct dm_target *target);
Signature · 1 line
2.42.0