Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2069601b authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Revert "fsnotify: store struct file not struct path"



This reverts commit 3bcf3860 (and the
accompanying commit c1e5c954 "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: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ad41a1e0
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -230,15 +230,6 @@ static void __fput(struct file *file)
	might_sleep();

	fsnotify_close(file);

	/*
	 * fsnotify_create_event may have taken one or more references on this
	 * file.  If it did so it left one reference for us to drop to make sure
	 * its calls to fput could not prematurely destroy the file.
	 */
	if (atomic_long_read(&file->f_count))
		return fput(file);

	/*
	 * The function eventpoll_release() should be the first called
	 * in the file cleanup chain.
+4 −4
Original line number Diff line number Diff line
@@ -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) {
+3 −3
Original line number Diff line number Diff line
@@ -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)
+6 −6
Original line number Diff line number Diff line
@@ -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;

+6 −6
Original line number Diff line number Diff line
@@ -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;
	}

Loading