Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1784750iob; Thu, 19 May 2022 14:42:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycehwkJ2FwWK4hkX2GdHCiZX8UH0Tf6RDhml+xUXf08TM3D9SEILlDtzuWiVrGHz+iVb0U X-Received: by 2002:a17:907:8c06:b0:6f4:9935:9049 with SMTP id ta6-20020a1709078c0600b006f499359049mr6369148ejc.517.1652996579549; Thu, 19 May 2022 14:42:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652996579; cv=none; d=google.com; s=arc-20160816; b=jyNwSn/VoHdhTvoS3mUTDT6NlXYdVUSOd4+DGa5d6D1NGcJkFBF4MHTFnIJbAehQ9G lNZ4ZJmP9VY53TxB705+FwEqKNQsdC+wEJzMKxFExGyEPx80Kgx08qsxqXsrTzE+PaHK p4ijMwsKszu48nmaO/I3K28bfdqBeeNNTHH2HK+cTqx5wwvde90RZ9Vn0uoxAN+kte48 Kb8QAssszfb8g0ulh73hGesbXnom1WuAie5o8ho2j/JYIGpo9J6Ta6Tq5AZEzMiRN0Nu 4QNRFMxDd37udABANynHfZVhuc1VaMhWBUJ7jTO02iJqkvP6Pvvye/vW6VJA1IOPBfbM RFhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:organization:subject:cc:to:from:dkim-signature; bh=Nv9/SuU2916Hj0d5tTFI7g4Zi3N/SgHz7tENHCwYVsU=; b=By4q3R2blnaz8cBP1y6YmeXLw9FoWIfxv2u37YTDjbqe8GiGQzYPZjR9lZ0YthuGAF /sXP/GjV8hQwjtaEEI8RM6nRBRwe1pok2nNrupOYBMVZ7Rp8b6t9xG1ni7cRBt+fxD6Y REDi9jMpe+l33ljmod3WTCSwk+Nlq3IadITQBZheds8UwHR160XjQYm8FHLfPEzvKAb1 G6LwORyI/UhfiVM7j4LjOJr74U43uK4CoMAvgU9IsUhxDwf1toUNFgQn1jKy69e8PZoR PHWcWoYZB4FOQjEIIgifCbGN+SDxdAhlOZZEDKgWmuabdz4oUMS1TFZBiTnLoCw/4B+t 0Yqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="mAh/bLJU"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u9-20020a50eac9000000b0042600ed167bsi5879616edp.221.2022.05.19.14.42.34; Thu, 19 May 2022 14:42:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="mAh/bLJU"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237305AbiESTwS (ORCPT + 99 others); Thu, 19 May 2022 15:52:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233971AbiESTwR (ORCPT ); Thu, 19 May 2022 15:52:17 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E34C57167 for ; Thu, 19 May 2022 12:52:16 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 593FA1F45F0D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1652989934; bh=VomzjzzCFyvyKndjLIaMric6uaiVW6aQWxQEa6yjllU=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=mAh/bLJUBl1G654LVZymUzj4D2nRiO5B7TzDI9MKL5pot6CI3nO9Z/2MErbEV6U6i 3t0Vv5p0dqbf+3ndgIvNBIUh5EdMVZFPPyQlcYF+wtGS114BZ/aa31rWBOm7SfE+ES TTZZPb5XI6ADTDZcvWeUxl2Xl/CZrWlEE+br6x0vo8sSNcoWRp4VF7ytG2DZEj3USN pFpiC9ymg3G5z9Jc2Y3+dlwlLsBUpXjiRbMkycL+KAAPpAdxXRrCpELTmDDK88fLn7 v6Sik/98VUwlGfGQOSOzquinEtZM14VHsYxIOyDpdcqH723upwTXSqo3Z8OgTMgAVd wnLTx6N676zZQ== From: Gabriel Krisman Bertazi To: Eric Biggers Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jaegeuk@kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel@collabora.com Subject: Re: [PATCH v6 4/8] ext4: Reuse generic_ci_match for ci comparisons Organization: Collabora References: <20220519014044.508099-1-krisman@collabora.com> <20220519014044.508099-5-krisman@collabora.com> Date: Thu, 19 May 2022 15:52:10 -0400 In-Reply-To: (Eric Biggers's message of "Wed, 18 May 2022 20:43:07 -0700") Message-ID: <87h75lnvv9.fsf@collabora.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham 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 Eric Biggers writes: > On Wed, May 18, 2022 at 09:40:40PM -0400, Gabriel Krisman Bertazi wrote: >> Instead of reimplementing ext4_match_ci, use the new libfs helper. >> >> It should be fine to drop the fname->cf_name in the encrypted directory >> case for the hash verification optimization because the only two ways >> for fname->cf_name to be NULL on a case-insensitive lookup is >> >> (1) if name under lookup has an invalid encoding and the FS is not in >> strict mode; or >> >> (2) if the directory is encrypted and we don't have the >> key. >> >> For case (1), it doesn't matter, because the lookup hash will be >> generated with fname->usr_name, the same as the disk (fallback to >> invalid encoding behavior on !strict mode). Case (2) is caught by the >> previous check (!IS_ENCRYPTED(parent) || >> fscrypt_has_encryption_key(parent)), so we never reach this code. > > The code actually can be reached in case (2), because the key could have been > added between ext4_fname_setup_ci_filename() and ext4_match(). Hm, I see! I didn't understand it would be possible to add a key during a lookup from your previous explanation, thanks for clarifying. > I *think* your change doesn't make it any worse, since in such a case the name > comparison is going to be comparing a no-key name to a regular one, which will > very likely fail. So adding an additional way for the match to fail > seems fine. Either way, no point in setting it for failure. I will restore the fname->cf_name != NULL check. > It's hard to reason about, though. f2fs does things in a much cleaner way, as > I've mentioned before, since it decides which type of match it wants at the > beginning, when initializing struct f2fs_filename. Yes, this is quite confusing. Are these implementation documented anywhere? Thank you for the review! -- Gabriel Krisman Bertazi