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