Commit a3816ab0e8fe542a89a53b82506a8ddac063fbe3

Authored by Joe Perches
Committed by Steven Rostedt
1 parent f365ef9b79

fs: Convert show_fdinfo functions to void

seq_printf functions shouldn't really check the return value.
Checking seq_has_overflowed() occasionally is used instead.

Update vfs documentation.

Link: http://lkml.kernel.org/p/e37e6e7b76acbdcc3bb4ab2a57c8f8ca1ae11b9a.1412031505.git.joe@perches.com

Cc: David S. Miller <davem@davemloft.net>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Joe Perches <joe@perches.com>
[ did a few clean ups ]
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Showing 10 changed files with 63 additions and 83 deletions Side-by-side Diff

Documentation/filesystems/vfs.txt
... ... @@ -828,7 +828,7 @@
828 828 ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned int);
829 829 int (*setlease)(struct file *, long arg, struct file_lock **, void **);
830 830 long (*fallocate)(struct file *, int mode, loff_t offset, loff_t len);
831   - int (*show_fdinfo)(struct seq_file *m, struct file *f);
  831 + void (*show_fdinfo)(struct seq_file *m, struct file *f);
832 832 };
833 833  
834 834 Again, all methods are called without any locks being held, unless
... ... @@ -2209,7 +2209,7 @@
2209 2209 }
2210 2210  
2211 2211 #ifdef CONFIG_PROC_FS
2212   -static int tun_chr_show_fdinfo(struct seq_file *m, struct file *f)
  2212 +static void tun_chr_show_fdinfo(struct seq_file *m, struct file *f)
2213 2213 {
2214 2214 struct tun_struct *tun;
2215 2215 struct ifreq ifr;
... ... @@ -2225,7 +2225,7 @@
2225 2225 if (tun)
2226 2226 tun_put(tun);
2227 2227  
2228   - return seq_printf(m, "iff:\t%s\n", ifr.ifr_name);
  2228 + seq_printf(m, "iff:\t%s\n", ifr.ifr_name);
2229 2229 }
2230 2230 #endif
2231 2231  
... ... @@ -287,17 +287,14 @@
287 287 }
288 288  
289 289 #ifdef CONFIG_PROC_FS
290   -static int eventfd_show_fdinfo(struct seq_file *m, struct file *f)
  290 +static void eventfd_show_fdinfo(struct seq_file *m, struct file *f)
291 291 {
292 292 struct eventfd_ctx *ctx = f->private_data;
293   - int ret;
294 293  
295 294 spin_lock_irq(&ctx->wqh.lock);
296   - ret = seq_printf(m, "eventfd-count: %16llx\n",
297   - (unsigned long long)ctx->count);
  295 + seq_printf(m, "eventfd-count: %16llx\n",
  296 + (unsigned long long)ctx->count);
298 297 spin_unlock_irq(&ctx->wqh.lock);
299   -
300   - return ret;
301 298 }
302 299 #endif
303 300  
... ... @@ -870,25 +870,22 @@
870 870 }
871 871  
872 872 #ifdef CONFIG_PROC_FS
873   -static int ep_show_fdinfo(struct seq_file *m, struct file *f)
  873 +static void ep_show_fdinfo(struct seq_file *m, struct file *f)
874 874 {
875 875 struct eventpoll *ep = f->private_data;
876 876 struct rb_node *rbp;
877   - int ret = 0;
878 877  
879 878 mutex_lock(&ep->mtx);
880 879 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) {
881 880 struct epitem *epi = rb_entry(rbp, struct epitem, rbn);
882 881  
883   - ret = seq_printf(m, "tfd: %8d events: %8x data: %16llx\n",
884   - epi->ffd.fd, epi->event.events,
885   - (long long)epi->event.data);
886   - if (ret)
  882 + seq_printf(m, "tfd: %8d events: %8x data: %16llx\n",
  883 + epi->ffd.fd, epi->event.events,
  884 + (long long)epi->event.data);
  885 + if (seq_has_overflowed(m))
887 886 break;
888 887 }
889 888 mutex_unlock(&ep->mtx);
890   -
891   - return ret;
892 889 }
893 890 #endif
894 891  
... ... @@ -20,25 +20,24 @@
20 20  
21 21 #if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY)
22 22  
23   -static int show_fdinfo(struct seq_file *m, struct file *f,
24   - int (*show)(struct seq_file *m, struct fsnotify_mark *mark))
  23 +static void show_fdinfo(struct seq_file *m, struct file *f,
  24 + void (*show)(struct seq_file *m,
  25 + struct fsnotify_mark *mark))
25 26 {
26 27 struct fsnotify_group *group = f->private_data;
27 28 struct fsnotify_mark *mark;
28   - int ret = 0;
29 29  
30 30 mutex_lock(&group->mark_mutex);
31 31 list_for_each_entry(mark, &group->marks_list, g_list) {
32   - ret = show(m, mark);
33   - if (ret)
  32 + show(m, mark);
  33 + if (seq_has_overflowed(m))
34 34 break;
35 35 }
36 36 mutex_unlock(&group->mark_mutex);
37   - return ret;
38 37 }
39 38  
40 39 #if defined(CONFIG_EXPORTFS)
41   -static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
  40 +static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
