Commit 07a3b8ed authored by Christoph Hellwig's avatar Christoph Hellwig

jfs: simplify procfs code

Use remove_proc_subtree to remove the whole subtree on cleanup, and
unwind the registration loop into individual calls.  Switch to use
proc_create_seq where applicable.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 247dbed8
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#ifdef PROC_FS_JFS /* see jfs_debug.h */ #ifdef PROC_FS_JFS /* see jfs_debug.h */
static struct proc_dir_entry *base;
#ifdef CONFIG_JFS_DEBUG #ifdef CONFIG_JFS_DEBUG
static int jfs_loglevel_proc_show(struct seq_file *m, void *v) static int jfs_loglevel_proc_show(struct seq_file *m, void *v)
{ {
...@@ -66,43 +65,29 @@ static const struct file_operations jfs_loglevel_proc_fops = { ...@@ -66,43 +65,29 @@ static const struct file_operations jfs_loglevel_proc_fops = {
}; };
#endif #endif
static struct {
const char *name;
const struct file_operations *proc_fops;
} Entries[] = {
#ifdef CONFIG_JFS_STATISTICS
{ "lmstats", &jfs_lmstats_proc_fops, },
{ "txstats", &jfs_txstats_proc_fops, },
{ "xtstat", &jfs_xtstat_proc_fops, },
{ "mpstat", &jfs_mpstat_proc_fops, },
#endif
#ifdef CONFIG_JFS_DEBUG
{ "TxAnchor", &jfs_txanchor_proc_fops, },
{ "loglevel", &jfs_loglevel_proc_fops }
#endif
};
#define NPROCENT ARRAY_SIZE(Entries)
void jfs_proc_init(void) void jfs_proc_init(void)
{ {
int i; struct proc_dir_entry *base;
if (!(base = proc_mkdir("fs/jfs", NULL))) base = proc_mkdir("fs/jfs", NULL);
if (!base)
return; return;
for (i = 0; i < NPROCENT; i++) #ifdef CONFIG_JFS_STATISTICS
proc_create(Entries[i].name, 0, base, Entries[i].proc_fops); proc_create_single("lmstats", 0, base, jfs_lmstats_proc_show);
proc_create_single("txstats", 0, base, jfs_txstats_proc_show);
proc_create_single("xtstat", 0, base, jfs_xtstat_proc_show);
proc_create_single("mpstat", 0, base, jfs_mpstat_proc_show);
#endif
#ifdef CONFIG_JFS_DEBUG
proc_create_single("TxAnchor", 0, base, jfs_txanchor_proc_show);
proc_create("loglevel", 0, base, &jfs_loglevel_proc_fops);
#endif
} }
void jfs_proc_clean(void) void jfs_proc_clean(void)
{ {
int i; remove_proc_subtree("fs/jfs", NULL);
if (base) {
for (i = 0; i < NPROCENT; i++)
remove_proc_entry(Entries[i].name, base);
remove_proc_entry("fs/jfs", NULL);
}
} }
#endif /* PROC_FS_JFS */ #endif /* PROC_FS_JFS */
...@@ -62,7 +62,7 @@ extern void jfs_proc_clean(void); ...@@ -62,7 +62,7 @@ extern void jfs_proc_clean(void);
extern int jfsloglevel; extern int jfsloglevel;
extern const struct file_operations jfs_txanchor_proc_fops; int jfs_txanchor_proc_show(struct seq_file *m, void *v);
/* information message: e.g., configuration, major event */ /* information message: e.g., configuration, major event */
#define jfs_info(fmt, arg...) do { \ #define jfs_info(fmt, arg...) do { \
...@@ -105,10 +105,10 @@ extern const struct file_operations jfs_txanchor_proc_fops; ...@@ -105,10 +105,10 @@ extern const struct file_operations jfs_txanchor_proc_fops;
* ---------- * ----------
*/ */
#ifdef CONFIG_JFS_STATISTICS #ifdef CONFIG_JFS_STATISTICS
extern const struct file_operations jfs_lmstats_proc_fops; int jfs_lmstats_proc_show(struct seq_file *m, void *v);
extern const struct file_operations jfs_txstats_proc_fops; int jfs_txstats_proc_show(struct seq_file *m, void *v);
extern const struct file_operations jfs_mpstat_proc_fops; int jfs_mpstat_proc_show(struct seq_file *m, void *v);
extern const struct file_operations jfs_xtstat_proc_fops; int jfs_xtstat_proc_show(struct seq_file *m, void *v);
#define INCREMENT(x) ((x)++) #define INCREMENT(x) ((x)++)
#define DECREMENT(x) ((x)--) #define DECREMENT(x) ((x)--)
......
...@@ -2493,7 +2493,7 @@ int lmLogFormat(struct jfs_log *log, s64 logAddress, int logSize) ...@@ -2493,7 +2493,7 @@ int lmLogFormat(struct jfs_log *log, s64 logAddress, int logSize)
} }
#ifdef CONFIG_JFS_STATISTICS #ifdef CONFIG_JFS_STATISTICS
static int jfs_lmstats_proc_show(struct seq_file *m, void *v) int jfs_lmstats_proc_show(struct seq_file *m, void *v)
{ {
seq_printf(m, seq_printf(m,
"JFS Logmgr stats\n" "JFS Logmgr stats\n"
...@@ -2510,16 +2510,4 @@ static int jfs_lmstats_proc_show(struct seq_file *m, void *v) ...@@ -2510,16 +2510,4 @@ static int jfs_lmstats_proc_show(struct seq_file *m, void *v)
lmStat.partial_page); lmStat.partial_page);
return 0; return 0;
} }
static int jfs_lmstats_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, jfs_lmstats_proc_show, NULL);
}
const struct file_operations jfs_lmstats_proc_fops = {
.open = jfs_lmstats_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif /* CONFIG_JFS_STATISTICS */ #endif /* CONFIG_JFS_STATISTICS */
...@@ -815,7 +815,7 @@ void __invalidate_metapages(struct inode *ip, s64 addr, int len) ...@@ -815,7 +815,7 @@ void __invalidate_metapages(struct inode *ip, s64 addr, int len)
} }
#ifdef CONFIG_JFS_STATISTICS #ifdef CONFIG_JFS_STATISTICS
static int jfs_mpstat_proc_show(struct seq_file *m, void *v) int jfs_mpstat_proc_show(struct seq_file *m, void *v)
{ {
seq_printf(m, seq_printf(m,
"JFS Metapage statistics\n" "JFS Metapage statistics\n"
...@@ -828,16 +828,4 @@ static int jfs_mpstat_proc_show(struct seq_file *m, void *v) ...@@ -828,16 +828,4 @@ static int jfs_mpstat_proc_show(struct seq_file *m, void *v)
mpStat.lockwait); mpStat.lockwait);
return 0; return 0;
} }
static int jfs_mpstat_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, jfs_mpstat_proc_show, NULL);
}
const struct file_operations jfs_mpstat_proc_fops = {
.open = jfs_mpstat_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif #endif
...@@ -2998,7 +2998,7 @@ int jfs_sync(void *arg) ...@@ -2998,7 +2998,7 @@ int jfs_sync(void *arg)
} }
#if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_DEBUG) #if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_DEBUG)
static int jfs_txanchor_proc_show(struct seq_file *m, void *v) int jfs_txanchor_proc_show(struct seq_file *m, void *v)
{ {
char *freewait; char *freewait;
char *freelockwait; char *freelockwait;
...@@ -3032,22 +3032,10 @@ static int jfs_txanchor_proc_show(struct seq_file *m, void *v) ...@@ -3032,22 +3032,10 @@ static int jfs_txanchor_proc_show(struct seq_file *m, void *v)
list_empty(&TxAnchor.unlock_queue) ? "" : "not "); list_empty(&TxAnchor.unlock_queue) ? "" : "not ");
return 0; return 0;
} }
static int jfs_txanchor_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, jfs_txanchor_proc_show, NULL);
}
const struct file_operations jfs_txanchor_proc_fops = {
.open = jfs_txanchor_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif #endif
#if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_STATISTICS) #if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_STATISTICS)
static int jfs_txstats_proc_show(struct seq_file *m, void *v) int jfs_txstats_proc_show(struct seq_file *m, void *v)
{ {
seq_printf(m, seq_printf(m,
"JFS TxStats\n" "JFS TxStats\n"
...@@ -3072,16 +3060,4 @@ static int jfs_txstats_proc_show(struct seq_file *m, void *v) ...@@ -3072,16 +3060,4 @@ static int jfs_txstats_proc_show(struct seq_file *m, void *v)
TxStat.txLockAlloc_freelock); TxStat.txLockAlloc_freelock);
return 0; return 0;
} }
static int jfs_txstats_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, jfs_txstats_proc_show, NULL);
}
const struct file_operations jfs_txstats_proc_fops = {
.open = jfs_txstats_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif #endif
...@@ -3874,7 +3874,7 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size) ...@@ -3874,7 +3874,7 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
} }
#ifdef CONFIG_JFS_STATISTICS #ifdef CONFIG_JFS_STATISTICS
static int jfs_xtstat_proc_show(struct seq_file *m, void *v) int jfs_xtstat_proc_show(struct seq_file *m, void *v)
{ {
seq_printf(m, seq_printf(m,
"JFS Xtree statistics\n" "JFS Xtree statistics\n"
...@@ -3887,16 +3887,4 @@ static int jfs_xtstat_proc_show(struct seq_file *m, void *v) ...@@ -3887,16 +3887,4 @@ static int jfs_xtstat_proc_show(struct seq_file *m, void *v)
xtStat.split); xtStat.split);
return 0; return 0;
} }
static int jfs_xtstat_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, jfs_xtstat_proc_show, NULL);
}
const struct file_operations jfs_xtstat_proc_fops = {
.open = jfs_xtstat_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment