Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12930343rwd; Fri, 23 Jun 2023 12:51:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Wgbfxf7+RquOWe7JSK6tLqvXrSFO75QALw7C0jiGjJy1k4bGt6JD+o6hBJD+pqs+m0Bc/ X-Received: by 2002:a05:6a20:42a5:b0:122:d201:23e5 with SMTP id o37-20020a056a2042a500b00122d20123e5mr10375024pzj.57.1687549888020; Fri, 23 Jun 2023 12:51:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687549888; cv=none; d=google.com; s=arc-20160816; b=hF6zkXjpuX1aK8lsylC52pOwsVzawRUcJD6jsFCTGhp5cnNmBrNwhj2IHeGC7ZpmwJ uhI7CMcq/eL3MA57wvMyfmpKzUi0waHdmYcD5KgVUfwL9hq+L9G5pkCTl3Y0Z3izQiym 7kjDfUCyNb8u6UOphmIk4uPf6iWDP3ong40LqRpoERDjdlL96uBWVtscJN7ybzuuuCPT n659ab5bDLF+dXTnZKx0Ad9HO/bInYJItLwzYdoUamgmRqRLFqH3pzOyFxUsdwcy/Cn8 6ZVP+JO+xxj9vBXox3qjXW2aAMH7XCc5mzYvsxrdn2pcq2Zt5BlVGGkHJuTCtHBMsOL7 wmUg== 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=18Di6G033KpjIOYPm4VhN1PSzlu9LJ0ou/gFriGRm/0=; b=Qzyfi5Ztwxims3qDSt3fIJPyaer2OptLIqs557mCqu6/H13XKORr/63H8gHbrP5Ymp Ve7zKm7yfQqaAGaJgTuztIfvZeL9prOQuI79vsWs7iltPqZRiqrcoWt/HlPSex6t8jog /WrGqk1A2dvM+9/sgv5RbtOpampfeCTU487om2HBxWH+scVi/hsYSQ8zEzzwMng2Cmww E9SBDedRFoZDVy9DuIcZK1VQAVdRoi/QR3icu4SEgwuX94CE7SN4n02xrvZxdLkYgTp1 0juvOqXD1IgozXjp1KLJJw+9bjCwX2bsi3EPg5zFFYbNcMzW/Kx5od+JdQL0wXZm0C0k xhug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Yst19NYT; 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 y8-20020a17090322c800b001ab039a411csi10731794plg.17.2023.06.23.12.51.15; Fri, 23 Jun 2023 12:51:27 -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=Yst19NYT; 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 S230459AbjFWTPu (ORCPT + 99 others); Fri, 23 Jun 2023 15:15:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbjFWTPs (ORCPT ); Fri, 23 Jun 2023 15:15:48 -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 607152697 for ; Fri, 23 Jun 2023 12:15:47 -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 E4FA961AFD for ; Fri, 23 Jun 2023 19:15:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33C45C433C8; Fri, 23 Jun 2023 19:15:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687547746; bh=jnTBrbslxp9wjuZpk/G+lTdN3BwKxiUCagWOzSpADAk=; h=Date:From:To:Subject:References:In-Reply-To:From; b=Yst19NYT3zXJGrou6Zzh0yxyjM6theurBQUx3Nx4j3qnLNs/8udC/ajwe7ed+MmGi CqI9Vp8SSbk2FUckSIudEFgmsAtLejfi7dQz0SYLleF48dCTOOVUEHiFvt3gN2k9hT /XRKHObhVPr15REkiTzF2Fa+6eyjTg/H2OCt+3/UX1JMnEzSXLHtwYcX+Rfeoza+30 o2tNIpQbCuAlxA51CcIuHijfae/ViEV/UUTQmUYsRhRSAT1ytAzRWSVz8z/axM6uHA j2MFDGR+vBtbLC3FeLZpYlFTOEoWioIQ4y+G8jTv3IMg8F5HZB0FJx/8tv+yODBidv 00dJjbENoiIZQ== Date: Fri, 23 Jun 2023 12:15:44 -0700 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH v4] 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,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 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 v3: - split temparature and compress extensions Change log from v2: - fix parameters Change log from v1: - refactor to allow abc.ext.dontcare only fs/f2fs/namei.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 3e35eb7dbb8f..ff89de115272 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,13 +49,27 @@ 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; } +static inline bool is_temperature_extension(const unsigned char *s, const char *sub) +{ + return is_extension_exist(s, sub, true, false); +} + +static inline bool is_compress_extension(const unsigned char *s, const char *sub) +{ + return is_extension_exist(s, sub, true, true); +} + int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name, bool hot, bool set) { @@ -148,7 +162,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_temperature_extension(name, extlist[i])) break; f2fs_up_read(&sbi->sb_lock); if (i < (cold_count + hot_count)) @@ -156,12 +170,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_compress_extension(name, noext[i])) return; /* Compress wanting extension. */ for (i = 0; i < ext_cnt; i++) { - if (is_extension_exist(name, ext[i], false)) { + if (is_compress_extension(name, ext[i])) { set_compress_context(inode); return; } @@ -189,7 +203,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_temperature_extension(name, extlist[i])) break; f2fs_up_read(&sbi->sb_lock); -- 2.41.0.162.gfafddb0af9-goog