aboutsummaryrefslogtreecommitdiffstats
path: root/fs/notify
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-11-19 13:02:53 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2014-11-19 13:02:53 -0500
commit8ce74dd6057832618957fc2cbd38fa959c3a0a6c (patch)
treeaf3bede951087ebc58988ad073182a85bf899e27 /fs/notify
parent78d28e651f97866d608d9b41f8ad291e65d47dd5 (diff)
parent9761536e1d9e9e1f325fb04d4ad46b15a39eb94a (diff)
Merge tag 'trace-seq-file-cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace into for-next
Pull the beginning of seq_file cleanup from Steven: "I'm looking to clean up the seq_file code and to eventually merge the trace_seq code with seq_file as well, since they basically do the same thing. Part of this process is to remove the return code of seq_printf() and friends as they are rather inconsistent. It is better to use the new function seq_has_overflowed() if you want to stop processing when the buffer is full. Note, if the buffer is full, the seq_file code will throw away the contents, allocate a bigger buffer, and then call your code again to fill in the data. The only thing that breaking out of the function early does is to save a little time which is probably never noticed. I started with patches from Joe Perches and modified them as well. There's many more places that need to be updated before we can convert seq_printf() and friends to return void. But this patch set introduces the seq_has_overflowed() and does some initial updates."
Diffstat (limited to 'fs/notify')
-rw-r--r--fs/notify/fdinfo.c78
-rw-r--r--fs/notify/fdinfo.h4
2 files changed, 34 insertions, 48 deletions
diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c
index 9d7e2b9659cb..6ffd220eb14d 100644
--- a/fs/notify/fdinfo.c
+++ b/fs/notify/fdinfo.c
@@ -20,25 +20,24 @@
20 20
21#if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY) 21#if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY)
22 22
23static int show_fdinfo(struct seq_file *m, struct file *f, 23static void show_fdinfo(struct seq_file *m, struct file *f,
24 int (*show)(struct seq_file *m, struct fsnotify_mark *mark)) 24 void (*show)(struct seq_file *m,
25 struct fsnotify_mark *mark))
25{ 26{
26 struct fsnotify_group *group = f->private_data; 27 struct fsnotify_group *group = f->private_data;
27 struct fsnotify_mark *mark; 28 struct fsnotify_mark *mark;
28 int ret = 0;
29 29
30 mutex_lock(&group->mark_mutex); 30 mutex_lock(&group->mark_mutex);
31 list_for_each_entry(mark, &group->marks_list, g_list) { 31 list_for_each_entry(mark, &group->marks_list, g_list) {
32 ret = show(m, mark); 32 show(m, mark);
33 if (ret) 33 if (seq_has_overflowed(m))
34 break; 34 break;
35 } 35 }
36 mutex_unlock(&group->mark_mutex); 36 mutex_unlock(&group->mark_mutex);
37 return ret;
38} 37}
39 38
40#if defined(CONFIG_EXPORTFS) 39#if defined(CONFIG_EXPORTFS)
41static int show_mark_fhandle(struct seq_file *m, struct inode *inode) 40static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
42{ 41{
43 struct { 42 struct {
44 struct file_handle handle; 43 struct file_handle handle;
@@ -52,71 +51,62 @@ static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
52 ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0); 51 ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0);
53 if ((ret == FILEID_INVALID) || (ret < 0)) { 52 if ((ret == FILEID_INVALID) || (ret < 0)) {
54 WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret); 53 WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret);
55 return 0; 54 return;
56 } 55 }
57 56
58 f.handle.handle_type = ret; 57 f.handle.handle_type = ret;
59 f.handle.handle_bytes = size * sizeof(u32); 58 f.handle.handle_bytes = size * sizeof(u32);
60 59
61 ret = seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:", 60 seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:",
62 f.handle.handle_bytes, f.handle.handle_type); 61 f.handle.handle_bytes, f.handle.handle_type);
63 62
64 for (i = 0; i < f.handle.handle_bytes; i++) 63 for (i = 0; i < f.handle.handle_bytes; i++)
65 ret |= seq_printf(m, "%02x", (int)f.handle.f_handle[i]); 64 seq_printf(m, "%02x", (int)f.handle.f_handle[i]);
66
67 return ret;
68} 65}
69#else 66#else
70static int show_mark_fhandle(struct seq_file *m, struct inode *inode) 67static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
71{ 68{
72 return 0;
73} 69}
74#endif 70#endif
75 71
76#ifdef CONFIG_INOTIFY_USER 72#ifdef CONFIG_INOTIFY_USER
77 73
78static int inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) 74static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
79{ 75{
80 struct inotify_inode_mark *inode_mark; 76 struct inotify_inode_mark *inode_mark;
81 struct inode *inode; 77 struct inode *inode;
82 int ret = 0;
83 78
84 if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE))) 79 if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE)))
85 return 0; 80 return;
86 81
87 inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark); 82 inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark);
88 inode = igrab(mark->i.inode); 83 inode = igrab(mark->i.inode);
89 if (inode) { 84 if (inode) {
90 ret = seq_printf(m, "inotify wd:%x ino:%lx sdev:%x " 85 seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:%x ",
91 "mask:%x ignored_mask:%x ", 86 inode_mark->wd, inode->i_ino, inode->i_sb->s_dev,
92 inode_mark->wd, inode->i_ino, 87 mark->mask, mark->ignored_mask);
93 inode->i_sb->s_dev, 88 show_mark_fhandle(m, inode);
94 mark->mask, mark->ignored_mask); 89 seq_putc(m, '\n');
95 ret |= show_mark_fhandle(m, inode);
96 ret |= seq_putc(m, '\n');
97 iput(inode); 90 iput(inode);
98 } 91 }
99
100 return ret;
101} 92}
102 93
103int inotify_show_fdinfo(struct seq_file *m, struct file *f) 94void 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#endif /* CONFIG_INOTIFY_USER */ 99#endif /* CONFIG_INOTIFY_USER */
109 100
110#ifdef CONFIG_FANOTIFY 101#ifdef CONFIG_FANOTIFY
111 102
112static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) 103static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
113{ 104{
114 unsigned int mflags = 0; 105 unsigned int mflags = 0;
115 struct inode *inode; 106 struct inode *inode;
116 int ret = 0;
117 107
118 if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE)) 108 if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE))
119 return 0; 109 return;
120 110
121 if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY) 111 if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY)
122 mflags |= FAN_MARK_IGNORED_SURV_MODIFY; 112 mflags |= FAN_MARK_IGNORED_SURV_MODIFY;
@@ -124,26 +114,22 @@ static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
124 if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) { 114 if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) {
125 inode = igrab(mark->i.inode); 115 inode = igrab(mark->i.inode);
126 if (!inode) 116 if (!inode)
127 goto out; 117 return;
128 ret = seq_printf(m, "fanotify ino:%lx sdev:%x " 118 seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x ",
129 "mflags:%x mask:%x ignored_mask:%x ", 119 inode->i_ino, inode->i_sb->s_dev,
130 inode->i_ino, inode->i_sb->s_dev, 120 mflags, mark->mask, mark->ignored_mask);
131 mflags, mark->mask, mark->ignored_mask); 121 show_mark_fhandle(m, inode);
132 ret |= show_mark_fhandle(m, inode); 122 seq_putc(m, '\n');
133 ret |= seq_putc(m, '\n');
134 iput(inode); 123 iput(inode);
135 } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) { 124 } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) {
136 struct mount *mnt = real_mount(mark->m.mnt); 125 struct mount *mnt = real_mount(mark->m.mnt);
137 126
138 ret = seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x " 127 seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x ignored_mask:%x\n",
139 "ignored_mask:%x\n", mnt->mnt_id, mflags, 128 mnt->mnt_id, mflags, mark->mask, mark->ignored_mask);
140 mark->mask, mark->ignored_mask);
141 } 129 }
142out:
143 return ret;
144} 130}
145 131
146int fanotify_show_fdinfo(struct seq_file *m, struct file *f) 132void fanotify_show_fdinfo(struct seq_file *m, struct file *f)
147{ 133{
148 struct fsnotify_group *group = f->private_data; 134 struct fsnotify_group *group = f->private_data;
149 unsigned int flags = 0; 135 unsigned int flags = 0;
@@ -169,7 +155,7 @@ int fanotify_show_fdinfo(struct seq_file *m, struct file *f)
169 seq_printf(m, "fanotify flags:%x event-flags:%x\n", 155 seq_printf(m, "fanotify flags:%x event-flags:%x\n",
170 flags, group->fanotify_data.f_flags); 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#endif /* CONFIG_FANOTIFY */ 161#endif /* CONFIG_FANOTIFY */
diff --git a/fs/notify/fdinfo.h b/fs/notify/fdinfo.h
index 556afda990e9..9664c4904d6b 100644
--- a/fs/notify/fdinfo.h
+++ b/fs/notify/fdinfo.h
@@ -10,11 +10,11 @@ struct file;
10#ifdef CONFIG_PROC_FS 10#ifdef CONFIG_PROC_FS
11 11
12#ifdef CONFIG_INOTIFY_USER 12#ifdef CONFIG_INOTIFY_USER
13extern int inotify_show_fdinfo(struct seq_file *m, struct file *f); 13void inotify_show_fdinfo(struct seq_file *m, struct file *f);
14#endif 14#endif
15 15
16#ifdef CONFIG_FANOTIFY 16#ifdef CONFIG_FANOTIFY
17extern int fanotify_show_fdinfo(struct seq_file *m, struct file *f); 17void fanotify_show_fdinfo(struct seq_file *m, struct file *f);
18#endif 18#endif
19 19
20#else /* CONFIG_PROC_FS */ 20#else /* CONFIG_PROC_FS */