summaryrefslogtreecommitdiffstats
path: root/fs/notify/mark.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2017-03-15 09:33:58 +0100
committerJan Kara <jack@suse.cz>2017-04-10 17:37:35 +0200
commitf06fd98759451876f51607f60abd74c89b141610 (patch)
treedbdaa1e77b6c9f9e32119afc6c693d7efd53eb86 /fs/notify/mark.c
parenta242677bb1e6faa9bd82bd33afb2621071258231 (diff)
downloadlinux-f06fd98759451876f51607f60abd74c89b141610.tar.gz
linux-f06fd98759451876f51607f60abd74c89b141610.tar.bz2
linux-f06fd98759451876f51607f60abd74c89b141610.zip
fsnotify: Move locking into fsnotify_find_mark()
Move locking of a mark list into fsnotify_find_mark(). This reduces code churn in the following patch changing lock protecting the list. Reviewed-by: Miklos Szeredi <mszeredi@redhat.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/notify/mark.c')
-rw-r--r--fs/notify/mark.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index 06faf166c7ae..0830e0af997a 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -485,16 +485,24 @@ struct fsnotify_mark *fsnotify_find_mark(struct fsnotify_mark_connector *conn,
struct fsnotify_group *group)
{
struct fsnotify_mark *mark;
+ spinlock_t *lock;
if (!conn)
return NULL;
+ if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE)
+ lock = &conn->inode->i_lock;
+ else
+ lock = &conn->mnt->mnt_root->d_lock;
+ spin_lock(lock);
hlist_for_each_entry(mark, &conn->list, obj_list) {
if (mark->group == group) {
fsnotify_get_mark(mark);
+ spin_unlock(lock);
return mark;
}
}
+ spin_unlock(lock);
return NULL;
}