compression.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. int 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_biovec(int type, struct page **pages_in, u64 disk_start,
  31. struct bio_vec *bvec, int vcnt, size_t srclen);
  32. int btrfs_decompress(int type, unsigned char *data_in, struct page *dest_page,
  33. unsigned long start_byte, size_t srclen, size_t destlen);
  34. int btrfs_submit_compressed_write(struct inode *inode, u64 start,
  35. unsigned long len, u64 disk_start,
  36. unsigned long compressed_len,
  37. struct page **compressed_pages,
  38. unsigned long nr_pages);
  39. int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
  40. int mirror_num, unsigned long bio_flags);
  41. struct btrfs_compress_op {
  42. struct list_head *(*alloc_workspace)(void);
  43. void (*free_workspace)(struct list_head *workspace);
  44. int (*compress_pages)(struct list_head *workspace,
  45. struct address_space *mapping,
  46. u64 start, unsigned long len,
  47. struct page **pages,
  48. unsigned long nr_dest_pages,
  49. unsigned long *out_pages,
  50. unsigned long *total_in,
  51. unsigned long *total_out,
  52. unsigned long max_out);
  53. int (*decompress_biovec)(struct list_head *workspace,
  54. struct page **pages_in,
  55. u64 disk_start,
  56. struct bio_vec *bvec,
  57. int vcnt,
  58. size_t srclen);
  59. int (*decompress)(struct list_head *workspace,
  60. unsigned char *data_in,
  61. struct page *dest_page,
  62. unsigned long start_byte,
  63. size_t srclen, size_t destlen);
  64. };
  65. extern struct btrfs_compress_op btrfs_zlib_compress;
  66. extern struct btrfs_compress_op btrfs_lzo_compress;
  67. #endif