Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5873959ioo; Wed, 1 Jun 2022 14:39:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3JCfHdT/ntC2CHIZHwXdk6jqheaTF0EvJqA7YBU34NWwQvLrM1+SS3BW6HeqSPayILZk7 X-Received: by 2002:a17:902:d2cb:b0:164:11ff:e55b with SMTP id n11-20020a170902d2cb00b0016411ffe55bmr1450260plc.111.1654119552836; Wed, 01 Jun 2022 14:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654119552; cv=none; d=google.com; s=arc-20160816; b=tv8WdZD14hOejvRSPjzE63QpwA8JgaMOGDCrePPrywBISXOFxIY/7fN1ZfmbKzCzPf vXnzKdjfd1mtYkVAimlEYYmzSJJmo1lq4O3PUW49GNlUNCN7TEJ4Jbqzy4bxD/9DSHid I/0liwG9DUWSiemCtYSTUYbdrIht6e5Raa10HQ5fbnpztUvhcHG5/Aa6/t+WB4NM6cLU UH0TChTT2DqGGMzQsioWUI8imjuDlJJTxQwPEpn/wI1yxKagfL4Kep8Y5Mlp4SL9myBK TVkpqZoldcPNLR69PCtpwRLxJ7kkiix97VPtDiw8BR662VA95FilwYtiQXV46JH8xsFM 9SDg== 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 :dkim-signature; bh=3ZuAKV+xWtrHYp2+U59hZd7+EEmy/hRTeWK0AferAEc=; b=ixLAeITKsoVQdID5H/u7mpdfa6bcsONa2zJQVCsFs6nyGJw4kOVGs3VzL/biO+HZ9u hsRxHV+xIixmNgYw/n/bDqYeYBq2ru3fWcV90Q+9XgF+5lvdYXZszu5JbFdJaBJPIew1 1Nkl4gV6uq1K1RH9VVEjpU6082G6mYdYrEKEm49Dhov+NOEzW91V5HZY14gzMgSWuLnq eljzbN0ie0klI2VJ8Hg+nOZMEb9u2pUkTfvpBeVgvi69mDP9TWpmvDAUWVoDwfJDVdhg Dts0aVZNfYMq26MSokHRHhdvqHy7g64bFAwjRTPDL1d+oFYV0SGLDTKr1Bf07ld8e4Rl bzVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TCt2xI7o; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x14-20020a63310e000000b003fc4d4c80fesi3705509pgx.69.2022.06.01.14.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 14:39:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TCt2xI7o; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 010E012D171; Wed, 1 Jun 2022 13:48:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230309AbiFAUsR (ORCPT + 99 others); Wed, 1 Jun 2022 16:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230411AbiFAUrp (ORCPT ); Wed, 1 Jun 2022 16:47:45 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D44527CCD1; Wed, 1 Jun 2022 13:44:55 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id AA62D1F43873 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1654116285; bh=ZplDD26se3sALbCKiz655gOmpmlfNBw3o5zrN9j2gHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TCt2xI7ooONrAXtH3MHq/Uy0k1zrQPWJNG/vjdcq6FafoTHLkOmf7xR7FDeOycjbG /fkTGZx2ae1jmDWU96+90DurKt9tOA0tA5g4cMV+3NKwgUD4/IPzT4dAF1kQodYKUz /RSDtBgSo/JWN3pfx669a1zLFJNqRnMFBbkGlMNAXi4C5+e+ZC6Fd+aPgtdFM62STv tW1ZoO10gJE/1aCjy5ItpCcpZhX5mAyMK070Wh0NhlTQG2Wo7agWUpztoQEiLOFJxI sSFAQ8Mr25h15o68oGsmnpFmJxPlz+duPbEUmg/UDLOU3o6d2n4Y1zrKT5RwQCEm8t lth22l4bJsX5Q== From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, tytso@mit.edu, jaegeuk@kernel.org Cc: ebiggers@kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH RFC 1/7] fs: Expose name under lookup to d_revalidate hook Date: Wed, 1 Jun 2022 16:44:31 -0400 Message-Id: <20220601204437.676872-2-krisman@collabora.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220601204437.676872-1-krisman@collabora.com> References: <20220601204437.676872-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Negative dentries support on case-insensitive ext4/f2fs will require access to the name under lookup to ensure it matches the dentry. This adds an optional new flavor of cached dentry revalidation hook to expose this extra parameter. I'm fine with extending d_revalidate instead of adding a new hook, if it is considered cleaner and the approach is accepted. I wrote a new hook to simplify reviewing. Signed-off-by: Gabriel Krisman Bertazi --- fs/dcache.c | 2 +- fs/namei.c | 23 ++++++++++++++--------- include/linux/dcache.h | 1 + 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 93f4f5ee07bf..a0fe9e3676fb 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1928,7 +1928,7 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) dentry->d_flags |= DCACHE_OP_HASH; if (op->d_compare) dentry->d_flags |= DCACHE_OP_COMPARE; - if (op->d_revalidate) + if (op->d_revalidate || op->d_revalidate_name) dentry->d_flags |= DCACHE_OP_REVALIDATE; if (op->d_weak_revalidate) dentry->d_flags |= DCACHE_OP_WEAK_REVALIDATE; diff --git a/fs/namei.c b/fs/namei.c index 509657fdf4f5..b2a2e715c1a8 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -848,11 +848,16 @@ static bool try_to_unlazy_next(struct nameidata *nd, struct dentry *dentry, unsi return false; } -static inline int d_revalidate(struct dentry *dentry, unsigned int flags) +static inline int d_revalidate(struct dentry *dentry, + const struct qstr *name, + unsigned int flags) { - if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE)) + + if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE)) { + if (dentry->d_op->d_revalidate_name) + return dentry->d_op->d_revalidate_name(dentry, name, flags); return dentry->d_op->d_revalidate(dentry, flags); - else + } else return 1; } @@ -1569,7 +1574,7 @@ static struct dentry *lookup_dcache(const struct qstr *name, { struct dentry *dentry = d_lookup(dir, name); if (dentry) { - int error = d_revalidate(dentry, flags); + int error = d_revalidate(dentry, name, flags); if (unlikely(error <= 0)) { if (!error) d_invalidate(dentry); @@ -1653,19 +1658,19 @@ static struct dentry *lookup_fast(struct nameidata *nd, return ERR_PTR(-ECHILD); *seqp = seq; - status = d_revalidate(dentry, nd->flags); + status = d_revalidate(dentry, &nd->last, nd->flags); if (likely(status > 0)) return dentry; if (!try_to_unlazy_next(nd, dentry, seq)) return ERR_PTR(-ECHILD); if (status == -ECHILD) /* we'd been told to redo it in non-rcu mode */ - status = d_revalidate(dentry, nd->flags); + status = d_revalidate(dentry, &nd->last, nd->flags); } else { dentry = __d_lookup(parent, &nd->last); if (unlikely(!dentry)) return NULL; - status = d_revalidate(dentry, nd->flags); + status = d_revalidate(dentry, &nd->last, nd->flags); } if (unlikely(status <= 0)) { if (!status) @@ -1693,7 +1698,7 @@ static struct dentry *__lookup_slow(const struct qstr *name, if (IS_ERR(dentry)) return dentry; if (unlikely(!d_in_lookup(dentry))) { - int error = d_revalidate(dentry, flags); + int error = d_revalidate(dentry, name, flags); if (unlikely(error <= 0)) { if (!error) { d_invalidate(dentry); @@ -3258,7 +3263,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file, if (d_in_lookup(dentry)) break; - error = d_revalidate(dentry, nd->flags); + error = d_revalidate(dentry, &nd->last, nd->flags); if (likely(error > 0)) break; if (error) diff --git a/include/linux/dcache.h b/include/linux/dcache.h index f5bba51480b2..871f65c8ef7f 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -126,6 +126,7 @@ enum dentry_d_lock_class struct dentry_operations { int (*d_revalidate)(struct dentry *, unsigned int); + int (*d_revalidate_name)(struct dentry *, const struct qstr *, unsigned int); int (*d_weak_revalidate)(struct dentry *, unsigned int); int (*d_hash)(const struct dentry *, struct qstr *); int (*d_compare)(const struct dentry *, -- 2.36.1