Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VDO-5662, VDO-5663] Remove sysfs from upstream #52

Merged
merged 4 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions Documentation/admin-guide/device-mapper/vdo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
==============

Expand Down
4 changes: 0 additions & 4 deletions drivers/md/dm-vdo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
70 changes: 3 additions & 67 deletions drivers/md/dm-vdo/dedupe.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
#include <linux/atomic.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/kobject.h>
#include <linux/list.h>
#include <linux/ratelimit.h>
#include <linux/spinlock.h>
Expand Down Expand Up @@ -279,7 +278,6 @@ struct hash_lock {

struct hash_zones {
struct action_manager *manager;
struct kobject dedupe_directory;
struct uds_parameters parameters;
struct uds_index_session *index_session;
struct ratelimit_state ratelimiter;
Expand Down Expand Up @@ -2022,56 +2020,6 @@ void vdo_share_compressed_write_lock(struct data_vio *data_vio,
VDO_ASSERT_LOG_ONLY(claimed, "impossible to fail to claim an initial increment");
}

static void dedupe_kobj_release(struct kobject *directory)
{
vdo_free(container_of(directory, struct hash_zones, dedupe_directory));
}

static ssize_t dedupe_status_show(struct kobject *directory, struct attribute *attr,
char *buf)
{
struct uds_attribute *ua = container_of(attr, struct uds_attribute, attr);
struct hash_zones *zones = container_of(directory, struct hash_zones,
dedupe_directory);

if (ua->show_string != NULL)
return sprintf(buf, "%s\n", ua->show_string(zones));
else
return -EINVAL;
}

static ssize_t dedupe_status_store(struct kobject *kobj __always_unused,
struct attribute *attr __always_unused,
const char *buf __always_unused,
size_t length __always_unused)
{
return -EINVAL;
}

/*----------------------------------------------------------------------*/

static const struct sysfs_ops dedupe_sysfs_ops = {
.show = dedupe_status_show,
.store = dedupe_status_store,
};

static struct uds_attribute dedupe_status_attribute = {
.attr = {.name = "status", .mode = 0444, },
.show_string = vdo_get_dedupe_index_state_name,
};

static struct attribute *dedupe_attrs[] = {
&dedupe_status_attribute.attr,
NULL,
};
ATTRIBUTE_GROUPS(dedupe);

static const struct kobj_type dedupe_directory_type = {
.release = dedupe_kobj_release,
.sysfs_ops = &dedupe_sysfs_ops,
.default_groups = dedupe_groups,
};

static void start_uds_queue(void *ptr)
{
/*
Expand Down Expand Up @@ -2266,7 +2214,6 @@ static int initialize_index(struct vdo *vdo, struct hash_zones *zones)
vdo_initialize_completion(&zones->completion, vdo, VDO_HASH_ZONES_COMPLETION);
vdo_set_completion_callback(&zones->completion, change_dedupe_state,
vdo->thread_config.dedupe_thread);
kobject_init(&zones->dedupe_directory, &dedupe_directory_type);
return VDO_SUCCESS;
}

Expand Down Expand Up @@ -2537,10 +2484,7 @@ void vdo_free_hash_zones(struct hash_zones *zones)
vdo_finish_dedupe_index(zones);

ratelimit_state_exit(&zones->ratelimiter);
if (vdo_get_admin_state_code(&zones->state) == VDO_ADMIN_STATE_NEW)
vdo_free(zones);
else
kobject_put(&zones->dedupe_directory);
vdo_free(zones);
}

static void initiate_suspend_index(struct admin_state *state)
Expand Down Expand Up @@ -3047,17 +2991,9 @@ int vdo_message_dedupe_index(struct hash_zones *zones, const char *name)
return -EINVAL;
}

int vdo_add_dedupe_index_sysfs(struct hash_zones *zones)
void vdo_set_dedupe_state_normal(struct hash_zones *zones)
{
int result = kobject_add(&zones->dedupe_directory,
&zones->completion.vdo->vdo_directory, "dedupe");

if (result == 0) {
vdo_set_admin_state_code(&zones->state,
VDO_ADMIN_STATE_NORMAL_OPERATION);
}

return result;
vdo_set_admin_state_code(&zones->state, VDO_ADMIN_STATE_NORMAL_OPERATION);
}

/* If create_flag, create a new index without first attempting to load an existing index. */
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-vdo/dedupe.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
47 changes: 7 additions & 40 deletions drivers/md/dm-vdo/dm-vdo-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "logger.h"
#include "memory-alloc.h"
#include "message-stats.h"
#include "pool-sysfs.h"
#include "recovery-journal.h"
#include "repair.h"
#include "slab-depot.h"
Expand All @@ -36,7 +35,6 @@
#include "thread-device.h"
#include "thread-registry.h"
#include "types.h"
#include "uds-sysfs.h"
#include "vdo.h"
#include "vio.h"

Expand All @@ -54,7 +52,6 @@ enum admin_phases {
GROW_PHYSICAL_PHASE_END,
GROW_PHYSICAL_PHASE_ERROR,
LOAD_PHASE_START,
LOAD_PHASE_STATS,
LOAD_PHASE_LOAD_DEPOT,
LOAD_PHASE_MAKE_DIRTY,
LOAD_PHASE_PREPARE_TO_ALLOCATE,
Expand Down Expand Up @@ -104,7 +101,6 @@ static const char * const ADMIN_PHASE_NAMES[] = {
"GROW_PHYSICAL_PHASE_END",
"GROW_PHYSICAL_PHASE_ERROR",
"LOAD_PHASE_START",
"LOAD_PHASE_STATS",
"LOAD_PHASE_LOAD_DEPOT",
"LOAD_PHASE_MAKE_DIRTY",
"LOAD_PHASE_PREPARE_TO_ALLOCATE",
Expand Down Expand Up @@ -947,8 +943,8 @@ static void vdo_io_hints(struct dm_target *ti, struct queue_limits *limits)
* blocked task warnings in kernel logs. In order to avoid these warnings, we choose to
* use the smallest reasonable value.
*
* The value is displayed in sysfs, and also used by dm-thin to determine whether to pass
* down discards. The block layer splits large discards on this boundary when this is set.
* The value is used by dm-thin to determine whether to pass down discards. The block layer
* splits large discards on this boundary when this is set.
*/
limits->max_discard_sectors =
(vdo->device_config->max_discard_blocks * VDO_SECTORS_PER_BLOCK);
Expand Down Expand Up @@ -2174,32 +2170,6 @@ static enum slab_depot_load_type get_load_type(struct vdo *vdo)
return VDO_SLAB_DEPOT_NORMAL_LOAD;
}

/**
* vdo_initialize_kobjects() - Initialize the vdo sysfs directory.
* @vdo: The vdo being initialized.
*
* Return: VDO_SUCCESS or an error code.
*/
static int vdo_initialize_kobjects(struct vdo *vdo)
{
int result;
struct dm_target *target = vdo->device_config->owning_target;
struct mapped_device *md = dm_table_get_md(target->table);

kobject_init(&vdo->vdo_directory, &vdo_directory_type);
vdo->sysfs_added = true;
result = kobject_add(&vdo->vdo_directory, &disk_to_dev(dm_disk(md))->kobj,
"vdo");
if (result != 0)
return VDO_CANT_ADD_SYSFS_NODE;

result = vdo_add_dedupe_index_sysfs(vdo->hash_zones);
if (result != 0)
return VDO_CANT_ADD_SYSFS_NODE;

return vdo_add_sysfs_stats_dir(vdo);
}

/**
* load_callback() - Callback to do the destructive parts of loading a VDO.
* @completion: The sub-task completion.
Expand All @@ -2225,11 +2195,8 @@ static void load_callback(struct vdo_completion *completion)
vdo_allow_read_only_mode_entry(completion);
return;

case LOAD_PHASE_STATS:
vdo_continue_completion(completion, vdo_initialize_kobjects(vdo));
return;

case LOAD_PHASE_LOAD_DEPOT:
vdo_set_dedupe_state_normal(vdo->hash_zones);
if (vdo_is_read_only(vdo)) {
/*
* In read-only mode we don't use the allocator and it may not even be
Expand Down Expand Up @@ -2866,7 +2833,7 @@ static void vdo_resume(struct dm_target *ti)
static struct target_type vdo_target_bio = {
.features = DM_TARGET_SINGLETON,
.name = "vdo",
.version = { 8, 2, 0 },
.version = { 9, 0, 0 },
.module = THIS_MODULE,
.ctr = vdo_ctr,
.dtr = vdo_dtr,
Expand Down Expand Up @@ -2905,8 +2872,6 @@ static int __init vdo_init(void)

/* Memory tracking must be initialized first for accurate accounting. */
vdo_memory_init();
uds_init_sysfs();

vdo_initialize_thread_device_registry();
vdo_initialize_device_registry_once();
uds_log_info("loaded version %s", CURRENT_VERSION);
Expand All @@ -2933,14 +2898,16 @@ static int __init vdo_init(void)
static void __exit vdo_exit(void)
{
vdo_module_destroy();
uds_put_sysfs();
/* Memory tracking cleanup must be done last. */
vdo_memory_exit();
}

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");
64 changes: 6 additions & 58 deletions drivers/md/dm-vdo/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,69 +16,17 @@
#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",
};

static int log_level = UDS_LOG_INFO;
int vdo_log_level = UDS_LOG_DEFAULT;

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;
int log_level_latch = READ_ONCE(vdo_log_level);

for (i = 0; PRIORITIES[i].name != NULL; i++) {
if (strcasecmp(string, PRIORITIES[i].name) == 0)
return PRIORITIES[i].priority;
if (unlikely(log_level_latch > UDS_LOG_MAX)) {
log_level_latch = UDS_LOG_DEFAULT;
WRITE_ONCE(vdo_log_level, log_level_latch);
}

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];
return log_level_latch;
}

static const char *get_current_interrupt_type(void)
Expand Down
Loading
Loading