aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fsnotify.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.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.h')
-rw-r--r--include/linux/fsnotify.h34
1 files changed, 25 insertions, 9 deletions
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 3856eb6e5973..6a662ed0bc8a 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -23,15 +23,31 @@
23static inline void fsnotify_d_instantiate(struct dentry *entry, 23static inline void fsnotify_d_instantiate(struct dentry *entry,
24 struct inode *inode) 24 struct inode *inode)
25{ 25{
26 __fsnotify_d_instantiate(entry, inode);
27
26 inotify_d_instantiate(entry, inode); 28 inotify_d_instantiate(entry, inode);
27} 29}
28 30
31/* Notify this dentry's parent about a child's events. */
32static inline void fsnotify_parent(struct dentry *dentry, __u32 mask)
33{
34 __fsnotify_parent(dentry, mask);
35
36 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
37}
38
29/* 39/*
30 * fsnotify_d_move - entry has been moved 40 * fsnotify_d_move - entry has been moved
31 * Called with dcache_lock and entry->d_lock held. 41 * Called with dcache_lock and entry->d_lock held.
32 */ 42 */
33static inline void fsnotify_d_move(struct dentry *entry) 43static inline void fsnotify_d_move(struct dentry *entry)
34{ 44{
45 /*
46 * On move we need to update entry->d_flags to indicate if the new parent
47 * cares about events from this entry.
48 */
49 __fsnotify_update_dcache_flags(entry);
50
35 inotify_d_move(entry); 51 inotify_d_move(entry);
36} 52}
37 53
@@ -117,7 +133,8 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
117 if (isdir) 133 if (isdir)
118 mask |= FS_IN_ISDIR; 134 mask |= FS_IN_ISDIR;
119 dnotify_parent(dentry, DN_DELETE); 135 dnotify_parent(dentry, DN_DELETE);
120 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name); 136
137 fsnotify_parent(dentry, mask);
121} 138}
122 139
123/* 140/*
@@ -188,9 +205,9 @@ static inline void fsnotify_access(struct dentry *dentry)
188 mask |= FS_IN_ISDIR; 205 mask |= FS_IN_ISDIR;
189 206
190 dnotify_parent(dentry, DN_ACCESS); 207 dnotify_parent(dentry, DN_ACCESS);
191 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
192 inotify_inode_queue_event(inode, mask, 0, NULL, NULL); 208 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
193 209
210 fsnotify_parent(dentry, mask);
194 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE); 211 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
195} 212}
196 213
@@ -206,9 +223,9 @@ static inline void fsnotify_modify(struct dentry *dentry)
206 mask |= FS_IN_ISDIR; 223 mask |= FS_IN_ISDIR;
207 224
208 dnotify_parent(dentry, DN_MODIFY); 225 dnotify_parent(dentry, DN_MODIFY);
209 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
210 inotify_inode_queue_event(inode, mask, 0, NULL, NULL); 226 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
211 227
228 fsnotify_parent(dentry, mask);
212 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE); 229 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
213} 230}
214 231
@@ -223,9 +240,9 @@ static inline void fsnotify_open(struct dentry *dentry)
223 if (S_ISDIR(inode->i_mode)) 240 if (S_ISDIR(inode->i_mode))
224 mask |= FS_IN_ISDIR; 241 mask |= FS_IN_ISDIR;
225 242
226 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
227 inotify_inode_queue_event(inode, mask, 0, NULL, NULL); 243 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
228 244
245 fsnotify_parent(dentry, mask);
229 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE); 246 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
230} 247}
231 248
@@ -236,16 +253,15 @@ static inline void fsnotify_close(struct file *file)
236{ 253{
237 struct dentry *dentry = file->f_path.dentry; 254 struct dentry *dentry = file->f_path.dentry;
238 struct inode *inode = dentry->d_inode; 255 struct inode *inode = dentry->d_inode;
239 const char *name = dentry->d_name.name;
240 fmode_t mode = file->f_mode; 256 fmode_t mode = file->f_mode;
241 __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; 257 __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE;
242 258
243 if (S_ISDIR(inode->i_mode)) 259 if (S_ISDIR(inode->i_mode))
244 mask |= FS_IN_ISDIR; 260 mask |= FS_IN_ISDIR;
245 261
246 inotify_dentry_parent_queue_event(dentry, mask, 0, name);
247 inotify_inode_queue_event(inode, mask, 0, NULL, NULL); 262 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
248 263
264 fsnotify_parent(dentry, mask);
249 fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE); 265 fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE);
250} 266}
251 267
@@ -260,9 +276,9 @@ static inline void fsnotify_xattr(struct dentry *dentry)
260 if (S_ISDIR(inode->i_mode)) 276 if (S_ISDIR(inode->i_mode))
261 mask |= FS_IN_ISDIR; 277 mask |= FS_IN_ISDIR;
262 278
263 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
264 inotify_inode_queue_event(inode, mask, 0, NULL, NULL); 279 inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
265 280
281 fsnotify_parent(dentry, mask);
266 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE); 282 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
267} 283}
268 284
@@ -311,8 +327,8 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
311 if (S_ISDIR(inode->i_mode)) 327 if (S_ISDIR(inode->i_mode))
312 in_mask |= FS_IN_ISDIR; 328 in_mask |= FS_IN_ISDIR;
313 inotify_inode_queue_event(inode, in_mask, 0, NULL, NULL); 329 inotify_inode_queue_event(inode, in_mask, 0, NULL, NULL);
314 inotify_dentry_parent_queue_event(dentry, in_mask, 0, 330
315 dentry->d_name.name); 331 fsnotify_parent(dentry, in_mask);
316 fsnotify(inode, in_mask, inode, FSNOTIFY_EVENT_INODE); 332 fsnotify(inode, in_mask, inode, FSNOTIFY_EVENT_INODE);
317 } 333 }
318} 334}