diff mbox

[RFCv2,5/7] fsnotify: use fsnotify_head for vfsmount data

Message ID 20150625001607.05D8CFF9@viggo.jf.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dave Hansen June 25, 2015, 12:16 a.m. UTC
From: Dave Hansen <dave.hansen@linux.intel.com>

Use the new 'struct fsnotify_head' for the vfsmount fsnotify data,
just like we did for inodes in the last patch.

Cc: Jan Kara <jack@suse.cz>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
---

 b/fs/mount.h                         |    6 ++----
 b/fs/namespace.c                     |    2 +-
 b/fs/notify/fanotify/fanotify_user.c |    4 ++--
 b/fs/notify/fsnotify.c               |    8 ++++----
 b/fs/notify/vfsmount_mark.c          |   14 +++++++-------
 5 files changed, 16 insertions(+), 18 deletions(-)
diff mbox

Patch

diff -puN fs/mount.h~fsnotify_head_mnt fs/mount.h
--- a/fs/mount.h~fsnotify_head_mnt	2015-06-24 17:14:36.276185800 -0700
+++ b/fs/mount.h	2015-06-24 17:14:36.286186250 -0700
@@ -3,6 +3,7 @@ 
 #include <linux/poll.h>
 #include <linux/ns_common.h>
 #include <linux/fs_pin.h>
