buffer.h 818 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef __FS_CEPH_BUFFER_H
  2. #define __FS_CEPH_BUFFER_H
  3. #include <linux/kref.h>
  4. #include <linux/mm.h>
  5. #include <linux/vmalloc.h>
  6. #include <linux/types.h>
  7. #include <linux/uio.h>
  8. /*
  9. * a simple reference counted buffer.
  10. *
  11. * use kmalloc for small sizes (<= one page), vmalloc for larger
  12. * sizes.
  13. */
  14. struct ceph_buffer {
  15. struct kref kref;
  16. struct kvec vec;
  17. size_t alloc_len;
  18. bool is_vmalloc;
  19. };
  20. extern struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp);
  21. extern void ceph_buffer_release(struct kref *kref);
  22. static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b)
  23. {
  24. kref_get(&b->kref);
  25. return b;
  26. }
  27. static inline void ceph_buffer_put(struct ceph_buffer *b)
  28. {
  29. kref_put(&b->kref, ceph_buffer_release);
  30. }
  31. extern int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end);
  32. #endif