convert NFS /proc interfaces to seq_file
Subsystems (3)
PATCH 1/1 convert NFS /proc interfaces to seq_file
Converts /proc/net/rpc/nfs and /proc/net/rpc/nfsd to use the simpler seq_file interface.
Tested against 2.6.0-test4 bk latest; output format should be unchanged.
fs/nfsd/stats.c +25 -42
@@ -26,6 +26,7 @@#include <linux/kernel.h> #include <linux/time.h> #include <linux/proc_fs.h> +#include <linux/seq_file.h> #include <linux/stat.h> #include <linux/module.h>
@@ -39,14 +40,11 @@ .program = &nfsd_program, }; -static int -nfsd_proc_read (char *buffer,char **start,off_t offset,int count, -int *eof,void *data) +static int nfsd_proc_show (struct seq_file *seq,void *v) { -int len; -int i; +int i; - len = sprintf(buffer, "rc %u %u %u\nfh %u %u %u %u %u\nio %u %u\n", + seq_printf(seq, "rc %u %u %u\nfh %u %u %u %u %u\nio %u %u\n", nfsdstats.rchits, nfsdstats.rcmisses, nfsdstats.rcnocache,
@@ -58,57 +56,42 @@ nfsdstats.io_read, nfsdstats.io_write);/* thread usage: */ - len +=sprintf (buffer+len,"th %u %u" , nfsdstats.th_cnt, nfsdstats.th_fullcnt); +seq_printf (seq,"th %u %u" , nfsdstats.th_cnt, nfsdstats.th_fullcnt);for (i=0 ; i<10 ; i++) {unsigned int jifs = nfsdstats.th_usage[i];unsigned int sec = jifs /HZ , msec = (jifs %HZ )*1000 /HZ ; - len +=sprintf (buffer+len," %u.%03u" , sec, msec); +seq_printf (seq," %u.%03u" , sec, msec); }/* newline and ra-cache */ - len +=sprintf (buffer+len,"\nra %u" , nfsdstats.ra_size); +seq_printf (seq,"\nra %u" , nfsdstats.ra_size);for (i=0 ; i<11 ; i++) - len +=sprintf (buffer+len," %u" , nfsdstats.ra_depth[i]); - len +=sprintf (buffer+len,"\n" ); +seq_printf (seq," %u" , nfsdstats.ra_depth[i]); +seq_putc (seq,'\n' ); +/* show my rpc info */ +svc_seq_show (seq, &nfsd_svcstats); -/* Assume we haven't hit EOF yet. Will be set by svc_proc_read. */ - *eof =0 ; - -/* -* Append generic nfsd RPC statistics if there's room for it. -*/ -if (len <= offset) { - len =svc_proc_read (buffer, start, offset - len, count, - eof, data); -return len; - } - -if (len < count) { - len +=svc_proc_read (buffer + len, start,0 , count - len, - eof, data); - } - -if (offset >= len) { - *start = buffer; -return 0 ; - } +return 0 ; +} - *start = buffer + offset; -if ((len -= offset) > count) -return count; -return len; +static int nfsd_proc_open (struct inode *inode,struct file *file) +{ +return single_open (file, nfsd_proc_show,NULL ); } +static struct file_operations nfsd_proc_fops = { + .owner =THIS_MODULE , + .open = nfsd_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +void nfsd_stat_init (void ) { -struct proc_dir_entry *ent; - -if ((ent =svc_proc_register (&nfsd_svcstats)) !=0 ) { - ent->read_proc = nfsd_proc_read; - ent->owner =THIS_MODULE ; - } +svc_proc_register (&nfsd_svcstats, &nfsd_proc_fops); }void
include/linux/sunrpc/stats.h +9 -10
@@ -48,14 +48,13 @@#ifdef CONFIG_PROC_FS struct proc_dir_entry *rpc_proc_register (struct rpc_stat *);void rpc_proc_unregister (const char *); -int rpc_proc_read (char *,char **,off_t ,int , -int *,void *);void rpc_proc_zero (struct rpc_program *); -struct proc_dir_entry *svc_proc_register (struct svc_stat *); +struct proc_dir_entry *svc_proc_register (struct svc_stat *, +struct file_operations *);void svc_proc_unregister (const char *); -int svc_proc_read (char *,char **,off_t ,int , -int *,void *); -void svc_proc_zero (struct svc_program *); + +void svc_seq_show (struct seq_file *, +const struct svc_stat *);extern struct proc_dir_entry *proc_net_rpc;
@@ -63,13 +62,13 @@static inline struct proc_dir_entry *rpc_proc_register (struct rpc_stat *s) {return NULL ; }static inline void rpc_proc_unregister (const char *p) {} -static inline int rpc_proc_read (char *a,char **b,off_t c,int d,int *e,void *f) {return 0 ; }static inline void rpc_proc_zero (struct rpc_program *p) {} -static inline struct proc_dir_entry *svc_proc_register (struct svc_stat *s) {return NULL ; } +static inline struct proc_dir_entry *svc_proc_register(struct svc_stat *s + struct file_operations *) { return NULL; }static inline void svc_proc_unregister (const char *p) {} -static inline int svc_proc_read (char *a,char **b,off_t c,int d,int *e,void *f) {return 0 ; } -static inline void svc_proc_zero (struct svc_program *p) {} + +static inline void svc_seq_show (struct seq_file *,const struct svc_stat *) {}#define proc_net_rpc NULL
net/sunrpc/stats.c +49 -57
182 lines not on this page · raw message
net/sunrpc/sunrpc_syms.c +1 -2
@@ -89,10 +89,9 @@#ifdef CONFIG_PROC_FS EXPORT_SYMBOL (rpc_proc_register);EXPORT_SYMBOL (rpc_proc_unregister); -EXPORT_SYMBOL (rpc_proc_read);EXPORT_SYMBOL (svc_proc_register);EXPORT_SYMBOL (svc_proc_unregister); -EXPORT_SYMBOL (svc_proc_read); +EXPORT_SYMBOL (svc_seq_show);#endif /* caching... */
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs