Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1171766

[RFCv2][PATCH 6/7] fsnotify: change fsnotify_recalc_mask() conventions

From Dave Hansen <dave@sr71.net>
Newsgroups linux.kernel
Subject [RFCv2][PATCH 6/7] fsnotify: change fsnotify_recalc_mask() conventions
Date 2015-06-25 02:20 +0200
Message-ID <pF33A-on-27@gated-at.bofh.it> (permalink)
References <pF33z-on-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Dave Hansen <dave.hansen@linux.intel.com>

fsnotify_recalc_mask() currently takes a list of fsnotify_marks
and calculates a mask from them.  Now that we store the marks
and the masks together in a fsnotify_head, just pass the whole
thing in and have fsnotify_recalc_mask() set ->mask internally.

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/notify/fsnotify.h      |    5 +++--
 b/fs/notify/inode_mark.c    |    6 +++---
 b/fs/notify/mark.c          |    8 +++++---
 b/fs/notify/vfsmount_mark.c |    6 +++---
 4 files changed, 14 insertions(+), 11 deletions(-)

diff -puN fs/notify/fsnotify.h~fsnotify_recalc_mask-redo fs/notify/fsnotify.h
--- a/fs/notify/fsnotify.h~fsnotify_recalc_mask-redo	2015-06-24 17:14:36.757207417 -0700
+++ b/fs/notify/fsnotify.h	2015-06-24 17:14:36.766207822 -0700
@@ -3,6 +3,7 @@
 
 #include <linux/list.h>
 #include <linux/fsnotify.h>
+#include <linux/fsnotify_head.h>
 #include <linux/srcu.h>
 #include <linux/types.h>
 
@@ -12,8 +13,8 @@ extern void fsnotify_flush_notify(struct
 /* protects reads of inode and vfsmount marks list */
 extern struct srcu_struct fsnotify_mark_srcu;
 
-/* Calculate mask of events for a list of marks */
-extern u32 fsnotify_recalc_mask(struct hlist_head *head);
+/* Recalculate the fsnotify_head's mask from its marks */
+extern void fsnotify_recalc_mask(struct fsnotify_head *fsn);
 
 /* compare two groups for sorting of marks lists */
 extern int fsnotify_compare_groups(struct fsnotify_group *a,
diff -puN fs/notify/inode_mark.c~fsnotify_recalc_mask-redo fs/notify/inode_mark.c
--- a/fs/notify/inode_mark.c~fsnotify_recalc_mask-redo	2015-06-24 17:14:36.759207507 -0700
+++ b/fs/notify/inode_mark.c	2015-06-24 17:14:36.766207822 -0700
@@ -37,7 +37,7 @@
 void fsnotify_recalc_inode_mask(struct inode *inode)
 {
 	spin_lock(&inode->i_lock);
-	inode->i_fsnotify.mask = fsnotify_recalc_mask(&inode->i_fsnotify.marks);
+	fsnotify_recalc_mask(&inode->i_fsnotify);
 	spin_unlock(&inode->i_lock);
 
 	__fsnotify_update_child_dentry_flags(inode);
@@ -60,7 +60,7 @@ void fsnotify_destroy_inode_mark(struct
 	 * hold the inode->i_lock, so this is the perfect time to update the
 	 * inode->i_fsnotify.mask
 	 */
-	inode->i_fsnotify.mask = fsnotify_recalc_mask(&inode->i_fsnotify.marks);
+	fsnotify_recalc_mask(&inode->i_fsnotify);
 	spin_unlock(&inode->i_lock);
 }
 
@@ -155,7 +155,7 @@ int fsnotify_add_inode_mark(struct fsnot
 	mark->inode = inode;
 	ret = fsnotify_add_mark_list(&inode->i_fsnotify.marks, mark,
 				     allow_dups);
-	inode->i_fsnotify.mask = fsnotify_recalc_mask(&inode->i_fsnotify.marks);
+	fsnotify_recalc_mask(&inode->i_fsnotify);
 	spin_unlock(&inode->i_lock);
 
 	return ret;
diff -puN fs/notify/mark.c~fsnotify_recalc_mask-redo fs/notify/mark.c
--- a/fs/notify/mark.c~fsnotify_recalc_mask-redo	2015-06-24 17:14:36.760207552 -0700
+++ b/fs/notify/mark.c	2015-06-24 17:14:36.765207777 -0700
@@ -89,6 +89,7 @@
 #include <linux/atomic.h>
 
 #include <linux/fsnotify_backend.h>
+#include <linux/fsnotify_head.h>
 #include "fsnotify.h"
 
 struct srcu_struct fsnotify_mark_srcu;
@@ -111,14 +112,15 @@ void fsnotify_put_mark(struct fsnotify_m
 }
 
 /* Calculate mask of events for a list of marks */
-u32 fsnotify_recalc_mask(struct hlist_head *head)
+void fsnotify_recalc_mask(struct fsnotify_head *fsn)
 {
 	u32 new_mask = 0;
 	struct fsnotify_mark *mark;
 
-	hlist_for_each_entry(mark, head, obj_list)
+	hlist_for_each_entry(mark, &fsn->marks, obj_list)
 		new_mask |= mark->mask;
-	return new_mask;
+
+	fsn->mask = new_mask;
 }
 
 /*
diff -puN fs/notify/vfsmount_mark.c~fsnotify_recalc_mask-redo fs/notify/vfsmount_mark.c
--- a/fs/notify/vfsmount_mark.c~fsnotify_recalc_mask-redo	2015-06-24 17:14:36.762207642 -0700
+++ b/fs/notify/vfsmount_mark.c	2015-06-24 17:14:36.766207822 -0700
@@ -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);
+	fsnotify_recalc_mask(&m->mnt_fsnotify);
 	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);
+	fsnotify_recalc_mask(&m->mnt_fsnotify);
 	spin_unlock(&mnt->mnt_root->d_lock);
 }
 
@@ -120,7 +120,7 @@ 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);
+	fsnotify_recalc_mask(&m->mnt_fsnotify);
 	spin_unlock(&mnt->mnt_root->d_lock);
 
 	return ret;
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFCv2][PATCH 1/7] fs: optimize inotify/fsnotify code for unwatched files Dave Hansen <dave@sr71.net> - 2015-06-25 02:20 +0200
  [RFCv2][PATCH 2/7] fs: use RCU for free_super() vs. __sb_start_write() Dave Hansen <dave@sr71.net> - 2015-06-25 02:20 +0200
  [RFCv2][PATCH 3/7] fs: fsnotify: replace memory barrier in __sb_end_write() with RCU Dave Hansen <dave@sr71.net> - 2015-06-25 02:20 +0200
  [RFCv2][PATCH 4/7] fsnotify: encapsulate embedded fsnotify data in a single spot Dave Hansen <dave@sr71.net> - 2015-06-25 02:20 +0200
  [RFCv2][PATCH 5/7] fsnotify: use fsnotify_head for vfsmount data Dave Hansen <dave@sr71.net> - 2015-06-25 02:20 +0200
  [RFCv2][PATCH 7/7] fsnotify: track when ignored mask clearing is needed Dave Hansen <dave@sr71.net> - 2015-06-25 02:20 +0200
  [RFCv2][PATCH 6/7] fsnotify: change fsnotify_recalc_mask() conventions Dave Hansen <dave@sr71.net> - 2015-06-25 02:20 +0200
  Re: [RFCv2][PATCH 1/7] fs: optimize inotify/fsnotify code for  unwatched files Eric Paris <eparis@redhat.com> - 2015-06-25 03:00 +0200

csiph-web