linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Eric Paris <eparis@redhat.com>, Jan Kara <jack@suse.cz>
Subject: [PATCH 2/3] fsnotify: Remove free_list list_head from fsnotify_mark
Date: Thu,  6 Nov 2014 14:03:39 +0100	[thread overview]
Message-ID: <1415279020-9175-3-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1415279020-9175-1-git-send-email-jack@suse.cz>

free_list list head is used only when all marks for an inode / mount
need to be destroyed. However we can just use obj_list for this
temporary tracking thus saving two pointers for each fsnotify_mark.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/notify/fsnotify.h             | 2 +-
 fs/notify/inode_mark.c           | 6 +++---
 fs/notify/mark.c                 | 7 ++++---
 fs/notify/vfsmount_mark.c        | 6 +++---
 include/linux/fsnotify_backend.h | 1 -
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/fs/notify/fsnotify.h b/fs/notify/fsnotify.h
index 7cf2f76fea4d..c1ad23c665cc 100644
--- a/fs/notify/fsnotify.h
+++ b/fs/notify/fsnotify.h
@@ -36,7 +36,7 @@ extern void fsnotify_destroy_vfsmount_mark(struct fsnotify_mark *mark);
 /* inode specific destruction of a mark */
 extern void fsnotify_destroy_inode_mark(struct fsnotify_mark *mark);
 /* Destroy all marks in the given list */
-extern void fsnotify_destroy_marks(struct list_head *to_free);
+extern void fsnotify_destroy_marks(struct hlist_head *to_free);
 /* Find mark belonging to given group in the list of marks */
 extern struct fsnotify_mark *fsnotify_find_mark(struct hlist_head *head,
 						struct fsnotify_group *group);
diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c
index a790505ba59f..15a71fdf677a 100644
--- a/fs/notify/inode_mark.c
+++ b/fs/notify/inode_mark.c
@@ -87,14 +87,14 @@ void fsnotify_clear_marks_by_inode(struct inode *inode)
 {
 	struct fsnotify_mark *mark;
 	struct hlist_node *n;
-	LIST_HEAD(free_list);
+	HLIST_HEAD(free_list);
 
+	/* Detach list from inode and grab us reference to each mark */
 	spin_lock(&inode->i_lock);
 	hlist_for_each_entry_safe(mark, n, &inode->i_fsnotify_marks, obj_list) {
-		list_add(&mark->free_list, &free_list);
-		hlist_del_init_rcu(&mark->obj_list);
 		fsnotify_get_mark(mark);
 	}
+	hlist_move_list(&inode->i_fsnotify_marks, &free_list);
 	spin_unlock(&inode->i_lock);
 
 	fsnotify_destroy_marks(&free_list);
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index 28c855a5058e..70dba449c33f 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -196,12 +196,13 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark,
  * Destroy all marks in the given list. The marks must be already detached from
  * the original inode / vfsmount.
  */
-void fsnotify_destroy_marks(struct list_head *to_free)
+void fsnotify_destroy_marks(struct hlist_head *to_free)
 {
-	struct fsnotify_mark *mark, *lmark;
+	struct fsnotify_mark *mark;
+	struct hlist_node *next;
 	struct fsnotify_group *group;
 
-	list_for_each_entry_safe(mark, lmark, to_free, free_list) {
+	hlist_for_each_entry_safe(mark, next, to_free, obj_list) {
 		spin_lock(&mark->lock);
 		fsnotify_get_group(mark->group);
 		group = mark->group;
diff --git a/fs/notify/vfsmount_mark.c b/fs/notify/vfsmount_mark.c
index 62d405ac7c34..c76860a761a5 100644
--- a/fs/notify/vfsmount_mark.c
+++ b/fs/notify/vfsmount_mark.c
@@ -35,14 +35,14 @@ void fsnotify_clear_marks_by_mount(struct vfsmount *mnt)
 	struct fsnotify_mark *mark;
 	struct hlist_node *n;
 	struct mount *m = real_mount(mnt);
-	LIST_HEAD(free_list);
+	HLIST_HEAD(free_list);
 
+	/* Detach list from mount and grab us reference to each mark */
 	spin_lock(&mnt->mnt_root->d_lock);
 	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);
 	}
+	hlist_move_list(&m->mnt_fsnotify_marks, &free_list);
 	spin_unlock(&mnt->mnt_root->d_lock);
 
 	fsnotify_destroy_marks(&free_list);
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 442847a02b8f..82022da18035 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -215,7 +215,6 @@ struct fsnotify_mark {
 	struct list_head g_list;	/* list of marks by group->i_fsnotify_marks */
 	spinlock_t lock;		/* protect group and inode */
 	struct hlist_node obj_list;	/* list of marks for inode / vfsmount */
-	struct list_head free_list;	/* tmp list used when freeing this mark */
 	union {
 		struct inode *inode;	/* inode this mark is associated with */
 		struct vfsmount *mnt;	/* vfsmount this mark is associated with */
-- 
1.8.1.4


  parent reply	other threads:[~2014-11-06 13:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-06 13:03 [PATCH 0/3] fsnotify: Cleanups Jan Kara
2014-11-06 13:03 ` [PATCH 1/3] fsnotify: Unify inode and mount marks handling Jan Kara
2014-11-06 13:03 ` Jan Kara [this message]
2014-11-06 13:03 ` [PATCH 3/3] fsnotify: Remove destroy_list from fsnotify_mark Jan Kara
2014-11-06 21:17   ` Heinrich Schuchardt
2014-11-10 10:30     ` Jan Kara
2014-11-10 12:54       ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415279020-9175-3-git-send-email-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=eparis@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).