Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp503084pxb; Mon, 25 Oct 2021 12:33:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzojmygD0VdcbsudDppLRBTL9aDXuhL7oulUPuRpAQKZ4NG5jb8D1B5hN7mFTPCQbrk4ZsU X-Received: by 2002:a63:2acb:: with SMTP id q194mr15113129pgq.384.1635190400528; Mon, 25 Oct 2021 12:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635190400; cv=none; d=google.com; s=arc-20160816; b=vNS/BSQah+0IBwfiq1vjBaLNsq/IzGW70EI6ThOBZW5gAghxwdggIb6WTog9+ImM6P 9AutpqAh45a+08bkN+kfoQ7Fr1OD2NR9/zaJvWnxiuoIRm8EEzs5AWnpXM8AD+VfZZWo UOgFH4+34dBt4j0FbdzkT/yrItIGvoe11jOmAx0Us3eXuhb3HNJxyhNiFuy1GSfwdkHG skyBaZgJwNUWVeIBqLNkPnEWEC1oT0T1w+EV3ForT7ZxUjfwMUqu8u5y/o3GyMac1qiW wgmaRX+tibzsH4RlBExDej5nG3shb1FQl+jPfkOHLqDoZyZgiC+/Pt6YNwhrLLXoULo0 eyyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+/DbszgDDz/dwOCZEdwPRjPA4mInf1f7nb//m0V2frM=; b=vPNVMqiR17BFsFOobLleBDQq5AM0O760nwCB/H5O49tuSnJqDLs/a08sOSABc1lWDD bupy7awghoUmi5Us/G9NnySM2ifeA+2UW+/Y5DZp86F7gNXPbpVRbI2YtTgpUsdJUPma wiMozKAry7kt4cbx/jz9uOlrf4tNGdrTJc2IVSWiI6T3g7c2uw5CXSoJs8oTpsr1VHtX f6DIN5Uy5Iqq5QnXK3b42zjiyFsNiCB+OBx7WleC9eHFwguSG8Tww4Yw3ab1c752wnWD eWgNI1dPPEFhJach7CqUOjIgoLHkCh9ZR+btZ6C0OwHFpcoiGtpmXFOzWEcw2qDVtYxa vXvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 25si23913923pfp.189.2021.10.25.12.32.49; Mon, 25 Oct 2021 12:33:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235635AbhJYTcf (ORCPT + 99 others); Mon, 25 Oct 2021 15:32:35 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:58208 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235928AbhJYTae (ORCPT ); Mon, 25 Oct 2021 15:30:34 -0400 Received: from localhost (unknown [IPv6:2804:14c:124:8a08::1002]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: krisman) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 9ABD51F430C9; Mon, 25 Oct 2021 20:28:09 +0100 (BST) From: Gabriel Krisman Bertazi To: amir73il@gmail.com, jack@suse.com Cc: djwong@kernel.org, tytso@mit.edu, david@fromorbit.com, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-ext4@vger.kernel.org, kernel@collabora.com, Jan Kara , Gabriel Krisman Bertazi Subject: [PATCH v9 02/31] fsnotify: pass dentry instead of inode data Date: Mon, 25 Oct 2021 16:27:17 -0300 Message-Id: <20211025192746.66445-3-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211025192746.66445-1-krisman@collabora.com> References: <20211025192746.66445-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Amir Goldstein Define a new data type to pass for event - FSNOTIFY_EVENT_DENTRY. Use it to pass the dentry instead of it's ->d_inode where available. This is needed in preparation to the refactor to retrieve the super block from the data field. In some cases (i.e. mkdir in kernfs), the data inode comes from a negative dentry, such that no super block information would be available. By receiving the dentry itself, instead of the inode, fsnotify can derive the super block even on these cases. Reviewed-by: Jan Kara Signed-off-by: Amir Goldstein [Expand explanation in commit message] Signed-off-by: Gabriel Krisman Bertazi --- Changes since v7: - Improve commit message (Jan) --- include/linux/fsnotify.h | 5 ++--- include/linux/fsnotify_backend.h | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index d1144d7c3536..df0fa4687a18 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -39,8 +39,7 @@ static inline int fsnotify_name(__u32 mask, const void *data, int data_type, static inline void fsnotify_dirent(struct inode *dir, struct dentry *dentry, __u32 mask) { - fsnotify_name(mask, d_inode(dentry), FSNOTIFY_EVENT_INODE, - dir, &dentry->d_name, 0); + fsnotify_name(mask, dentry, FSNOTIFY_EVENT_DENTRY, dir, &dentry->d_name, 0); } static inline void fsnotify_inode(struct inode *inode, __u32 mask) @@ -87,7 +86,7 @@ static inline int fsnotify_parent(struct dentry *dentry, __u32 mask, */ static inline void fsnotify_dentry(struct dentry *dentry, __u32 mask) { - fsnotify_parent(dentry, mask, d_inode(dentry), FSNOTIFY_EVENT_INODE); + fsnotify_parent(dentry, mask, dentry, FSNOTIFY_EVENT_DENTRY); } static inline int fsnotify_file(struct file *file, __u32 mask) diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 1ce66748a2d2..a2db821e8a8f 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -248,6 +248,7 @@ enum fsnotify_data_type { FSNOTIFY_EVENT_NONE, FSNOTIFY_EVENT_PATH, FSNOTIFY_EVENT_INODE, + FSNOTIFY_EVENT_DENTRY, }; static inline struct inode *fsnotify_data_inode(const void *data, int data_type) @@ -255,6 +256,8 @@ static inline struct inode *fsnotify_data_inode(const void *data, int data_type) switch (data_type) { case FSNOTIFY_EVENT_INODE: return (struct inode *)data; + case FSNOTIFY_EVENT_DENTRY: + return d_inode(data); case FSNOTIFY_EVENT_PATH: return d_inode(((const struct path *)data)->dentry); default: @@ -262,6 +265,19 @@ static inline struct inode *fsnotify_data_inode(const void *data, int data_type) } } +static inline struct dentry *fsnotify_data_dentry(const void *data, int data_type) +{ + switch (data_type) { + case FSNOTIFY_EVENT_DENTRY: + /* Non const is needed for dget() */ + return (struct dentry *)data; + case FSNOTIFY_EVENT_PATH: + return ((const struct path *)data)->dentry; + default: + return NULL; + } +} + static inline const struct path *fsnotify_data_path(const void *data, int data_type) { -- 2.33.0