From patchwork Wed Nov 14 17:43:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10682951 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 DA4E8109C for ; Wed, 14 Nov 2018 17:43:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE4DA28521 for ; Wed, 14 Nov 2018 17:43:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2B5A28ABB; Wed, 14 Nov 2018 17:43:57 +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 343CD286CF for ; Wed, 14 Nov 2018 17:43:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728021AbeKODsE (ORCPT ); Wed, 14 Nov 2018 22:48:04 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:56101 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727576AbeKODsE (ORCPT ); Wed, 14 Nov 2018 22:48:04 -0500 Received: by mail-wm1-f65.google.com with SMTP id i73-v6so11026770wmd.5 for ; Wed, 14 Nov 2018 09:43:54 -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=1ts4Cvr3O9dADF7T4wTj5zkNnTJnlrvaMmGYdfr718I=; b=ZmmirjAjAbzhelvOgTCjQ9pq9OgNXVZwiWb4ZM6/EqQEnxTqQLKZC7DKDYcEu2JKXI eCvmH434aCQigmCo3lstQzmHLEIOVZ1HPt2nM9MYGHPRquLKtwjVQnsGETWSPqNEMpXh EzpJrs6UnF+pYJCVa5kzIxA2GLj1gdbWlmNDiX2XysCjlaD7rhxyWr+7MPPcW+10Wige rRjqCpQATobK/4oW0tPLKsS+u8n26T+BHvxifcwCg9rVv2sNX2O0t07HCLl0+1hn51gF 2YIwiIVlE1Ni1ug0O5nnBjGwI8/QYQDXzshBFWNQVfL599psb6RqsdCL+P5ASfR+knaN sWFQ== 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=1ts4Cvr3O9dADF7T4wTj5zkNnTJnlrvaMmGYdfr718I=; b=io/aqNl2WMxI37XmRAKs52z6EEZ88sYJIxzskFk0y7u/WdCfTeC2EUjax8DF7UClLJ Xw/OIB/Ih5ln4bYcp4fCrxOdsm49sLYCvgxOWPMUDt27TC/1QE7G73g8T9lpzmhD5wKv mbcp55aP6r8QFqVjWQkDtm/yS9EVAGh+aR0O2RGiFoYVgbQmHyV/y8rNkq7m42Mtt8lN UBZfeIt3H66NzLIXxPgPdsYm3hQyNNVkwTeTUbmU/FoH/bxhGTccSX8Uaqdgy50GdTc1 4GqZYLTJVqRSM5Ra9Gfec72cfFI89KNcliBIMF/MXji7HtFCNAoOxGfrxU0WlzexsXK+ B4dA== X-Gm-Message-State: AGRZ1gI30wffLEzctSDlTQV2pxoR3/xORQ1sTek0nFFEeHgvtn+4KQGU dQh67bP42O3lrzbJXljQDUg= X-Google-Smtp-Source: AJdET5fBL5Z8Rd4Tt2IV7d8y5SetdCPmMUOAbB1UWUaG3E6Kc/DPtb7zuZviD1YgaT7du0MtH302jA== X-Received: by 2002:a1c:90cf:: with SMTP id s198-v6mr2659739wmd.124.1542217433467; Wed, 14 Nov 2018 09:43:53 -0800 (PST) Received: from localhost.localdomain ([37.46.46.74]) by smtp.gmail.com with ESMTPSA id d18-v6sm8587887wre.25.2018.11.14.09.43.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Nov 2018 09:43:52 -0800 (PST) From: Amir Goldstein To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 1/5] fsnotify: pass dentry instead of inode when available Date: Wed, 14 Nov 2018 19:43:40 +0200 Message-Id: <20181114174344.17530-2-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181114174344.17530-1-amir73il@gmail.com> References: <20181114174344.17530-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 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 | 8 ++++---- include/linux/fsnotify.h | 15 +++++++-------- include/linux/fsnotify_backend.h | 3 ++- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index ecf09b6243d9..6a120b7f8b94 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -178,11 +178,11 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask take_dentry_name_snapshot(&name, dentry); if (path) - ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH, - name.name, 0); + ret = fsnotify(p_inode, mask, path, + FSNOTIFY_EVENT_PATH, name.name, 0); else - ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE, - name.name, 0); + ret = fsnotify(p_inode, mask, dentry, + FSNOTIFY_EVENT_DENTRY, name.name, 0); release_dentry_name_snapshot(&name); } diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index 2ccb08cb5d6a..9dadc0bcd7a9 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -99,14 +99,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); } @@ -155,7 +155,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); } /* @@ -168,7 +168,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); } /* @@ -177,11 +177,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); } /* @@ -262,7 +261,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); } /* @@ -297,7 +296,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 7639774e7475..24d92455be03 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -208,10 +208,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 enum fsnotify_obj_type { FSNOTIFY_OBJ_TYPE_INODE,