aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fsnotify_backend.h
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2009-05-21 17:01:29 -0400
committerEric Paris <eparis@redhat.com>2009-06-11 14:57:53 -0400
commitc28f7e56e9d95fb531dc3be8df2e7f52bee76d21 (patch)
treeefce13ed8c4f5b312ef0b77950489d52ef5a039a /include/linux/fsnotify_backend.h
parent3be25f49b9d6a97eae9bcb96d3292072b7658bd8 (diff)
fsnotify: parent event notification
inotify and dnotify both use a similar parent notification mechanism. We add a generic parent notification mechanism to fsnotify for both of these to use. This new machanism also adds the dentry flag optimization which exists for inotify to dnotify. Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: Al Viro <viro@zeniv.linux.org.uk> Cc: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'include/linux/fsnotify_backend.h')
-rw-r--r--include/linux/fsnotify_backend.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index cad5c4d75c1d..13d2dd570049 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -46,6 +46,17 @@
46#define FS_DN_RENAME 0x10000000 /* file renamed */ 46#define FS_DN_RENAME 0x10000000 /* file renamed */
47#define FS_DN_MULTISHOT 0x20000000 /* dnotify multishot */ 47#define FS_DN_MULTISHOT 0x20000000 /* dnotify multishot */
48 48
49/* This inode cares about things that happen to its children. Always set for
50 * dnotify and inotify. */
51#define FS_EVENT_ON_CHILD 0x08000000
52
53/* This is a list of all events that may get sent to a parernt based on fs event
54 * happening to inodes inside that directory */
55#define FS_EVENTS_POSS_ON_CHILD (FS_ACCESS | FS_MODIFY | FS_ATTRIB |\
56 FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN |\
57 FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE |\
58 FS_DELETE)
59
49struct fsnotify_group; 60struct fsnotify_group;
50struct fsnotify_event; 61struct fsnotify_event;
51struct fsnotify_mark_entry; 62struct fsnotify_mark_entry;
@@ -183,8 +194,52 @@ struct fsnotify_mark_entry {
183 194
184/* main fsnotify call to send events */ 195/* main fsnotify call to send events */
185extern void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is); 196extern void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is);
197extern void __fsnotify_parent(struct dentry *dentry, __u32 mask);
186extern void __fsnotify_inode_delete(struct inode *inode); 198extern void __fsnotify_inode_delete(struct inode *inode);
187 199
200static inline int fsnotify_inode_watches_children(struct inode *inode)
201{
202 /* FS_EVENT_ON_CHILD is set if the inode may care */
203 if (!(inode->i_fsnotify_mask & FS_EVENT_ON_CHILD))
204 return 0;
205 /* this inode might care about child events, does it care about the
206 * specific set of events that can happen on a child? */
207 return inode->i_fsnotify_mask & FS_EVENTS_POSS_ON_CHILD;
208}
209
210/*
211 * Update the dentry with a flag indicating the interest of its parent to receive
212 * filesystem events when those events happens to this dentry->d_inode.
213 */
214static inline void __fsnotify_update_dcache_flags(struct dentry *dentry)
215{
216 struct dentry *parent;
217
218 assert_spin_locked(&dcache_lock);
219 assert_spin_locked(&dentry->d_lock);
220
221 parent = dentry->d_parent;
222 if (fsnotify_inode_watches_children(parent->d_inode))
223 dentry->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED;
224 else
225 dentry->d_flags &= ~DCACHE_FSNOTIFY_PARENT_WATCHED;
226}
227
228/*
229 * fsnotify_d_instantiate - instantiate a dentry for inode
230 * Called with dcache_lock held.
231 */
232static inline void __fsnotify_d_instantiate(struct dentry *dentry, struct inode *inode)
233{
234 if (!inode)
235 return;
236
237 assert_spin_locked(&dcache_lock);
238
239 spin_lock(&dentry->d_lock);
240 __fsnotify_update_dcache_flags(dentry);
241 spin_unlock(&dentry->d_lock);
242}
188 243
189/* called from fsnotify listeners, such as fanotify or dnotify */ 244/* called from fsnotify listeners, such as fanotify or dnotify */
190 245
@@ -230,9 +285,18 @@ extern struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32
230static inline void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is) 285static inline void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is)
231{} 286{}
232 287
288static inline void __fsnotify_parent(struct dentry *dentry, __u32 mask)
289{}
290
233static inline void __fsnotify_inode_delete(struct inode *inode) 291static inline void __fsnotify_inode_delete(struct inode *inode)
234{} 292{}
235 293
294static inline void __fsnotify_update_dcache_flags(struct dentry *dentry)
295{}
296
297static inline void __fsnotify_d_instantiate(struct dentry *dentry, struct inode *inode)
298{}
299
236#endif /* CONFIG_FSNOTIFY */ 300#endif /* CONFIG_FSNOTIFY */
237 301
238#endif /* __KERNEL __ */ 302#endif /* __KERNEL __ */