From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A486EC43387 for ; Thu, 10 Jan 2019 17:04:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7210520685 for ; Thu, 10 Jan 2019 17:04:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B+XeUxIl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728999AbfAJRE5 (ORCPT ); Thu, 10 Jan 2019 12:04:57 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:35781 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728995AbfAJRE4 (ORCPT ); Thu, 10 Jan 2019 12:04:56 -0500 Received: by mail-wr1-f65.google.com with SMTP id 96so12250280wrb.2 for ; Thu, 10 Jan 2019 09:04:55 -0800 (PST) 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=/RXJW/vzjOzgP3J1gPPKjZxog4WrinVi+jeCLAKErWc=; b=B+XeUxIlynnrXDsEeo9gcxqXSXwtizQNEmL0wnZRkcFeByE4U4mZDhwIs+XqJPEC8O zL4w5ZdVP2fmaeoVtlWmxbS4FQIEZNw2sKjTv7FZSJWeE4lVZ+uNXXLX6V/doca9H3tP HiuBIU2lx/LNmt723yOaQRy0obTVJzmAlT90MdT5itd0tkOqEPvBz1O+Qm0P9g2BPQ3D fDq2cB+eet+acuLETJfr+KCVK4OKf2r9LnT2S8RdReC3QbndxIV7KjFOmiAbnU3LQRis vo1Zd36HGZ0cjm0UaPLoWP3H3mw72L7Xwg7H0pc0JFM2XKVgD54eEJ758JJmNUL1TkgV y3ig== 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=/RXJW/vzjOzgP3J1gPPKjZxog4WrinVi+jeCLAKErWc=; b=XNXOaDDzvP883uVhtUz/G5WPbAs75/mvPiuckfAkNUNj0GAD9ojIbsy6ShUkye4Kw0 sRTDAT/nGUDNp2+5H/L1ZJt9QQ34mvt6eLq5SoX9v0dNnhd6k2EXf4WUvCj3zTzJ4fKJ Mw2RTmRri+iuv1+n+ZW8BmpcqWK6hgrvAI2Gwih1lze03C73WZXeM1SUu8wB/DZn7iLB 9PVJwGDwEbqcCt4vKpUhUW2ouWbmMMBu43SOq6j8N2JTANOeelqvKwzEb9rPonOO69PR 5KWqWl5NDm0/41mp4tuMmIq/TgG4EgeaXZVK3RMvgwBYgmL1xGwJQXKftoRkklir39vw g+Cw== X-Gm-Message-State: AJcUukechetkuG+4dlQPvfDiKSEEbui7mrG7b2P2RNWR90ktVEOUifHC wQe6Ud2cR0oJvnqq3yupIEoqdkzp X-Google-Smtp-Source: ALg8bN71ESxPPzn0Ud+6kypn3q7VREf3ob1E5ga5nWRniXHt08N9Mmy2XZC3R47isCRJ9QsdudcruA== X-Received: by 2002:adf:b649:: with SMTP id i9mr10384744wre.70.1547139894533; Thu, 10 Jan 2019 09:04:54 -0800 (PST) Received: from amir-VirtualBox.ctera.local ([188.120.129.201]) by smtp.gmail.com with ESMTPSA id m4sm5725868wmi.3.2019.01.10.09.04.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:04:54 -0800 (PST) From: Amir Goldstein To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: [PATCH v5 02/17] fsnotify: remove dirent events from FS_EVENTS_POSS_ON_CHILD mask Date: Thu, 10 Jan 2019 19:04:29 +0200 Message-Id: <20190110170444.30616-3-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110170444.30616-1-amir73il@gmail.com> References: <20190110170444.30616-1-amir73il@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org "dirent" events are referring to events that modify directory entries, such as create,delete,rename. Those events are always be reported on a watched directory, regardless if FS_EVENT_ON_CHILD is set on the watch mask. ALL_FSNOTIFY_DIRENT_EVENTS defines all the dirent event types and those event types are removed from FS_EVENTS_POSS_ON_CHILD. That means for a directory with an inotify watch and only dirent events in the mask (i.e. create,delete,move), all children dentries will no longer have the DCACHE_FSNOTIFY_PARENT_WATCHED flag set. This will allow all events that happen on children to be optimized away in __fsnotify_parent() without the need to dereference child->d_parent->d_inode->i_fsnotify_mask. Since the dirent events are never repoted via __fsnotify_parent(), this results in no change of logic, but only an optimization. Signed-off-by: Amir Goldstein --- include/linux/fsnotify_backend.h | 36 +++++++++++++++++++------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 7639774e7475..7f195d43efaf 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -59,27 +59,33 @@ * dnotify and inotify. */ #define FS_EVENT_ON_CHILD 0x08000000 -/* This is a list of all events that may get sent to a parernt based on fs event - * happening to inodes inside that directory */ -#define FS_EVENTS_POSS_ON_CHILD (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_OPEN_PERM | FS_ACCESS_PERM | \ - FS_OPEN_EXEC | FS_OPEN_EXEC_PERM) - #define FS_MOVE (FS_MOVED_FROM | FS_MOVED_TO) +/* + * Directory entry modification events - reported only to directory + * where entry is modified and not to a watching parent. + * The watching parent may get an FS_ATTRIB|FS_EVENT_ON_CHILD event + * when a directory entry inside a child subdir changes. + */ +#define ALL_FSNOTIFY_DIRENT_EVENTS (FS_CREATE | FS_DELETE | FS_MOVE) + #define ALL_FSNOTIFY_PERM_EVENTS (FS_OPEN_PERM | FS_ACCESS_PERM | \ FS_OPEN_EXEC_PERM) +/* + * This is a list of all events that may get sent to a parent based on fs event + * happening to inodes inside that directory. + */ +#define FS_EVENTS_POSS_ON_CHILD (ALL_FSNOTIFY_PERM_EVENTS | \ + FS_ACCESS | FS_MODIFY | FS_ATTRIB | \ + FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | \ + FS_OPEN | FS_OPEN_EXEC) + /* 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_DN_RENAME | \ - FS_OPEN_EXEC | FS_OPEN_EXEC_PERM) +#define ALL_FSNOTIFY_EVENTS (ALL_FSNOTIFY_DIRENT_EVENTS | \ + FS_EVENTS_POSS_ON_CHILD | \ + FS_DELETE_SELF | FS_MOVE_SELF | FS_DN_RENAME | \ + FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED) /* 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 | \ -- 2.17.1