42 41 {
43 42 struct {
44 43 struct file_handle handle;
45 44  
46 45  
47 46  
48 47  
49 48  
50 49  
51 50  
52 51  
53 52  
54 53  
55 54  
56 55  
57 56  
58 57  
... ... @@ -52,71 +51,62 @@
52 51 ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0);
53 52 if ((ret == FILEID_INVALID) || (ret < 0)) {
54 53 WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret);
55   - return 0;
  54 + return;
56 55 }
57 56  
58 57 f.handle.handle_type = ret;
59 58 f.handle.handle_bytes = size * sizeof(u32);
60 59  
61   - ret = seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:",
62   - f.handle.handle_bytes, f.handle.handle_type);
  60 + seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:",
  61 + f.handle.handle_bytes, f.handle.handle_type);
63 62  
64 63 for (i = 0; i < f.handle.handle_bytes; i++)
65   - ret |= seq_printf(m, "%02x", (int)f.handle.f_handle[i]);
66   -
67   - return ret;
  64 + seq_printf(m, "%02x", (int)f.handle.f_handle[i]);
68 65 }
69 66 #else
70   -static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
  67 +static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
71 68 {
72   - return 0;
73 69 }
74 70 #endif
75 71  
76 72 #ifdef CONFIG_INOTIFY_USER
77 73  
78   -static int inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
  74 +static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
79 75 {
80 76 struct inotify_inode_mark *inode_mark;
81 77 struct inode *inode;
82   - int ret = 0;
83 78  
84 79 if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE)))
85   - return 0;
  80 + return;
86 81  
87 82 inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark);
88 83 inode = igrab(mark->i.inode);
89 84 if (inode) {
90   - ret = seq_printf(m, "inotify wd:%x ino:%lx sdev:%x "
91   - "mask:%x ignored_mask:%x ",
92   - inode_mark->wd, inode->i_ino,
93   - inode->i_sb->s_dev,
94   - mark->mask, mark->ignored_mask);
95   - ret |= show_mark_fhandle(m, inode);
96   - ret |= seq_putc(m, '\n');
  85 + seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:%x ",
  86 + inode_mark->wd, inode->i_ino, inode->i_sb->s_dev,
  87 + mark->mask, mark->ignored_mask);
  88 + show_mark_fhandle(m, inode);
  89 + seq_putc(m, '\n');
97 90 iput(inode);
98 91 }
99   -
100   - return ret;
101 92 }
102 93  
103   -int inotify_show_fdinfo(struct seq_file *m, struct file *f)
  94 +void inotify_show_fdinfo(struct seq_file *m, struct file *f)
104 95 {
105   - return show_fdinfo(m, f, inotify_fdinfo);
  96 + show_fdinfo(m, f, inotify_fdinfo);
106 97 }
107 98  
108 99 #endif /* CONFIG_INOTIFY_USER */
109 100  
110 101 #ifdef CONFIG_FANOTIFY
111 102  
112   -static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
  103 +static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
113 104 {
114 105 unsigned int mflags = 0;
115 106 struct inode *inode;
116   - int ret = 0;
117 107  
118 108 if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE))
119   - return 0;
  109 + return;
120 110  
121 111 if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY)
122 112 mflags |= FAN_MARK_IGNORED_SURV_MODIFY;
123 113  
124 114  
125 115  
... ... @@ -124,26 +114,22 @@
124 114 if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) {
125 115 inode = igrab(mark->i.inode);
126 116 if (!inode)
127   - goto out;
128   - ret = seq_printf(m, "fanotify ino:%lx sdev:%x "
129   - "mflags:%x mask:%x ignored_mask:%x ",
130   - inode->i_ino, inode->i_sb->s_dev,
131   - mflags, mark->mask, mark->ignored_mask);
132   - ret |= show_mark_fhandle(m, inode);
133   - ret |= seq_putc(m, '\n');
  117 + return;
  118 + seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x ",
  119 + inode->i_ino, inode->i_sb->s_dev,
  120 + mflags, mark->mask, mark->ignored_mask);
  121 + show_mark_fhandle(m, inode);
  122 + seq_putc(m, '\n');
134 123 iput(inode);
135 124 } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) {
136 125 struct mount *mnt = real_mount(mark->m.mnt);
137 126  
138   - ret = seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x "
139   - "ignored_mask:%x\n", mnt->mnt_id, mflags,
140   - mark->mask, mark->ignored_mask);
  127 + seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x ignored_mask:%x\n",
  128 + mnt->mnt_id, mflags, mark->mask, mark->ignored_mask);
