Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

JFS: switch to seq_files

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>

authored by

Alexey Dobriyan and committed by
Dave Kleikamp
b2e03ca7 88f85a55

+120 -139
+29 -35
fs/jfs/jfs_debug.c
··· 21 21 #include <linux/ctype.h> 22 22 #include <linux/module.h> 23 23 #include <linux/proc_fs.h> 24 + #include <linux/seq_file.h> 24 25 #include <asm/uaccess.h> 25 26 #include "jfs_incore.h" 26 27 #include "jfs_filsys.h" ··· 31 30 32 31 static struct proc_dir_entry *base; 33 32 #ifdef CONFIG_JFS_DEBUG 34 - static int loglevel_read(char *page, char **start, off_t off, 35 - int count, int *eof, void *data) 33 + static int jfs_loglevel_proc_show(struct seq_file *m, void *v) 36 34 { 37 - int len; 38 - 39 - len = sprintf(page, "%d\n", jfsloglevel); 40 - 41 - len -= off; 42 - *start = page + off; 43 - 44 - if (len > count) 45 - len = count; 46 - else 47 - *eof = 1; 48 - 49 - if (len < 0) 50 - len = 0; 51 - 52 - return len; 35 + seq_printf(m, "%d\n", jfsloglevel); 36 + return 0; 53 37 } 54 38 55 - static int loglevel_write(struct file *file, const char __user *buffer, 56 - unsigned long count, void *data) 39 + static int jfs_loglevel_proc_open(struct inode *inode, struct file *file) 40 + { 41 + return single_open(file, jfs_loglevel_proc_show, NULL); 42 + } 43 + 44 + static ssize_t jfs_loglevel_proc_write(struct file *file, 45 + const char __user *buffer, size_t count, loff_t *ppos) 57 46 { 58 47 char c; 59 48 ··· 56 65 jfsloglevel = c - '0'; 57 66 return count; 58 67 } 68 + 69 + static const struct file_operations jfs_loglevel_proc_fops = { 70 + .owner = THIS_MODULE, 71 + .open = jfs_loglevel_proc_open, 72 + .read = seq_read, 73 + .llseek = seq_lseek, 74 + .release = single_release, 75 + .write = jfs_loglevel_proc_write, 76 + }; 59 77 #endif 60 78 61 79 static struct { 62 80 const char *name; 63 - read_proc_t *read_fn; 64 - write_proc_t *write_fn; 81 + const struct file_operations *proc_fops; 65 82 } Entries[] = { 66 83 #ifdef CONFIG_JFS_STATISTICS 67 - { "lmstats", jfs_lmstats_read, }, 68 - { "txstats", jfs_txstats_read, }, 69 - { "xtstat", jfs_xtstat_read, }, 70 - { "mpstat", jfs_mpstat_read, }, 84 + { "lmstats", &jfs_lmstats_proc_fops, }, 85 + { "txstats", &jfs_txstats_proc_fops, }, 86 + { "xtstat", &jfs_xtstat_proc_fops, }, 87 + { "mpstat", &jfs_mpstat_proc_fops, }, 71 88 #endif 72 89 #ifdef CONFIG_JFS_DEBUG 73 - { "TxAnchor", jfs_txanchor_read, }, 74 - { "loglevel", loglevel_read, loglevel_write } 90 + { "TxAnchor", &jfs_txanchor_proc_fops, }, 91 + { "loglevel", &jfs_loglevel_proc_fops } 75 92 #endif 76 93 }; 77 94 #define NPROCENT ARRAY_SIZE(Entries) ··· 92 93 return; 93 94 base->owner = THIS_MODULE; 94 95 95 - for (i = 0; i < NPROCENT; i++) { 96 - struct proc_dir_entry *p; 97 - if ((p = create_proc_entry(Entries[i].name, 0, base))) { 98 - p->read_proc = Entries[i].read_fn; 99 - p->write_proc = Entries[i].write_fn; 100 - } 101 - } 96 + for (i = 0; i < NPROCENT; i++) 97 + proc_create(Entries[i].name, 0, base, Entries[i].proc_fops); 102 98 } 103 99 104 100 void jfs_proc_clean(void)
+5 -5
fs/jfs/jfs_debug.h
··· 62 62 63 63 extern int jfsloglevel; 64 64 65 - extern int jfs_txanchor_read(char *, char **, off_t, int, int *, void *); 65 + extern const struct file_operations jfs_txanchor_proc_fops; 66 66 67 67 /* information message: e.g., configuration, major event */ 68 68 #define jfs_info(fmt, arg...) do { \ ··· 105 105 * ---------- 106 106 */ 107 107 #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; 112 112 113 113 #define INCREMENT(x) ((x)++) 114 114 #define DECREMENT(x) ((x)--)
+17 -20
fs/jfs/jfs_logmgr.c
··· 69 69 #include <linux/freezer.h> 70 70 #include <linux/delay.h> 71 71 #include <linux/mutex.h> 72 + #include <linux/seq_file.h> 72 73 #include "jfs_incore.h" 73 74 #include "jfs_filsys.h" 74 75 #include "jfs_metapage.h" ··· 2504 2503 } 2505 2504 2506 2505 #ifdef CONFIG_JFS_STATISTICS 2507 - int jfs_lmstats_read(char *buffer, char **start, off_t offset, int length, 2508 - int *eof, void *data) 2506 + static int jfs_lmstats_proc_show(struct seq_file *m, void *v) 2509 2507 { 2510 - int len = 0; 2511 - off_t begin; 2512 - 2513 - len += sprintf(buffer, 2508 + seq_printf(m, 2514 2509 "JFS Logmgr stats\n" 2515 2510 "================\n" 2516 2511 "commits = %d\n" ··· 2519 2522 lmStat.pagedone, 2520 2523 lmStat.full_page, 2521 2524 lmStat.partial_page); 2522 - 2523 - begin = offset; 2524 - *start = buffer + begin; 2525 - len -= begin; 2526 - 2527 - if (len > length) 2528 - len = length; 2529 - else 2530 - *eof = 1; 2531 - 2532 - if (len < 0) 2533 - len = 0; 2534 - 2535 - return len; 2525 + return 0; 2536 2526 } 2527 + 2528 + static int jfs_lmstats_proc_open(struct inode *inode, struct file *file) 2529 + { 2530 + return single_open(file, jfs_lmstats_proc_show, NULL); 2531 + } 2532 + 2533 + const struct file_operations jfs_lmstats_proc_fops = { 2534 + .owner = THIS_MODULE, 2535 + .open = jfs_lmstats_proc_open, 2536 + .read = seq_read, 2537 + .llseek = seq_lseek, 2538 + .release = single_release, 2539 + }; 2537 2540 #endif /* CONFIG_JFS_STATISTICS */
+18 -20
fs/jfs/jfs_metapage.c
··· 19 19 20 20 #include <linux/fs.h> 21 21 #include <linux/mm.h> 22 + #include <linux/module.h> 22 23 #include <linux/bio.h> 23 24 #include <linux/init.h> 24 25 #include <linux/buffer_head.h> 25 26 #include <linux/mempool.h> 27 + #include <linux/seq_file.h> 26 28 #include "jfs_incore.h" 27 29 #include "jfs_superblock.h" 28 30 #include "jfs_filsys.h" ··· 806 804 } 807 805 808 806 #ifdef CONFIG_JFS_STATISTICS 809 - int jfs_mpstat_read(char *buffer, char **start, off_t offset, int length, 810 - int *eof, void *data) 807 + static int jfs_mpstat_proc_show(struct seq_file *m, void *v) 811 808 { 812 - int len = 0; 813 - off_t begin; 814 - 815 - len += sprintf(buffer, 809 + seq_printf(m, 816 810 "JFS Metapage statistics\n" 817 811 "=======================\n" 818 812 "page allocations = %d\n" ··· 817 819 mpStat.pagealloc, 818 820 mpStat.pagefree, 819 821 mpStat.lockwait); 820 - 821 - begin = offset; 822 - *start = buffer + begin; 823 - len -= begin; 824 - 825 - if (len > length) 826 - len = length; 827 - else 828 - *eof = 1; 829 - 830 - if (len < 0) 831 - len = 0; 832 - 833 - return len; 822 + return 0; 834 823 } 824 + 825 + static int jfs_mpstat_proc_open(struct inode *inode, struct file *file) 826 + { 827 + return single_open(file, jfs_mpstat_proc_show, NULL); 828 + } 829 + 830 + const struct file_operations jfs_mpstat_proc_fops = { 831 + .owner = THIS_MODULE, 832 + .open = jfs_mpstat_proc_open, 833 + .read = seq_read, 834 + .llseek = seq_lseek, 835 + .release = single_release, 836 + }; 835 837 #endif
+33 -39
fs/jfs/jfs_txnmgr.c
··· 49 49 #include <linux/module.h> 50 50 #include <linux/moduleparam.h> 51 51 #include <linux/kthread.h> 52 + #include <linux/seq_file.h> 52 53 #include "jfs_incore.h" 53 54 #include "jfs_inode.h" 54 55 #include "jfs_filsys.h" ··· 3010 3009 } 3011 3010 3012 3011 #if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_DEBUG) 3013 - int jfs_txanchor_read(char *buffer, char **start, off_t offset, int length, 3014 - int *eof, void *data) 3012 + static int jfs_txanchor_proc_show(struct seq_file *m, void *v) 3015 3013 { 3016 - int len = 0; 3017 - off_t begin; 3018 3014 char *freewait; 3019 3015 char *freelockwait; 3020 3016 char *lowlockwait; ··· 3023 3025 lowlockwait = 3024 3026 waitqueue_active(&TxAnchor.lowlockwait) ? "active" : "empty"; 3025 3027 3026 - len += sprintf(buffer, 3028 + seq_printf(m, 3027 3029 "JFS TxAnchor\n" 3028 3030 "============\n" 3029 3031 "freetid = %d\n" ··· 3042 3044 TxAnchor.tlocksInUse, 3043 3045 jfs_tlocks_low, 3044 3046 list_empty(&TxAnchor.unlock_queue) ? "" : "not "); 3045 - 3046 - begin = offset; 3047 - *start = buffer + begin; 3048 - len -= begin; 3049 - 3050 - if (len > length) 3051 - len = length; 3052 - else 3053 - *eof = 1; 3054 - 3055 - if (len < 0) 3056 - len = 0; 3057 - 3058 - return len; 3047 + return 0; 3059 3048 } 3049 + 3050 + static int jfs_txanchor_proc_open(struct inode *inode, struct file *file) 3051 + { 3052 + return single_open(file, jfs_txanchor_proc_show, NULL); 3053 + } 3054 + 3055 + const struct file_operations jfs_txanchor_proc_fops = { 3056 + .owner = THIS_MODULE, 3057 + .open = jfs_txanchor_proc_open, 3058 + .read = seq_read, 3059 + .llseek = seq_lseek, 3060 + .release = single_release, 3061 + }; 3060 3062 #endif 3061 3063 3062 3064 #if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_STATISTICS) 3063 - int jfs_txstats_read(char *buffer, char **start, off_t offset, int length, 3064 - int *eof, void *data) 3065 + static int jfs_txstats_proc_show(struct seq_file *m, void *v) 3065 3066 { 3066 - int len = 0; 3067 - off_t begin; 3068 - 3069 - len += sprintf(buffer, 3067 + seq_printf(m, 3070 3068 "JFS TxStats\n" 3071 3069 "===========\n" 3072 3070 "calls to txBegin = %d\n" ··· 3083 3089 TxStat.txBeginAnon_lockslow, 3084 3090 TxStat.txLockAlloc, 3085 3091 TxStat.txLockAlloc_freelock); 3086 - 3087 - begin = offset; 3088 - *start = buffer + begin; 3089 - len -= begin; 3090 - 3091 - if (len > length) 3092 - len = length; 3093 - else 3094 - *eof = 1; 3095 - 3096 - if (len < 0) 3097 - len = 0; 3098 - 3099 - return len; 3092 + return 0; 3100 3093 } 3094 + 3095 + static int jfs_txstats_proc_open(struct inode *inode, struct file *file) 3096 + { 3097 + return single_open(file, jfs_txstats_proc_show, NULL); 3098 + } 3099 + 3100 + const struct file_operations jfs_txstats_proc_fops = { 3101 + .owner = THIS_MODULE, 3102 + .open = jfs_txstats_proc_open, 3103 + .read = seq_read, 3104 + .llseek = seq_lseek, 3105 + .release = single_release, 3106 + }; 3101 3107 #endif
+18 -20
fs/jfs/jfs_xtree.c
··· 20 20 */ 21 21 22 22 #include <linux/fs.h> 23 + #include <linux/module.h> 23 24 #include <linux/quotaops.h> 25 + #include <linux/seq_file.h> 24 26 #include "jfs_incore.h" 25 27 #include "jfs_filsys.h" 26 28 #include "jfs_metapage.h" ··· 4136 4134 } 4137 4135 4138 4136 #ifdef CONFIG_JFS_STATISTICS 4139 - int jfs_xtstat_read(char *buffer, char **start, off_t offset, int length, 4140 - int *eof, void *data) 4137 + static int jfs_xtstat_proc_show(struct seq_file *m, void *v) 4141 4138 { 4142 - int len = 0; 4143 - off_t begin; 4144 - 4145 - len += sprintf(buffer, 4139 + seq_printf(m, 4146 4140 "JFS Xtree statistics\n" 4147 4141 "====================\n" 4148 4142 "searches = %d\n" ··· 4147 4149 xtStat.search, 4148 4150 xtStat.fastSearch, 4149 4151 xtStat.split); 4150 - 4151 - begin = offset; 4152 - *start = buffer + begin; 4153 - len -= begin; 4154 - 4155 - if (len > length) 4156 - len = length; 4157 - else 4158 - *eof = 1; 4159 - 4160 - if (len < 0) 4161 - len = 0; 4162 - 4163 - return len; 4152 + return 0; 4164 4153 } 4154 + 4155 + static int jfs_xtstat_proc_open(struct inode *inode, struct file *file) 4156 + { 4157 + return single_open(file, jfs_xtstat_proc_show, NULL); 4158 + } 4159 + 4160 + const struct file_operations jfs_xtstat_proc_fops = { 4161 + .owner = THIS_MODULE, 4162 + .open = jfs_xtstat_proc_open, 4163 + .read = seq_read, 4164 + .llseek = seq_lseek, 4165 + .release = single_release, 4166 + }; 4165 4167 #endif