From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA206C433C1 for ; Tue, 30 Mar 2021 01:49:14 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F12C60C41 for ; Tue, 30 Mar 2021 01:49:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F12C60C41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1lR3VI-00040R-1x; Tue, 30 Mar 2021 01:49:12 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lR3VG-00040I-Dd for linux-f2fs-devel@lists.sourceforge.net; Tue, 30 Mar 2021 01:49:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=3Y1VDQRq1LfrD1XIsfEAJG7MbEKCTChZ0EmxY+Op0AM=; b=a4AXGc6oQ7A9XehD35flBudMrU s8ymC2tV6CjxkknMES5gvHUNhCJOMpLidWxk6NhSqzCNEExxfi+qw1R51DTG9LiHKbEdy1nOQtJmf yoJEkr+Qin2zqonK037F8nxPapYMekzlJqR041G4rP8ek4g1w9zGdCCmM5YcAf+SOxFc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Transfer-Encoding:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=3Y1VDQRq1LfrD1XIsfEAJG7MbEKCTChZ0EmxY+Op0AM=; b=bfTMb6Xv6WH/KczHdJyzMZaPUs yTttZhJxs4VDaKRhS/lz8fW1LbT+cNumzBA6UwMoKPIVbBLDt97naXu+1tenG8TaDojNBEZpoJqUd HW7TKVTz0BHKBe5iqlK8nTj4IrfyRZu4iQsM/x5XY5xiuabhIe4yA0FGpQ7We3PN/Nwg=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1lR3V4-00Asp9-KS for linux-f2fs-devel@lists.sourceforge.net; Tue, 30 Mar 2021 01:49:10 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8C49360C41; Tue, 30 Mar 2021 01:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617068927; bh=iIeIM/OuGtjaYTjydbbG0UkVMkzGNNchPxEVUAEmnkM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nDxq7K9t7dlImUknG3pZavwpTDgqaPC7F9NdQLDcVbBczilmQZvhCW0eksYB8RuYt WjNUkzadhFtYGdO6BMlWvTRw1NW2eir9qEheqsePkacJsCdS2n/WJYmFgsXweXbnHo 1PT+uC3kAf881vRVcH30ssY4QqHieFaZg+7iVRum4xbCXh6WBWyd4aP52uL34rkcvH rTPtpyumwG13TKR9pY8RmdZsGh7As/NrnVe8LDGtHCGWBLPbo4ro2YhnSCs1MvmKHl KaK/qtyaBcuqUh91ULqym24uAAtps7VmWan4KPhFTY2ueJ92c5xT/nlAI4snicxy2l clT9SDt2FfZaA== Date: Mon, 29 Mar 2021 18:48:46 -0700 From: Eric Biggers To: =?iso-8859-1?Q?Andr=E9?= Almeida Message-ID: References: <20210328144356.12866-1-andrealmeid@collabora.com> <20210328144356.12866-2-andrealmeid@collabora.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210328144356.12866-2-andrealmeid@collabora.com> X-Headers-End: 1lR3V4-00Asp9-KS Subject: Re: [f2fs-dev] [PATCH 1/3] fs/dcache: Add d_clear_dir_neg_dentries() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-ext4@vger.kernel.org, Theodore Ts'o , Daniel Rosenberg , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Andreas Dilger , Alexander Viro , linux-fsdevel@vger.kernel.org, Jaegeuk Kim , kernel@collabora.com, krisman@collabora.com Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Sun, Mar 28, 2021 at 11:43:54AM -0300, Andr=E9 Almeida wrote: > For directories with negative dentries that are becoming case-insensitive > dirs, we need to remove all those negative dentries, otherwise they will > become dangling dentries. During the creation of a new file, if a d_hash > collision happens and the names match in a case-insensitive way, the name > of the file will be the name defined at the negative dentry, that may be > different from the specified by the user. To prevent this from > happening, we need to remove all dentries in a directory. Given that the > directory must be empty before we call this function we are sure that > all dentries there will be negative. > = > Create a function to remove all negative dentries from a directory, to > be used as explained above by filesystems that support case-insensitive > lookups. > = > Signed-off-by: Andr=E9 Almeida > --- > fs/dcache.c | 27 +++++++++++++++++++++++++++ > include/linux/dcache.h | 1 + > 2 files changed, 28 insertions(+) > = > diff --git a/fs/dcache.c b/fs/dcache.c > index 7d24ff7eb206..fafb3016d6fd 100644 > --- a/fs/dcache.c > +++ b/fs/dcache.c > @@ -1723,6 +1723,33 @@ void d_invalidate(struct dentry *dentry) > } > EXPORT_SYMBOL(d_invalidate); > = > +/** > + * d_clear_dir_neg_dentries - Remove negative dentries in an inode > + * @dir: Directory to clear negative dentries > + * > + * For directories with negative dentries that are becoming case-insensi= tive > + * dirs, we need to remove all those negative dentries, otherwise they w= ill > + * become dangling dentries. During the creation of a new file, if a d_h= ash > + * collision happens and the names match in a case-insensitive, the name= of > + * the file will be the name defined at the negative dentry, that can be > + * different from the specified by the user. To prevent this from happen= ing, we > + * need to remove all dentries in a directory. Given that the directory = must be > + * empty before we call this function we are sure that all dentries ther= e will > + * be negative. > + */ > +void d_clear_dir_neg_dentries(struct inode *dir) > +{ > + struct dentry *alias, *dentry; > + > + hlist_for_each_entry(alias, &dir->i_dentry, d_u.d_alias) { > + list_for_each_entry(dentry, &alias->d_subdirs, d_child) { > + d_drop(dentry); > + dput(dentry); > + } > + } > +} > +EXPORT_SYMBOL(d_clear_dir_neg_dentries); As Al already pointed out, this doesn't work as intended, for a number of different reasons. Did you consider just using shrink_dcache_parent()? That already does what= you are trying to do here, I think. The harder part (which I don't think you've considered) is how to ensure th= at all negative dentries really get invalidated even if there are lookups of t= hem happening concurrently. Concurrent lookups can take temporary references t= o the negative dentries, preventing them from being invalidated. - Eric _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel