mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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>
This commit is contained in:
parent
3be25f49b9
commit
c28f7e56e9
6 changed files with 205 additions and 10 deletions
|
@ -23,15 +23,31 @@
|
|||
static inline void fsnotify_d_instantiate(struct dentry *entry,
|
||||
struct inode *inode)
|
||||
{
|
||||
__fsnotify_d_instantiate(entry, inode);
|
||||
|
||||
inotify_d_instantiate(entry, inode);
|
||||
}
|
||||
|
||||
/* Notify this dentry's parent about a child's events. */
|
||||
static inline void fsnotify_parent(struct dentry *dentry, __u32 mask)
|
||||
{
|
||||
__fsnotify_parent(dentry, mask);
|
||||
|
||||
inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
|
||||
}
|
||||
|
||||
/*
|
||||
* fsnotify_d_move - entry has been moved
|
||||
* Called with dcache_lock and entry->d_lock held.
|
||||
*/
|
||||
static inline void fsnotify_d_move(struct dentry *entry)
|
||||
{
|
||||
/*
|
||||
* On move we need to update entry->d_flags to indicate if the new parent
|
||||
* cares about events from this entry.
|
||||
*/
|
||||
__fsnotify_update_dcache_flags(entry);
|
||||
|
||||
inotify_d_move(entry);
|
||||
}
|
||||
|
||||
|
@ -117,7 +133,8 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
|
|||
if (isdir)
|
||||
mask |= FS_IN_ISDIR;
|
||||
dnotify_parent(dentry, DN_DELETE);
|
||||
inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
|
||||
|
||||
fsnotify_parent(dentry, mask);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -188,9 +205,9 @@ static inline void fsnotify_access(struct dentry *dentry)
|
|||
mask |= FS_IN_ISDIR;
|
||||
|
||||
dnotify_parent(dentry, DN_ACCESS);
|
||||
inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
|
||||
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
||||
|
||||
fsnotify_parent(dentry, mask);
|
||||
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
|
||||
}
|
||||
|
||||
|
@ -206,9 +223,9 @@ static inline void fsnotify_modify(struct dentry *dentry)
|
|||
mask |= FS_IN_ISDIR;
|
||||
|
||||
dnotify_parent(dentry, DN_MODIFY);
|
||||
inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
|
||||
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
||||
|
||||
fsnotify_parent(dentry, mask);
|
||||
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
|
||||
}
|
||||
|
||||
|
@ -223,9 +240,9 @@ static inline void fsnotify_open(struct dentry *dentry)
|
|||
if (S_ISDIR(inode->i_mode))
|
||||
mask |= FS_IN_ISDIR;
|
||||
|
||||
inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
|
||||
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
||||
|
||||
fsnotify_parent(dentry, mask);
|
||||
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
|
||||
}
|
||||
|
||||
|
@ -236,16 +253,15 @@ static inline void fsnotify_close(struct file *file)
|
|||
{
|
||||
struct dentry *dentry = file->f_path.dentry;
|
||||
struct inode *inode = dentry->d_inode;
|
||||
const char *name = dentry->d_name.name;
|
||||
fmode_t mode = file->f_mode;
|
||||
__u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE;
|
||||
|
||||
if (S_ISDIR(inode->i_mode))
|
||||
mask |= FS_IN_ISDIR;
|
||||
|
||||
inotify_dentry_parent_queue_event(dentry, mask, 0, name);
|
||||
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
||||
|
||||
fsnotify_parent(dentry, mask);
|
||||
fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE);
|
||||
}
|
||||
|
||||
|
@ -260,9 +276,9 @@ static inline void fsnotify_xattr(struct dentry *dentry)
|
|||
if (S_ISDIR(inode->i_mode))
|
||||
mask |= FS_IN_ISDIR;
|
||||
|
||||
inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
|
||||
inotify_inode_queue_event(inode, mask, 0, NULL, NULL);
|
||||
|
||||
fsnotify_parent(dentry, mask);
|
||||
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE);
|
||||
}
|
||||
|
||||
|
@ -311,8 +327,8 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
|
|||
if (S_ISDIR(inode->i_mode))
|
||||
in_mask |= FS_IN_ISDIR;
|
||||
inotify_inode_queue_event(inode, in_mask, 0, NULL, NULL);
|
||||
inotify_dentry_parent_queue_event(dentry, in_mask, 0,
|
||||
dentry->d_name.name);
|
||||
|
||||
fsnotify_parent(dentry, in_mask);
|
||||
fsnotify(inode, in_mask, inode, FSNOTIFY_EVENT_INODE);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue