Commit 361735fd8ff8f7d8b9f0e134d0d99d99ee193d92

Authored by Alexey Dobriyan
Committed by Alex Elder
1 parent f08a59f146

xfs: switch to seq_file

create_proc_read_entry() is getting deprecated.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Reviewed-by: Alex Elder <aelder@sgi.com>
Signed-off-by: Alex Elder <aelder@sgi.com>

Showing 2 changed files with 55 additions and 74 deletions Side-by-side Diff

fs/xfs/linux-2.6/xfs_stats.c
... ... @@ -20,16 +20,9 @@
20 20  
21 21 DEFINE_PER_CPU(struct xfsstats, xfsstats);
22 22  
23   -STATIC int
24   -xfs_read_xfsstats(
25   - char *buffer,
26   - char **start,
27   - off_t offset,
28   - int count,
29   - int *eof,
30   - void *data)
  23 +static int xfs_stat_proc_show(struct seq_file *m, void *v)
31 24 {
32   - int c, i, j, len, val;
  25 + int c, i, j, val;
33 26 __uint64_t xs_xstrat_bytes = 0;
34 27 __uint64_t xs_write_bytes = 0;
35 28 __uint64_t xs_read_bytes = 0;
36 29  
37 30  
... ... @@ -60,18 +53,18 @@
60 53 };
61 54  
62 55 /* Loop over all stats groups */
63   - for (i=j=len = 0; i < ARRAY_SIZE(xstats); i++) {
64   - len += sprintf(buffer + len, "%s", xstats[i].desc);
  56 + for (i=j = 0; i < ARRAY_SIZE(xstats); i++) {
  57 + seq_printf(m, "%s", xstats[i].desc);
65 58 /* inner loop does each group */
66 59 while (j < xstats[i].endpoint) {
67 60 val = 0;
68 61 /* sum over all cpus */
69 62 for_each_possible_cpu(c)
70 63 val += *(((__u32*)&per_cpu(xfsstats, c) + j));
71   - len += sprintf(buffer + len, " %u", val);
  64 + seq_printf(m, " %u", val);
72 65 j++;
73 66 }
74   - buffer[len++] = '\n';
  67 + seq_putc(m, '\n');
75 68 }
76 69 /* extra precision counters */
77 70 for_each_possible_cpu(i) {
78 71  
79 72  
80 73  
81 74  
82 75  
... ... @@ -80,36 +73,38 @@
80 73 xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes;
81 74 }
82 75  
83   - len += sprintf(buffer + len, "xpc %Lu %Lu %Lu\n",
  76 + seq_printf(m, "xpc %Lu %Lu %Lu\n",
84 77 xs_xstrat_bytes, xs_write_bytes, xs_read_bytes);
85   - len += sprintf(buffer + len, "debug %u\n",
  78 + seq_printf(m, "debug %u\n",
86 79 #if defined(DEBUG)
87 80 1);
88 81 #else
89 82 0);
90 83 #endif
  84 + return 0;
  85 +}
91 86  
92   - if (offset >= len) {
93   - *start = buffer;
94   - *eof = 1;
95   - return 0;
96   - }
97   - *start = buffer + offset;
98   - if ((len -= offset) > count)
99   - return count;
100   - *eof = 1;
101   -
102   - return len;
  87 +static int xfs_stat_proc_open(struct inode *inode, struct file *file)
  88 +{
  89 + return single_open(file, xfs_stat_proc_show, NULL);
103 90 }
104 91  
  92 +static const struct file_operations xfs_stat_proc_fops = {
  93 + .owner = THIS_MODULE,
  94 + .open = xfs_stat_proc_open,
  95 + .read = seq_read,
  96 + .llseek = seq_lseek,
  97 + .release = single_release,
  98 +};
  99 +
105 100 int
106 101 xfs_init_procfs(void)
107 102 {
108 103 if (!proc_mkdir("fs/xfs", NULL))
109 104 goto out;
110 105  
111   - if (!create_proc_read_entry("fs/xfs/stat", 0, NULL,
112   - xfs_read_xfsstats, NULL))
  106 + if (!proc_create("fs/xfs/stat", 0, NULL,
  107 + &xfs_stat_proc_fops))
113 108 goto out_remove_entry;
114 109 return 0;
115 110  
fs/xfs/quota/xfs_qm_stats.c
... ... @@ -48,50 +48,34 @@
48 48  
49 49 struct xqmstats xqmstats;
50 50  
51   -STATIC int
52   -xfs_qm_read_xfsquota(
53   - char *buffer,
54   - char **start,
55   - off_t offset,
56   - int count,
57   - int *eof,
58   - void *data)
  51 +static int xqm_proc_show(struct seq_file *m, void *v)
59 52 {
60   - int len;
61   -
62 53 /* maximum; incore; ratio free to inuse; freelist */
63   - len = sprintf(buffer, "%d\t%d\t%d\t%u\n",
  54 + seq_printf(m, "%d\t%d\t%d\t%u\n",
64 55 ndquot,
65 56 xfs_Gqm? atomic_read(&xfs_Gqm->qm_totaldquots) : 0,
66 57 xfs_Gqm? xfs_Gqm->qm_dqfree_ratio : 0,
67 58 xfs_Gqm? xfs_Gqm->qm_dqfreelist.qh_nelems : 0);
68   -
69   - if (offset >= len) {
70   - *start = buffer;
71   - *eof = 1;
72   - return 0;
73   - }
74   - *start = buffer + offset;
75   - if ((len -= offset) > count)
76   - return count;
77   - *eof = 1;
78   -
79   - return len;
  59 + return 0;
80 60 }
81 61  
82   -STATIC int
83   -xfs_qm_read_stats(
84   - char *buffer,
85   - char **start,
86   - off_t offset,
87   - int count,
88   - int *eof,
89   - void *data)
  62 +static int xqm_proc_open(struct inode *inode, struct file *file)
90 63 {
91   - int len;
  64 + return single_open(file, xqm_proc_show, NULL);
  65 +}
92 66  
  67 +static const struct file_operations xqm_proc_fops = {
  68 + .owner = THIS_MODULE,
  69 + .open = xqm_proc_open,
  70 + .read = seq_read,
  71 + .llseek = seq_lseek,
  72 + .release = single_release,
  73 +};
  74 +
  75 +static int xqmstat_proc_show(struct seq_file *m, void *v)
  76 +{
93 77 /* quota performance statistics */
94   - len = sprintf(buffer, "qm %u %u %u %u %u %u %u %u\n",
  78 + seq_printf(m, "qm %u %u %u %u %u %u %u %u\n",
95 79 xqmstats.xs_qm_dqreclaims,
96 80 xqmstats.xs_qm_dqreclaim_misses,
97 81 xqmstats.xs_qm_dquot_dups,
98 82  
99 83  
100 84  
... ... @@ -100,25 +84,27 @@
100 84 xqmstats.xs_qm_dqwants,
101 85 xqmstats.xs_qm_dqshake_reclaims,
102 86 xqmstats.xs_qm_dqinact_reclaims);
  87 + return 0;
  88 +}
103 89  
104   - if (offset >= len) {
105   - *start = buffer;
106   - *eof = 1;
107   - return 0;
108   - }
109   - *start = buffer + offset;
110   - if ((len -= offset) > count)
111   - return count;
112   - *eof = 1;
113   -
114   - return len;
  90 +static int xqmstat_proc_open(struct inode *inode, struct file *file)
  91 +{
  92 + return single_open(file, xqmstat_proc_show, NULL);
115 93 }
116 94  
  95 +static const struct file_operations xqmstat_proc_fops = {
  96 + .owner = THIS_MODULE,
  97 + .open = xqmstat_proc_open,
  98 + .read = seq_read,
  99 + .llseek = seq_lseek,
  100 + .release = single_release,
  101 +};
  102 +
117 103 void
118 104 xfs_qm_init_procfs(void)
119 105 {
120   - create_proc_read_entry("fs/xfs/xqmstat", 0, NULL, xfs_qm_read_stats, NULL);
121   - create_proc_read_entry("fs/xfs/xqm", 0, NULL, xfs_qm_read_xfsquota, NULL);
  106 + proc_create("fs/xfs/xqmstat", 0, NULL, &xqmstat_proc_fops);
  107 + proc_create("fs/xfs/xqm", 0, NULL, &xqm_proc_fops);
122 108 }
123 109  
124 110 void