btrfs: export compression and decompression callbacks
authorDavid Sterba <dsterba@suse.com>
Tue, 1 Oct 2019 20:38:34 +0000 (22:38 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 18 Nov 2019 11:46:56 +0000 (12:46 +0100)
Export compress_pages, decompress_bio and decompress callbacks for all
compression algos. The indirect calls will be replaced by a switch.

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c
fs/btrfs/lzo.c
fs/btrfs/zlib.c
fs/btrfs/zstd.c

index 93deaf0cc2b84d164f9e9797f67c3f028e4f25e6..8611a8b3321a5795668c0409ab5d7a8cf0a7501b 100644 (file)
 #include "extent_io.h"
 #include "extent_map.h"
 
+int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
+               u64 start, struct page **pages, unsigned long *out_pages,
+               unsigned long *total_in, unsigned long *total_out);
+int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
+int zlib_decompress(struct list_head *ws, unsigned char *data_in,
+               struct page *dest_page, unsigned long start_byte, size_t srclen,
+               size_t destlen);
+
+int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
+               u64 start, struct page **pages, unsigned long *out_pages,
+               unsigned long *total_in, unsigned long *total_out);
+int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
+int lzo_decompress(struct list_head *ws, unsigned char *data_in,
+               struct page *dest_page, unsigned long start_byte, size_t srclen,
+               size_t destlen);
+
+int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
+               u64 start, struct page **pages, unsigned long *out_pages,
+               unsigned long *total_in, unsigned long *total_out);
+int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
+int zstd_decompress(struct list_head *ws, unsigned char *data_in,
+               struct page *dest_page, unsigned long start_byte, size_t srclen,
+               size_t destlen);
+
 static const char* const btrfs_compress_types[] = { "", "zlib", "lzo", "zstd" };
 
 const char* btrfs_compress_type2str(enum btrfs_compression_type type)
index acad4174f68d314455bca77b59e200daaa679740..04a6815ea9cb118519a8de90ef3cf6563b4e2ac8 100644 (file)
@@ -131,13 +131,9 @@ static inline size_t read_compress_length(const char *buf)
        return le32_to_cpu(dlen);
 }
 
-static int lzo_compress_pages(struct list_head *ws,
-                             struct address_space *mapping,
-                             u64 start,
-                             struct page **pages,
-                             unsigned long *out_pages,
-                             unsigned long *total_in,
-                             unsigned long *total_out)
+int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
+               u64 start, struct page **pages, unsigned long *out_pages,
+               unsigned long *total_in, unsigned long *total_out)
 {
        struct workspace *workspace = list_entry(ws, struct workspace, list);
        int ret = 0;
@@ -303,7 +299,7 @@ out:
        return ret;
 }
 
-static int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
+int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 {
        struct workspace *workspace = list_entry(ws, struct workspace, list);
        int ret = 0, ret2;
@@ -444,10 +440,9 @@ done:
        return ret;
 }
 
-static int lzo_decompress(struct list_head *ws, unsigned char *data_in,
-                         struct page *dest_page,
-                         unsigned long start_byte,
-                         size_t srclen, size_t destlen)
+int lzo_decompress(struct list_head *ws, unsigned char *data_in,
+               struct page *dest_page, unsigned long start_byte, size_t srclen,
+               size_t destlen)
 {
        struct workspace *workspace = list_entry(ws, struct workspace, list);
        size_t in_len;
index df1aace5df5010969b9fb001a68444d46680cbe3..4091f94ba378cfc98a989c5309f63d7d3e55a8bd 100644 (file)
@@ -88,13 +88,9 @@ fail:
        return ERR_PTR(-ENOMEM);
 }
 
-static int zlib_compress_pages(struct list_head *ws,
-                              struct address_space *mapping,
-                              u64 start,
-                              struct page **pages,
-                              unsigned long *out_pages,
-                              unsigned long *total_in,
-                              unsigned long *total_out)
+int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
+               u64 start, struct page **pages, unsigned long *out_pages,
+               unsigned long *total_in, unsigned long *total_out)
 {
        struct workspace *workspace = list_entry(ws, struct workspace, list);
        int ret;
@@ -228,7 +224,7 @@ out:
        return ret;
 }
 
-static int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
+int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 {
        struct workspace *workspace = list_entry(ws, struct workspace, list);
        int ret = 0, ret2;
@@ -319,10 +315,9 @@ done:
        return ret;
 }
 
-static int zlib_decompress(struct list_head *ws, unsigned char *data_in,
-                          struct page *dest_page,
-                          unsigned long start_byte,
-                          size_t srclen, size_t destlen)
+int zlib_decompress(struct list_head *ws, unsigned char *data_in,
+               struct page *dest_page, unsigned long start_byte, size_t srclen,
+               size_t destlen)
 {
        struct workspace *workspace = list_entry(ws, struct workspace, list);
        int ret = 0;
index 764d47b107e569e35be29665c04869a66971b96b..b3728220c3295859536030040908801a8c13ff73 100644 (file)
@@ -367,13 +367,9 @@ fail:
        return ERR_PTR(-ENOMEM);
 }
 
-static int zstd_compress_pages(struct list_head *ws,
-               struct address_space *mapping,
-               u64 start,
-               struct page **pages,
-               unsigned long *out_pages,
-               unsigned long *total_in,
-               unsigned long *total_out)
+int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
+               u64 start, struct page **pages, unsigned long *out_pages,
+               unsigned long *total_in, unsigned long *total_out)
 {
        struct workspace *workspace = list_entry(ws, struct workspace, list);
        ZSTD_CStream *stream;
@@ -548,7 +544,7 @@ out:
        return ret;
 }
 
-static int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
+int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 {
        struct workspace *workspace = list_entry(ws, struct workspace, list);
        struct page **pages_in = cb->compressed_pages;
@@ -626,10 +622,9 @@ done:
        return ret;
 }
 
-static int zstd_decompress(struct list_head *ws, unsigned char *data_in,
-               struct page *dest_page,
-               unsigned long start_byte,
-               size_t srclen, size_t destlen)
+int zstd_decompress(struct list_head *ws, unsigned char *data_in,
+               struct page *dest_page, unsigned long start_byte, size_t srclen,
+               size_t destlen)
 {
        struct workspace *workspace = list_entry(ws, struct workspace, list);
        ZSTD_DStream *stream;