buffer.h 785 B

12345678910111213141516171819202122232425262728293031323334353637
  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 smaller sizes, vmalloc for larger sizes.
  12. */
  13. struct ceph_buffer {
  14. struct kref kref;
  15. struct kvec vec;
  16. size_t alloc_len;
  17. };
  18. extern struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp);
  19. extern void ceph_buffer_release(struct kref *kref);
  20. static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b)
  21. {
  22. kref_get(&b->kref);
  23. return b;
  24. }
  25. static inline void ceph_buffer_put(struct ceph_buffer *b)
  26. {
  27. kref_put(&b->kref, ceph_buffer_release);
  28. }
  29. extern int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end);
  30. #endif