From patchwork Thu Jun 25 00:16:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 6671321 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6AC409F39B for ; Thu, 25 Jun 2015 00:18:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 365FE204DE for ; Thu, 25 Jun 2015 00:18:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E69FD20837 for ; Thu, 25 Jun 2015 00:17:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752899AbbFYAQy (ORCPT ); Wed, 24 Jun 2015 20:16:54 -0400 Received: from mga11.intel.com ([192.55.52.93]:22197 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752346AbbFYAQK (ORCPT ); Wed, 24 Jun 2015 20:16:10 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 24 Jun 2015 17:16:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,673,1427785200"; d="scan'208";a="734110616" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.39.19]) by fmsmga001.fm.intel.com with ESMTP; 24 Jun 2015 17:16:07 -0700 Subject: [RFCv2][PATCH 5/7] fsnotify: use fsnotify_head for vfsmount data To: dave@sr71.net Cc: jack@suse.cz, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com, tim.c.chen@linux.intel.com, ak@linux.intel.com, dave.hansen@linux.intel.com From: Dave Hansen Date: Wed, 24 Jun 2015 17:16:07 -0700 References: <20150625001605.72553909@viggo.jf.intel.com> In-Reply-To: <20150625001605.72553909@viggo.jf.intel.com> Message-Id: <20150625001607.05D8CFF9@viggo.jf.intel.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dave Hansen Use the new 'struct fsnotify_head' for the vfsmount fsnotify data, just like we did for inodes in the last patch. Cc: Jan Kara Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Paul E. McKenney Cc: Tim Chen Cc: Andi Kleen Signed-off-by: Dave Hansen --- b/fs/mount.h | 6 ++---- b/fs/namespace.c | 2 +- b/fs/notify/fanotify/fanotify_user.c | 4 ++-- b/fs/notify/fsnotify.c | 8 ++++---- b/fs/notify/vfsmount_mark.c | 14 +++++++------- 5 files changed, 16 insertions(+), 18 deletions(-) diff -puN fs/mount.h~fsnotify_head_mnt fs/mount.h --- a/fs/mount.h~fsnotify_head_mnt 2015-06-24 17:14:36.276185800 -0700 +++ b/fs/mount.h 2015-06-24 17:14:36.286186250 -0700 @@ -3,6 +3,7 @@ #include #include #include +#include struct mnt_namespace { atomic_t count; @@ -55,10 +56,7 @@ struct mount { struct mnt_namespace *mnt_ns; /* containing namespace */ struct mountpoint *mnt_mp; /* where is it mounted */ struct hlist_node mnt_mp_list; /* list mounts with the same mountpoint */ -#ifdef CONFIG_FSNOTIFY - struct hlist_head mnt_fsnotify_marks; - __u32 mnt_fsnotify_mask; -#endif + struct fsnotify_head mnt_fsnotify; int mnt_id; /* mount identifier */ int mnt_group_id; /* peer group identifier */ int mnt_expiry_mark; /* true if marked for expiry */ diff -puN fs/namespace.c~fsnotify_head_mnt fs/namespace.c --- a/fs/namespace.c~fsnotify_head_mnt 2015-06-24 17:14:36.278185890 -0700 +++ b/fs/namespace.c 2015-06-24 17:14:36.287186295 -0700 @@ -235,7 +235,7 @@ static struct mount *alloc_vfsmnt(const INIT_LIST_HEAD(&mnt->mnt_slave); INIT_HLIST_NODE(&mnt->mnt_mp_list); #ifdef CONFIG_FSNOTIFY - INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks); + INIT_HLIST_HEAD(&mnt->mnt_fsnotify.marks); #endif init_fs_pin(&mnt->mnt_umount, drop_mountpoint); } diff -puN fs/notify/fanotify/fanotify_user.c~fsnotify_head_mnt fs/notify/fanotify/fanotify_user.c --- a/fs/notify/fanotify/fanotify_user.c~fsnotify_head_mnt 2015-06-24 17:14:36.279185935 -0700 +++ b/fs/notify/fanotify/fanotify_user.c 2015-06-24 17:14:36.287186295 -0700 @@ -533,7 +533,7 @@ static int fanotify_remove_vfsmount_mark mutex_unlock(&group->mark_mutex); fsnotify_put_mark(fsn_mark); - if (removed & real_mount(mnt)->mnt_fsnotify_mask) + if (removed & real_mount(mnt)->mnt_fsnotify.mask) fsnotify_recalc_vfsmount_mask(mnt); return 0; @@ -641,7 +641,7 @@ static int fanotify_add_vfsmount_mark(st added = fanotify_mark_add_to_mask(fsn_mark, mask, flags); mutex_unlock(&group->mark_mutex); - if (added & ~real_mount(mnt)->mnt_fsnotify_mask) + if (added & ~real_mount(mnt)->mnt_fsnotify.mask) fsnotify_recalc_vfsmount_mask(mnt); fsnotify_put_mark(fsn_mark); diff -puN fs/notify/fsnotify.c~fsnotify_head_mnt fs/notify/fsnotify.c --- a/fs/notify/fsnotify.c~fsnotify_head_mnt 2015-06-24 17:14:36.281186025 -0700 +++ b/fs/notify/fsnotify.c 2015-06-24 17:14:36.288186339 -0700 @@ -211,7 +211,7 @@ int fsnotify(struct inode *to_tell, __u3 */ if (!(mask & FS_MODIFY) && !(test_mask & to_tell->i_fsnotify.mask) && - !(mnt && test_mask & mnt->mnt_fsnotify_mask)) + !(mnt && test_mask & mnt->mnt_fsnotify.mask)) return 0; /* * Optimization: srcu_read_lock() has a memory barrier which can @@ -221,7 +221,7 @@ int fsnotify(struct inode *to_tell, __u3 * need SRCU to keep them "alive". */ if (!to_tell->i_fsnotify.marks.first && - (!mnt || !mnt->mnt_fsnotify_marks.first)) + (!mnt || !mnt->mnt_fsnotify.marks.first)) return 0; idx = srcu_read_lock(&fsnotify_mark_srcu); @@ -232,8 +232,8 @@ int fsnotify(struct inode *to_tell, __u3 &fsnotify_mark_srcu); if (mnt && ((mask & FS_MODIFY) || - (test_mask & mnt->mnt_fsnotify_mask))) { - vfsmount_node = srcu_dereference(mnt->mnt_fsnotify_marks.first, + (test_mask & mnt->mnt_fsnotify.mask))) { + vfsmount_node = srcu_dereference(mnt->mnt_fsnotify.marks.first, &fsnotify_mark_srcu); inode_node = srcu_dereference(to_tell->i_fsnotify.marks.first, &fsnotify_mark_srcu); diff -puN fs/notify/vfsmount_mark.c~fsnotify_head_mnt fs/notify/vfsmount_mark.c --- a/fs/notify/vfsmount_mark.c~fsnotify_head_mnt 2015-06-24 17:14:36.282186070 -0700 +++ b/fs/notify/vfsmount_mark.c 2015-06-24 17:14:36.288186339 -0700 @@ -38,7 +38,7 @@ void fsnotify_clear_marks_by_mount(struc LIST_HEAD(free_list); spin_lock(&mnt->mnt_root->d_lock); - hlist_for_each_entry_safe(mark, n, &m->mnt_fsnotify_marks, obj_list) { + hlist_for_each_entry_safe(mark, n, &m->mnt_fsnotify.marks, obj_list) { list_add(&mark->free_list, &free_list); hlist_del_init_rcu(&mark->obj_list); fsnotify_get_mark(mark); @@ -54,7 +54,7 @@ void fsnotify_clear_vfsmount_marks_by_gr } /* - * Recalculate the mnt->mnt_fsnotify_mask, or the mask of all FS_* event types + * Recalculate the mnt->mnt_fsnotify.mask, or the mask of all FS_* event types * any notifier is interested in hearing for this mount point */ void fsnotify_recalc_vfsmount_mask(struct vfsmount *mnt) @@ -62,7 +62,7 @@ void fsnotify_recalc_vfsmount_mask(struc struct mount *m = real_mount(mnt); spin_lock(&mnt->mnt_root->d_lock); - m->mnt_fsnotify_mask = fsnotify_recalc_mask(&m->mnt_fsnotify_marks); + m->mnt_fsnotify.mask = fsnotify_recalc_mask(&m->mnt_fsnotify.marks); spin_unlock(&mnt->mnt_root->d_lock); } @@ -79,7 +79,7 @@ void fsnotify_destroy_vfsmount_mark(stru hlist_del_init_rcu(&mark->obj_list); mark->mnt = NULL; - m->mnt_fsnotify_mask = fsnotify_recalc_mask(&m->mnt_fsnotify_marks); + m->mnt_fsnotify.mask = fsnotify_recalc_mask(&m->mnt_fsnotify.marks); spin_unlock(&mnt->mnt_root->d_lock); } @@ -94,7 +94,7 @@ struct fsnotify_mark *fsnotify_find_vfsm struct fsnotify_mark *mark; spin_lock(&mnt->mnt_root->d_lock); - mark = fsnotify_find_mark(&m->mnt_fsnotify_marks, group); + mark = fsnotify_find_mark(&m->mnt_fsnotify.marks, group); spin_unlock(&mnt->mnt_root->d_lock); return mark; @@ -119,8 +119,8 @@ int fsnotify_add_vfsmount_mark(struct fs spin_lock(&mnt->mnt_root->d_lock); mark->mnt = mnt; - ret = fsnotify_add_mark_list(&m->mnt_fsnotify_marks, mark, allow_dups); - m->mnt_fsnotify_mask = fsnotify_recalc_mask(&m->mnt_fsnotify_marks); + ret = fsnotify_add_mark_list(&m->mnt_fsnotify.marks, mark, allow_dups); + m->mnt_fsnotify.mask = fsnotify_recalc_mask(&m->mnt_fsnotify.marks); spin_unlock(&mnt->mnt_root->d_lock); return ret;