Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp100082pxb; Tue, 17 Nov 2020 22:24:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4hWZXkjyevWlNz+4n0QXgbThotZ+so2Hh5/gSOoeapqWR3w0n0uuO02bWOTFo4sQHYM11 X-Received: by 2002:a17:906:a186:: with SMTP id s6mr23347057ejy.193.1605680694207; Tue, 17 Nov 2020 22:24:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605680694; cv=none; d=google.com; s=arc-20160816; b=uicVGJqFznaziJAZpOngfo4cYW1LIOmWmr4mlK1n3Q5FosKBCVfuWjd9vZIqypKIRI VQeI5MP3Tm/NSeUliFKPyh46T5C/06bVo94iRMC3cmtxZA9f2prprXOvXP+FynCFw6hu u1bUAoBIQ5G7HMDCqzOtteTJo7JLPmLxHOe8cOpzLi/zAAQWx6H0ph4HOBxYYmSrN7NL svuYSjuzIbYqZT8xrRcoVW3Y9XXQbD/QG9gJRJPdC7DCI2n8EGGG7zeuQmcaxYKQO9H5 L2nKEkxtQctxdUUhwmWGETyhKThD4VCbYY5xQ+5mPnacVzCDLpA1OLCdGHh+3d0LS+Ms i3lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YtbFnHLC0F4iSC34KfXMYG3W+T/7MuJJbJ93crg4rYY=; b=kX52g50QPuqfe6NcoUm2HkJIbdobJP3dKkPR9yzc0m1tPImJVAfib3crA5vCt9Npz8 gT8DheabikD3NR14rt5OdBmXEbc0CpzG9vLx8PJNF47c5naUOLapasPRqmWbBkcmTBW6 Wj3i6gZUUjFoHZ34HsFYppEbifM3cYUehEAfAv6lCPRuFXLF/Ugf7qzdbc8hTemxuH4Z 8nI6itITafFto5XV7uN0dnvSb96J0/ldm/t8TtWCV8oUAt/h2Ngb9wmMo+q58lqzl4OF afItjj0jAUoF+r17WyGn2LUtJ9/etlOgUOHjJuDoMTwAwP1WxoA5wV4037Wl0HQ3Zzm/ ypFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="s/0gcm/n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k5si1981299eji.617.2020.11.17.22.24.31; Tue, 17 Nov 2020 22:24:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="s/0gcm/n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726424AbgKRGWl (ORCPT + 99 others); Wed, 18 Nov 2020 01:22:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726360AbgKRGWk (ORCPT ); Wed, 18 Nov 2020 01:22:40 -0500 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 408B5C061A4D for ; Tue, 17 Nov 2020 22:22:40 -0800 (PST) Received: by mail-ot1-x344.google.com with SMTP id z16so715776otq.6 for ; Tue, 17 Nov 2020 22:22:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YtbFnHLC0F4iSC34KfXMYG3W+T/7MuJJbJ93crg4rYY=; b=s/0gcm/nu0ykiimxR8WdTqn9/oRW/XbyL4w3MNEAnCfzuYkMI3OFhwyBJe63/t0URk MF/eQSENFOP4uuanpMx/bVQmSBCMt9205j/XRDkg2inxeNJhKoi7iACS4a6LKhzYyyPq qa4dNN1q0jLGZrs5Lrn7jSqxzCJiOKKH3hQaT5DpJF7rkZje9PEQmxHX/SUM+QIQdrko eTsEfmyf6ZOcB2cirE8P2cFHN4xZybxLcNtsGeHE28KzS3mQ7JEffWMaUWI2FOczvsSz zEPr9p1knwW2aa2cMoNyVRYTr6BAKJgMrSjOb12HfcwQQj2g7+qML5P4PBXcJLFoIouH gSng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YtbFnHLC0F4iSC34KfXMYG3W+T/7MuJJbJ93crg4rYY=; b=ey8eCnFL0knqx0E0fw5H+dsHX4ok8t5MUC+K/zNxShk+oGVLl0tR/LHqZbpAlkTRtN utUid0zqc3mh5RnuIvKeHtDVYauAVX922oZuHbqD0SPZVENBVoWcp8hX4eCda84uOoFI yMfKXvntuhGSfFyRmy+A6CCBHGW0Yhbkfz4CvLDJvpYraU3OP87mxJjeo7p10eDiPbxX Q6BJkb24rzraTFRwtFI/KfZ3+kbHJ+Fj1GeVbtlXpAentxSrBygTwuJfQ3O3Z9YQkJ7O HgF/sSYHwED93AK4a1gvVlRzuZnB+ZZM2s/MOu0jwSJyapokUhRq4jflFn4O4zHpWE6B 7HcA== X-Gm-Message-State: AOAM531fkQZ8BBlQAIVQ95ZjTX1tL8nnvW33xI5mSpArHQgbGXWruTvD AJoNsvvzkcBGqmVu1UelubtUtRgNyicWk7geUgICaA== X-Received: by 2002:a9d:8ee:: with SMTP id 101mr5606894otf.93.1605680559385; Tue, 17 Nov 2020 22:22:39 -0800 (PST) MIME-Version: 1.0 References: <20201117040315.28548-1-drosen@google.com> <20201117040315.28548-4-drosen@google.com> In-Reply-To: From: Daniel Rosenberg Date: Tue, 17 Nov 2020 22:22:28 -0800 Message-ID: Subject: Re: [PATCH v2 3/3] f2fs: Handle casefolding with Encryption To: Eric Biggers Cc: "Theodore Y . Ts'o" , Jaegeuk Kim , Andreas Dilger , Chao Yu , Alexander Viro , Richard Weinberger , linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mtd@lists.infradead.org, Gabriel Krisman Bertazi , kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 17, 2020 at 10:50 AM Eric Biggers wrote: > > > What is the assignment to dentry_page supposed to be accomplishing? It looks > like it's meant to pass up errors from f2fs_find_target_dentry(), but it doesn't > do that. Woops. Fixed that for the next version. > > > @@ -222,14 +250,20 @@ static bool f2fs_match_ci_name(const struct inode *dir, const struct qstr *name, > > * fall back to treating them as opaque byte sequences. > > */ > > if (sb_has_strict_encoding(sb) || name->len != entry.len) > > - return false; > > - return !memcmp(name->name, entry.name, name->len); > > + res = 0; > > + else > > + res = memcmp(name->name, entry.name, name->len) == 0; > > + } else { > > + /* utf8_strncasecmp_folded returns 0 on match */ > > + res = (res == 0); > > } > > The following might be easier to understand: > > /* > * In strict mode, ignore invalid names. In non-strict mode, fall back > * to treating them as opaque byte sequences. > */ > if (res < 0 && !sb_has_strict_encoding(sb)) { > res = name->len == entry.len && > memcmp(name->name, entry.name, name->len) == 0; > } else { > /* utf8_strncasecmp_folded returns 0 on match */ > res = (res == 0); > } > Thanks, that is a fair bit nicer. > > @@ -273,10 +308,14 @@ struct f2fs_dir_entry *f2fs_find_target_dentry(const struct f2fs_dentry_ptr *d, > > continue; > > } > > > > - if (de->hash_code == fname->hash && > > - f2fs_match_name(d->inode, fname, d->filename[bit_pos], > > - le16_to_cpu(de->name_len))) > > - goto found; > > + if (de->hash_code == fname->hash) { > > + res = f2fs_match_name(d->inode, fname, d->filename[bit_pos], > > + le16_to_cpu(de->name_len)); > > + if (res < 0) > > + return ERR_PTR(res); > > + else if (res) > > + goto found; > > + } > > Overly long line here. Also 'else if' is unnecessary, just use 'if'. > > - Eric The 0 case is important, since that reflects that the name was not found. -Daniel