Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1240075ybi; Thu, 30 May 2019 14:02:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVtPBkB7P1/b2RBcQ58mCBr50H+EK6mBSocm7u3fOk3gAyV8QtLE6nmv8nfEAbX+WxGQ8z X-Received: by 2002:a17:90a:d582:: with SMTP id v2mr5140021pju.22.1559250175547; Thu, 30 May 2019 14:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559250175; cv=none; d=google.com; s=arc-20160816; b=xYHCt0gXPfOmH0dXiuldBd2Xm6j7sfgfuuVQbxwke9gEes4Ofr4nvBFl02oWJuU7Tz xs4wVftH6+Xz0zL1yUBONs1o5y2XL+TxUt0AOlyuGGNZPkqLvu96/jBRbNtVglCN8IhZ N7i+CS3Z6DHrmuglIzIAWmGA1CAJar6ZSFemELeHUafLCk66hl3LVf/hAB/b9q/VPnuB DHJJxDz4816LFE9i5lVcv7J7GPUlNRIU4r5Gy7kFNkTFs6Rndtt6bL7UhU8mgxUaaYDM fvm83VrLcOK9jizJuC2zoEmZFypRZiFZRhqylRO9MzElS9MhQyQ3RVQXj+nGyteFH26r 0dcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=brO+sD+iB3kknU7RNQjcpzvOCL8DgGhj5MRsUW+lV2I=; b=BZ/0oSlNmcjnFBy2ziYaJdVvw7Tb02Z6fXQEBv+4tGirdTdXiLa1alHWc8+J7J8yIZ zfqGEKpMYZ+b6b+UPHCUy1mh1skdDAgYsDJTUOXKKjDehlfK+FwhMF6T+iy8PPaUZa15 1sPsv8YgjSV4SB3silLUIXV4B4MWBaiSdrwhYZqQ8ffVWSL8vf3IfV1ulciQpHr4or82 7d4la3fCMQ6wYQIICgtziLuiuBnWzLYs2DTA5KmViuD2Z4+JnFW/jI4z6kR+N37hMRoY ytCSczkQs13wa7u86eJ8qqUnPmJHBCvt0PZ7xHkbf7xjVmt1m71vz0GOcRPD6CUrCD62 OjPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9si3836615pgs.115.2019.05.30.14.02.33; Thu, 30 May 2019 14:02:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726541AbfE3VCD (ORCPT + 99 others); Thu, 30 May 2019 17:02:03 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:49436 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725440AbfE3VCC (ORCPT ); Thu, 30 May 2019 17:02:02 -0400 Received: from callcc.thunk.org (guestnat-104-133-0-109.corp.google.com [104.133.0.109] (may be forged)) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id x4UL1uQF009574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 May 2019 17:01:57 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id 7865B420481; Thu, 30 May 2019 17:01:56 -0400 (EDT) Date: Thu, 30 May 2019 17:01:56 -0400 From: "Theodore Ts'o" To: Gabriel Krisman Bertazi Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-fscrypt@vger.kernel.orglinux-fscrypt Subject: Re: [PATCH] ext4: Optimize case-insensitive lookups Message-ID: <20190530210156.GI2998@mit.edu> References: <20190529185446.22757-1-krisman@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190529185446.22757-1-krisman@collabora.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, May 29, 2019 at 02:54:46PM -0400, Gabriel Krisman Bertazi wrote: > diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h > index c18ab748d20d..e3809cfda9f4 100644 > --- a/fs/ext4/ext4.h > +++ b/fs/ext4/ext4.h > @@ -2078,6 +2078,10 @@ struct ext4_filename { > #ifdef CONFIG_FS_ENCRYPTION > struct fscrypt_str crypto_buf; > #endif > +#ifdef CONFIG_UNICODE > + int cf_len; > + unsigned char cf_name[EXT4_NAME_LEN]; > +#endif > }; > > #define fname_name(p) ((p)->disk_name.name) EXT4_NAME_LEN is 256, and struct ext4_filename is allocated on the stack. So this is going to increase the stack usage by 258 bytes. Perhaps should we just kmalloc the temporary buffer when it's needed? The other thing that this patch reminds me is that there is great interest in supporting case folded directories and fscrypt at the same time. Today fscrypt works by encrypting the filename, and stashes it in fname->crypto_buf, and this allows for a byte-for-byte comparison of the encrypted name. To support fscrypt && casefold, what we would need to do is to change the htree hash so that the hash is caluclated on the normalized form, and then we'll have to decrypt each filename in the directory block and then compare it against the normalized form that stashed in cf_name. So that means we'll never need to allocate memory for cf_name and crypto_buf at the same time. We can also use struct fscrypt_str for cf_name; it's defined as a combined unsighed char *name and u32 len. We already use fscrypt_str even the !CONFIG_FS_ENCRYPTION case, since it's a convenient way of handling a non-NULL terminated filename blob. And this will hopefully make it simpler to deal with integrating casefolding and fscrypt in the future. Cheers, - Ted