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

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>

authored by

Joe Perches and committed by
Steven Rostedt
a3816ab0 f365ef9b

+63 -83
+1 -1
Documentation/filesystems/vfs.txt
··· 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
+2 -2
drivers/net/tun.c
··· 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 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
+3 -6
fs/eventfd.c
··· 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
+5 -8
fs/eventpoll.c
··· 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
+32 -46
fs/notify/fdinfo.c
··· 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; ··· 51 52 ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0); 52 53 if ((ret == FILEID_INVALID) || (ret < 0)) { 53 54 WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret); 54 - return 0; 55 + return; 55 56 } 56 57 57 58 f.handle.handle_type = ret; 58 59 f.handle.handle_bytes = size * sizeof(u32); 59 60 60 - ret = seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:", 61 - f.handle.handle_bytes, f.handle.handle_type); 61 + seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:", 62 + f.handle.handle_bytes, f.handle.handle_type); 62 63 63 64 for (i = 0; i < f.handle.handle_bytes; i++) 64 - ret |= seq_printf(m, "%02x", (int)f.handle.f_handle[i]); 65 - 66 - return ret; 65 + seq_printf(m, "%02x", (int)f.handle.f_handle[i]); 67 66 } 68 67 #else 69 - static int show_mark_fhandle(struct seq_file *m, struct inode *inode) 68 + static void show_mark_fhandle(struct seq_file *m, struct inode *inode) 70 69 { 71 - return 0; 72 70 } 73 71 #endif 74 72 75 73 #ifdef CONFIG_INOTIFY_USER 76 74 77 - static int inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) 75 + static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) 78 76 { 79 77 struct inotify_inode_mark *inode_mark; 80 78 struct inode *inode; 81 - int ret = 0; 82 79 83 80 if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE))) 84 - return 0; 81 + return; 85 82 86 83 inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark); 87 84 inode = igrab(mark->i.inode); 88 85 if (inode) { 89 - ret = seq_printf(m, "inotify wd:%x ino:%lx sdev:%x " 90 - "mask:%x ignored_mask:%x ", 91 - inode_mark->wd, inode->i_ino, 92 - inode->i_sb->s_dev, 93 - mark->mask, mark->ignored_mask); 94 - ret |= show_mark_fhandle(m, inode); 95 - ret |= seq_putc(m, '\n'); 86 + seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:%x ", 87 + inode_mark->wd, inode->i_ino, inode->i_sb->s_dev, 88 + mark->mask, mark->ignored_mask); 89 + show_mark_fhandle(m, inode); 90 + seq_putc(m, '\n'); 96 91 iput(inode); 97 92 } 98 - 99 - return ret; 100 93 } 101 94 102 - int inotify_show_fdinfo(struct seq_file *m, struct file *f) 95 + void inotify_show_fdinfo(struct seq_file *m, struct file *f) 103 96 { 104 - return show_fdinfo(m, f, inotify_fdinfo); 97 + show_fdinfo(m, f, inotify_fdinfo); 105 98 } 106 99 107 100 #endif /* CONFIG_INOTIFY_USER */ 108 101 109 102 #ifdef CONFIG_FANOTIFY 110 103 111 - static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) 104 + static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) 112 105 { 113 106 unsigned int mflags = 0; 114 107 struct inode *inode; 115 - int ret = 0; 116 108 117 109 if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE)) 118 - return 0; 110 + return; 119 111 120 112 if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY) 121 113 mflags |= FAN_MARK_IGNORED_SURV_MODIFY; ··· 114 124 if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) { 115 125 inode = igrab(mark->i.inode); 116 126 if (!inode) 117 - goto out; 118 - ret = seq_printf(m, "fanotify ino:%lx sdev:%x " 119 - "mflags:%x mask:%x ignored_mask:%x ", 120 - inode->i_ino, inode->i_sb->s_dev, 121 - mflags, mark->mask, mark->ignored_mask); 122 - ret |= show_mark_fhandle(m, inode); 123 - ret |= seq_putc(m, '\n'); 127 + return; 128 + seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x ", 129 + inode->i_ino, inode->i_sb->s_dev, 130 + mflags, mark->mask, mark->ignored_mask); 131 + show_mark_fhandle(m, inode); 132 + seq_putc(m, '\n'); 124 133 iput(inode); 125 134 } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) { 126 135 struct mount *mnt = real_mount(mark->m.mnt); 127 136 128 - ret = seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x " 129 - "ignored_mask:%x\n", mnt->mnt_id, mflags, 130 - mark->mask, mark->ignored_mask); 137 + seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x ignored_mask:%x\n", 138 + mnt->mnt_id, mflags, mark->mask, mark->ignored_mask); 131 139 } 132 - out: 133 - return ret; 134 140 } 135 141 136 - int fanotify_show_fdinfo(struct seq_file *m, struct file *f) 142 + void fanotify_show_fdinfo(struct seq_file *m, struct file *f) 137 143 { 138 144 struct fsnotify_group *group = f->private_data; 139 145 unsigned int flags = 0; ··· 155 169 seq_printf(m, "fanotify flags:%x event-flags:%x\n", 156 170 flags, group->fanotify_data.f_flags); 157 171 158 - return show_fdinfo(m, f, fanotify_fdinfo); 172 + show_fdinfo(m, f, fanotify_fdinfo); 159 173 } 160 174 161 175 #endif /* CONFIG_FANOTIFY */
+2 -2
fs/notify/fdinfo.h
··· 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 */
+2 -1
fs/proc/fd.c
··· 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
+1 -3
fs/signalfd.c
··· 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 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
+14 -13
fs/timerfd.c
··· 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 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
+1 -1
include/linux/fs.h
··· 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 {