Commit e1ddce71 authored by Anand Jain's avatar Anand Jain Committed by David Sterba

btrfs: reduce arguments for decompress_bio ops

struct compressed_bio pointer can be used instead.
Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 8140dc30
...@@ -42,45 +42,6 @@ ...@@ -42,45 +42,6 @@
#include "extent_io.h" #include "extent_io.h"
#include "extent_map.h" #include "extent_map.h"
struct compressed_bio {
/* number of bios pending for this compressed extent */
refcount_t pending_bios;
/* the pages with the compressed data on them */
struct page **compressed_pages;
/* inode that owns this data */
struct inode *inode;
/* starting offset in the inode for our pages */
u64 start;
/* number of bytes in the inode we're working on */
unsigned long len;
/* number of bytes on disk */
unsigned long compressed_len;
/* the compression algorithm for this bio */
int compress_type;
/* number of compressed pages in the array */
unsigned long nr_pages;
/* IO errors */
int errors;
int mirror_num;
/* for reads, this is the bio we are copying the data into */
struct bio *orig_bio;
/*
* the start of a variable length array of checksums only
* used by reads
*/
u32 sums;
};
static int btrfs_decompress_bio(struct compressed_bio *cb); static int btrfs_decompress_bio(struct compressed_bio *cb);
static inline int compressed_bio_size(struct btrfs_fs_info *fs_info, static inline int compressed_bio_size(struct btrfs_fs_info *fs_info,
...@@ -963,12 +924,9 @@ static int btrfs_decompress_bio(struct compressed_bio *cb) ...@@ -963,12 +924,9 @@ static int btrfs_decompress_bio(struct compressed_bio *cb)
int type = cb->compress_type; int type = cb->compress_type;
workspace = find_workspace(type); workspace = find_workspace(type);
ret = btrfs_compress_op[type - 1]->decompress_bio(workspace, cb);
ret = btrfs_compress_op[type - 1]->decompress_bio(workspace,
cb->compressed_pages, cb->start, cb->orig_bio,
cb->compressed_len);
free_workspace(type, workspace); free_workspace(type, workspace);
return ret; return ret;
} }
......
...@@ -34,6 +34,45 @@ ...@@ -34,6 +34,45 @@
/* Maximum size of data before compression */ /* Maximum size of data before compression */
#define BTRFS_MAX_UNCOMPRESSED (SZ_128K) #define BTRFS_MAX_UNCOMPRESSED (SZ_128K)
struct compressed_bio {
/* number of bios pending for this compressed extent */
refcount_t pending_bios;
/* the pages with the compressed data on them */
struct page **compressed_pages;
/* inode that owns this data */
struct inode *inode;
/* starting offset in the inode for our pages */
u64 start;
/* number of bytes in the inode we're working on */
unsigned long len;
/* number of bytes on disk */
unsigned long compressed_len;
/* the compression algorithm for this bio */
int compress_type;
/* number of compressed pages in the array */
unsigned long nr_pages;
/* IO errors */
int errors;
int mirror_num;
/* for reads, this is the bio we are copying the data into */
struct bio *orig_bio;
/*
* the start of a variable length array of checksums only
* used by reads
*/
u32 sums;
};
void btrfs_init_compress(void); void btrfs_init_compress(void);
void btrfs_exit_compress(void); void btrfs_exit_compress(void);
...@@ -78,10 +117,7 @@ struct btrfs_compress_op { ...@@ -78,10 +117,7 @@ struct btrfs_compress_op {
unsigned long *total_out); unsigned long *total_out);
int (*decompress_bio)(struct list_head *workspace, int (*decompress_bio)(struct list_head *workspace,
struct page **pages_in, struct compressed_bio *cb);
u64 disk_start,
struct bio *orig_bio,
size_t srclen);
int (*decompress)(struct list_head *workspace, int (*decompress)(struct list_head *workspace,
unsigned char *data_in, unsigned char *data_in,
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/bio.h> #include <linux/bio.h>
#include <linux/lzo.h> #include <linux/lzo.h>
#include <linux/refcount.h>
#include "compression.h" #include "compression.h"
#define LZO_LEN 4 #define LZO_LEN 4
...@@ -254,16 +255,13 @@ static int lzo_compress_pages(struct list_head *ws, ...@@ -254,16 +255,13 @@ static int lzo_compress_pages(struct list_head *ws,
return ret; return ret;
} }
static int lzo_decompress_bio(struct list_head *ws, static int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
struct page **pages_in,
u64 disk_start,
struct bio *orig_bio,
size_t srclen)
{ {
struct workspace *workspace = list_entry(ws, struct workspace, list); struct workspace *workspace = list_entry(ws, struct workspace, list);
int ret = 0, ret2; int ret = 0, ret2;
char *data_in; char *data_in;
unsigned long page_in_index = 0; unsigned long page_in_index = 0;
size_t srclen = cb->compressed_len;
unsigned long total_pages_in = DIV_ROUND_UP(srclen, PAGE_SIZE); unsigned long total_pages_in = DIV_ROUND_UP(srclen, PAGE_SIZE);
unsigned long buf_start; unsigned long buf_start;
unsigned long buf_offset = 0; unsigned long buf_offset = 0;
...@@ -278,6 +276,9 @@ static int lzo_decompress_bio(struct list_head *ws, ...@@ -278,6 +276,9 @@ static int lzo_decompress_bio(struct list_head *ws,
unsigned long tot_len; unsigned long tot_len;
char *buf; char *buf;
bool may_late_unmap, need_unmap; bool may_late_unmap, need_unmap;
struct page **pages_in = cb->compressed_pages;
u64 disk_start = cb->start;
struct bio *orig_bio = cb->orig_bio;
data_in = kmap(pages_in[0]); data_in = kmap(pages_in[0]);
tot_len = read_compress_length(data_in); tot_len = read_compress_length(data_in);
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/bio.h> #include <linux/bio.h>
#include <linux/refcount.h>
#include "compression.h" #include "compression.h"
struct workspace { struct workspace {
...@@ -211,10 +212,7 @@ static int zlib_compress_pages(struct list_head *ws, ...@@ -211,10 +212,7 @@ static int zlib_compress_pages(struct list_head *ws,
return ret; return ret;
} }
static int zlib_decompress_bio(struct list_head *ws, struct page **pages_in, static int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
u64 disk_start,
struct bio *orig_bio,
size_t srclen)
{ {
struct workspace *workspace = list_entry(ws, struct workspace, list); struct workspace *workspace = list_entry(ws, struct workspace, list);
int ret = 0, ret2; int ret = 0, ret2;
...@@ -222,8 +220,12 @@ static int zlib_decompress_bio(struct list_head *ws, struct page **pages_in, ...@@ -222,8 +220,12 @@ static int zlib_decompress_bio(struct list_head *ws, struct page **pages_in,
char *data_in; char *data_in;
size_t total_out = 0; size_t total_out = 0;
unsigned long page_in_index = 0; unsigned long page_in_index = 0;
size_t srclen = cb->compressed_len;
unsigned long total_pages_in = DIV_ROUND_UP(srclen, PAGE_SIZE); unsigned long total_pages_in = DIV_ROUND_UP(srclen, PAGE_SIZE);
unsigned long buf_start; unsigned long buf_start;
struct page **pages_in = cb->compressed_pages;
u64 disk_start = cb->start;
struct bio *orig_bio = cb->orig_bio;
data_in = kmap(pages_in[page_in_index]); data_in = kmap(pages_in[page_in_index]);
workspace->strm.next_in = data_in; workspace->strm.next_in = data_in;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment