Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame^] | 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 | |
| 25 | static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b) |
| 26 | { |
| 27 | kref_get(&b->kref); |
| 28 | return b; |
| 29 | } |
| 30 | |
| 31 | static inline void ceph_buffer_put(struct ceph_buffer *b) |
| 32 | { |
| 33 | kref_put(&b->kref, ceph_buffer_release); |
| 34 | } |
| 35 | |
| 36 | extern int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end); |
| 37 | |
| 38 | #endif |