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