Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3811645pxu; Wed, 9 Dec 2020 00:48:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOo3tE63jElcKml2tjYvfFqTPaTHm6OXnztuwnKp/ZJvrKSIAAECMQnXdcdgehF3kvBVRb X-Received: by 2002:a17:906:b74b:: with SMTP id fx11mr1168565ejb.410.1607503708624; Wed, 09 Dec 2020 00:48:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607503708; cv=none; d=google.com; s=arc-20160816; b=Jk5FBhxOAqrgf7EfFPPwL7djDTCeq/q7h8wD+y7CYdQn6FtadbX3oQaGyAOuJu1PH/ nHpb552ULC7qoDxkypm5uEuK8cCC6hAthNTOI/ggR57gBXdcp1Q0VIoYR7b74GBb9uTP VIsuF0nspzfHz/c3aJITVufgVywXi1UjYpGioPKXajoYU7y+o9vRsk40uYjdNusF1+H5 R8blyW8vtI+xt8qddFxd4R4ilwpWLBLSU6kANpSsczJQKUFJQ/RdqZOhbl4vbJBg+pVU gOjXbq/CYH8RgmD87/4e99hSaU5wM9boWuhzrWqZLMohYe9WKmsyXtrlaFQvRPOkXkE2 ToiA== 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=RGvXrE8BrACGIvb26r90e+sh2ME9Tisq2RPdl1WBt08=; b=qFyRn75y7zcadlHVOox6KAeX5jSVypiRhAQ3W+hkzKis0BGNZYXiM+ZN9hK6mM8X1K zMaz8ydHSAGeeQ9JukwboNwAzE2z+ozzqwfSnrCz5LtV/bqBEa0U7z5TdD7nkxkNy23C pYGKbHQRn+qwKaWBaVtSehyn+vT1xSdQoni/p/iETUozvXgcEDn9iXIO4vEc+gnT9VVA BLRbcypis+CKTsb7ZFPAu+bw3pmvPG7RU3YTVCN+WGLuZ9eVBhMieqO309ZFeJ2RPC5H Agl2BZE2BBz4ns1sRG0/lrD9aKWSxXOxRKavSATG9HPHsS6lX8rEXrCCFVycZ+l7NfTe maPQ== 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 u9si490577edr.63.2020.12.09.00.48.06; Wed, 09 Dec 2020 00:48:28 -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 S1727156AbgLIIot (ORCPT + 99 others); Wed, 9 Dec 2020 03:44:49 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:8729 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727964AbgLIIol (ORCPT ); Wed, 9 Dec 2020 03:44:41 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CrVtr1kDLzkmFM; Wed, 9 Dec 2020 16:43:16 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Wed, 9 Dec 2020 16:43:46 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH RESEND v2 3/5] f2fs: compress: deny setting unsupported compress algorithm Date: Wed, 9 Dec 2020 16:43:26 +0800 Message-ID: <20201209084328.30416-3-yuchao0@huawei.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201209084328.30416-1-yuchao0@huawei.com> References: <20201209084328.30416-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 7c5c880a97be..fe077ef88768 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