From patchwork Tue Dec 20 15:20:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9481695 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 C8A8A601C0 for ; Tue, 20 Dec 2016 15:21:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB4D327F8C for ; Tue, 20 Dec 2016 15:21:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B05C228486; Tue, 20 Dec 2016 15:21:10 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable 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 6538B27F8C for ; Tue, 20 Dec 2016 15:21:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763820AbcLTPUw (ORCPT ); Tue, 20 Dec 2016 10:20:52 -0500 Received: from mail-wj0-f195.google.com ([209.85.210.195]:36663 "EHLO mail-wj0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758256AbcLTPUa (ORCPT ); Tue, 20 Dec 2016 10:20:30 -0500 Received: by mail-wj0-f195.google.com with SMTP id j10so28133455wjb.3; Tue, 20 Dec 2016 07:20:29 -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=gN+Ge95gMpHUXdlaKFk3kQZxHBd+FQKjOZGPu1G7Wa8=; b=ln4CBDFr5KWwVPl73Gvj5LzguSLGVqzXWfBAvPUoBvFyhRQTvTueSOxypSVleNhisG OEjI0eX1DbbRfigp892sZJNRx5VTF86M7JXZtly1vSPV/NCKmgq6ecgj9X8FyMDr9o+l 8iNyP3mEaBJAP6I94KWxdPY1lPOyQ744whnBNubx3B4z20KfsUBShkq9i456a2xWodTU NqZhUZysrkUbXNCoorqotJ+1B5OQcdkOQ+bM8K1BAyo4K7ksYk2KZb0UAFB4j+5F8HxZ 8LZ+uKaI1HfJJbzeF6vTxpVlPgZ4kwMFVGpNplIlMO0krJZ+8PjA/dKO4/mDzAL2SaNC RLYA== 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=gN+Ge95gMpHUXdlaKFk3kQZxHBd+FQKjOZGPu1G7Wa8=; b=f0SFnBJGQqIdqThXNsqBHOi/v94/QFNXfEDpKw0/fo4KKvQwqi7eoXH0LbCjRm5WTS IfSdayakKc10TlXt4yC/L1v0H6pv4Td4OCw/x3bzvqB8it8VICpiPBWi9Dpu9mOTJvv0 cRYYRwpsqgTDvrk3OkdbxAFiLW+SE5BysSCL+lPSwdpnHsmlRCmtTDOLDv/4dW2mbI33 xiOVLjdQa5tqQtlfpOKLrd1glJzDrv4aKl1yHd5hVEiO7Q0uq+Bm/AIrfbnqegH6TVLq orookkMat3pAnZBg6QkAOzrpLdr3jv6ONJ3kv+HxrY/Y6ek5sCspNbBiqC/5vcEJP4ap uBdw== X-Gm-Message-State: AIkVDXIfiItAI+5SUINumwJB1g2Ogt2INSjHMs2m/b7BEn4SyGjPfY4XPpGQ13a1UtcXpw== X-Received: by 10.194.185.146 with SMTP id fc18mr10823405wjc.45.1482247228403; Tue, 20 Dec 2016 07:20:28 -0800 (PST) Received: from amir-VirtualBox.ctera.local (bzq-82-81-193-202.cablep.bezeqint.net. [82.81.193.202]) by smtp.gmail.com with ESMTPSA id d64sm22537792wmh.3.2016.12.20.07.20.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Dec 2016 07:20:27 -0800 (PST) From: Amir Goldstein To: Jan Kara Cc: Al Viro , Eric Paris , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC][PATCH 1/2] fsnotify: add event mask FS_EVENT_ON_SB Date: Tue, 20 Dec 2016 17:20:06 +0200 Message-Id: <1482247207-4424-2-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482247207-4424-1-git-send-email-amir73il@gmail.com> References: <1482247207-4424-1-git-send-email-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 When a watch is added on a super block's root inode with the FS_EVENT_ON_SB flag, the watched inode is intended to report events on all inodes on the same super block. Signed-off-by: Amir Goldstein --- fs/notify/fsnotify.c | 2 +- include/linux/fsnotify_backend.h | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 3ba0e4a..12d4479 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -297,7 +297,7 @@ static __init int fsnotify_init(void) { int ret; - BUG_ON(hweight32(ALL_FSNOTIFY_EVENTS) != 23); + BUG_ON(hweight32(ALL_FSNOTIFY_EVENTS) != 24); ret = init_srcu_struct(&fsnotify_mark_srcu); if (ret) diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index b55c64d..b7992da 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -54,6 +54,13 @@ * dnotify and inotify. */ #define FS_EVENT_ON_CHILD 0x08000000 +/* This root inode cares about things that happen to inodes on same super block. + * Can only be set for fanotify. + * Overloads IN_ONLYDIR inotify open only flag */ +#define FS_EVENT_ON_SB 0x01000000 + +#define FS_EVENT_ON_DESCENDANT (FS_EVENT_ON_CHILD | FS_EVENT_ON_SB) + /* 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 |\ @@ -61,6 +68,11 @@ FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE |\ FS_DELETE | FS_OPEN_PERM | FS_ACCESS_PERM) +/* This is a list of all events that may get sent to the root inode based on fs + * event happening to inodes on the same super block */ +#define FS_EVENTS_POSS_ON_SB (FS_EVENTS_POSS_ON_CHILD |\ + FS_DELETE_SELF | FS_MOVE_SELF) + #define FS_MOVE (FS_MOVED_FROM | FS_MOVED_TO) #define ALL_FSNOTIFY_PERM_EVENTS (FS_OPEN_PERM | FS_ACCESS_PERM) @@ -70,9 +82,10 @@ 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_DN_MULTISHOT | FS_EVENT_ON_CHILD) + FS_OPEN_PERM | FS_ACCESS_PERM | \ + FS_EXCL_UNLINK | FS_ISDIR | FS_IN_ONESHOT | \ + FS_DN_RENAME | FS_DN_MULTISHOT | \ + FS_EVENT_ON_CHILD | FS_EVENT_ON_SB) struct fsnotify_group; struct fsnotify_event;