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

Commit 5b0457ad authored by Amir Goldstein's avatar Amir Goldstein Committed by Jan Kara
Browse files

fsnotify: remove redundant arguments to handle_event()



inode_mark and vfsmount_mark arguments are passed to handle_event()
operation as function arguments as well as on iter_info struct.
The difference is that iter_info struct may contain marks that should
not be handled and are represented as NULL arguments to inode_mark or
vfsmount_mark.

Instead of passing the inode_mark and vfsmount_mark arguments, add
a report_mask member to iter_info struct to indicate which marks should
be handled, versus marks that should only be kept alive during user
wait.

This change is going to be used for passing more mark types
with handle_event() (i.e. super block marks).

Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent d6f7b98b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -79,12 +79,11 @@ static void dnotify_recalc_inode_mask(struct fsnotify_mark *fsn_mark)
 */
static int dnotify_handle_event(struct fsnotify_group *group,
				struct inode *inode,
				struct fsnotify_mark *inode_mark,
				struct fsnotify_mark *vfsmount_mark,
				u32 mask, const void *data, int data_type,
				const unsigned char *file_name, u32 cookie,
				struct fsnotify_iter_info *iter_info)
{
	struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info);
	struct dnotify_mark *dn_mark;
	struct dnotify_struct *dn;
	struct dnotify_struct **prev;
@@ -95,7 +94,8 @@ static int dnotify_handle_event(struct fsnotify_group *group,
	if (!S_ISDIR(inode->i_mode))
		return 0;

	BUG_ON(vfsmount_mark);
	if (WARN_ON(fsnotify_iter_vfsmount_mark(iter_info)))
		return 0;

	dn_mark = container_of(inode_mark, struct dnotify_mark, fsn_mark);

+6 −8
Original line number Diff line number Diff line
@@ -87,11 +87,12 @@ static int fanotify_get_response(struct fsnotify_group *group,
	return ret;
}

static bool fanotify_should_send_event(struct fsnotify_mark *inode_mark,
				       struct fsnotify_mark *vfsmnt_mark,
				       u32 event_mask,
				       const void *data, int data_type)
static bool fanotify_should_send_event(struct fsnotify_iter_info *iter_info,
				       u32 event_mask, const void *data,
				       int data_type)
{
	struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info);
	struct fsnotify_mark *vfsmnt_mark = fsnotify_iter_vfsmount_mark(iter_info);
	__u32 marks_mask = 0, marks_ignored_mask = 0;
	const struct path *path = data;

@@ -178,8 +179,6 @@ init: __maybe_unused

static int fanotify_handle_event(struct fsnotify_group *group,
				 struct inode *inode,
				 struct fsnotify_mark *inode_mark,
				 struct fsnotify_mark *fanotify_mark,
				 u32 mask, const void *data, int data_type,
				 const unsigned char *file_name, u32 cookie,
				 struct fsnotify_iter_info *iter_info)
@@ -199,8 +198,7 @@ static int fanotify_handle_event(struct fsnotify_group *group,
	BUILD_BUG_ON(FAN_ACCESS_PERM != FS_ACCESS_PERM);
	BUILD_BUG_ON(FAN_ONDIR != FS_ISDIR);

	if (!fanotify_should_send_event(inode_mark, fanotify_mark, mask, data,
					data_type))
	if (!fanotify_should_send_event(iter_info, mask, data, data_type))
		return 0;

	pr_debug("%s: group=%p inode=%p mask=%x\n", __func__, group, inode,
+20 −18
Original line number Diff line number Diff line
@@ -184,22 +184,20 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask
EXPORT_SYMBOL_GPL(__fsnotify_parent);

static int send_to_group(struct inode *to_tell,
			 struct fsnotify_mark *inode_mark,
			 struct fsnotify_mark *vfsmount_mark,
			 __u32 mask, const void *data,
			 int data_is, u32 cookie,
			 const unsigned char *file_name,
			 struct fsnotify_iter_info *iter_info)
{
	struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info);
	struct fsnotify_mark *vfsmount_mark = fsnotify_iter_vfsmount_mark(iter_info);
	struct fsnotify_group *group = NULL;
	__u32 test_mask = (mask & ~FS_EVENT_ON_CHILD);
	__u32 marks_mask = 0;
	__u32 marks_ignored_mask = 0;

	if (unlikely(!inode_mark && !vfsmount_mark)) {
		BUG();
	if (WARN_ON(!iter_info->report_mask))
		return 0;
	}

	/* clear ignored on inode modification */
	if (mask & FS_MODIFY) {
@@ -235,8 +233,7 @@ static int send_to_group(struct inode *to_tell,
	if (!(test_mask & marks_mask & ~marks_ignored_mask))
		return 0;

	return group->ops->handle_event(group, to_tell, inode_mark,
					vfsmount_mark, mask, data, data_is,
	return group->ops->handle_event(group, to_tell, mask, data, data_is,
					file_name, cookie, iter_info);
}

@@ -327,27 +324,32 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
	while (iter_info.inode_mark || iter_info.vfsmount_mark) {
		struct fsnotify_mark *inode_mark = iter_info.inode_mark;
		struct fsnotify_mark *vfsmount_mark = iter_info.vfsmount_mark;
		int cmp;

		if (inode_mark && vfsmount_mark) {
			int cmp = fsnotify_compare_groups(inode_mark->group,
			cmp = fsnotify_compare_groups(inode_mark->group,
						      vfsmount_mark->group);
			if (cmp > 0)
				inode_mark = NULL;
			else if (cmp < 0)
				vfsmount_mark = NULL;
		} else {
			cmp = inode_mark ? -1 : 1;
		}

		ret = send_to_group(to_tell, inode_mark, vfsmount_mark, mask,
				    data, data_is, cookie, file_name,
				    &iter_info);
		iter_info.report_mask = 0;
		if (cmp <= 0)
			iter_info.report_mask |= FSNOTIFY_OBJ_TYPE_INODE_FL;
		if (cmp >= 0)
			iter_info.report_mask |= FSNOTIFY_OBJ_TYPE_VFSMOUNT_FL;

		ret = send_to_group(to_tell, mask, data, data_is, cookie,
				    file_name, &iter_info);

		if (ret && (mask & ALL_FSNOTIFY_PERM_EVENTS))
			goto out;

		if (inode_mark)
		if (iter_info.report_mask & FSNOTIFY_OBJ_TYPE_INODE_FL)
			iter_info.inode_mark =
				fsnotify_next_mark(iter_info.inode_mark);
		if (vfsmount_mark)

		if (iter_info.report_mask & FSNOTIFY_OBJ_TYPE_VFSMOUNT_FL)
			iter_info.vfsmount_mark =
				fsnotify_next_mark(iter_info.vfsmount_mark);
	}
+0 −6
Original line number Diff line number Diff line
@@ -9,12 +9,6 @@

#include "../mount.h"

struct fsnotify_iter_info {
	struct fsnotify_mark *inode_mark;
	struct fsnotify_mark *vfsmount_mark;
	int srcu_idx;
};

/* destroy all events sitting in this groups notification queue */
extern void fsnotify_flush_notify(struct fsnotify_group *group);

+0 −2
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@ extern void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
					   struct fsnotify_group *group);
extern int inotify_handle_event(struct fsnotify_group *group,
				struct inode *inode,
				struct fsnotify_mark *inode_mark,
				struct fsnotify_mark *vfsmount_mark,
				u32 mask, const void *data, int data_type,
				const unsigned char *file_name, u32 cookie,
				struct fsnotify_iter_info *iter_info);
Loading