Skip to content

Commit b2e03ca

Browse files
Alexey DobriyanDave Kleikamp
authored andcommitted
JFS: switch to seq_files
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
1 parent 88f85a5 commit b2e03ca

6 files changed

Lines changed: 114 additions & 133 deletions

File tree

‎fs/jfs/jfs_debug.c‎

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/ctype.h>
2222
#include <linux/module.h>
2323
#include <linux/proc_fs.h>
24+
#include <linux/seq_file.h>
2425
#include <asm/uaccess.h>
2526
#include "jfs_incore.h"
2627
#include "jfs_filsys.h"
@@ -30,29 +31,19 @@
3031

3132
static struct proc_dir_entry *base;
3233
#ifdef CONFIG_JFS_DEBUG
33-
static int loglevel_read(char *page, char **start, off_t off,
34-
int count, int *eof, void *data)
34+
static int jfs_loglevel_proc_show(struct seq_file *m, void *v)
3535
{
36-
int len;
37-
38-
len = sprintf(page, "%d\n", jfsloglevel);
39-
40-
len -= off;
41-
*start = page + off;
42-
43-
if (len > count)
44-
len = count;
45-
else
46-
*eof = 1;
47-
48-
if (len < 0)
49-
len = 0;
36+
seq_printf(m, "%d\n", jfsloglevel);
37+
return 0;
38+
}
5039

51-
return len;
40+
static int jfs_loglevel_proc_open(struct inode *inode, struct file *file)
41+
{
42+
return single_open(file, jfs_loglevel_proc_show, NULL);
5243
}
5344

54-
static int loglevel_write(struct file *file, const char __user *buffer,
55-
unsigned long count, void *data)
45+
static ssize_t jfs_loglevel_proc_write(struct file *file,
46+
const char __user *buffer, size_t count, loff_t *ppos)
5647
{
5748
char c;
5849

@@ -65,22 +56,30 @@ static int loglevel_write(struct file *file, const char __user *buffer,
6556
jfsloglevel = c - '0';
6657
return count;
6758
}
59+
60+
static const struct file_operations jfs_loglevel_proc_fops = {
61+
.owner = THIS_MODULE,
62+
.open = jfs_loglevel_proc_open,
63+
.read = seq_read,
64+
.llseek = seq_lseek,
65+
.release = single_release,
66+
.write = jfs_loglevel_proc_write,
67+
};
6868
#endif
6969

7070
static struct {
7171
const char *name;
72-
read_proc_t *read_fn;
73-
write_proc_t *write_fn;
72+
const struct file_operations *proc_fops;
7473
} Entries[] = {
7574
#ifdef CONFIG_JFS_STATISTICS
76-
{ "lmstats", jfs_lmstats_read, },
77-
{ "txstats", jfs_txstats_read, },
78-
{ "xtstat", jfs_xtstat_read, },
79-
{ "mpstat", jfs_mpstat_read, },
75+
{ "lmstats", &jfs_lmstats_proc_fops, },
76+
{ "txstats", &jfs_txstats_proc_fops, },
77+
{ "xtstat", &jfs_xtstat_proc_fops, },
78+
{ "mpstat", &jfs_mpstat_proc_fops, },
8079
#endif
8180
#ifdef CONFIG_JFS_DEBUG
82-
{ "TxAnchor", jfs_txanchor_read, },
83-
{ "loglevel", loglevel_read, loglevel_write }
81+
{ "TxAnchor", &jfs_txanchor_proc_fops, },
82+
{ "loglevel", &jfs_loglevel_proc_fops }
8483
#endif
8584
};
8685
#define NPROCENT ARRAY_SIZE(Entries)
@@ -93,13 +92,8 @@ void jfs_proc_init(void)
9392
return;
9493
base->owner = THIS_MODULE;
9594

96-
for (i = 0; i < NPROCENT; i++) {
97-
struct proc_dir_entry *p;
98-
if ((p = create_proc_entry(Entries[i].name, 0, base))) {
99-
p->read_proc = Entries[i].read_fn;
100-
p->write_proc = Entries[i].write_fn;
101-
}
102-
}
95+
for (i = 0; i < NPROCENT; i++)
96+
proc_create(Entries[i].name, 0, base, Entries[i].proc_fops);
10397
}
10498

10599
void jfs_proc_clean(void)

‎fs/jfs/jfs_debug.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ extern void jfs_proc_clean(void);
6262

6363
extern int jfsloglevel;
6464

65-
extern int jfs_txanchor_read(char *, char **, off_t, int, int *, void *);
65+
extern const struct file_operations jfs_txanchor_proc_fops;
6666

