From patchwork Tue Mar 28 16:13:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9650199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E25E56034B for ; Tue, 28 Mar 2017 16:14:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2DF628414 for ; Tue, 28 Mar 2017 16:14:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C80052841C; Tue, 28 Mar 2017 16:14:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 773982841A for ; Tue, 28 Mar 2017 16:14:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753487AbdC1QO3 (ORCPT ); Tue, 28 Mar 2017 12:14:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:52909 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755251AbdC1QOT (ORCPT ); Tue, 28 Mar 2017 12:14:19 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 51EDAAE00; Tue, 28 Mar 2017 16:13:38 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 148AA1E1253; Tue, 28 Mar 2017 18:13:35 +0200 (CEST) From: Jan Kara To: Cc: Miklos Szeredi , Amir Goldstein , Paul Moore , Jan Kara Subject: [PATCH 13/33] fsnotify: Determine lock in fsnotify_destroy_marks() Date: Tue, 28 Mar 2017 18:13:12 +0200 Message-Id: <20170328161332.29736-14-jack@suse.cz> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170328161332.29736-1-jack@suse.cz> References: <20170328161332.29736-1-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of passing spinlock into fsnotify_destroy_marks() determine it directly in that function from the connector type. This will reduce code churn when changing lock protecting list of marks. Reviewed-by: Amir Goldstein Signed-off-by: Jan Kara --- fs/notify/fsnotify.h | 10 ++++------ fs/notify/mark.c | 9 +++++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/notify/fsnotify.h b/fs/notify/fsnotify.h index 96051780d50e..225924274f8a 100644 --- a/fs/notify/fsnotify.h +++ b/fs/notify/fsnotify.h @@ -26,19 +26,17 @@ extern struct inode *fsnotify_destroy_inode_mark(struct fsnotify_mark *mark); extern struct fsnotify_mark *fsnotify_find_mark( struct fsnotify_mark_connector *conn, struct fsnotify_group *group); -/* Destroy all marks connected via given connector protected by 'lock' */ -extern void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn, - spinlock_t *lock); +/* Destroy all marks connected via given connector */ +extern void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn); /* run the list of all marks associated with inode and destroy them */ static inline void fsnotify_clear_marks_by_inode(struct inode *inode) { - fsnotify_destroy_marks(inode->i_fsnotify_marks, &inode->i_lock); + fsnotify_destroy_marks(inode->i_fsnotify_marks); } /* run the list of all marks associated with vfsmount and destroy them */ static inline void fsnotify_clear_marks_by_mount(struct vfsmount *mnt) { - fsnotify_destroy_marks(real_mount(mnt)->mnt_fsnotify_marks, - &mnt->mnt_root->d_lock); + fsnotify_destroy_marks(real_mount(mnt)->mnt_fsnotify_marks); } /* prepare for freeing all marks associated with given group */ extern void fsnotify_detach_group_marks(struct fsnotify_group *group); diff --git a/fs/notify/mark.c b/fs/notify/mark.c index 0830e0af997a..f32ca924c44e 100644 --- a/fs/notify/mark.c +++ b/fs/notify/mark.c @@ -572,14 +572,19 @@ void fsnotify_detach_group_marks(struct fsnotify_group *group) } } -void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn, - spinlock_t *lock) +void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn) { struct fsnotify_mark *mark; + spinlock_t *lock; if (!conn) return; + if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE) + lock = &conn->inode->i_lock; + else + lock = &conn->mnt->mnt_root->d_lock; + while (1) { /* * We have to be careful since we can race with e.g.