Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7963502rwd; Tue, 20 Jun 2023 08:25:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58SL2VjXAMJ9mrhIgb1NcqdBewnvMAjBkP5Z1loDHRDajgekVDDnrTiFbeyhP2ocHDVQmW X-Received: by 2002:a17:90a:52:b0:25b:c53e:4697 with SMTP id 18-20020a17090a005200b0025bc53e4697mr12488474pjb.16.1687274719653; Tue, 20 Jun 2023 08:25:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687274719; cv=none; d=google.com; s=arc-20160816; b=sjAO2Uii0F0IPrzrKDohWqZLFk5cPJ1YhgB6P2ECFAsgZA4xRY7FrXizz15t9UsnBb k8GE/MV4w8bdFgg4EcwT/6gyNqrejkTz5g5DH4aaQuxECx4/tZychr20M98z815CxA6S DAUy1bagyuCu79kyWo20MvqbyZiw4PK+D+ijOBKAtWRRT29F5700Xw2k+oaC2AF4kSzE l0sOjKqZ5yL2SxggsKmCK/5xOredopR2jKHWasiGldPKqyxoeuWVpsntlRy0y5/oqKzF jJUxlBiqqHBozXJMlhF7oUYdN3D7FnrxD1vMi2uXcDv2BgFA5xv2E3HqkRFCReOTxVkw PlFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=eOVXvtNAcD5PLY0CKl8aakxRRteKV8yTl9Qs7T1Rqu0=; b=l+h/6LIpXP6sXcn7KcFlmU6gViauEUGZwomG5QVSlmXre+WimZr71UA1rBh9uXTuhv kkzYCLmLaul33kAwNR4vi6ZKJRAg41BHoKj1b6KnZya6FZsTCEOYax6j1+toNG2G4SSD 1bfxxwRSXsxS8p6noloFk7qgnwqf/syXlSgIhEVgSFhAgcaXNDcsoRyTpZ5JBDgzVxhb IJrewHFXEL7wMFPeHVxrFdSLgpRx5XQOLp7E2VqukGDvgpE3fdiQoQ7xYiOwaMXbJDbx CbrdcfhXJRlRnuS5W8YrIdVpNeot5rz1KmiTyQESSLR+mj9+SGqVExc5p5Qyf2z2+1Em bV9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XVd6YKmm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m18-20020a637112000000b0051b1966e6b6si1829132pgc.521.2023.06.20.08.25.03; Tue, 20 Jun 2023 08:25:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@kernel.org header.s=k20201202 header.b=XVd6YKmm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233654AbjFTPPR (ORCPT + 99 others); Tue, 20 Jun 2023 11:15:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233779AbjFTPOv (ORCPT ); Tue, 20 Jun 2023 11:14:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB2CB1BD9 for ; Tue, 20 Jun 2023 08:14:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D86FF6109A for ; Tue, 20 Jun 2023 15:14:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A98CC433C9; Tue, 20 Jun 2023 15:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687274068; bh=xpcefpiU++C3oDlU0Wn9zWuqnqGHuvxn4dXB9f/77gc=; h=Date:To:References:From:Subject:In-Reply-To:From; b=XVd6YKmm8EBcElAd/EJEKG/h9U6xpexYpoor74O3uNCtx2gkzActiCDE6QrDXA9J3 5BBGVdLtf4f0OQ0dF8KgMWEW+i+a8m1NG8OyhKG85WbFr+wXK9VGNmZDzQR0rb5WSf xzK+BF7Fe3n9NHC6slatcOk0z1OA82vICaKfkj/lrDb6NaE8eoQYA6CJYKCXG4Din/ z3L5pvwT44BcSTU5ld3QWFCZ5A80DeCAvpG5OTI355ctSsShPriLKz3cwkTU7ulBdQ R3PHLKeufyGiId8yYSKzI7EZ/32CaDSjfXU76Y7PrKQfJ/Iknn4JhJjFLP+pp/fLET IIU4bxmySWwXg== Message-ID: Date: Tue, 20 Jun 2023 23:14:23 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Content-Language: en-US To: Jaegeuk Kim , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <20230606203645.3926651-1-jaegeuk@kernel.org> From: Chao Yu Subject: Re: [f2fs-dev] [PATCH v2] f2fs: compress tmp files given extension In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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-kernel@vger.kernel.org On 2023/6/14 6:14, Jaegeuk Kim wrote: > Let's compress tmp files for the given extension list. > > This patch does not change the previous behavior, but allow the cases as below. > > Extention example: "ext" > > - abc.ext : allow > - abc.ext.abc : allow > - abc.extm : not allow > > Signed-off-by: Jaegeuk Kim > --- > > Change log from v1: > - refactor to allow abc.ext.dontcare only > > fs/f2fs/namei.c | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c > index 3e35eb7dbb8f..49573ef4115d 100644 > --- a/fs/f2fs/namei.c > +++ b/fs/f2fs/namei.c > @@ -23,7 +23,7 @@ > #include > > static inline bool is_extension_exist(const unsigned char *s, const char *sub, > - bool tmp_ext) > + bool tmp_ext, bool tmp_dot) > { > size_t slen = strlen(s); > size_t sublen = strlen(sub); > @@ -49,8 +49,12 @@ static inline bool is_extension_exist(const unsigned char *s, const char *sub, > for (i = 1; i < slen - sublen; i++) { > if (s[i] != '.') > continue; > - if (!strncasecmp(s + i + 1, sub, sublen)) > - return true; > + if (!strncasecmp(s + i + 1, sub, sublen)) { > + if (!tmp_dot) > + return true; > + if (i == slen - sublen - 1 || s[i + 1 + sublen] == '.') Do you mean? if (i == slen - sublen - 1 && s[i + 1 + sublen] == '.') > + return true; > + } > } > > return false; > @@ -148,7 +152,7 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir, > cold_count = le32_to_cpu(sbi->raw_super->extension_count); > hot_count = sbi->raw_super->hot_ext_count; > for (i = cold_count; i < cold_count + hot_count; i++) > - if (is_extension_exist(name, extlist[i], false)) > + if (is_extension_exist(name, extlist[i], false, false)) Parameters should be consistent w/ the one in set_file_temperature()? if (is_extension_exist(name, extlist[i], true, false)) > break; > f2fs_up_read(&sbi->sb_lock); > if (i < (cold_count + hot_count)) > @@ -156,12 +160,12 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir, > > /* Don't compress unallowed extension. */ > for (i = 0; i < noext_cnt; i++) > - if (is_extension_exist(name, noext[i], false)) > + if (is_extension_exist(name, noext[i], false, false)) is_extension_exist(name, noext[i], true, true) ? Thanks, > return; > > /* Compress wanting extension. */ > for (i = 0; i < ext_cnt; i++) { > - if (is_extension_exist(name, ext[i], false)) { > + if (is_extension_exist(name, ext[i], true, true)) { > set_compress_context(inode); > return; > } > @@ -189,7 +193,7 @@ static void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *inode, > cold_count = le32_to_cpu(sbi->raw_super->extension_count); > hot_count = sbi->raw_super->hot_ext_count; > for (i = 0; i < cold_count + hot_count; i++) > - if (is_extension_exist(name, extlist[i], true)) > + if (is_extension_exist(name, extlist[i], true, false)) > break; > f2fs_up_read(&sbi->sb_lock); >