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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 834FEC433C1 for ; Sun, 28 Mar 2021 17:40:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3795661964 for ; Sun, 28 Mar 2021 17:40:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230350AbhC1Rjz (ORCPT ); Sun, 28 Mar 2021 13:39:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230497AbhC1Rjg (ORCPT ); Sun, 28 Mar 2021 13:39:36 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0C4EC061756; Sun, 28 Mar 2021 10:39:36 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lQZNk-000U9Y-BT; Sun, 28 Mar 2021 17:39:24 +0000 Date: Sun, 28 Mar 2021 17:39:24 +0000 From: Al Viro To: =?iso-8859-1?Q?Andr=E9?= Almeida Cc: Theodore Ts'o , Andreas Dilger , Jaegeuk Kim , Chao Yu , krisman@collabora.com, kernel@collabora.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Daniel Rosenberg , Chao Yu Subject: Re: [PATCH 1/3] fs/dcache: Add d_clear_dir_neg_dentries() Message-ID: References: <20210328144356.12866-1-andrealmeid@collabora.com> <20210328144356.12866-2-andrealmeid@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210328144356.12866-2-andrealmeid@collabora.com> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Sun, Mar 28, 2021 at 11:43:54AM -0300, André Almeida wrote: > +/** > + * 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-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, 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 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. > + */ > +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); > + } > + } > +} That makes no sense whatsoever. 1) directories can never have more than one alias 2) what the hell are you doing to refcounts on those children?