btrfs: define compression levels statically
authorDavid Sterba <dsterba@suse.com>
Fri, 9 Aug 2019 14:25:34 +0000 (16:25 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 9 Sep 2019 12:59:11 +0000 (14:59 +0200)
The maximum and default levels do not change and can be defined
directly. The set_level callback was a temporary solution and will be
removed.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.h
fs/btrfs/lzo.c
fs/btrfs/zlib.c
fs/btrfs/zstd.c

index 2035b8eb12904c95cd35792ae54b668069de0a48..cffd689adb6e7fd374bb5b6d232f10f7d67e5e7d 100644 (file)
@@ -162,6 +162,10 @@ struct btrfs_compress_op {
         * if the level is out of bounds or the default if 0 is passed in.
         */
        unsigned int (*set_level)(unsigned int level);
+
+       /* Maximum level supported by the compression algorithm */
+       unsigned int max_level;
+       unsigned int default_level;
 };
 
 /* The heuristic workspaces are managed via the 0th workspace manager */
index 579d53ae256f3e63396d415f7efa8f976b7f5229..adac6cb30d65c4c46852ec9085df85962363aacd 100644 (file)
@@ -523,4 +523,6 @@ const struct btrfs_compress_op btrfs_lzo_compress = {
        .decompress_bio         = lzo_decompress_bio,
        .decompress             = lzo_decompress,
        .set_level              = lzo_set_level,
+       .max_level              = 1,
+       .default_level          = 1,
 };
index b86b7ad6b900a6d2785eb77283cf148cc3d3258f..03d6c3683bd99780ba138dae3fb058c81cacb449 100644 (file)
@@ -437,4 +437,6 @@ const struct btrfs_compress_op btrfs_zlib_compress = {
        .decompress_bio         = zlib_decompress_bio,
        .decompress             = zlib_decompress,
        .set_level              = zlib_set_level,
+       .max_level              = 9,
+       .default_level          = BTRFS_ZLIB_DEFAULT_LEVEL,
 };
index 3837ca180d52d67ec1c59459ed3a5c0e0b40d378..b2b23a6a497d8c29f3ee2bd0d9d0a94ef06b5b11 100644 (file)
@@ -729,4 +729,6 @@ const struct btrfs_compress_op btrfs_zstd_compress = {
        .decompress_bio = zstd_decompress_bio,
        .decompress = zstd_decompress,
        .set_level = zstd_set_level,
+       .max_level      = ZSTD_BTRFS_MAX_LEVEL,
+       .default_level  = ZSTD_BTRFS_DEFAULT_LEVEL,
 };