diff options
author | Sage Weil <sage@newdream.net> | 2009-12-07 15:17:17 -0500 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-12-07 15:17:17 -0500 |
commit | b6c1d5b81ea0841ae9d3ce2cda319ab986b081cf (patch) | |
tree | c7ddbaa1acdaec0704dfb0c1c539ddaf6e8c7506 /fs/ceph/buffer.h | |
parent | dd26d857a7bf1b5b734a23180c19eac3e46db944 (diff) |
ceph: simplify ceph_buffer interface
We never allocate the ceph_buffer and buffer separtely, so use a single
constructor.
Disallow put on NULL buffer; make the caller check.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/buffer.h')
-rw-r--r-- | fs/ceph/buffer.h | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/fs/ceph/buffer.h b/fs/ceph/buffer.h index 3f541a13094f..47b9514c5bbd 100644 --- a/fs/ceph/buffer.h +++ b/fs/ceph/buffer.h | |||
@@ -20,8 +20,8 @@ struct ceph_buffer { | |||
20 | bool is_vmalloc; | 20 | bool is_vmalloc; |
21 | }; | 21 | }; |
22 | 22 | ||
23 | struct ceph_buffer *ceph_buffer_new(gfp_t gfp); | 23 | extern struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp); |
24 | int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp); | 24 | extern void ceph_buffer_release(struct kref *kref); |
25 | 25 | ||
26 | static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b) | 26 | static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b) |
27 | { | 27 | { |
@@ -29,23 +29,9 @@ static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b) | |||
29 | return b; | 29 | return b; |
30 | } | 30 | } |
31 | 31 | ||
32 | void ceph_buffer_release(struct kref *kref); | ||
33 | |||
34 | static inline void ceph_buffer_put(struct ceph_buffer *b) | 32 | static inline void ceph_buffer_put(struct ceph_buffer *b) |
35 | { | 33 | { |
36 | if (b) | 34 | kref_put(&b->kref, ceph_buffer_release); |
37 | kref_put(&b->kref, ceph_buffer_release); | ||
38 | } | ||
39 | |||
40 | static inline struct ceph_buffer *ceph_buffer_new_alloc(int len, gfp_t gfp) | ||
41 | { | ||
42 | struct ceph_buffer *b = ceph_buffer_new(gfp); | ||
43 | |||
44 | if (b && ceph_buffer_alloc(b, len, gfp) < 0) { | ||
45 | ceph_buffer_put(b); | ||
46 | b = NULL; | ||
47 | } | ||
48 | return b; | ||
49 | } | 35 | } |
50 | 36 | ||
51 | #endif | 37 | #endif |