Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10513749rwd; Thu, 22 Jun 2023 00:37:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5eAHHhjkmSV2+IM3Z5eXM5r3C81RGvfOpY7KNfA+b/Yv+0iTnOVAR2WMv4U6qwbOuX5B6L X-Received: by 2002:a17:902:c209:b0:1b3:f5f0:8c50 with SMTP id 9-20020a170902c20900b001b3f5f08c50mr15065949pll.11.1687419471390; Thu, 22 Jun 2023 00:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687419471; cv=none; d=google.com; s=arc-20160816; b=Bvt5UTYuQbmhlHT088EerlvOGdQ62s+pf3MGAlJBr/s8hMwMZHzOEeIlDoq/TtuDDv A8DuvWVCvW4xN5onrNdd6/lvYczEviVyFR+CTIXQkwGfg2hodvU0YUzTFCxKVeIL54wp wthJZPZvU7U9/nCQKV7u4VjZrMrFVrv/xwWz0+zj7CZWrKHw7Nk6WhVjZ2dpvjt6h8D3 0F0nG8IpJXmqfm0K6vRJDigbZ398Zb9gvYjvM6yHCrNSCZiDlR+cM3VCwjohpWchG0cS WSXHcPO+IaAruYVKivycnq38Z/kRjsctjmzjZwcq9E5M9T6OGAKZwuUb6CMQT4PAsGS4 YDjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature; bh=ts81l7dfuJiU1bEnBMPO6/aks0gF2eLVemgTt357AUI=; b=IlXQdc3GFrLXq/SCWIGelB+eEfVbBTq7OipE7OZDgPx2aUqVx5RY8sNL9gFDyeDRP0 YqRlyFVoV1aJOZzE3WGSi7BuMDeK0UrsrjyUy8gpPBAQBDjGgd8CtGrrFViWcrBzIuaS cEGglXymWy3Ky0pIQVVoOEm4o2XAH7jc+9Gr91rtfW7mcU3/kXsKG5hSVr51Vghsp2ls CKD74enrvgvWes30hatYocl1yaP9NEhH+B3uw8hiuaS+gytObfKW28keBE2DAuWfTUqX G/61hP9f7uMrgoTuiea5gCk1TvNxTVGgn9XVZjexUmrwKiRQqoCFFufmbWgG8rwEDxGy 5/jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vKpzyF7M; 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 h8-20020a170902f54800b001b69ede5b6esi2907054plf.551.2023.06.22.00.37.39; Thu, 22 Jun 2023 00:37:51 -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=vKpzyF7M; 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 S230100AbjFVHM6 (ORCPT + 99 others); Thu, 22 Jun 2023 03:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230507AbjFVHMr (ORCPT ); Thu, 22 Jun 2023 03:12:47 -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 B0AC11BDC for ; Thu, 22 Jun 2023 00:12:44 -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 412236177C for ; Thu, 22 Jun 2023 07:12:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95E64C433CA; Thu, 22 Jun 2023 07:12:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687417963; bh=FrHV/aMYkgKJL7vYPTB/f+fAorcu5w2trEwg00r+1/4=; h=Date:From:To:Subject:References:In-Reply-To:From; b=vKpzyF7M/taaUfr2eUVeK3zXkQjzykKdEkWrEcsha2+UlziELuyNE4/zglr33vT9N Y4tkpP4zPLnXYjJ1PkW8TLIAeY+7hpfrfT0n7x2oTj9KY2fCZ/uxh6x+Btc2WQuB1l 9JUpyXeSnvSEzzEnvDpHcDo24Z/SGrHnf5o99Om6P09EsRKEQ6qtOnf4fyd3GSS+67 1txDZVSIMZEnmLp+WKywCg2S43ZmSDYMrEzizxjQgSHIcPlQFJZPZZctYi5wMmz8R6 Hqu1k/NfB0kvyrkMpHYUOaiShwSL7UxA40mgAXz7OhGMcyvcmCb1CEw+hdiiIwtOgk bF02r3o/cFXqA== Date: Thu, 22 Jun 2023 00:12:42 -0700 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH v3] f2fs: compress tmp files given extension Message-ID: References: <20230606203645.3926651-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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)) 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); -- 2.41.0.162.gfafddb0af9-goog