+#include <linux/fsnotify_head.h>
 
 struct mnt_namespace {
 	atomic_t		count;
@@ -55,10 +56,7 @@  struct mount {
 	struct mnt_namespace *mnt_ns;	/* containing namespace */
 	struct mountpoint *mnt_mp;	/* where is it mounted */
 	struct hlist_node mnt_mp_list;	/* list mounts with the same mountpoint */
-#ifdef CONFIG_FSNOTIFY
-	struct hlist_head mnt_fsnotify_marks;
-	__u32 mnt_fsnotify_mask;
-#endif
+	struct fsnotify_head mnt_fsnotify;
 	int mnt_id;			/* mount identifier */
 	int mnt_group_id;		/* peer group identifier */
 	int mnt_expiry_mark;		/* true if marked for expiry */
diff -puN fs/namespace.c~fsnotify_head_mnt fs/namespace.c
--- a/fs/namespace.c~fsnotify_head_mnt	2015-06-24 17:14:36.278185890 -0700
+++ b/fs/namespace.c	2015-06-24 17:14:36.287186295 -0700
@@ -235,7 +235,7 @@  static struct mount *alloc_vfsmnt(const
 		INIT_LIST_HEAD(&mnt->mnt_slave);
 		INIT_HLIST_NODE(&mnt->mnt_mp_list);
 #ifdef CONFIG_FSNOTIFY
-		INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks);
+		INIT_HLIST_HEAD(&mnt->mnt_fsnotify.marks);
 #endif
 		init_fs_pin(&mnt->mnt_umount, drop_mountpoint);
 	}
diff -puN fs/notify/fanotify/fanotify_user.c~fsnotify_head_mnt fs/notify/fanotify/fanotify_user.c
--- a/fs/notify/fanotify/fanotify_user.c~fsnotify_head_mnt	2015-06-24 17:14:36.279185935 -0700
+++ b/fs/notify/fanotify/fanotify_user.c	2015-06-24 17:14:36.287186295 -0700
@@ -533,7 +533,7 @@  static int fanotify_remove_vfsmount_mark
 	mutex_unlock(&group->mark_mutex);
 
 	fsnotify_put_mark(fsn_mark);
-	if (removed & real_mount(mnt)->mnt_fsnotify_mask)
+	if (removed & real_mount(mnt)->mnt_fsnotify.mask)
 		fsnotify_recalc_vfsmount_mask(mnt);
 
 	return 0;
@@ -641,7 +641,7 @@  static int fanotify_add_vfsmount_mark(st
 	added = fanotify_mark_add_to_mask(fsn_mark, mask, flags);
 	mutex_unlock(&group->mark_mutex);
 
-	if (added & ~real_mount(mnt)->mnt_fsnotify_mask)
+	if (added & ~real_mount(mnt)->mnt_fsnotify.mask)
 		fsnotify_recalc_vfsmount_mask(mnt);
 
 	fsnotify_put_mark(fsn_mark);
diff -puN fs/notify/fsnotify.c~fsnotify_head_mnt fs/notify/fsnotify.c
--- a/fs/notify/fsnotify.c~fsnotify_head_mnt	2015-06-24 17:14:36.281186025 -0700
+++ b/fs/notify/fsnotify.c	2015-06-24 17:14:36.288186339 -0700
@@ -211,7 +211,7 @@  int fsnotify(struct inode *to_tell, __u3
 	 */
 	if (!(mask & FS_MODIFY) &&
 	    !(test_mask & to_tell->i_fsnotify.mask) &&
-	    !(mnt && test_mask & mnt->mnt_fsnotify_mask))
+	    !(mnt && test_mask & mnt->mnt_fsnotify.mask))
 		return 0;
 	/*
 	 * Optimization: srcu_read_lock() has a memory barrier which can
@@ -221,7 +221,7 @@  int fsnotify(struct inode *to_tell, __u3
 	 * need SRCU to keep them "alive".
 	 */
 	if (!to_tell->i_fsnotify.marks.first &&
-	    (!mnt || !mnt->mnt_fsnotify_marks.first))
+	    (!mnt || !mnt->mnt_fsnotify.marks.first))
 		return 0;
 
 	idx = srcu_read_lock(&fsnotify_mark_srcu);
@@ -232,8 +232,8 @@  int fsnotify(struct inode *to_tell, __u3
 					      &fsnotify_mark_srcu);
 
 	if (mnt && ((mask & FS_MODIFY) ||
-		    (test_mask & mnt->mnt_fsnotify_mask))) {
-		vfsmount_node = srcu_dereference(mnt->mnt_fsnotify_marks.first,
+		    (test_mask & mnt->mnt_fsnotify.mask))) {
+		vfsmount_node = srcu_dereference(mnt->mnt_fsnotify.marks.first,
 						 &fsnotify_mark_srcu);
 		inode_node = srcu_dereference(to_tell->i_fsnotify.marks.first,
 					      &fsnotify_mark_srcu);
diff -puN fs/notify/vfsmount_mark.c~fsnotify_head_mnt fs/notify/vfsmount_mark.c
--- a/fs/notify/vfsmount_mark.c~fsnotify_head_mnt	2015-06-24 17:14:36.282186070 -0700
+++ b/fs/notify/vfsmount_mark.c	2015-06-24 17:14:36.288186339 -0700
@@ -38,7 +38,7 @@  void fsnotify_clear_marks_by_mount(struc
 	LIST_HEAD(free_list);
 
 	spin_lock(&mnt->mnt_root->d_lock);
-	hlist_for_each_entry_safe(mark, n, &m->mnt_fsnotify_marks, obj_list) {
+	hlist_for_each_entry_safe(mark, n, &m->mnt_fsnotify.marks, obj_list) {
 		list_add(&mark->free_list, &free_list);
 		hlist_del_init_rcu(&mark->obj_list);
 		fsnotify_get_mark(mark);
@@ -54,7 +54,7 @@  void fsnotify_clear_vfsmount_marks_by_gr
 }
 
 /*
- * Recalculate the mnt->mnt_fsnotify_mask, or the mask of all FS_* event types
+ * Recalculate the mnt->mnt_fsnotify.mask, or the mask of all FS_* event types
  * any notifier is interested in hearing for this mount point
  */
 void fsnotify_recalc_vfsmount_mask(struct vfsmount *mnt)
@@ -62,7 +62,7 @@  void fsnotify_recalc_vfsmount_mask(struc
 	struct mount *m = real_mount(mnt);
 
 	spin_lock(&mnt->mnt_root->d_lock);
-	m->mnt_fsnotify_mask = fsnotify_recalc_mask(&m->mnt_fsnotify_marks);
+	m->mnt_fsnotify.mask = fsnotify_recalc_mask(&m->mnt_fsnotify.marks);
 	spin_unlock(&mnt->mnt_root->d_lock);
 }
 
@@ -79,7 +79,7 @@  void fsnotify_destroy_vfsmount_mark(stru
 	hlist_del_init_rcu(&mark->obj_list);
 	mark->mnt = NULL;
 
-	m->mnt_fsnotify_mask = fsnotify_recalc_mask(&m->mnt_fsnotify_marks);
+	m->mnt_fsnotify.mask = fsnotify_recalc_mask(&m->mnt_fsnotify.marks);
 	spin_unlock(&mnt->mnt_root->d_lock);
 }
 
@@ -94,7 +94,7 @@  struct fsnotify_mark *fsnotify_find_vfsm
 	struct fsnotify_mark *mark;
 
 	spin_lock(&mnt->mnt_root->d_lock);
-	mark = fsnotify_find_mark(&m->mnt_fsnotify_marks, group);
+	mark = fsnotify_find_mark(&m->mnt_fsnotify.marks, group);
 	spin_unlock(&mnt->mnt_root->d_lock);
 
 	return mark;
@@ -119,8 +119,8 @@  int fsnotify_add_vfsmount_mark(struct fs
 
 	spin_lock(&mnt->mnt_root->d_lock);
 	mark->mnt = mnt;
-	ret = fsnotify_add_mark_list(&m->mnt_fsnotify_marks, mark, allow_dups);
-	m->mnt_fsnotify_mask = fsnotify_recalc_mask(&m->mnt_fsnotify_marks);
+	ret = fsnotify_add_mark_list(&m->mnt_fsnotify.marks, mark, allow_dups);
+	m->mnt_fsnotify.mask = fsnotify_recalc_mask(&m->mnt_fsnotify.marks);
 	spin_unlock(&mnt->mnt_root->d_lock);
 
 	return ret;