From patchwork Thu Aug 30 15:15:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10582061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8BEAB175A for ; Thu, 30 Aug 2018 15:16:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BC0D2C064 for ; Thu, 30 Aug 2018 15:16:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FD9F2C06C; Thu, 30 Aug 2018 15:16:04 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 0D1E82C065 for ; Thu, 30 Aug 2018 15:16:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727200AbeH3TSl (ORCPT ); Thu, 30 Aug 2018 15:18:41 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:52160 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726690AbeH3TSl (ORCPT ); Thu, 30 Aug 2018 15:18:41 -0400 Received: by mail-wm0-f65.google.com with SMTP id y2-v6so2390652wma.1 for ; Thu, 30 Aug 2018 08:16:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UFR4Gr5JBOnfj0hmDbjl7YEGyHdsFtUiiff4c4kZI74=; b=AGZxveutzvfZOHg1oHHXSR/t0k3xr9GITeTKqXwEoo8+OMT6+BYTrMPRelb5S49qFG ej6grpPQj4uqRN0A9UOlF7gAJYv7bZenfanDJtfLU8F6myuwtcMC9D9Ejm3QLMQWsxAt WDIGrWFT9tDsaNoq5/A5nTi5nv1Tp3BRQZjp9ymHlpX7IlEirz7G5SNdgy6wrLBWsEa7 G+1ZrLJbyKGVBqZxvaHeJKEkbqj07f6+xGLywWtyOjn7Cb7sk/0XyDW0p3UQ5GDUo3bU LKqgj3EiUTgyUoUt2xLuiD4bTvt3KVVUcCM4rKsWiTrA4PJC70rxL1A0Pr31aBeGYXR3 bbKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UFR4Gr5JBOnfj0hmDbjl7YEGyHdsFtUiiff4c4kZI74=; b=Rgo6IdiXz50IUYovbjxSAKX5w7S3DC2biYk9cHhw1gbIgKlVwlfY0ph3KoUc2WIPf9 G4cktyTeu5I7lpOOHKJaUE4R3ZZk/wkWdVVDnDf2bR6anNlpmgN8/teqReahgW19jbuM PhgFkv/guIC8G6jido3r2I7EgeL6lpycrJwW0Qo20z7ghVApRzPSno5pDiK3Wqrk+lPK pUqG6+0DCF+yr5UkjOXZfrMBtvBvFYdZH4HPlkhc4LUroJ/eGOpKLUoBFrQ71wcS2ZwN nQa4BcrcHxkxx879JM4WNeedSJ+ADDOYZd0prDmFpPnhcrUcWS4vFebqLXPHeP11cRHf RBBA== X-Gm-Message-State: APzg51BquE5pEX5l6GDLJp4DEOyuWfTncq76m7ocT11BOGLefKwOUQrT 5TsVMrEIGCdS36aN8TAByCw= X-Google-Smtp-Source: ANB0VdZelmqopqGMz3dr0DEORK04bzKJnp00zfjOWWHfwrVSWa0myQPhkRw/xGxuOXS+oL5ImZPhLw== X-Received: by 2002:a1c:6a06:: with SMTP id f6-v6mr2042481wmc.159.1535642161193; Thu, 30 Aug 2018 08:16:01 -0700 (PDT) Received: from localhost.localdomain (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id 124-v6sm3186823wmk.20.2018.08.30.08.16.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 08:16:00 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: Marko Rauhamaa , linux-fsdevel@vger.kernel.org Subject: [PATCH v3 2/3] fsnotify: send path type events to group with super block marks Date: Thu, 30 Aug 2018 18:15:50 +0300 Message-Id: <20180830151551.27422-3-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180830151551.27422-1-amir73il@gmail.com> References: <20180830151551.27422-1-amir73il@gmail.com> 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 Send events to group if super block mark mask matches the event and unless the same group has an ignore mask on the vfsmount or the inode on which the event occurred. Soon, fanotify backend is going to support super block marks and fanotify backend only supports path type events. Signed-off-by: Amir Goldstein --- fs/notify/fsnotify.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 775e731d3016..89a71242b786 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -325,15 +325,18 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, const unsigned char *file_name, u32 cookie) { struct fsnotify_iter_info iter_info = {}; - struct mount *mnt; + struct super_block *sb = NULL; + struct mount *mnt = NULL; + __u32 mnt_or_sb_mask = 0; int ret = 0; /* global tests shouldn't care about events on child only the specific event */ __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); - if (data_is == FSNOTIFY_EVENT_PATH) + if (data_is == FSNOTIFY_EVENT_PATH) { mnt = real_mount(((const struct path *)data)->mnt); - else - mnt = NULL; + sb = mnt->mnt.mnt_sb; + mnt_or_sb_mask = mnt->mnt_fsnotify_mask | sb->s_fsnotify_mask; + } /* * Optimization: srcu_read_lock() has a memory barrier which can @@ -343,16 +346,16 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, * need SRCU to keep them "alive". */ if (!to_tell->i_fsnotify_marks && - (!mnt || !mnt->mnt_fsnotify_marks)) + (!mnt || (!mnt->mnt_fsnotify_marks && !sb->s_fsnotify_marks))) return 0; /* * if this is a modify event we may need to clear the ignored masks - * otherwise return if neither the inode nor the vfsmount care about + * otherwise return if neither the inode nor the vfsmount/sb care about * this type of event. */ if (!(mask & FS_MODIFY) && !(test_mask & to_tell->i_fsnotify_mask) && - !(mnt && test_mask & mnt->mnt_fsnotify_mask)) + !(mnt && (test_mask & mnt_or_sb_mask))) return 0; iter_info.srcu_idx = srcu_read_lock(&fsnotify_mark_srcu); @@ -364,16 +367,20 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, } if (mnt && ((mask & FS_MODIFY) || - (test_mask & mnt->mnt_fsnotify_mask))) { + (test_mask & mnt_or_sb_mask))) { iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE] = fsnotify_first_mark(&to_tell->i_fsnotify_marks); iter_info.marks[FSNOTIFY_OBJ_TYPE_VFSMOUNT] = fsnotify_first_mark(&mnt->mnt_fsnotify_marks); + if ((mask & FS_MODIFY) || + (test_mask & sb->s_fsnotify_mask)) + iter_info.marks[FSNOTIFY_OBJ_TYPE_SB] = + fsnotify_first_mark(&sb->s_fsnotify_marks); } /* - * We need to merge inode & vfsmount mark lists so that inode mark - * ignore masks are properly reflected for mount mark notifications. + * We need to merge inode/vfsmount/sb mark lists so that e.g. inode mark + * ignore masks are properly reflected for mount/sb mark notifications. * That's why this traversal is so complicated... */ while (fsnotify_iter_select_report_types(&iter_info)) {