Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11794988rwd; Thu, 22 Jun 2023 19:27:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4j5c0f0oYG7cOxzGwRNYbny8ynXyCWJ3yDAdwsqNeS1cBI/RB8AK597i1J2adAwH6v89Tn X-Received: by 2002:a17:90b:4c42:b0:261:636:dee8 with SMTP id np2-20020a17090b4c4200b002610636dee8mr4440129pjb.5.1687487252249; Thu, 22 Jun 2023 19:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687487252; cv=none; d=google.com; s=arc-20160816; b=mNvkL2dD7gWT/QSjAurhrdFtnCvoPPPLe5dLN59vLbzEzPQcMPhUM+dCtXsqEXc8kD yBO2mByMVXeo2l9ML7lVhD/3HGjufRks3TR0U4dUesD6Vtl0Q0R7HqvtiIlkn7VofxqV +EPjaKgfSwBAJVWbjomFkV87k7l2UUKQ7VyoFAfnvNQA7DH3j31X2R4IR8FUt/RsacEu qwWENeb0ATD2+LqvTXy6MVHxEIRl0rNWVo18cDd+u6QrsSickZMbWaHhg1fB9g6gzLZI 3Ig8jDSaiU+PEcSYNVi+MDtzFDOl8yyAl+eh1PdAnfdgZbzKtrN7ZyqQaXDpkNZptKK6 c0jw== 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:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=NSehen4O1lDhj/FQw/7iOUMNbquR7TTAAtXa2NTQEl4=; b=c5ZWYm3PUwzXvvz0CDlOrgncBJEUh+wGuHAMmOgo45WBHLcEoGjq5uDUQZ0Aq6SVGg zdfm4PKoju2SSRSk8hXWDyDTWn+WlEEc53JvkaDkL7hsUCHsK0tNqLlO3sbfAZYMATiE HvRcSheQMDPrNhwNt0jlt4M4a0KTnn5P4fkkEz07ATLeC2qy+9jY1hwxatNkpm1piQDI LL2Jq0d49wQxTg4+9tuIe5VQkPE229ubFNkJTCC5/Auoh4nHLjvMZq/9jKntBOhBr1XO 88DbKERn1msRZ2nSb4RNHGfhPNQ3uIWuMhIrducMDOsJvMDwLJ9ezKbnCOCaZ1Ma6vuW 6FMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rlph2JL+; 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 8-20020a17090a004800b0025eeb3cc4b2si920626pjb.9.2023.06.22.19.27.20; Thu, 22 Jun 2023 19:27:32 -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=rlph2JL+; 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 S230351AbjFWBl6 (ORCPT + 99 others); Thu, 22 Jun 2023 21:41:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbjFWBl4 (ORCPT ); Thu, 22 Jun 2023 21:41:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 765072114 for ; Thu, 22 Jun 2023 18:41:55 -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 0A12C61939 for ; Fri, 23 Jun 2023 01:41:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA7AAC433C0; Fri, 23 Jun 2023 01:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687484514; bh=I2aZF3V0Z194tldhoqu9fKjJ+bgd1Czgm3Eg3VR8zX8=; h=Date:Subject:To:References:From:In-Reply-To:From; b=rlph2JL+wWLr52ep9ZVnZ0edZ7FFq80p8L3yLNatM0oeTsYwPig61CKK2hWB8BocS cTR9vIzo8Oh5xDhxkAzlWo79OyyKna/THtGn4GrYiR4fgOZ/CWMryT/0eynODfEPP/ eJ3x1ZgLgRPfZ0Tn47D8YGgseG8azaJ5mZac6PIpKJb35Yi5Ld+AK4BgMIDoCxU7/r doI5wmjMdB1oa7NKWdpOfvVRgkk6VbQsLvr4XhvlKUbK0KJPsJFhmktvVUTgCosmdE 2Ls1oteh5t72Ah2VjAvKpzHGLCkK8Ax0aU6YKQ0vm7x+bxAmJZXUv77OmXHEBnLH/J H7W1h0A5OuQSQ== Message-ID: <768b0591-ba30-ba0e-0992-2f312ac76f16@kernel.org> Date: Fri, 23 Jun 2023 09:41:51 +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 Subject: Re: [f2fs-dev] [PATCH v3] f2fs: compress tmp files given extension 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 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 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_HI,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/22 15:12, 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 v2: > - fix parameters > > 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..80806ce1289f 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] == '.') > + 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], 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], true, false)) is_extension_exist(name, ext[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); >