hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/ubifs/compress.c
....@@ -1,21 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * This file is part of UBIFS.
34 *
45 * Copyright (C) 2006-2008 Nokia Corporation.
56 * Copyright (C) 2006, 2007 University of Szeged, Hungary
6
- *
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms of the GNU General Public License version 2 as published by
9
- * the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful, but WITHOUT
12
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
- * more details.
15
- *
16
- * You should have received a copy of the GNU General Public License along with
17
- * this program; if not, write to the Free Software Foundation, Inc., 51
18
- * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
197 *
208 * Authors: Adrian Hunter
219 * Artem Bityutskiy (Битюцкий Артём)
....@@ -68,6 +56,24 @@
6856 static struct ubifs_compressor zlib_compr = {
6957 .compr_type = UBIFS_COMPR_ZLIB,
7058 .name = "zlib",
59
+};
60
+#endif
61
+
62
+#ifdef CONFIG_UBIFS_FS_ZSTD
63
+static DEFINE_MUTEX(zstd_enc_mutex);
64
+static DEFINE_MUTEX(zstd_dec_mutex);
65
+
66
+static struct ubifs_compressor zstd_compr = {
67
+ .compr_type = UBIFS_COMPR_ZSTD,
68
+ .comp_mutex = &zstd_enc_mutex,
69
+ .decomp_mutex = &zstd_dec_mutex,
70
+ .name = "zstd",
71
+ .capi_name = "zstd",
72
+};
73
+#else
74
+static struct ubifs_compressor zstd_compr = {
75
+ .compr_type = UBIFS_COMPR_ZSTD,
76
+ .name = "zstd",
7177 };
7278 #endif
7379
....@@ -228,13 +234,19 @@
228234 if (err)
229235 return err;
230236
231
- err = compr_init(&zlib_compr);
237
+ err = compr_init(&zstd_compr);
232238 if (err)
233239 goto out_lzo;
240
+
241
+ err = compr_init(&zlib_compr);
242
+ if (err)
243
+ goto out_zstd;
234244
235245 ubifs_compressors[UBIFS_COMPR_NONE] = &none_compr;
236246 return 0;
237247
248
+out_zstd:
249
+ compr_exit(&zstd_compr);
238250 out_lzo:
239251 compr_exit(&lzo_compr);
240252 return err;
....@@ -247,4 +259,5 @@
247259 {
248260 compr_exit(&lzo_compr);
249261 compr_exit(&zlib_compr);
262
+ compr_exit(&zstd_compr);
250263 }