6767
/* information message: e.g., configuration, major event */
6868
#define jfs_info(fmt, arg...) do { \
@@ -105,10 +105,10 @@ extern int jfs_txanchor_read(char *, char **, off_t, int, int *, void *);
105105
* ----------
106106
*/
107107
#ifdef CONFIG_JFS_STATISTICS
108-
extern int jfs_lmstats_read(char *, char **, off_t, int, int *, void *);
109-
extern int jfs_txstats_read(char *, char **, off_t, int, int *, void *);
110-
extern int jfs_mpstat_read(char *, char **, off_t, int, int *, void *);
111-
extern int jfs_xtstat_read(char *, char **, off_t, int, int *, void *);
108+
extern const struct file_operations jfs_lmstats_proc_fops;
109+
extern const struct file_operations jfs_txstats_proc_fops;
110+
extern const struct file_operations jfs_mpstat_proc_fops;
111+
extern const struct file_operations jfs_xtstat_proc_fops;
112112

113113
#define INCREMENT(x) ((x)++)
114114
#define DECREMENT(x) ((x)--)

‎fs/jfs/jfs_logmgr.c‎

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include <linux/freezer.h>
7070
#include <linux/delay.h>
7171
#include <linux/mutex.h>
72+
#include <linux/seq_file.h>
7273
#include "jfs_incore.h"
7374
#include "jfs_filsys.h"
7475
#include "jfs_metapage.h"
@@ -2503,13 +2504,9 @@ int lmLogFormat(struct jfs_log *log, s64 logAddress, int logSize)
25032504
}
25042505

