Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2894025pxu; Mon, 7 Dec 2020 20:12:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBEBY16dNVoTFD2r4Mtf/8X2o5XLruu1cq1MgmZ32CnD+/goSk6KAdBs7bWY4XEmywRIv1 X-Received: by 2002:a50:fd88:: with SMTP id o8mr23299154edt.386.1607400723675; Mon, 07 Dec 2020 20:12:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607400723; cv=none; d=google.com; s=arc-20160816; b=ADWXZh04LWfXHRS9EsT0ZZqe9NxF9a3hoAnfcC5oGtVGa0ANAW1qe1gcEyl9wbAJiC +mS9xbGdZmPJZF0DrGchhbOxn+zbbR0BaqWAjlKniZu/vauyrW+Yf4hTmaC21zYAYe9j J4INVsc+K91jeVhu1ryVzajBjFdX4MVLqQP2jg8SaO6poFs1hesxiNWo49ki3PETDfZ0 BtUVdndmLTc9PrMtrpIWv3tfoxRcIUBEuR2alURB2NGgMvkSIrUsecBhTmYTrAhTwzv4 NMVugxSF+h1pFHclRz9/CGOVTrYs4j55rwlCDsTNityCHVcYHEok21fk031kB16jklmr 6Sxg== 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=7qQcciNJEQeMmdBuKuQMgk6DLpAOSyCDedfRlbaRQrI=; b=VfILmwqgfnyfW1/1Tmk2piN8yqGOPJp47GC2gD9syy0O2SUV5yReAnXoyGUTD+gYUf KXIOpjvMMmngDJROs7RiSo8tk2J0pFZ3NGirZdPSmmPTngsCoEs+W3U06GzbdKAUJszr MMOW49G8f+ueZAJ5UXTi9QAXEUBDO4Wjjr3jdavRvqbRIU6GEsmSgNGD23IlF/88wI3i o9IYKws3qjGAQUpjznJXPtc58bY0affU8RnVn3vmqt9pTOqOJUVGqMEKytNacRPa8sK8 DVYfkSDsjeylu6w+h7zlbgULffP0Ng4b5HvGDmoh6Pms59S+p+1SABcxpVOGgsh9tFVy OrBw== 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 ce8si788485edb.133.2020.12.07.20.11.41; Mon, 07 Dec 2020 20:12:03 -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 S1727485AbgLHDbg (ORCPT + 99 others); Mon, 7 Dec 2020 22:31:36 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:9127 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725995AbgLHDbg (ORCPT ); Mon, 7 Dec 2020 22:31:36 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Cqm0G69S1z15YPk; Tue, 8 Dec 2020 11:30:22 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Tue, 8 Dec 2020 11:30:46 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH v2] f2fs: compress: deny setting unsupported compress algorithm Date: Tue, 8 Dec 2020 11:30:33 +0800 Message-ID: <20201208033033.64582-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 --- v2: - fix wrong message in log. fs/f2fs/super.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 529ee8ef46c1..bf96f5776f99 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