[PATCH 3/5] fsnotify: dont call fsnotify_add_[inode|vfsmount]_mark() with mark lock held.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dont call fsnotify_add_[inode|vfsmount]_mark() with the mark lock already held,
but take the lock in these functions.

Signed-off-by: Lino Sanfilippo <LinoSanfilippo@xxxxxx>
---
 fs/notify/inode_mark.c    |    8 ++++++--
 fs/notify/mark.c          |    8 --------
 fs/notify/vfsmount_mark.c |    8 ++++++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c
index a9b8661..b357e4b 100644
--- a/fs/notify/inode_mark.c
+++ b/fs/notify/inode_mark.c
@@ -186,12 +186,13 @@ int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
 	struct hlist_node *node, *last = NULL;
 	int ret = 0;
 
+	spin_lock(&mark->lock);
+	mark->group = group;
+	mark->flags |= FSNOTIFY_MARK_FLAG_ALIVE;
 	mark->flags |= FSNOTIFY_MARK_FLAG_INODE;
 	mark->i.inode = igrab(inode);
 	mark->flags |= FSNOTIFY_MARK_FLAG_OBJECT_PINNED;
 
-	assert_spin_locked(&mark->lock);
-
 	spin_lock(&inode->i_lock);
 	/* is mark the first mark? */
 	if (hlist_empty(&inode->i_fsnotify_marks)) {
@@ -231,7 +232,10 @@ out:
 		iput(mark->i.inode);
 		mark->i.inode = NULL;
 		mark->flags &= ~FSNOTIFY_MARK_FLAG_INODE;
+		mark->flags &= ~FSNOTIFY_MARK_FLAG_ALIVE;
+		mark->group = NULL;
 	}
+	spin_unlock(&mark->lock);
 
 	return ret;
 }
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index 6d9bf1d..57f8dd6 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -202,10 +202,7 @@ int fsnotify_add_mark_locked(struct fsnotify_mark *mark,
 {
 	int ret;
 
-	spin_lock(&mark->lock);
 
-	mark->flags |= FSNOTIFY_MARK_FLAG_ALIVE;
-	mark->group = group;
 	list_add(&mark->g_list, &group->marks_list);
 	fsnotify_get_mark(mark); /* for i_list and g_list */
 	atomic_inc(&group->num_marks);
@@ -220,20 +217,15 @@ int fsnotify_add_mark_locked(struct fsnotify_mark *mark,
 	if (ret)
 		goto err;
 
-	spin_unlock(&mark->lock);
 
 	if (inode)
 		__fsnotify_update_child_dentry_flags(inode);
 
 	return 0;
 err:
-	mark->flags &= ~FSNOTIFY_MARK_FLAG_ALIVE;
 	list_del_init(&mark->g_list);
-	mark->group = NULL;
 	atomic_dec(&group->num_marks);
 
-	spin_unlock(&mark->lock);
-
 	spin_lock(&destroy_lock);
 	list_add(&mark->destroy_list, &destroy_list);
 	spin_unlock(&destroy_lock);
diff --git a/fs/notify/vfsmount_mark.c b/fs/notify/vfsmount_mark.c
index b33e78b..a6fe562 100644
--- a/fs/notify/vfsmount_mark.c
+++ b/fs/notify/vfsmount_mark.c
@@ -143,11 +143,12 @@ int fsnotify_add_vfsmount_mark(struct fsnotify_mark *mark,
 	struct hlist_node *node, *last = NULL;
 	int ret = 0;
 
+	spin_lock(&mark->lock);
+	mark->group = group;
+	mark->flags |= FSNOTIFY_MARK_FLAG_ALIVE;
 	mark->flags |= FSNOTIFY_MARK_FLAG_VFSMOUNT;
 	mark->m.mnt = mnt;
 
-	assert_spin_locked(&mark->lock);
-
 	spin_lock(&mnt->mnt_root->d_lock);
 	/* is mark the first mark? */
 	if (hlist_empty(&mnt->mnt_fsnotify_marks)) {
@@ -185,7 +186,10 @@ out:
 	if (ret) {
 		mark->m.mnt = NULL;
 		mark->flags &= ~FSNOTIFY_MARK_FLAG_VFSMOUNT;
+		mark->flags &= ~FSNOTIFY_MARK_FLAG_ALIVE;
+		mark->group = NULL;
 	}
+	spin_unlock(&mark->lock);
 
 	return ret;
 }
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux