From patchwork Wed Oct 3 21:25:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10625323 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 CE46F1515 for ; Wed, 3 Oct 2018 21:25:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFB6E2907A for ; Wed, 3 Oct 2018 21:25:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B26412907B; Wed, 3 Oct 2018 21:25:53 +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 4CB1A29075 for ; Wed, 3 Oct 2018 21:25:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726426AbeJDEP6 (ORCPT ); Thu, 4 Oct 2018 00:15:58 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:35254 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbeJDEP6 (ORCPT ); Thu, 4 Oct 2018 00:15:58 -0400 Received: by mail-wr1-f67.google.com with SMTP id w5-v6so7694004wrt.2 for ; Wed, 03 Oct 2018 14:25:51 -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=OiboQWa8g8E/+1lfti7v/DhBkShJu2jya4W+TAcS7u8=; b=f4rkh0Iy1isiXYe1X7RbWO7sU3ad8ZQuIU7OUwJrHbIyjtQ9SqSJ1ozdk3VRW5yoOw ZAcXuQDXGVbqPdsQOglypZ+SkQCTWjGdJ5JQGlCa7/XhcJpl+1xfyigsxSrQlY5463UA NzyJOL8axKva7AGoY0MMsmnndJnNkb90pWhTGZJWXSAix2XGbpXMU2BwBS5/4tTvAtZj uLWu8MIBaWfKopCQ47YykTyJCF6Cr46NLX/U9//unRwEgm2zeWU/NS/jUqeuWtHrshKe drxsfIsu5NB+t1UiNkfCXtBBZGpTrHTkTXa9j9F1f+aRvhesdnMrGpqPySvWsmMhmumQ yc9Q== 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=OiboQWa8g8E/+1lfti7v/DhBkShJu2jya4W+TAcS7u8=; b=I0YebBHnpNZ0bPL2Ormr0aMO1n19NiDfmLf6cx1tU9eoDw3gkLv8F5pdiiee14dmR+ 8UFf7Bk9gObHRCEeVlY5NO/fq9XVqbvTUi9I2dtq57hRWdBbHdh0ZE2E48AIed1jwcDh /kgkCN2B1osNXf6Mn51JTvOYuX5+wS8g9wfw7eEHwvqW3xxXiuD346aJ5EBLu+45C2QR dSJq9uAMA+hWqzhpu3b2oIEEbCl+vnfN8/7iiJKZLB+xFNIOdXuw4zDYnizuhXd6s1v6 khU8xrKESf6OSo4vDf37alFV3SkoFxSnBadFLVBur+X0X+8OR8rp+qcQfBZaYebwSXU/ DSRA== X-Gm-Message-State: ABuFfoh9zqo+jK8nTuh0DrEvV1Efm11+fDgsOmxeUWAw8aGYlsKhwpG2 sZcjqjg3LLjyIsBPHwu2Xnw= X-Google-Smtp-Source: ACcGV61tWaw2QHzPzuSE8KCfev3foUMU8YIw5UIzDdhUVgGXOShRu86AjYApq6SaRlTNFdcGJVa06A== X-Received: by 2002:adf:da43:: with SMTP id r3-v6mr2673572wrl.221.1538601950616; Wed, 03 Oct 2018 14:25:50 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id 193-v6sm4073866wmj.21.2018.10.03.14.25.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 14:25:50 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH v3 2/8] fsnotify: generalize handling of extra event flags Date: Thu, 4 Oct 2018 00:25:33 +0300 Message-Id: <20181003212539.2384-3-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003212539.2384-1-amir73il@gmail.com> References: <20181003212539.2384-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 FS_EVENT_ON_CHILD gets a special treatment in fsnotify() because it is not a flag specifying an event type, but rather an extra flags that may be reported along with another event and control the handling of the event by the backend. FS_ISDIR is also an "extra flag" and not an "event type" and therefore desrves the same treatment. With inotify/dnotify backends it was never possible to set FS_ISDIR in mark masks, so it did not matter. With fanotify backend, mark adding code jumps through hoops to avoid setting the FS_ISDIR in the commulative object mask. Separate the constant ALL_FSNOTIFY_EVENTS to ALL_FSNOTIFY_FLAGS and ALL_FSNOTIFY_EVENTS, so the latter can be used to test for specific event types. Signed-off-by: Amir Goldstein --- fs/notify/fsnotify.c | 7 +++---- include/linux/fsnotify_backend.h | 9 +++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 422fbc6dffde..7391a02bf723 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -196,7 +196,7 @@ static int send_to_group(struct inode *to_tell, struct fsnotify_iter_info *iter_info) { struct fsnotify_group *group = NULL; - __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); + __u32 test_mask = (mask & ALL_FSNOTIFY_EVENTS); __u32 marks_mask = 0; __u32 marks_ignored_mask = 0; struct fsnotify_mark *mark; @@ -329,8 +329,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, 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); + __u32 test_mask = (mask & ALL_FSNOTIFY_EVENTS); if (data_is == FSNOTIFY_EVENT_PATH) { mnt = real_mount(((const struct path *)data)->mnt); @@ -396,7 +395,7 @@ static __init int fsnotify_init(void) { int ret; - BUG_ON(hweight32(ALL_FSNOTIFY_EVENTS) != 23); + BUG_ON(hweight32(ALL_FSNOTIFY_BITS) != 23); ret = init_srcu_struct(&fsnotify_mark_srcu); if (ret) diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 8e91341cbd8a..135b973e44d1 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -68,15 +68,20 @@ #define ALL_FSNOTIFY_PERM_EVENTS (FS_OPEN_PERM | FS_ACCESS_PERM) +/* Events that can be reported to backends */ #define ALL_FSNOTIFY_EVENTS (FS_ACCESS | FS_MODIFY | FS_ATTRIB | \ FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN | \ FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE | \ FS_DELETE | FS_DELETE_SELF | FS_MOVE_SELF | \ FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \ - FS_OPEN_PERM | FS_ACCESS_PERM | FS_EXCL_UNLINK | \ - FS_ISDIR | FS_IN_ONESHOT | FS_DN_RENAME | \ + FS_OPEN_PERM | FS_ACCESS_PERM | FS_DN_RENAME) + +/* Extra flags that may be reported with event or control handling of events */ +#define ALL_FSNOTIFY_FLAGS (FS_EXCL_UNLINK | FS_ISDIR | FS_IN_ONESHOT | \ FS_DN_MULTISHOT | FS_EVENT_ON_CHILD) +#define ALL_FSNOTIFY_BITS (ALL_FSNOTIFY_EVENTS | ALL_FSNOTIFY_FLAGS) + struct fsnotify_group; struct fsnotify_event; struct fsnotify_mark;