From patchwork Sat Dec 17 14:20:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9479017 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 078FA60760 for ; Sat, 17 Dec 2016 14:21:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC9F228470 for ; Sat, 17 Dec 2016 14:21:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E184028538; Sat, 17 Dec 2016 14:21:06 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 1C7EF28536 for ; Sat, 17 Dec 2016 14:21:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754611AbcLQOVC (ORCPT ); Sat, 17 Dec 2016 09:21:02 -0500 Received: from mail-wj0-f196.google.com ([209.85.210.196]:35655 "EHLO mail-wj0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754121AbcLQOVC (ORCPT ); Sat, 17 Dec 2016 09:21:02 -0500 Received: by mail-wj0-f196.google.com with SMTP id he10so17974204wjc.2 for ; Sat, 17 Dec 2016 06:21:01 -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=nAC+WltgiKV9VEBjFPdvC7nEJZLmPO9Xhkk+0bGullE=; b=EHiQ7lqp8MOW5ZBOSNCY2F4GAD/A2D/E6UQTx9ZKX/kfo5FOPYZEMBTOazal+byeJ6 3fWg4gkYkkXc4OZSrLard8bKlYhVKRlfCtS+aZ/ZREWYWecfY98QqShDP6zbHpJRhZnX f8j9i3nndzInH2WNpv1MWbbLG/laJAJXjPnqE9j0dW+MGKW+7kg56KzkyVDO1Va7e/yX LrHCZUj+4m/NcCJ0UJ4yBYeUFdcrpVh0I5ICUDw5M9a4hUUVyjK18QlDl68yrRskqMk0 8whpyBM6xCrxwcAPBKlnYdlc7P2pAcRFnyoQPqWnA0bM18CkzQnLnqJeGVh2JU50R6BP QFlA== 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=nAC+WltgiKV9VEBjFPdvC7nEJZLmPO9Xhkk+0bGullE=; b=WL4xERUWcnr61QmuiGpZf6i6yIs+UvGNzBmu41aIrUlVT0V8lvMZC4/f6Ke22jmu/l HfecphrAfzee0ZNWBWRc9sMOKpQ9okrwKRiEO5vcnr10BYQZqGyYoDDDFZxX2CorCbAk tOZ0iKfThpwjwlH+11Fe4yLXRifWYPu2OVevKhRnkqX0DeUd7Hemqq+E26Vms4xsE1w0 x6vXlZHEjvNPaxeHg2odFlMMjZDaJ8rLlGuDBaMUFxRwYy0N/pKqILAEBh44WZBUddWW N2A8zS4N5HIEBi/hpF5ooZXQtuBbO82EoaTH4VzIHC/te+Rw/xBJZVcqFRoKng03wpIn OdIQ== X-Gm-Message-State: AIkVDXI0vH/oW2wNCZpA6dxG/EI75ECbRSBYhXQLQWcSnAzkIzBxh4cQgAAKy3TM5g5JiQ== X-Received: by 10.194.22.41 with SMTP id a9mr7991427wjf.30.1481984460391; Sat, 17 Dec 2016 06:21:00 -0800 (PST) Received: from amir-VirtualBox.Home (bzq-79-180-107-203.red.bezeqint.net. [79.180.107.203]) by smtp.gmail.com with ESMTPSA id gj6sm11691106wjb.29.2016.12.17.06.20.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 17 Dec 2016 06:20:59 -0800 (PST) From: Amir Goldstein To: Al Viro Cc: Jan Kara , Eric Paris , linux-fsdevel@vger.kernel.org Subject: [PATCH 1/4] fsnotify: pass dentry instead of inode when available Date: Sat, 17 Dec 2016 16:20:31 +0200 Message-Id: <1481984434-13293-2-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481984434-13293-1-git-send-email-amir73il@gmail.com> References: <1481984434-13293-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 Define a new data type to pass for event FSNOTIFY_EVENT_DENTRY and use it whenever a dentry is available instead of passing it's ->d_inode as data type FSNOTIFY_EVENT_INODE. None of the current fsnotify backends make use of the inode data with data type FSNOTIFY_EVENT_INODE - only the data of type FSNOTIFY_EVENT_PATH is ever used, so this change has no immediate consequences. Soon, we are going to use the dentry data type to support more events with fanotify backend. Signed-off-by: Amir Goldstein --- fs/notify/fsnotify.c | 2 +- include/linux/fsnotify.h | 15 +++++++-------- include/linux/fsnotify_backend.h | 3 ++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index b41515d..768f334 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -112,7 +112,7 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH, dentry->d_name.name, 0); else - ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE, + ret = fsnotify(p_inode, mask, dentry, FSNOTIFY_EVENT_DENTRY, dentry->d_name.name, 0); } diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index b43d3f5..86244c5 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -86,14 +86,14 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, fsnotify(old_dir, old_dir_mask, source, FSNOTIFY_EVENT_INODE, old_name, fs_cookie); - fsnotify(new_dir, new_dir_mask, source, FSNOTIFY_EVENT_INODE, new_name, + fsnotify(new_dir, new_dir_mask, moved, FSNOTIFY_EVENT_DENTRY, new_name, fs_cookie); if (target) fsnotify_link_count(target); if (source) - fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE, NULL, 0); + fsnotify(source, FS_MOVE_SELF, moved, FSNOTIFY_EVENT_DENTRY, NULL, 0); audit_inode_child(new_dir, moved, AUDIT_TYPE_CHILD_CREATE); } @@ -142,7 +142,7 @@ static inline void fsnotify_create(struct inode *inode, struct dentry *dentry) { audit_inode_child(inode, dentry, AUDIT_TYPE_CHILD_CREATE); - fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); + fsnotify(inode, FS_CREATE, dentry, FSNOTIFY_EVENT_DENTRY, dentry->d_name.name, 0); } /* @@ -155,7 +155,7 @@ static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct fsnotify_link_count(inode); audit_inode_child(dir, new_dentry, AUDIT_TYPE_CHILD_CREATE); - fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, new_dentry->d_name.name, 0); + fsnotify(dir, FS_CREATE, new_dentry, FSNOTIFY_EVENT_DENTRY, new_dentry->d_name.name, 0); } /* @@ -164,11 +164,10 @@ static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry) { __u32 mask = (FS_CREATE | FS_ISDIR); - struct inode *d_inode = dentry->d_inode; audit_inode_child(inode, dentry, AUDIT_TYPE_CHILD_CREATE); - fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); + fsnotify(inode, mask, dentry, FSNOTIFY_EVENT_DENTRY, dentry->d_name.name, 0); } /* @@ -254,7 +253,7 @@ static inline void fsnotify_xattr(struct dentry *dentry) mask |= FS_ISDIR; fsnotify_parent(NULL, dentry, mask); - fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); + fsnotify(inode, mask, dentry, FSNOTIFY_EVENT_DENTRY, NULL, 0); } /* @@ -289,7 +288,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid) mask |= FS_ISDIR; fsnotify_parent(NULL, dentry, mask); - fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); + fsnotify(inode, mask, dentry, FSNOTIFY_EVENT_DENTRY, NULL, 0); } } diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 0cf34d6..e8a5791 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -188,10 +188,11 @@ struct fsnotify_group { }; }; -/* when calling fsnotify tell it if the data is a path or inode */ +/* when calling fsnotify tell it if the data is a path or inode or dentry */ #define FSNOTIFY_EVENT_NONE 0 #define FSNOTIFY_EVENT_PATH 1 #define FSNOTIFY_EVENT_INODE 2 +#define FSNOTIFY_EVENT_DENTRY 3 /* * A mark is simply an object attached to an in core inode which allows an