From patchwork Mon Jun 12 20:16:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13277266 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 500ABC7EE2E for ; Mon, 12 Jun 2023 20:16:43 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1q8nxy-0000ar-RL; Mon, 12 Jun 2023 20:16:42 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q8nxu-0000aY-OS for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 20:16:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ug1VxCEmHAqGISqkhoUB4D6Ip4k3KyuFNIlhKVmS6bk=; b=hcDt9PsCv2wH8nLAmoNX1z19nK wCp79vpumcFksGKfOJG4FHP3+jW2Lh+WZ6wEguZ4uJFiwDwYgrBWL0LZkG+rpdi+79oErZ1G0j2Lx HicKPhHvQ3ifBN39r0PMVGHUz8PgN1Udc+WcYFJ4i3/McgTxc7DR5RaN5hRMMxQ4wrWo=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=ug1VxCEmHAqGISqkhoUB4D6Ip4k3KyuFNIlhKVmS6bk=; b=N PcJNG3wb+NoUwSTIZcnuKYs0quK+HqDhWLJ+lfZLmObkAkE1hOJnv7joYVM1srF429RhAUXAxfJdb jAA4TDh63h2j++7j0KbI+vfSINHq56Lk/nGoLQJzu1qmVD6cWSPVzsqBFhTKIllvw/qIW8R5DFrHS kHztdYI4lPQJfOno=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1q8nxs-0012Ba-Tf for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 20:16:38 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B188D62946 for ; Mon, 12 Jun 2023 20:16:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15A04C433EF; Mon, 12 Jun 2023 20:16:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686600990; bh=IFNcl3Qr1j61HWEFzbLwNkndMDHFIaUy4E04xrmndB0=; h=From:To:Cc:Subject:Date:From; b=IsYOGsxQ+G+xE05S99c1FUqdnyA5A0r8/EhbCRuw0sMxfM3FubILmfAFyp76cq/P7 zptzsxHFMYtBoVTdMsHEzTlfx5nOMGpzYDZcOMVuSxFFO5qlaafRO4cvD+Ur51UHCo LMWALzfw00GkhIrmQLLs1p5fPwVgIX3+bTK4aDMtLrHrv6YubXRfuZkdHHVs8cqYhn mkyexby7SIRqonCAREHNet3KtO304KOyHvkgKcEFngMWEDGSqFTiwpwM/91mFPhBOw Zsf9bKzZE5+ui8xZwBp3TqLbUgLiilTi+xgKwcO6Q/WXX98y57cbfJB49ar+ASFgGf WCFL45smMkm8g== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Mon, 12 Jun 2023 13:16:26 -0700 Message-ID: <20230612201626.3768393-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog MIME-Version: 1.0 X-Headers-End: 1q8nxs-0012Ba-Tf Subject: [f2fs-dev] [PATCH] f2fs: assign default compression level X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Let's avoid any confusion from assigning compress_level=0 for LZ4HC and ZSTD. Signed-off-by: Jaegeuk Kim --- fs/f2fs/compress.c | 3 +-- fs/f2fs/f2fs.h | 2 ++ fs/f2fs/super.c | 12 +++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index 1132d3cd8f33..438af59d3571 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -317,8 +317,6 @@ static const struct f2fs_compress_ops f2fs_lz4_ops = { #endif #ifdef CONFIG_F2FS_FS_ZSTD -#define F2FS_ZSTD_DEFAULT_CLEVEL 1 - static int zstd_init_compress_ctx(struct compress_ctx *cc) { zstd_parameters params; @@ -327,6 +325,7 @@ static int zstd_init_compress_ctx(struct compress_ctx *cc) unsigned int workspace_size; unsigned char level = F2FS_I(cc->inode)->i_compress_level; + /* Need to remain this for backward compatibility */ if (!level) level = F2FS_ZSTD_DEFAULT_CLEVEL; diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 4b249716ae7b..c61f728e1116 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1440,6 +1440,8 @@ struct compress_data { #define F2FS_COMPRESSED_PAGE_MAGIC 0xF5F2C000 +#define F2FS_ZSTD_DEFAULT_CLEVEL 1 + #define COMPRESS_LEVEL_OFFSET 8 /* compress context */ diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 8fd23caa1ed9..7162e55c4eb4 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -589,14 +589,12 @@ static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str) { #ifdef CONFIG_F2FS_FS_LZ4HC unsigned int level; -#endif if (strlen(str) == 3) { - F2FS_OPTION(sbi).compress_level = 0; + F2FS_OPTION(sbi).compress_level = LZ4HC_DEFAULT_CLEVEL; return 0; } -#ifdef CONFIG_F2FS_FS_LZ4HC str += 3; if (str[0] != ':') { @@ -614,6 +612,10 @@ static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str) F2FS_OPTION(sbi).compress_level = level; return 0; #else + if (strlen(str) == 3) { + F2FS_OPTION(sbi).compress_level = 0; + return 0; + } f2fs_info(sbi, "kernel doesn't support lz4hc compression"); return -EINVAL; #endif @@ -627,7 +629,7 @@ static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str) int len = 4; if (strlen(str) == len) { - F2FS_OPTION(sbi).compress_level = 0; + F2FS_OPTION(sbi).compress_level = F2FS_ZSTD_DEFAULT_CLEVEL; return 0; } @@ -640,7 +642,7 @@ static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str) if (kstrtouint(str + 1, 10, &level)) return -EINVAL; - if (!level || level > zstd_max_clevel()) { + if (level < zstd_min_clevel() || level > zstd_max_clevel()) { f2fs_info(sbi, "invalid zstd compress level: %d", level); return -EINVAL; }