Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

fix a bug of sysctl for centos 6.3 kernel 2.6.32-279 #218

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/flashcache_procfs.c
Expand Up @@ -68,6 +68,13 @@ static char *flashcache_cons_procfs_cachename(struct cache_c *dmc, char *path_co
static char *flashcache_cons_sysctl_devname(struct cache_c *dmc);

#define FLASHCACHE_PROC_ROOTDIR_NAME "flashcache"
static struct ctl_path cache_path[] = {
{ .procname = "dev", .ctl_name = CTL_DEV, },
{ .procname = FLASHCACHE_PROC_ROOTDIR_NAME, .ctl_name = CTL_UNNUMBERED, },
{ },
};

static struct ctl_table_header *sysctl_cache_dir = NULL;

static int
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
Expand Down Expand Up @@ -805,9 +812,9 @@ flashcache_writeback_sysctl_register(struct cache_c *dmc)
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
t->sysctl_header = register_sysctl_table(t->root, 0);
t->sysctl_header = register_sysctl_paths(cache_path, t->dev, 0);
#else
t->sysctl_header = register_sysctl_table(t->root);
t->sysctl_header = register_sysctl_paths(cache_path, t->dev);
#endif
if (t->sysctl_header == NULL)
goto out;
Expand Down Expand Up @@ -1130,6 +1137,7 @@ static struct file_operations flashcache_version_operations = {
void
flashcache_module_procfs_init(void)
{
static struct ctl_table empty[1];
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *entry;

Expand All @@ -1145,6 +1153,11 @@ flashcache_module_procfs_init(void)

}
#endif /* CONFIG_PROC_FS */

sysctl_cache_dir = register_sysctl_paths(cache_path, empty);
if ( sysctl_cache_dir == NULL ) {
printk(KERN_ERR "Failed to create sysctl path for cache");
}
}

void
Expand All @@ -1154,6 +1167,10 @@ flashcache_module_procfs_release(void)
(void)remove_proc_entry("flashcache/flashcache_version", NULL);
(void)remove_proc_entry("flashcache", NULL);
#endif /* CONFIG_PROC_FS */

if ( sysctl_cache_dir != NULL ) {
unregister_sysctl_table(sysctl_cache_dir);
}
}

static char *
Expand Down