Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3790971pxu; Wed, 9 Dec 2020 00:04:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJws20IvRVg7DC1Sqnfy5lt3VyUA5DQUDtJKpdUnu1vmPEd4+tTBvJyKWmtXMil4I8J1fuB4 X-Received: by 2002:a17:906:6010:: with SMTP id o16mr1047330ejj.55.1607501050091; Wed, 09 Dec 2020 00:04:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607501050; cv=none; d=google.com; s=arc-20160816; b=rH+AOV8OSAAzVM2+8Ufp/9IkbWGQIBSJ6MUPKCIX17OBjOfKmE3QwS4PM6RN3yZN0b Mbhf0feB6MIFs9ZJV1fLvrxfNQtSazTdYeK3WqQ895QNFs2Z1EPn/2/whbUVZ66tdEWB 68YxItCHGx7mDPTy0WAa/qDK9bl9wggIvF8F4N1qTh1jFsA3ScNLAsBpcqwU0gix9W+/ DCGh17OJcsuu7nFJuQjsuaRt5g/DXBfJfgrHEvH5bABD8GlYGSU/T6AK2TBRjAX5C66R CQA4ulFxnxPJddElIYEvsIBNVdlHuy6Ur2JwRnxuTsx74wBvlIseu3L1migo1rxmOomg dIPA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=MbqYEnSIIySQYFTig2D7YXPDFe3rLebmdHXiSAdEZx4=; b=qxxBpGrzZseA/I+BPB/KExv5HDklt1YJKP+BSsH67R51leErTCN8j4xCQey/dW+KKl mfqJ2l/5HVg0xYSXdDjlGxwTr2iLMR4unurHKvzM7GTpohcFXbdPralYUahNLTSRZM4K 5te69eQbNVjbnlLDYEvxFFXsBdF8A5LFJg/+DDXUt+LdAjda6rohrbgr3apXvp/TMhPP fl0I1L0iOg3wHIfCbQBecvr4ZxVBqdfkCGEYD8W2Awc2kMGEKFYLnh/mdDetVy92X0s9 tdpUHZ8mVAxM4/aZT6sQq3Qd1ZkzOER3KXoY1XsS736/Ym/NbQMeA1ZgELSFGy6avPs0 UdqQ== 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 h26si371791ejq.399.2020.12.09.00.03.26; Wed, 09 Dec 2020 00:04:10 -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 S1728026AbgLIG0T (ORCPT + 99 others); Wed, 9 Dec 2020 01:26:19 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:9400 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727629AbgLIG0P (ORCPT ); Wed, 9 Dec 2020 01:26:15 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CrRq84pStz7Bhp; Wed, 9 Dec 2020 14:24:52 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Wed, 9 Dec 2020 14:25:16 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH RESEND 4/6] f2fs: compress: deny setting unsupported compress algorithm Date: Wed, 9 Dec 2020 14:24:55 +0800 Message-ID: <20201209062457.111907-4-yuchao0@huawei.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201209062457.111907-1-yuchao0@huawei.com> References: <20201209062457.111907-1-yuchao0@huawei.com> 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 --- fs/f2fs/super.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 8637196dec7c..d128b5cb763d 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, "kernel 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, "kernel 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, "kernel 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, "kernel doesn't support lzorle compression"); +#endif } else { kfree(name); return -EINVAL; -- 2.29.2