Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3500253pxb; Mon, 18 Oct 2021 17:01:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjz12TqGc4hh0OCCig7W9Iwrso3zFheirk3HoFt6q/Bp4e9ugIv32I+9N9hi+2qrIWj3Pk X-Received: by 2002:a05:6402:4410:: with SMTP id y16mr48459634eda.366.1634601679406; Mon, 18 Oct 2021 17:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634601679; cv=none; d=google.com; s=arc-20160816; b=oDWZcrMB77nLP3TTbc6rcXUjbKgVV0wridjmtwbcn9wdxD64m2nT4Rnfh/Ar8xfaxu 0oHE579wz/2UFaTwMdytAvCzznhcF1YJBW717NKnSmfOCH5AeRbxyIjGf1+G4mnJ8saQ 81PNPtz0fXFet3IIvzfrVNbdqCbe/x+9CLYTRKPG20jylTnF3G/bWpFJMroR8B3FOmov s7lYuYvYId+EejXQ6tdiJTk6buc3BaUY46JiL1F7I1vHlg3U/6aYNFvtAaUCs3zuBK/G MbkN39FhF7hC37Zu+fbMG3Tz2zXtzfv/g/BeShHfQFtbW/+BYDngUnQ9/WnBBKgiw92K eQaw== 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=Yw11vGx0QD5kxVx0Cru3Hidh+9wLY57lwKeeg0vuYk9lrm0dsZYRwK7W8FlUPipoRf jPChM/dvLp7gGAG1QoLUcX4fpcu7gDzzWhKTh28oMikO+LIdB1S1ezYGPRqBWQRTxhCU ahiXqM/UPS8zquPN2TpA18s44xEGJzymuqdOIKWZGeN1HroezgMnpj5uH4glw8mrO4/i kgO9dd1IarkN8EXP8VelUwK+dvL0ShDyo/qsTo+27/MvcktTzl/znMH7IApl+tJpEeFe 1k+Qr0CNXgNz1Sc8MdIiWMRSs7XBWoSfHBXX8dKmugpKl0oRdDyTJnUf1j20Hc0C1TDQ l9Iw== 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 t7si26967796edd.523.2021.10.18.17.00.54; Mon, 18 Oct 2021 17:01:19 -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 S233239AbhJSACu (ORCPT + 99 others); Mon, 18 Oct 2021 20:02:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbhJSACu (ORCPT ); Mon, 18 Oct 2021 20:02:50 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67476C06161C; Mon, 18 Oct 2021 17:00:38 -0700 (PDT) Received: from localhost (unknown [IPv6:2804:14c:124:8a08::1007]) (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 D17291F41A9C; Tue, 19 Oct 2021 01:00:36 +0100 (BST) From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, david@fromorbit.com, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-api@vger.kernel.org, kernel@collabora.com, Jan Kara , Gabriel Krisman Bertazi Subject: [PATCH v8 02/32] fsnotify: pass dentry instead of inode data Date: Mon, 18 Oct 2021 20:59:45 -0300 Message-Id: <20211019000015.1666608-3-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211019000015.1666608-1-krisman@collabora.com> References: <20211019000015.1666608-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