Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2269910pxu; Mon, 7 Dec 2020 01:59:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUZ6gYT6E099Z9fkvtdV9pMfxNzlk95FqswAGbw7ckum0UsfCwY02NaZ1Lze4kLaDXCWsR X-Received: by 2002:a50:a694:: with SMTP id e20mr19043309edc.261.1607335177278; Mon, 07 Dec 2020 01:59:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607335177; cv=none; d=google.com; s=arc-20160816; b=qhCt/+3hNfwdxKGULpjjyZgoBZ3PTQRDqqbJnrwMLmEeluVEeyFyyjbPKlO4p4pS0m 4Lux0Vez+8tt5c1ywVbAsURDScl/xG0gIyKRetgPqkb+p/TgnuWG35Nzw3+MeBiIQL3z Ib56iglBzpoDu2IuIeCKUPH/x+J/R+F80WDqSTeLVRzAVcpbnOP1wIv2O0RPxU0jUleB sYLDw42cNqyRMG7bsz8W42lRWOmmB84L4WpxK4htAQ81VmQsfmZwk0g67UUhk3tYTJBg vC4UGDNpw0ul1lAXvhoyt/POcCdzPOQcGiHAPRzfR/OQkYseF2D3tWtG4Css/ru6fHKC mlXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=t+ZKyMXujhNNkmen0YgVccFIcCx2LszsqGBAlsORwEY=; b=hKk+9nlYZlF80vZ0VtcRCld7LhRx1dbPmwv20FxjpUe9QEQucUou/ph7ykUfMxrxFx SCvXeWCsPvo12urpchrP2kJeXwWeLKvzIIqbrGr7vBuGSGCgS70A/o8p1Qppi/5Km5DS /KsGMz5kuBfot2g4BU/lCtc8y8EFegLSbDdwl1iCAuRDtST8RsgDX5twUody163ZJXk0 HHXSF2HbMPW1xI4TEmielAXxaN21zIhA68FOyTZHjwfSxzkmeewUqWPgfw6rimOOAnoh lJYzvAYAbZYKCK4xu6Tv00b1/gim6nWFo0bDBSX7mcVYIwdnxoUH5+VuEmHYIUsAx1Rw dhfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si6066240ejm.641.2020.12.07.01.59.15; Mon, 07 Dec 2020 01:59:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726869AbgLGJ5L (ORCPT + 99 others); Mon, 7 Dec 2020 04:57:11 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:8717 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726023AbgLGJ5L (ORCPT ); Mon, 7 Dec 2020 04:57:11 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CqJbV3t5gzklX5; Mon, 7 Dec 2020 17:55:50 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Mon, 7 Dec 2020 17:56:19 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH RESEND] f2fs: compress: deny setting unsupported compress algorithm Date: Mon, 7 Dec 2020 17:56:09 +0800 Message-ID: <20201207095609.73825-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If kernel doesn't support certain kinds of compress algorithm, deny to set them as compress algorithm of f2fs via 'compress_algorithm=%s' mount option. Signed-off-by: Chao Yu --- no changes, just rebase on dev branch. fs/f2fs/super.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index e0fe72f1d2c8..662e59f32645 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -936,9 +936,14 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) if (!name) return -ENOMEM; if (!strcmp(name, "lzo")) { +#ifdef CONFIG_F2FS_FS_LZO F2FS_OPTION(sbi).compress_algorithm = COMPRESS_LZO; +#else + f2fs_info(sbi, "Image doesn't support lzo compression"); +#endif } else if (!strncmp(name, "lz4", 3)) { +#ifdef CONFIG_F2FS_FS_LZ4 ret = f2fs_compress_set_level(sbi, name, COMPRESS_LZ4); if (ret) { @@ -947,7 +952,11 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) } F2FS_OPTION(sbi).compress_algorithm = COMPRESS_LZ4; +#else + f2fs_info(sbi, "Image doesn't support lz4 compression"); +#endif } else if (!strncmp(name, "zstd", 4)) { +#ifdef CONFIG_F2FS_FS_ZSTD ret = f2fs_compress_set_level(sbi, name, COMPRESS_ZSTD); if (ret) { @@ -956,9 +965,16 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) } F2FS_OPTION(sbi).compress_algorithm = COMPRESS_ZSTD; +#else + f2fs_info(sbi, "Image doesn't support zstd compression"); +#endif } else if (!strcmp(name, "lzo-rle")) { +#ifdef CONFIG_F2FS_FS_LZORLE F2FS_OPTION(sbi).compress_algorithm = COMPRESS_LZORLE; +#else + f2fs_info(sbi, "Image doesn't support lzorle compression"); +#endif } else { kfree(name); return -EINVAL; -- 2.29.2