25052506
#ifdef CONFIG_JFS_STATISTICS
2506-
int jfs_lmstats_read(char *buffer, char **start, off_t offset, int length,
2507-
int *eof, void *data)
2507+
static int jfs_lmstats_proc_show(struct seq_file *m, void *v)
25082508
{
2509-
int len = 0;
2510-
off_t begin;
2511-
2512-
len += sprintf(buffer,
2509+
seq_printf(m,
25132510
"JFS Logmgr stats\n"
25142511
"================\n"
25152512
"commits = %d\n"
@@ -2522,19 +2519,19 @@ int jfs_lmstats_read(char *buffer, char **start, off_t offset, int length,
25222519
lmStat.pagedone,
25232520
lmStat.full_page,
25242521
lmStat.partial_page);
2522+
return 0;
2523+
}
25252524

2526-
begin = offset;
2527-
*start = buffer + begin;
2528-
len -= begin;
2529-
2530-
if (len > length)
2531-
len = length;
2532-
else
2533-
*eof = 1;
2534-
2535-
if (len < 0)
2536-
len = 0;
2537-
2538-
return len;
2525+
static int jfs_lmstats_proc_open(struct inode *inode, struct file *file)
2526+
{
2527+
return single_open(file, jfs_lmstats_proc_show, NULL);
25392528
}
2529+
2530+
const struct file_operations jfs_lmstats_proc_fops = {
2531+
.owner = THIS_MODULE,
2532+
.open = jfs_lmstats_proc_open,
2533+
.read = seq_read,
2534+
.llseek = seq_lseek,
2535+
.release = single_release,
2536+
};
25402537
#endif /* CONFIG_JFS_STATISTICS */

‎fs/jfs/jfs_metapage.c‎

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919

2020
#include <linux/fs.h>
2121
#include <linux/mm.h>
22+
#include <linux/module.h>
2223
#include <linux/bio.h>
2324
#include <linux/init.h>
2425
#include <linux/buffer_head.h>
2526
#include <linux/mempool.h>
27+
#include <linux/seq_file.h>
2628
#include "jfs_incore.h"
2729
#include "jfs_superblock.h"
2830
#include "jfs_filsys.h"
@@ -804,13 +806,9 @@ void __invalidate_metapages(struct inode *ip, s64 addr, int len)
804806
}
805807

806808
#ifdef CONFIG_JFS_STATISTICS
807-
int jfs_mpstat_read(char *buffer, char **start, off_t offset, int length,
808-
int *eof, void *data)
809+
static int jfs_mpstat_proc_show(struct seq_file *m, void *v)
809810
{
810-
int len = 0;
811-
off_t begin;
812-
813-
len += sprintf(buffer,
811+
seq_printf(m,
814812
"JFS Metapage statistics\n"
815813
"=======================\n"
816814
"page allocations = %d\n"
@@ -819,19 +817,19 @@ int jfs_mpstat_read(char *buffer, char **start, off_t offset, int length,
819817
mpStat.pagealloc,
820818
mpStat.pagefree,
821819
mpStat.lockwait);
820+
return 0;
821+
}
822822

823-
begin = offset;
824-
*start = buffer + begin;
825-
len -= begin;
826-
827-
if (len > length)
828-
len = length;
829-
else
830-
*eof = 1;
831-
832-
if (len < 0)
833-
len = 0;
834-
835-
return len;
823+
static int jfs_mpstat_proc_open(struct inode *inode, struct file *file)
824+
{
825+
return single_open(file, jfs_mpstat_proc_show, NULL);
836826
}
827+
828+
const struct file_operations jfs_mpstat_proc_fops = {
829+
.owner = THIS_MODULE,
830+
.open = jfs_mpstat_proc_open,
831+
.read = seq_read,
832+
.llseek = seq_lseek,
833+
.release = single_release,
834+
};
837835
#endif

‎fs/jfs/jfs_txnmgr.c‎

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include <linux/module.h>
5050
#include <linux/moduleparam.h>
5151
#include <linux/kthread.h>
52+
#include <linux/seq_file.h>
5253
#include "jfs_incore.h"
5354
#include "jfs_inode.h"
5455
#include "jfs_filsys.h"
@@ -3009,11 +3010,8 @@ int jfs_sync(void *arg)
30093010
}
30103011

30113012
#if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_DEBUG)
3012-
int jfs_txanchor_read(char *buffer, char **start, off_t offset, int length,
3013-
int *eof, void *data)
3013+
static int jfs_txanchor_proc_show(struct seq_file *m, void *v)
30143014
{
3015-
int len = 0;
3016-
off_t begin;
30173015
char *freewait;
30183016
char *freelockwait;
30193017
char *lowlockwait;
@@ -3025,7 +3023,7 @@ int jfs_txanchor_read(char *buffer, char **start, off_t offset, int length,
30253023
lowlockwait =
30263024
waitqueue_active(&TxAnchor.lowlockwait) ? "active" : "empty";
30273025

3028-
len += sprintf(buffer,
3026+
seq_printf(m,
30293027
"JFS TxAnchor\n"
30303028
"============\n"
30313029
"freetid = %d\n"
@@ -3044,31 +3042,27 @@ int jfs_txanchor_read(char *buffer, char **start, off_t offset, int length,
30443042
TxAnchor.tlocksInUse,
30453043
jfs_tlocks_low,
30463044
list_empty(&TxAnchor.unlock_queue) ? "" : "not ");
3045+
return 0;
3046+
}
30473047

3048-
begin = offset;
3049-
*start = buffer + begin;
3050-
len -= begin;
3051-
3052-
if (len > length)
3053-
len = length;
3054-
else
3055-
*eof = 1;
3056-
3057-
if (len < 0)
3058-
len = 0;
3059-
3060-
return len;
3048+
static int jfs_txanchor_proc_open(struct inode *inode, struct file *file)
3049+
{
3050+
return single_open(file, jfs_txanchor_proc_show, NULL);
30613051
}
3052+
3053+
const struct file_operations jfs_txanchor_proc_fops = {
3054+
.owner = THIS_MODULE,
3055+
.open = jfs_txanchor_proc_open,
3056+
.read = seq_read,
3057+
.llseek = seq_lseek,
3058+
.release = single_release,
3059+
};
30623060
#endif
30633061

30643062
#if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_STATISTICS)
3065-
int jfs_txstats_read(char *buffer, char **start, off_t offset, int length,
3066-
int *eof, void *data)
3063+
static int jfs_txstats_proc_show(struct seq_file *m, void *v)
30673064
{
3068-
int len = 0;
3069-
off_t begin;
3070-
3071-
len += sprintf(buffer,
3065+
seq_printf(m,
30723066
"JFS TxStats\n"
30733067
"===========\n"
30743068
"calls to txBegin = %d\n"
@@ -3089,19 +3083,19 @@ int jfs_txstats_read(char *buffer, char **start, off_t offset, int length,
30893083
TxStat.txBeginAnon_lockslow,
30903084
TxStat.txLockAlloc,
30913085
TxStat.txLockAlloc_freelock);
3086+
return 0;
3087+
}
30923088

3093-
begin = offset;
3094-
*start = buffer + begin;
3095-
len -= begin;
3096-
3097-
if (len > length)
3098-
len = length;
3099-
else
3100-
*eof = 1;
3101-
3102-
if (len < 0)
3103-
len = 0;
3104-
3105-
return len;
3089+
static int jfs_txstats_proc_open(struct inode *inode, struct file *file)
3090+
{
3091+
return single_open(file, jfs_txstats_proc_show, NULL);
31063092
}
3093+
3094+
const struct file_operations jfs_txstats_proc_fops = {
3095+
.owner = THIS_MODULE,
3096+
.open = jfs_txstats_proc_open,
3097+
.read = seq_read,
3098+
.llseek = seq_lseek,
3099+
.release = single_release,
3100+
};
31073101
#endif

0 commit comments

Comments
 (0)