From: Jan Kara Date: Thu, 30 Mar 2017 07:14:47 +0000 (+0200) Subject: fsnotify: Avoid double locking in fsnotify_detach_from_object() X-Git-Tag: v4.12-rc1~118^2~21 X-Git-Url: http://git.samba.org/samba.git/?p=sfrench%2Fcifs-2.6.git;a=commitdiff_plain;h=73cd3c33ab793325ebaae27fa58b4f713c16f12c fsnotify: Avoid double locking in fsnotify_detach_from_object() We lock object list lock in fsnotify_detach_from_object() twice - once to detach mark and second time to recalculate mask. That is unnecessary and later it will become problematic as we will free the connector as soon as there is no mark in it. So move recalculation of fsnotify mask into the same critical section that is detaching mark. This also removes recalculation of child dentry flags from fsnotify_detach_from_object(). That is however fine. Those marks will get recalculated once some event happens on a child. Reviewed-by: Miklos Szeredi Signed-off-by: Jan Kara --- diff --git a/fs/notify/mark.c b/fs/notify/mark.c index 08ab7b252322..416ba91750a9 100644 --- a/fs/notify/mark.c +++ b/fs/notify/mark.c @@ -158,9 +158,9 @@ static struct inode *fsnotify_detach_from_object(struct fsnotify_mark *mark) if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE) inode = conn->inode; } + __fsnotify_recalc_mask(conn); mark->connector = NULL; spin_unlock(lock); - fsnotify_recalc_mask(conn); return inode; }