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

Commit 3a9b16b4 authored by Eric Paris's avatar Eric Paris
Browse files

fsnotify: send fsnotify_mark to groups in event handling functions



With the change of fsnotify to use srcu walking the marks list instead of
walking the global groups list we now know the mark in question.  The code can
send the mark to the group's handling functions and the groups won't have to
find those marks themselves.

Signed-off-by: default avatarEric Paris <eparis@redhat.com>
parent 8778abb9
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ static void dnotify_recalc_inode_mask(struct fsnotify_mark *fsn_mark)
 * events.
 */
static int dnotify_handle_event(struct fsnotify_group *group,
				struct fsnotify_mark *mark,
				struct fsnotify_event *event)
{
	struct fsnotify_mark *fsn_mark = NULL;
@@ -130,7 +131,8 @@ static int dnotify_handle_event(struct fsnotify_group *group,
 */
static bool dnotify_should_send_event(struct fsnotify_group *group,
				      struct inode *inode, struct vfsmount *mnt,
				      __u32 mask, void *data, int data_type)
				      struct fsnotify_mark *mark, __u32 mask,
				      void *data, int data_type)
{
	struct fsnotify_mark *fsn_mark;
	bool send;
+5 −3
Original line number Diff line number Diff line
@@ -114,7 +114,9 @@ static int fanotify_get_response_from_access(struct fsnotify_group *group,
}
#endif

static int fanotify_handle_event(struct fsnotify_group *group, struct fsnotify_event *event)
static int fanotify_handle_event(struct fsnotify_group *group,
				 struct fsnotify_mark *mark,
				 struct fsnotify_event *event)
{
	int ret = 0;
	struct fsnotify_event *notify_event = NULL;
@@ -214,8 +216,8 @@ static bool should_send_inode_event(struct fsnotify_group *group, struct inode *
}

static bool fanotify_should_send_event(struct fsnotify_group *group, struct inode *to_tell,
				       struct vfsmount *mnt, __u32 mask, void *data,
				       int data_type)
				       struct vfsmount *mnt, struct fsnotify_mark *mark,
				       __u32 mask, void *data, int data_type)
{
	pr_debug("%s: group=%p to_tell=%p mnt=%p mask=%x data=%p data_type=%d\n",
		 __func__, group, to_tell, mnt, mask, data, data_type);
+10 −9
Original line number Diff line number Diff line
@@ -171,15 +171,16 @@ void __fsnotify_flush_ignored_mask(struct inode *inode, void *data, int data_is)
}

static int send_to_group(struct fsnotify_group *group, struct inode *to_tell,
			 struct vfsmount *mnt, __u32 mask, void *data,
			 int data_is, u32 cookie, const unsigned char *file_name,
			 struct vfsmount *mnt, struct fsnotify_mark *mark,
			 __u32 mask, void *data, int data_is, u32 cookie,
			 const unsigned char *file_name,
			 struct fsnotify_event **event)
{
	pr_debug("%s: group=%p to_tell=%p mnt=%p mask=%x data=%p data_is=%d"
		 " cookie=%d event=%p\n", __func__, group, to_tell, mnt,
		 mask, data, data_is, cookie, *event);
	pr_debug("%s: group=%p to_tell=%p mnt=%p mark=%p mask=%x data=%p"
		 " data_is=%d cookie=%d event=%p\n", __func__, group, to_tell,
		 mnt, mark, mask, data, data_is, cookie, *event);

	if (!group->ops->should_send_event(group, to_tell, mnt, mask,
	if (!group->ops->should_send_event(group, to_tell, mnt, mark, mask,
					   data, data_is))
		return 0;
	if (!*event) {
@@ -189,7 +190,7 @@ static int send_to_group(struct fsnotify_group *group, struct inode *to_tell,
		if (!*event)
			return -ENOMEM;
	}
	return group->ops->handle_event(group, *event);
	return group->ops->handle_event(group, mark, *event);
}

static bool needed_by_vfsmount(__u32 test_mask, struct vfsmount *mnt)
@@ -252,7 +253,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
				group = mark->group;
				if (!group)
					continue;
				ret = send_to_group(group, to_tell, NULL, mask,
				ret = send_to_group(group, to_tell, NULL, mark, mask,
						    data, data_is, cookie, file_name,
						    &event);
				if (ret)
@@ -271,7 +272,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
				group = mark->group;
				if (!group)
					continue;
				ret = send_to_group(group, to_tell, mnt, mask,
				ret = send_to_group(group, to_tell, mnt, mark, mask,
						    data, data_is, cookie, file_name,
						    &event);
				if (ret)
+5 −3
Original line number Diff line number Diff line
@@ -89,7 +89,9 @@ static struct fsnotify_event *inotify_merge(struct list_head *list,
	return last_event;
}

static int inotify_handle_event(struct fsnotify_group *group, struct fsnotify_event *event)
static int inotify_handle_event(struct fsnotify_group *group,
				struct fsnotify_mark *mark,
				struct fsnotify_event *event)
{
	struct fsnotify_mark *fsn_mark;
	struct inotify_inode_mark *i_mark;
@@ -148,8 +150,8 @@ static void inotify_freeing_mark(struct fsnotify_mark *fsn_mark, struct fsnotify
}

static bool inotify_should_send_event(struct fsnotify_group *group, struct inode *inode,
				      struct vfsmount *mnt, __u32 mask, void *data,
				      int data_type)
				      struct vfsmount *mnt, struct fsnotify_mark *mark,
				      __u32 mask, void *data, int data_type)
{
	struct fsnotify_mark *fsn_mark;
	bool send;
+4 −3
Original line number Diff line number Diff line
@@ -92,9 +92,10 @@ struct fsnotify_event_private_data;
 */
struct fsnotify_ops {
	bool (*should_send_event)(struct fsnotify_group *group, struct inode *inode,
				  struct vfsmount *mnt, __u32 mask, void *data,
				  int data_type);
	int (*handle_event)(struct fsnotify_group *group, struct fsnotify_event *event);
				  struct vfsmount *mnt, struct fsnotify_mark *mark,
				  __u32 mask, void *data, int data_type);
	int (*handle_event)(struct fsnotify_group *group, struct fsnotify_mark *mark,
			    struct fsnotify_event *event);
	void (*free_group_priv)(struct fsnotify_group *group);
	void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
	void (*free_event_priv)(struct fsnotify_event_private_data *priv);
Loading