fsnotify: store struct file not struct path
Al explains that calling dentry_open() with a mnt/dentry pair is only
garunteed to be safe if they are already used in an open struct file. To
make sure this is the case don't store and use a struct path in fsnotify,
always use a struct file.
Signed-off-by: Eric Paris <eparis@redhat.com>
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index 72aae40..4788c86 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -84,7 +84,7 @@
}
/* Notify this dentry's parent about a child's events. */
-void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask)
+void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask)
{
struct dentry *parent;
struct inode *p_inode;
@@ -92,7 +92,7 @@
bool should_update_children = false;
if (!dentry)
- dentry = path->dentry;
+ dentry = file->f_path.dentry;
if (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED))
return;
@@ -124,8 +124,8 @@
* specifies these are events which came from a child. */
mask |= FS_EVENT_ON_CHILD;
- if (path)
- fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
+ if (file)
+ fsnotify(p_inode, mask, file, FSNOTIFY_EVENT_FILE,
dentry->d_name.name, 0);
else
fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
@@ -154,10 +154,10 @@
spin_unlock(&inode->i_lock);
}
- if (data_is == FSNOTIFY_EVENT_PATH) {
+ if (data_is == FSNOTIFY_EVENT_FILE) {
struct vfsmount *mnt;
- mnt = ((struct path *)data)->mnt;
+ mnt = ((struct file *)data)->f_path.mnt;
if (mnt && !hlist_empty(&mnt->mnt_fsnotify_marks)) {
spin_lock(&mnt->mnt_root->d_lock);
hlist_for_each_entry(mark, node, &mnt->mnt_fsnotify_marks, m.m_list) {
@@ -228,8 +228,8 @@
!(test_mask & fsnotify_vfsmount_mask))
return 0;
- if (data_is == FSNOTIFY_EVENT_PATH)
- mnt = ((struct path *)data)->mnt;
+ if (data_is == FSNOTIFY_EVENT_FILE)
+ mnt = ((struct file *)data)->f_path.mnt;
/* if this inode's directed listeners don't care and nothing on the vfsmount
* listeners list cares, nothing to do */