141 129 }
142   -out:
143   - return ret;
144 130 }
145 131  
146   -int fanotify_show_fdinfo(struct seq_file *m, struct file *f)
  132 +void fanotify_show_fdinfo(struct seq_file *m, struct file *f)
147 133 {
148 134 struct fsnotify_group *group = f->private_data;
149 135 unsigned int flags = 0;
... ... @@ -169,7 +155,7 @@
169 155 seq_printf(m, "fanotify flags:%x event-flags:%x\n",
170 156 flags, group->fanotify_data.f_flags);
171 157  
172   - return show_fdinfo(m, f, fanotify_fdinfo);
  158 + show_fdinfo(m, f, fanotify_fdinfo);
173 159 }
174 160  
175 161 #endif /* CONFIG_FANOTIFY */
... ... @@ -10,11 +10,11 @@
10 10 #ifdef CONFIG_PROC_FS
11 11  
12 12 #ifdef CONFIG_INOTIFY_USER
13   -extern int inotify_show_fdinfo(struct seq_file *m, struct file *f);
  13 +void inotify_show_fdinfo(struct seq_file *m, struct file *f);
14 14 #endif
15 15  
16 16 #ifdef CONFIG_FANOTIFY
17   -extern int fanotify_show_fdinfo(struct seq_file *m, struct file *f);
  17 +void fanotify_show_fdinfo(struct seq_file *m, struct file *f);
18 18 #endif
19 19  
20 20 #else /* CONFIG_PROC_FS */
... ... @@ -53,7 +53,8 @@
53 53 (long long)file->f_pos, f_flags,
54 54 real_mount(file->f_path.mnt)->mnt_id);
55 55 if (file->f_op->show_fdinfo)
56   - ret = file->f_op->show_fdinfo(m, file);
  56 + file->f_op->show_fdinfo(m, file);
  57 + ret = seq_has_overflowed(m);
57 58 fput(file);
58 59 }
59 60  
... ... @@ -230,7 +230,7 @@
230 230 }
231 231  
232 232 #ifdef CONFIG_PROC_FS
233   -static int signalfd_show_fdinfo(struct seq_file *m, struct file *f)
  233 +static void signalfd_show_fdinfo(struct seq_file *m, struct file *f)
234 234 {
235 235 struct signalfd_ctx *ctx = f->private_data;
236 236 sigset_t sigmask;
... ... @@ -238,8 +238,6 @@
238 238 sigmask = ctx->sigmask;
239 239 signotset(&sigmask);
240 240 render_sigset_t(m, "sigmask:\t", &sigmask);
241   -
242   - return 0;
243 241 }
244 242 #endif
245 243  
... ... @@ -288,7 +288,7 @@
288 288 }
289 289  
290 290 #ifdef CONFIG_PROC_FS
291   -static int timerfd_show(struct seq_file *m, struct file *file)
  291 +static void timerfd_show(struct seq_file *m, struct file *file)
292 292 {
293 293 struct timerfd_ctx *ctx = file->private_data;
294 294 struct itimerspec t;
... ... @@ -298,18 +298,19 @@
298 298 t.it_interval = ktime_to_timespec(ctx->tintv);
299 299 spin_unlock_irq(&ctx->wqh.lock);
300 300  
301   - return seq_printf(m,
302   - "clockid: %d\n"
303   - "ticks: %llu\n"
304   - "settime flags: 0%o\n"
305   - "it_value: (%llu, %llu)\n"
306   - "it_interval: (%llu, %llu)\n",
307   - ctx->clockid, (unsigned long long)ctx->ticks,
308   - ctx->settime_flags,
309   - (unsigned long long)t.it_value.tv_sec,
310   - (unsigned long long)t.it_value.tv_nsec,
311   - (unsigned long long)t.it_interval.tv_sec,
312   - (unsigned long long)t.it_interval.tv_nsec);
  301 + seq_printf(m,
  302 + "clockid: %d\n"
  303 + "ticks: %llu\n"
  304 + "settime flags: 0%o\n"
  305 + "it_value: (%llu, %llu)\n"
  306 + "it_interval: (%llu, %llu)\n",
  307 + ctx->clockid,
  308 + (unsigned long long)ctx->ticks,
  309 + ctx->settime_flags,
  310 + (unsigned long long)t.it_value.tv_sec,
  311 + (unsigned long long)t.it_value.tv_nsec,
  312 + (unsigned long long)t.it_interval.tv_sec,
  313 + (unsigned long long)t.it_interval.tv_nsec);
313 314 }
314 315 #else
315 316 #define timerfd_show NULL
... ... @@ -1491,7 +1491,7 @@
1491 1491 int (*setlease)(struct file *, long, struct file_lock **, void **);
1492 1492 long (*fallocate)(struct file *file, int mode, loff_t offset,
1493 1493 loff_t len);
1494   - int (*show_fdinfo)(struct seq_file *m, struct file *f);
  1494 + void (*show_fdinfo)(struct seq_file *m, struct file *f);
1495 1495 };
1496 1496  
1497 1497 struct inode_operations {