aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fsnotify.h
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2009-12-17 21:24:25 -0500
committerEric Paris <eparis@redhat.com>2010-07-28 09:58:54 -0400
commitecf081d1a73b077916f514f2ec744ded32b88ca1 (patch)
treef1a9892131a297d0f67cb0fd9189e3aac83e2219 /include/linux/fsnotify.h
parent35566087099c3ff8901d65ee98af56347ee66e5a (diff)
vfs: introduce FMODE_NONOTIFY
This is a new f_mode which can only be set by the kernel. It indicates that the fd was opened by fanotify and should not cause future fanotify events. This is needed to prevent fanotify livelock. An example of obvious livelock is from fanotify close events. Process A closes file1 This creates a close event for file1. fanotify opens file1 for Listener X Listener X deals with the event and closes its fd for file1. This creates a close event for file1. fanotify opens file1 for Listener X Listener X deals with the event and closes its fd for file1. This creates a close event for file1. fanotify opens file1 for Listener X Listener X deals with the event and closes its fd for file1. notice a pattern? The fix is to add the FMODE_NONOTIFY bit to the open filp done by the kernel for fanotify. Thus when that file is used it will not generate future events. This patch simply defines the bit. Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'include/linux/fsnotify.h')
-rw-r--r--include/linux/fsnotify.h24
1 files changed, 16 insertions, 8 deletions
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 62e93a9dd115..5184a2b786c1 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -165,8 +165,10 @@ static inline void fsnotify_access(struct file *file)
165 if (S_ISDIR(inode->i_mode)) 165 if (S_ISDIR(inode->i_mode))
166 mask |= FS_IN_ISDIR; 166 mask |= FS_IN_ISDIR;
167 167
168 fsnotify_parent(path, NULL, mask); 168 if (!(file->f_mode & FMODE_NONOTIFY)) {
169 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 169 fsnotify_parent(path, NULL, mask);
170 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
171 }
170} 172}
171 173
172/* 174/*
@@ -181,8 +183,10 @@ static inline void fsnotify_modify(struct file *file)
181 if (S_ISDIR(inode->i_mode)) 183 if (S_ISDIR(inode->i_mode))
182 mask |= FS_IN_ISDIR; 184 mask |= FS_IN_ISDIR;
183 185
184 fsnotify_parent(path, NULL, mask); 186 if (!(file->f_mode & FMODE_NONOTIFY)) {
185 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 187 fsnotify_parent(path, NULL, mask);
188 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
189 }
186} 190}
187 191
188/* 192/*
@@ -197,8 +201,10 @@ static inline void fsnotify_open(struct file *file)
197 if (S_ISDIR(inode->i_mode)) 201 if (S_ISDIR(inode->i_mode))
198 mask |= FS_IN_ISDIR; 202 mask |= FS_IN_ISDIR;
199 203
200 fsnotify_parent(path, NULL, mask); 204 if (!(file->f_mode & FMODE_NONOTIFY)) {
201 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 205 fsnotify_parent(path, NULL, mask);
206 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
207 }
202} 208}
203 209
204/* 210/*
@@ -214,8 +220,10 @@ static inline void fsnotify_close(struct file *file)
214 if (S_ISDIR(inode->i_mode)) 220 if (S_ISDIR(inode->i_mode))
215 mask |= FS_IN_ISDIR; 221 mask |= FS_IN_ISDIR;
216 222
217 fsnotify_parent(path, NULL, mask); 223 if (!(file->f_mode & FMODE_NONOTIFY)) {
218 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 224 fsnotify_parent(path, NULL, mask);
225 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
226 }
219} 227}
220 228
221/* 229/*