summaryrefslogtreecommitdiff
path: root/fs/btrfs/compression.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2017-10-31 19:24:26 +0300
committerDavid Sterba <dsterba@suse.com>2018-01-22 18:08:16 +0300
commite128f9c3f7242318e1c76d204c7ae32bc878b8c7 (patch)
treef481867c52ea0a6889aead29b254782b23f5e055 /fs/btrfs/compression.c
parentbf8d32b9b3c5fb183aa4ac5cb7bae9580dcb0dfb (diff)
downloadlinux-e128f9c3f7242318e1c76d204c7ae32bc878b8c7.tar.xz
btrfs: compression: add helper for type to string conversion
There are several places opencoding this conversion, add a helper now that we have 3 compression algorithms. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/compression.c')
-rw-r--r--fs/btrfs/compression.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 8cd48d7c3f76..28c3940062b7 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -44,6 +44,21 @@
#include "extent_io.h"
#include "extent_map.h"
+static const char* const btrfs_compress_types[] = { "", "zlib", "lzo", "zstd" };
+
+const char* btrfs_compress_type2str(enum btrfs_compression_type type)
+{
+ switch (type) {
+ case BTRFS_COMPRESS_ZLIB:
+ case BTRFS_COMPRESS_LZO:
+ case BTRFS_COMPRESS_ZSTD:
+ case BTRFS_COMPRESS_NONE:
+ return btrfs_compress_types[type];
+ }
+
+ return NULL;
+}
+
static int btrfs_decompress_bio(struct compressed_bio *cb);
static inline int compressed_bio_size(struct btrfs_fs_info *fs_info,