compression.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (C) 2008 Oracle. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public
  6. * License v2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public
  14. * License along with this program; if not, write to the
  15. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  16. * Boston, MA 021110-1307, USA.
  17. */
  18. #ifndef __BTRFS_COMPRESSION_
  19. #define __BTRFS_COMPRESSION_
  20. void btrfs_init_compress(void);
  21. void btrfs_exit_compress(void);
  22. int btrfs_compress_pages(int type, struct address_space *mapping,
  23. u64 start, unsigned long len,
  24. struct page **pages,
  25. unsigned long nr_dest_pages,
  26. unsigned long *out_pages,
  27. unsigned long *total_in,
  28. unsigned long *total_out,
  29. unsigned long max_out);
  30. int btrfs_decompress(int type, unsigned char *data_in, struct page *dest_page,
  31. unsigned long start_byte, size_t srclen, size_t destlen);
  32. int btrfs_decompress_buf2page(char *buf, unsigned long buf_start,
  33. unsigned long total_out, u64 disk_start,
  34. struct bio_vec *bvec, int vcnt,
  35. unsigned long *pg_index,
  36. unsigned long *pg_offset);
  37. int btrfs_submit_compressed_write(struct inode *inode, u64 start,
  38. unsigned long len, u64 disk_start,
  39. unsigned long compressed_len,
  40. struct page **compressed_pages,
  41. unsigned long nr_pages);
  42. int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
  43. int mirror_num, unsigned long bio_flags);
  44. void btrfs_clear_biovec_end(struct bio_vec *bvec, int vcnt,
  45. unsigned long pg_index,
  46. unsigned long pg_offset);
  47. struct btrfs_compress_op {
  48. struct list_head *(*alloc_workspace)(void);
  49. void (*free_workspace)(struct list_head *workspace);
  50. int (*compress_pages)(struct list_head *workspace,
  51. struct address_space *mapping,
  52. u64 start, unsigned long len,
  53. struct page **pages,
  54. unsigned long nr_dest_pages,
  55. unsigned long *out_pages,
  56. unsigned long *total_in,
  57. unsigned long *total_out,
  58. unsigned long max_out);
  59. int (*decompress_biovec)(struct list_head *workspace,
  60. struct page **pages_in,
  61. u64 disk_start,
  62. struct bio_vec *bvec,
  63. int vcnt,
  64. size_t srclen);
  65. int (*decompress)(struct list_head *workspace,
  66. unsigned char *data_in,
  67. struct page *dest_page,
  68. unsigned long start_byte,
  69. size_t srclen, size_t destlen);
  70. };
  71. extern const struct btrfs_compress_op btrfs_zlib_compress;
  72. extern const struct btrfs_compress_op btrfs_lzo_compress;
  73. #endif