compression.h 2.8 KB

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