You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Revert "fsnotify: store struct file not struct path"
This reverts commit3bcf3860a4(and the accompanying commitc1e5c95402"vfs/fsnotify: fsnotify_close can delay the final work in fput" that was a horribly ugly hack to make it work at all). The 'struct file' approach not only causes that disgusting hack, it somehow breaks pulseaudio, probably due to some other subtlety with f_count handling. Fix up various conflicts due to later fsnotify work. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
@@ -17,9 +17,9 @@ static bool should_merge(struct fsnotify_event *old, struct fsnotify_event *new)
|
||||
old->data_type == new->data_type &&
|
||||
old->tgid == new->tgid) {
|
||||
switch (old->data_type) {
|
||||
case (FSNOTIFY_EVENT_FILE):
|
||||
if ((old->file->f_path.mnt == new->file->f_path.mnt) &&
|
||||
(old->file->f_path.dentry == new->file->f_path.dentry))
|
||||
case (FSNOTIFY_EVENT_PATH):
|
||||
if ((old->path.mnt == new->path.mnt) &&
|
||||
(old->path.dentry == new->path.dentry))
|
||||
return true;
|
||||
case (FSNOTIFY_EVENT_NONE):
|
||||
return true;
|
||||
@@ -174,7 +174,7 @@ static bool fanotify_should_send_event(struct fsnotify_group *group,
|
||||
return false;
|
||||
|
||||
/* if we don't have enough info to send an event to userspace say no */
|
||||
if (data_type != FSNOTIFY_EVENT_FILE)
|
||||
if (data_type != FSNOTIFY_EVENT_PATH)
|
||||
return false;
|
||||
|
||||
if (inode_mark && vfsmnt_mark) {
|
||||
|
||||
@@ -65,7 +65,7 @@ static int create_fd(struct fsnotify_group *group, struct fsnotify_event *event)
|
||||
if (client_fd < 0)
|
||||
return client_fd;
|
||||
|
||||
if (event->data_type != FSNOTIFY_EVENT_FILE) {
|
||||
if (event->data_type != FSNOTIFY_EVENT_PATH) {
|
||||
WARN_ON(1);
|
||||
put_unused_fd(client_fd);
|
||||
return -EINVAL;
|
||||
@@ -75,8 +75,8 @@ static int create_fd(struct fsnotify_group *group, struct fsnotify_event *event)
|
||||
* we need a new file handle for the userspace program so it can read even if it was
|
||||
* originally opened O_WRONLY.
|
||||
*/
|
||||
dentry = dget(event->file->f_path.dentry);
|
||||
mnt = mntget(event->file->f_path.mnt);
|
||||
dentry = dget(event->path.dentry);
|
||||
mnt = mntget(event->path.mnt);
|
||||
/* it's possible this event was an overflow event. in that case dentry and mnt
|
||||
* are NULL; That's fine, just don't call dentry open */
|
||||
if (dentry && mnt)
|
||||
|
||||
@@ -84,7 +84,7 @@ void __fsnotify_update_child_dentry_flags(struct inode *inode)
|
||||
}
|
||||
|
||||
/* Notify this dentry's parent about a child's events. */
|
||||
void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask)
|
||||
void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask)
|
||||
{
|
||||
struct dentry *parent;
|
||||
struct inode *p_inode;
|
||||
@@ -92,7 +92,7 @@ void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask)
|
||||
bool should_update_children = false;
|
||||
|
||||
if (!dentry)
|
||||
dentry = file->f_path.dentry;
|
||||
dentry = path->dentry;
|
||||
|
||||
if (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED))
|
||||
return;
|
||||
@@ -124,8 +124,8 @@ void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask)
|
||||
* specifies these are events which came from a child. */
|
||||
mask |= FS_EVENT_ON_CHILD;
|
||||
|
||||
if (file)
|
||||
fsnotify(p_inode, mask, file, FSNOTIFY_EVENT_FILE,
|
||||
if (path)
|
||||
fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
|
||||
dentry->d_name.name, 0);
|
||||
else
|
||||
fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
|
||||
@@ -217,8 +217,8 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
|
||||
/* global tests shouldn't care about events on child only the specific event */
|
||||
__u32 test_mask = (mask & ~FS_EVENT_ON_CHILD);
|
||||
|
||||
if (data_is == FSNOTIFY_EVENT_FILE)
|
||||
mnt = ((struct file *)data)->f_path.mnt;
|
||||
if (data_is == FSNOTIFY_EVENT_PATH)
|
||||
mnt = ((struct path *)data)->mnt;
|
||||
else
|
||||
mnt = NULL;
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@ static bool event_compare(struct fsnotify_event *old, struct fsnotify_event *new
|
||||
!strcmp(old->file_name, new->file_name))
|
||||
return true;
|
||||
break;
|
||||
case (FSNOTIFY_EVENT_FILE):
|
||||
if ((old->file->f_path.mnt == new->file->f_path.mnt) &&
|
||||
(old->file->f_path.dentry == new->file->f_path.dentry))
|
||||
case (FSNOTIFY_EVENT_PATH):
|
||||
if ((old->path.mnt == new->path.mnt) &&
|
||||
(old->path.dentry == new->path.dentry))
|
||||
return true;
|
||||
break;
|
||||
case (FSNOTIFY_EVENT_NONE):
|
||||
@@ -147,10 +147,10 @@ static bool inotify_should_send_event(struct fsnotify_group *group, struct inode
|
||||
__u32 mask, void *data, int data_type)
|
||||
{
|
||||
if ((inode_mark->mask & FS_EXCL_UNLINK) &&
|
||||
(data_type == FSNOTIFY_EVENT_FILE)) {
|
||||
struct file *file = data;
|
||||
(data_type == FSNOTIFY_EVENT_PATH)) {
|
||||
struct path *path = data;
|
||||
|
||||
if (d_unlinked(file->f_path.dentry))
|
||||
if (d_unlinked(path->dentry))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+11
-22
@@ -31,7 +31,6 @@
|
||||
* allocated and used.
|
||||
*/
|
||||
|
||||
#include <linux/file.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
@@ -90,8 +89,8 @@ void fsnotify_put_event(struct fsnotify_event *event)
|
||||
if (atomic_dec_and_test(&event->refcnt)) {
|
||||
pr_debug("%s: event=%p\n", __func__, event);
|
||||
|
||||
if (event->data_type == FSNOTIFY_EVENT_FILE)
|
||||
fput(event->file);
|
||||
if (event->data_type == FSNOTIFY_EVENT_PATH)
|
||||
path_put(&event->path);
|
||||
|
||||
BUG_ON(!list_empty(&event->private_data_list));
|
||||
|
||||
@@ -376,8 +375,8 @@ struct fsnotify_event *fsnotify_clone_event(struct fsnotify_event *old_event)
|
||||
}
|
||||
}
|
||||
event->tgid = get_pid(old_event->tgid);
|
||||
if (event->data_type == FSNOTIFY_EVENT_FILE)
|
||||
get_file(event->file);
|
||||
if (event->data_type == FSNOTIFY_EVENT_PATH)
|
||||
path_get(&event->path);
|
||||
|
||||
return event;
|
||||
}
|
||||
@@ -424,22 +423,11 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask,
|
||||
event->data_type = data_type;
|
||||
|
||||
switch (data_type) {
|
||||
case FSNOTIFY_EVENT_FILE: {
|
||||
event->file = data;
|
||||
/*
|
||||
* if this file is about to disappear hold an extra reference
|
||||
* until we return to __fput so we don't have to worry about
|
||||
* future get/put destroying the file under us or generating
|
||||
* additional events. Notice that we change f_mode without
|
||||
* holding f_lock. This is safe since this is the only possible
|
||||
* reference to this object in the kernel (it was about to be
|
||||
* freed, remember?)
|
||||
*/
|
||||
if (!atomic_long_read(&event->file->f_count)) {
|
||||
event->file->f_mode |= FMODE_NONOTIFY;
|
||||
get_file(event->file);
|
||||
}
|
||||
get_file(event->file);
|
||||
case FSNOTIFY_EVENT_PATH: {
|
||||
struct path *path = data;
|
||||
event->path.dentry = path->dentry;
|
||||
event->path.mnt = path->mnt;
|
||||
path_get(&event->path);
|
||||
break;
|
||||
}
|
||||
case FSNOTIFY_EVENT_INODE:
|
||||
@@ -447,7 +435,8 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask,
|
||||
break;
|
||||
case FSNOTIFY_EVENT_NONE:
|
||||
event->inode = NULL;
|
||||
event->file = NULL;
|
||||
event->path.dentry = NULL;
|
||||
event->path.mnt = NULL;
|
||||
break;
|
||||
default:
|
||||
BUG();
|
||||
|
||||
Reference in New Issue
Block a user