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

Commit 5444e298 authored by Eric Paris's avatar Eric Paris
Browse files

fsnotify: split generic and inode specific mark code



currently all marking is done by functions in inode-mark.c.  Some of this
is pretty generic and should be instead done in a generic function and we
should only put the inode specific code in inode-mark.c

Signed-off-by: default avatarEric Paris <eparis@redhat.com>
parent 32c32632
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
obj-$(CONFIG_FSNOTIFY)		+= fsnotify.o notification.o group.o inode_mark.o
obj-$(CONFIG_FSNOTIFY)		+= fsnotify.o notification.o group.o inode_mark.o \
				   mark.o

obj-y			+= dnotify/
obj-y			+= inotify/
+6 −6
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ static int dnotify_handle_event(struct fsnotify_group *group,

	to_tell = event->to_tell;

	fsn_mark = fsnotify_find_mark(group, to_tell);
	fsn_mark = fsnotify_find_inode_mark(group, to_tell);
	if (unlikely(!fsn_mark))
		return 0;
	dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
@@ -143,14 +143,14 @@ static bool dnotify_should_send_event(struct fsnotify_group *group,
	if (!S_ISDIR(inode->i_mode))
		return false;

	fsn_mark = fsnotify_find_mark(group, inode);
	fsn_mark = fsnotify_find_inode_mark(group, inode);
	if (!fsn_mark)
		return false;

	mask = (mask & ~FS_EVENT_ON_CHILD);
	send = (mask & fsn_mark->mask);

	fsnotify_put_mark(fsn_mark); /* matches fsnotify_find_mark */
	fsnotify_put_mark(fsn_mark); /* matches fsnotify_find_inode_mark */

	return send;
}
@@ -193,7 +193,7 @@ void dnotify_flush(struct file *filp, fl_owner_t id)
	if (!S_ISDIR(inode->i_mode))
		return;

	fsn_mark = fsnotify_find_mark(dnotify_group, inode);
	fsn_mark = fsnotify_find_inode_mark(dnotify_group, inode);
	if (!fsn_mark)
		return;
	dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
@@ -346,12 +346,12 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
	mutex_lock(&dnotify_mark_mutex);

	/* add the new_fsn_mark or find an old one. */
	fsn_mark = fsnotify_find_mark(dnotify_group, inode);
	fsn_mark = fsnotify_find_inode_mark(dnotify_group, inode);
	if (fsn_mark) {
		dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
		spin_lock(&fsn_mark->lock);
	} else {
		fsnotify_add_mark(new_fsn_mark, dnotify_group, inode, 0);
		fsnotify_add_mark(new_fsn_mark, dnotify_group, inode, NULL, 0);
		spin_lock(&new_fsn_mark->lock);
		fsn_mark = new_fsn_mark;
		dn_mark = new_dn_mark;
+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ static bool fanotify_should_send_event(struct fsnotify_group *group, struct inod
	if (data_type != FSNOTIFY_EVENT_PATH)
		return false;

	fsn_mark = fsnotify_find_mark(group, inode);
	fsn_mark = fsnotify_find_inode_mark(group, inode);
	if (!fsn_mark)
		return false;

+4 −4
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ static int fanotify_remove_mark(struct fsnotify_group *group,
	pr_debug("%s: group=%p inode=%p mask=%x\n", __func__,
		 group, inode, mask);

	fsn_mark = fsnotify_find_mark(group, inode);
	fsn_mark = fsnotify_find_inode_mark(group, inode);
	if (!fsn_mark)
		return -ENOENT;

@@ -321,7 +321,7 @@ static int fanotify_remove_mark(struct fsnotify_group *group,

	fsnotify_recalc_group_mask(group);

	/* matches the fsnotify_find_mark() */
	/* matches the fsnotify_find_inode_mark() */
	fsnotify_put_mark(fsn_mark);

	return 0;
@@ -338,7 +338,7 @@ static int fanotify_add_mark(struct fsnotify_group *group,
	pr_debug("%s: group=%p inode=%p mask=%x\n", __func__,
		 group, inode, mask);

	fsn_mark = fsnotify_find_mark(group, inode);
	fsn_mark = fsnotify_find_inode_mark(group, inode);
	if (!fsn_mark) {
		struct fsnotify_mark *new_fsn_mark;

@@ -348,7 +348,7 @@ static int fanotify_add_mark(struct fsnotify_group *group,
			goto out;

		fsnotify_init_mark(new_fsn_mark, fanotify_free_mark);
		ret = fsnotify_add_mark(new_fsn_mark, group, inode, 0);
		ret = fsnotify_add_mark(new_fsn_mark, group, inode, NULL, 0);
		if (ret) {
			fanotify_free_mark(new_fsn_mark);
			goto out;
+7 −0
Original line number Diff line number Diff line
@@ -20,6 +20,11 @@ extern __u32 fsnotify_vfsmount_mask;
/* destroy all events sitting in this groups notification queue */
extern void fsnotify_flush_notify(struct fsnotify_group *group);

/* add a mark to an inode */
extern int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
				   struct fsnotify_group *group, struct inode *inode,
				   int allow_dups);

/* add a group to the inode group list */
extern void fsnotify_add_inode_group(struct fsnotify_group *group);
/* add a group to the vfsmount group list */
@@ -27,6 +32,8 @@ extern void fsnotify_add_vfsmount_group(struct fsnotify_group *group);
/* final kfree of a group */
extern void fsnotify_final_destroy_group(struct fsnotify_group *group);

/* inode specific destruction of a mark */
extern void fsnotify_destroy_inode_mark(struct fsnotify_mark *mark);
/* run the list of all marks associated with inode and flag them to be freed */
extern void fsnotify_clear_marks_by_inode(struct inode *inode);
/*
Loading