Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4579206pxb; Tue, 5 Oct 2021 06:11:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEGQFHttqbVBTDRvazrRfcZCf8nVn2ctyG2TjV1JoaHEREj4qYtQfQeYsh6FVOouS7Lp5Z X-Received: by 2002:adf:aad7:: with SMTP id i23mr20372885wrc.209.1633439473179; Tue, 05 Oct 2021 06:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633439473; cv=none; d=google.com; s=arc-20160816; b=BTbTpSX3HkvDMTLpXBc3nJGUx0bPh8X8rKC9/oCWfm6MKnmbbIONBO3OWIAU1AbH8a gHIt1EoVZ/ebj3mRB1QV5Q72ddNBC8E80aCxggjSNaKdN/Uear9bBMWMkALw4Ldiz/93 xeOydCPpjoWzUH6IX3Ow+RXJyqi8NiER5EuV7P4s3CuZ+/iXvVtnwUNLEw5qPsG5UNzL 4E3DkXjsKGBp6wvNJRb5O2iAWlqXhiMZ9lb/9O423YaQesY5UAPbmznYEnCFnazpJzTj EjHZY3RKG2dDsczIO3zu/h82eZWSxfFueOPaSUiYc8pT15Jlov1tUnaSe4jcPOa4qmgR 6tVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=laXOT3JSkc9PvpMuq7NIwi0X0wJVftJ5to9z6oSpmPA=; b=f9y0QgmwIP+ayTJsZZ8LncHTI1GRaxnKY1YqPPB/aRxrnqoEHO68jXl/a1/DQmffPC zkEDtH0E4T1fXkL95pvXD40wpv1oZH/2WoKt8tV6CkHYKGb5ikz6dOvj2WI8U6QlAf/c 2hiZ6PE9U2x/oI3SPgNbhhOAFxorR0mn/DIJIxe1YjJasCgbGje3oS++6RFjLxWn9jI+ mibHOdJKuyf0bDDXGQBVdchkvJV3agMqU6sB0wk9lLwjC0pqXz/7UZuduk4md/O6vEDu 6Wjn4rUAH19k36B2R6zv51NIk57qNeCalTKJ7PP4tb7U3hlvmk0Ke5t1XgsscfJuLixF P0vQ== 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 m5si21013523edc.107.2021.10.05.06.10.21; Tue, 05 Oct 2021 06:11:13 -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 S234103AbhJENL4 (ORCPT + 99 others); Tue, 5 Oct 2021 09:11:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233365AbhJENLz (ORCPT ); Tue, 5 Oct 2021 09:11:55 -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 73265C061749; Tue, 5 Oct 2021 06:10:05 -0700 (PDT) Received: from [IPv6:2401:4900:1c20:6ff1:a04:f397:fd5d:ecb8] (unknown [IPv6:2401:4900:1c20:6ff1:a04:f397:fd5d:ecb8]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: shreeya) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 1FE401F43751; Tue, 5 Oct 2021 14:10:03 +0100 (BST) Subject: Re: [PATCH 1/2] fs: dcache: Handle case-exact lookup in d_alloc_parallel To: Al Viro Cc: tytso@mit.edu, adilger.kernel@dilger.ca, krisman@collabora.com, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com References: <0b8fd2677b797663bfcb97f6aa108193fedf9767.1632909358.git.shreeya.patel@collabora.com> From: Shreeya Patel Message-ID: <589db4cf-5cab-2d1f-10ce-3a5009685948@collabora.com> Date: Tue, 5 Oct 2021 18:39:59 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 03/10/21 7:08 pm, Al Viro wrote: > On Wed, Sep 29, 2021 at 04:23:38PM +0530, Shreeya Patel wrote: >> There is a soft hang caused by a deadlock in d_alloc_parallel which >> waits up on lookups to finish for the dentries in the parent directory's >> hash_table. >> In case when d_add_ci is called from the fs layer's lookup functions, >> the dentry being looked up is already in the hash table (created before >> the fs lookup function gets called). We should not be processing the >> same dentry that is being looked up, hence, in case of case-insensitive >> filesystems we are making it a case-exact match to prevent this from >> happening. > NAK. What you are doing would lead to parallel calls of ->lookup() in the > same directory for names that would compare as equal. Which violates > all kinds of assumptions in the analysis of dentry tree locking. > > d_add_ci() is used to force the "exact" spelling of the name on lookup - > that's the whole point of that thing. What are you trying to achieve, > and what's the point of mixing that with non-trivial ->d_compare()? > Sending again as plain text... Hi Al Viro, This patch was added to resolve some of the issues faced in patch 02/02 of the series. Originally, the 'native', per-directory case-insensitive implementation merged in ext4/f2fs stores the case of the first lookup on the dcache, regardless of the disk exact file name case. This gets reflected in symlink returned by /proc/self/cwd. To solve this we are calling d_add_ci from the fs lookup function to store the disk exact name in the dcache even if an inexact-match string is used on the FIRST lookup. But this caused a soft hang since there was a deadlock in d_wait_lookup called from d_alloc_parallel. The reason for the hang is that d_same_name uses d_compare which does a case-insensitive match and is able to find the dentry name in the secondary hash table leading it to d_wait_lookup which would wait for the lookup to finish on that dentry causing a deadlock. To avoid the hang, we are doing a case-sensitive match using dentry_cmp here. Thanks > If it's "force to exact spelling on lookup, avoid calling ->lookup() on > aliases", d_add_ci() is simply not a good match.