From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:51126 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753553AbdDCPeh (ORCPT ); Mon, 3 Apr 2017 11:34:37 -0400 From: Jan Kara To: Cc: Miklos Szeredi , Amir Goldstein , Paul Moore , Jan Kara Subject: [PATCH 16/35] fsnotify: Avoid double locking in fsnotify_detach_from_object() Date: Mon, 3 Apr 2017 17:34:05 +0200 Message-Id: <20170403153424.24945-17-jack@suse.cz> In-Reply-To: <20170403153424.24945-1-jack@suse.cz> References: <20170403153424.24945-1-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 --- fs/notify/mark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } -- 2.10.2