Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5060558pxb; Thu, 14 Oct 2021 18:18:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjm2rPAFibXWh16sovu6CWgOqVdXKJqIV+w7GEc9VaiObLx2YXTD6tuW+Fq1BTsrOnRFnd X-Received: by 2002:a62:1d08:0:b0:44c:6f89:85ef with SMTP id d8-20020a621d08000000b0044c6f8985efmr8903476pfd.42.1634260695958; Thu, 14 Oct 2021 18:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634260695; cv=none; d=google.com; s=arc-20160816; b=EhjUyDFHWxdtJemaHyjaJkRXTQNH/fnIvCQWiWYxm4o/QqvpzyNw685rIx5B3gFoeK 3miygxqT5tn1EqF7kqHmxHeoHjTuna4d3EVkNHcF3jwhsldVWAhX9Wopgq4LrtQQawWj IdZjd1bBzRGiXBrqZiQxKRmJtscKpb73sR0HEIolEcKEL27ShYf/JU26aJHA3YBsX96g ch+M4YQ+SMHOtPJ5zeJabY3jbe3EhWS0imo50ePn5o7hWvUS1uziIf7dnqbL7SNnk2mS sy/Wg6+dapWxJl+karF4U7CJjriSgj0jfRUZ8NfcQPd7VoEU1NZqLuIZQrhURQmdK+i2 ghag== 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=9AQFDyDITyM0WINxPxSX3ayUoYDPKURMnS2UFo/6rMA=; b=OJUPOCWUiLm8muczRFcL13SucaZKr4qVZlvbWk3iCSwH6SLys/Q2HNswenURNQ8iej e94FwJTVnZA+bIUOAs+yVlfUw8cYIawJQp/PPv1zDGTKKYV+CWtV8NoVfEEvmDbji71l oXSoL8GD8e5f3fMPZINbRZ5WljCc7IUautGHJhJ53LurpmykHePAsI25I37+UURnH4R2 NASo0EI1GgbnXk6vZ2zO8ekZdmexbnp4QCJBLVYH8HiC8rVY9EZv0sQ4ukoqAtzoZb8v YEyRbpIAsgzotIj/9pvDudbB5WX2b7brGvaI6+v6Cs4SCDfWYk4Gn5u17iWmON/86e5d zLVg== 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 d14si6637808plh.93.2021.10.14.18.17.58; Thu, 14 Oct 2021 18:18:15 -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 S233184AbhJNVjX (ORCPT + 99 others); Thu, 14 Oct 2021 17:39:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232180AbhJNVjW (ORCPT ); Thu, 14 Oct 2021 17:39:22 -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 49B74C061570; Thu, 14 Oct 2021 14:37:17 -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 9D7B41F44F6C; Thu, 14 Oct 2021 22:37:15 +0100 (BST) From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-api@vger.kernel.org, repnop@google.com, kernel@collabora.com, Gabriel Krisman Bertazi Subject: [PATCH v7 02/28] fsnotify: pass dentry instead of inode data Date: Thu, 14 Oct 2021 18:36:20 -0300 Message-Id: <20211014213646.1139469-3-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211014213646.1139469-1-krisman@collabora.com> References: <20211014213646.1139469-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. Signed-off-by: Amir Goldstein Signed-off-by: Gabriel Krisman Bertazi --- 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