dect
/
linux-2.6
Archived
13
0
Fork 0

JFS: switch to seq_files

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
This commit is contained in:
Alexey Dobriyan 2008-05-13 08:22:10 -05:00 committed by Dave Kleikamp
parent 88f85a55c0
commit b2e03ca748
6 changed files with 120 additions and 139 deletions

View File

@ -21,6 +21,7 @@
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "jfs_incore.h" #include "jfs_incore.h"
#include "jfs_filsys.h" #include "jfs_filsys.h"
@ -30,29 +31,19 @@
static struct proc_dir_entry *base; static struct proc_dir_entry *base;
#ifdef CONFIG_JFS_DEBUG #ifdef CONFIG_JFS_DEBUG
static int loglevel_read(char *page, char **start, off_t off, static int jfs_loglevel_proc_show(struct seq_file *m, void *v)
int count, int *eof, void *data)
{ {
int len; seq_printf(m, "%d\n", jfsloglevel);
return 0;
len = sprintf(page, "%d\n", jfsloglevel);
len -= off;
*start = page + off;
if (len > count)
len = count;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
static int loglevel_write(struct file *file, const char __user *buffer, static int jfs_loglevel_proc_open(struct inode *inode, struct file *file)
unsigned long count, void *data) {
return single_open(file, jfs_loglevel_proc_show, NULL);
}
static ssize_t jfs_loglevel_proc_write(struct file *file,
const char __user *buffer, size_t count, loff_t *ppos)
{ {
char c; char c;
@ -65,22 +56,30 @@ static int loglevel_write(struct file *file, const char __user *buffer,
jfsloglevel = c - '0'; jfsloglevel = c - '0';
return count; return count;
} }
static const struct file_operations jfs_loglevel_proc_fops = {
.owner = THIS_MODULE,
.open = jfs_loglevel_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = jfs_loglevel_proc_write,
};
#endif #endif
static struct { static struct {
const char *name; const char *name;
read_proc_t *read_fn; const struct file_operations *proc_fops;
write_proc_t *write_fn;
} Entries[] = { } Entries[] = {
#ifdef CONFIG_JFS_STATISTICS #ifdef CONFIG_JFS_STATISTICS
{ "lmstats", jfs_lmstats_read, }, { "lmstats", &jfs_lmstats_proc_fops, },
{ "txstats", jfs_txstats_read, }, { "txstats", &jfs_txstats_proc_fops, },
{ "xtstat", jfs_xtstat_read, }, { "xtstat", &jfs_xtstat_proc_fops, },
{ "mpstat", jfs_mpstat_read, }, { "mpstat", &jfs_mpstat_proc_fops, },
#endif #endif
#ifdef CONFIG_JFS_DEBUG #ifdef CONFIG_JFS_DEBUG
{ "TxAnchor", jfs_txanchor_read, }, { "TxAnchor", &jfs_txanchor_proc_fops, },
{ "loglevel", loglevel_read, loglevel_write } { "loglevel", &jfs_loglevel_proc_fops }
#endif #endif
}; };
#define NPROCENT ARRAY_SIZE(Entries) #define NPROCENT ARRAY_SIZE(Entries)
@ -93,13 +92,8 @@ void jfs_proc_init(void)
return; return;
base->owner = THIS_MODULE; base->owner = THIS_MODULE;
for (i = 0; i < NPROCENT; i++) { for (i = 0; i < NPROCENT; i++)
struct proc_dir_entry *p; proc_create(Entries[i].name, 0, base, Entries[i].proc_fops);
if ((p = create_proc_entry(Entries[i].name, 0, base))) {
p->read_proc = Entries[i].read_fn;
p->write_proc = Entries[i].write_fn;
}
}
} }
void jfs_proc_clean(void) void jfs_proc_clean(void)

View File

@ -62,7 +62,7 @@ extern void jfs_proc_clean(void);
extern int jfsloglevel; extern int jfsloglevel;
extern int jfs_txanchor_read(char *, char **, off_t, int, int *, void *); extern const struct file_operations jfs_txanchor_proc_fops;
/* 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 int jfs_txanchor_read(char *, char **, off_t, int, int *, void *);
* ---------- * ----------
*/ */
#ifdef CONFIG_JFS_STATISTICS #ifdef CONFIG_JFS_STATISTICS
extern int jfs_lmstats_read(char *, char **, off_t, int, int *, void *); extern const struct file_operations jfs_lmstats_proc_fops;
extern int jfs_txstats_read(char *, char **, off_t, int, int *, void *); extern const struct file_operations jfs_txstats_proc_fops;
extern int jfs_mpstat_read(char *, char **, off_t, int, int *, void *); extern const struct file_operations jfs_mpstat_proc_fops;
extern int jfs_xtstat_read(char *, char **, off_t, int, int *, void *); extern const struct file_operations jfs_xtstat_proc_fops;
#define INCREMENT(x) ((x)++) #define INCREMENT(x) ((x)++)
#define DECREMENT(x) ((x)--) #define DECREMENT(x) ((x)--)

View File

@ -69,6 +69,7 @@
#include <linux/freezer.h> #include <linux/freezer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/seq_file.h>
#include "jfs_incore.h" #include "jfs_incore.h"
#include "jfs_filsys.h" #include "jfs_filsys.h"
#include "jfs_metapage.h" #include "jfs_metapage.h"
@ -2503,13 +2504,9 @@ exit:
} }
#ifdef CONFIG_JFS_STATISTICS #ifdef CONFIG_JFS_STATISTICS
int jfs_lmstats_read(char *buffer, char **start, off_t offset, int length, static int jfs_lmstats_proc_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
int len = 0; seq_printf(m,
off_t begin;
len += sprintf(buffer,
"JFS Logmgr stats\n" "JFS Logmgr stats\n"
"================\n" "================\n"
"commits = %d\n" "commits = %d\n"
@ -2522,19 +2519,19 @@ int jfs_lmstats_read(char *buffer, char **start, off_t offset, int length,
lmStat.pagedone, lmStat.pagedone,
lmStat.full_page, lmStat.full_page,
lmStat.partial_page); lmStat.partial_page);
return 0;
begin = offset;
*start = buffer + begin;
len -= begin;
if (len > length)
len = length;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
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 = {
.owner = THIS_MODULE,
.open = jfs_lmstats_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif /* CONFIG_JFS_STATISTICS */ #endif /* CONFIG_JFS_STATISTICS */

View File

@ -19,10 +19,12 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/module.h>
#include <linux/bio.h> #include <linux/bio.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/mempool.h> #include <linux/mempool.h>
#include <linux/seq_file.h>
#include "jfs_incore.h" #include "jfs_incore.h"
#include "jfs_superblock.h" #include "jfs_superblock.h"
#include "jfs_filsys.h" #include "jfs_filsys.h"
@ -804,13 +806,9 @@ void __invalidate_metapages(struct inode *ip, s64 addr, int len)
} }
#ifdef CONFIG_JFS_STATISTICS #ifdef CONFIG_JFS_STATISTICS
int jfs_mpstat_read(char *buffer, char **start, off_t offset, int length, static int jfs_mpstat_proc_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
int len = 0; seq_printf(m,
off_t begin;
len += sprintf(buffer,
"JFS Metapage statistics\n" "JFS Metapage statistics\n"
"=======================\n" "=======================\n"
"page allocations = %d\n" "page allocations = %d\n"
@ -819,19 +817,19 @@ int jfs_mpstat_read(char *buffer, char **start, off_t offset, int length,
mpStat.pagealloc, mpStat.pagealloc,
mpStat.pagefree, mpStat.pagefree,
mpStat.lockwait); mpStat.lockwait);
return 0;
begin = offset;
*start = buffer + begin;
len -= begin;
if (len > length)
len = length;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
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 = {
.owner = THIS_MODULE,
.open = jfs_mpstat_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif #endif

View File

@ -49,6 +49,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/seq_file.h>
#include "jfs_incore.h" #include "jfs_incore.h"
#include "jfs_inode.h" #include "jfs_inode.h"
#include "jfs_filsys.h" #include "jfs_filsys.h"
@ -3009,11 +3010,8 @@ int jfs_sync(void *arg)
} }
#if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_DEBUG) #if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_DEBUG)
int jfs_txanchor_read(char *buffer, char **start, off_t offset, int length, static int jfs_txanchor_proc_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
int len = 0;
off_t begin;
char *freewait; char *freewait;
char *freelockwait; char *freelockwait;
char *lowlockwait; char *lowlockwait;
@ -3025,7 +3023,7 @@ int jfs_txanchor_read(char *buffer, char **start, off_t offset, int length,
lowlockwait = lowlockwait =
waitqueue_active(&TxAnchor.lowlockwait) ? "active" : "empty"; waitqueue_active(&TxAnchor.lowlockwait) ? "active" : "empty";
len += sprintf(buffer, seq_printf(m,
"JFS TxAnchor\n" "JFS TxAnchor\n"
"============\n" "============\n"
"freetid = %d\n" "freetid = %d\n"
@ -3044,31 +3042,27 @@ int jfs_txanchor_read(char *buffer, char **start, off_t offset, int length,
TxAnchor.tlocksInUse, TxAnchor.tlocksInUse,
jfs_tlocks_low, jfs_tlocks_low,
list_empty(&TxAnchor.unlock_queue) ? "" : "not "); list_empty(&TxAnchor.unlock_queue) ? "" : "not ");
return 0;
begin = offset;
*start = buffer + begin;
len -= begin;
if (len > length)
len = length;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
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 = {
.owner = THIS_MODULE,
.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)
int jfs_txstats_read(char *buffer, char **start, off_t offset, int length, static int jfs_txstats_proc_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
int len = 0; seq_printf(m,
off_t begin;
len += sprintf(buffer,
"JFS TxStats\n" "JFS TxStats\n"
"===========\n" "===========\n"
"calls to txBegin = %d\n" "calls to txBegin = %d\n"
@ -3089,19 +3083,19 @@ int jfs_txstats_read(char *buffer, char **start, off_t offset, int length,
TxStat.txBeginAnon_lockslow, TxStat.txBeginAnon_lockslow,
TxStat.txLockAlloc, TxStat.txLockAlloc,
TxStat.txLockAlloc_freelock); TxStat.txLockAlloc_freelock);
return 0;
begin = offset;
*start = buffer + begin;
len -= begin;
if (len > length)
len = length;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
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 = {
.owner = THIS_MODULE,
.open = jfs_txstats_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif #endif

View File

@ -20,7 +20,9 @@
*/ */
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/module.h>
#include <linux/quotaops.h> #include <linux/quotaops.h>
#include <linux/seq_file.h>
#include "jfs_incore.h" #include "jfs_incore.h"
#include "jfs_filsys.h" #include "jfs_filsys.h"
#include "jfs_metapage.h" #include "jfs_metapage.h"
@ -4134,13 +4136,9 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
} }
#ifdef CONFIG_JFS_STATISTICS #ifdef CONFIG_JFS_STATISTICS
int jfs_xtstat_read(char *buffer, char **start, off_t offset, int length, static int jfs_xtstat_proc_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
int len = 0; seq_printf(m,
off_t begin;
len += sprintf(buffer,
"JFS Xtree statistics\n" "JFS Xtree statistics\n"
"====================\n" "====================\n"
"searches = %d\n" "searches = %d\n"
@ -4149,19 +4147,19 @@ int jfs_xtstat_read(char *buffer, char **start, off_t offset, int length,
xtStat.search, xtStat.search,
xtStat.fastSearch, xtStat.fastSearch,
xtStat.split); xtStat.split);
return 0;
begin = offset;
*start = buffer + begin;
len -= begin;
if (len > length)
len = length;
else
*eof = 1;
if (len < 0)
len = 0;
return len;
} }
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 = {
.owner = THIS_MODULE,
.open = jfs_xtstat_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif #endif