From patchwork Wed Feb 1 10:44:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9549295 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 4606160425 for ; Wed, 1 Feb 2017 10:45:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48E74281E1 for ; Wed, 1 Feb 2017 10:45:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E15228338; Wed, 1 Feb 2017 10:45:35 +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 D497827D85 for ; Wed, 1 Feb 2017 10:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751419AbdBAKpS (ORCPT ); Wed, 1 Feb 2017 05:45:18 -0500 Received: from mx2.suse.de ([195.135.220.15]:46375 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751284AbdBAKpQ (ORCPT ); Wed, 1 Feb 2017 05:45:16 -0500 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 88601AD41; Wed, 1 Feb 2017 10:45:14 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 9AD7A1E1133; Wed, 1 Feb 2017 11:45:11 +0100 (CET) From: Jan Kara To: Cc: Amir Goldstein , Paul Moore , Miklos Szeredi , Jan Kara Subject: [PATCH 07/25] fsnotify: Move fsnotify_destroy_marks() Date: Wed, 1 Feb 2017 11:44:39 +0100 Message-Id: <20170201104457.23194-8-jack@suse.cz> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170201104457.23194-1-jack@suse.cz> References: <20170201104457.23194-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 Move fsnotify_destroy_marks() to be later in the fs/notify/mark.c. It will need some functions that are declared after its current declaration. No functional change. Signed-off-by: Jan Kara Reviewed-by: Amir Goldstein --- fs/notify/mark.c | 86 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/fs/notify/mark.c b/fs/notify/mark.c index ce2314ae96d0..f3f6286bf9bb 100644 --- a/fs/notify/mark.c +++ b/fs/notify/mark.c @@ -221,49 +221,6 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark, fsnotify_free_mark(mark); } -void fsnotify_destroy_marks(struct fsnotify_mark_connector **connp, - spinlock_t *lock) -{ - struct fsnotify_mark *mark; - - while (1) { - /* - * We have to be careful since we can race with e.g. - * fsnotify_clear_marks_by_group() and once we drop 'lock', - * mark can get removed from the obj_list and destroyed. But - * we are holding mark reference so mark cannot be freed and - * calling fsnotify_destroy_mark() more than once is fine. - */ - spin_lock(lock); - if (hlist_empty(&(*connp)->list)) { - spin_unlock(lock); - break; - } - mark = hlist_entry((*connp)->list.first, struct fsnotify_mark, - obj_list); - /* - * We don't update i_fsnotify_mask / mnt_fsnotify_mask here - * since inode / mount is going away anyway. So just remove - * mark from the list. - */ - hlist_del_init_rcu(&mark->obj_list); - fsnotify_get_mark(mark); - spin_unlock(lock); - fsnotify_destroy_mark(mark, mark->group); - fsnotify_put_mark(mark); - } - /* - * Skip freeing of connector when inode is just unlinked. We leave that - * until destroy_inode() is called at which moment nobody will be - * looking at the inode anymore. - */ - if ((*connp)->flags & FSNOTIFY_OBJ_TYPE_INODE && - !((*connp)->inode->i_state & I_CLEAR)) - return; - kmem_cache_free(fsnotify_mark_connector_cachep, *connp); - *connp = NULL; -} - void fsnotify_set_mark_mask_locked(struct fsnotify_mark *mark, __u32 mask) { assert_spin_locked(&mark->lock); @@ -574,6 +531,49 @@ void fsnotify_detach_group_marks(struct fsnotify_group *group) } } +void fsnotify_destroy_marks(struct fsnotify_mark_connector **connp, + spinlock_t *lock) +{ + struct fsnotify_mark *mark; + + while (1) { + /* + * We have to be careful since we can race with e.g. + * fsnotify_clear_marks_by_group() and once we drop 'lock', + * mark can get removed from the obj_list and destroyed. But + * we are holding mark reference so mark cannot be freed and + * calling fsnotify_destroy_mark() more than once is fine. + */ + spin_lock(lock); + if (hlist_empty(&(*connp)->list)) { + spin_unlock(lock); + break; + } + mark = hlist_entry((*connp)->list.first, struct fsnotify_mark, + obj_list); + /* + * We don't update i_fsnotify_mask / mnt_fsnotify_mask here + * since inode / mount is going away anyway. So just remove + * mark from the list. + */ + hlist_del_init_rcu(&mark->obj_list); + fsnotify_get_mark(mark); + spin_unlock(lock); + fsnotify_destroy_mark(mark, mark->group); + fsnotify_put_mark(mark); + } + /* + * Skip freeing of connector when inode is just unlinked. We leave that + * until destroy_inode() is called at which moment nobody will be + * looking at the inode anymore. + */ + if ((*connp)->flags & FSNOTIFY_OBJ_TYPE_INODE && + !((*connp)->inode->i_state & I_CLEAR)) + return; + kmem_cache_free(fsnotify_mark_connector_cachep, *connp); + *connp = NULL; +} + /* * Nothing fancy, just initialize lists and locks and counters. */