Skip to contentSkip to conversation

Btrfs: add decompression code for direct I/O.

RFC PATCH New jim owens 1 participant 1 message Jan 8, 2010 Btrfs file system

lore
Share & tools
lore

jim owens

author
#0 lore raw

RFC PATCH 1/1 Btrfs: add decompression code for direct I/O.

Direct I/O needs to inflate compressed temp pages with the uncompressed result stored in not-necessarily-aligned user memory. Add btrfs_zlib_inflate() to do this and expose struct workspace, find_zlib_workspace(), and free_workspace() so that multiple extents can be processed using one workspace.

---
 fs/btrfs/compression.h |   20 +++++++
 fs/btrfs/zlib.c        |  143 +++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 155 insertions(+), 8 deletions(-)
fs/btrfs/compression.h +20 -0
index 421f5b4..afd262d 100644
@@ -19,6 +19,26 @@
 #ifndef __BTRFS_COMPRESSION_
 #define __BTRFS_COMPRESSION_
 
+#include <linux/zlib.h>
+struct workspace {
+	z_stream z_strm;
+	char *buf;
+	struct list_head list;
+};
+
+struct btrfs_inflate {
+	struct workspace *workspace;
+	int (*get_next_in)(struct bio_vec *vec, struct btrfs_inflate *icb);
+	int (*get_next_out)(struct bio_vec *vec, struct btrfs_inflate *icb);
+	void (*done_with_out)(struct bio_vec *vec, struct btrfs_inflate *icb);
+	u32 out_start;
+	u32 out_len;
+};
+
+struct workspace *find_zlib_workspace(void);
+int free_workspace(struct workspace *workspace);
+int btrfs_zlib_inflate(struct btrfs_inflate *icb);
+
 int btrfs_zlib_decompress(unsigned char *data_in,
 			  struct page *dest_page,
 			  unsigned long start_byte,
fs/btrfs/zlib.c +135 -8

170 lines not on this page · raw message

Signature · 1 line
1.5.6.3