summaryrefslogtreecommitdiffstats
path: root/fs/ceph/buffer.c
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2009-12-05 10:13:33 -0800
committerSage Weil <sage@newdream.net>2009-12-07 12:10:04 -0800
commitdd26d857a7bf1b5b734a23180c19eac3e46db944 (patch)
tree24b7ef04c08959df09739056b097ccd157e0251f /fs/ceph/buffer.c
parent2f2ffd35822688a3650e503197b8724f47312748 (diff)
ceph: use kref for ceph_buffer
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/buffer.c')
-rw-r--r--fs/ceph/buffer.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/fs/ceph/buffer.c b/fs/ceph/buffer.c
index cf9aaccef22..847c5da9a0d 100644
--- a/fs/ceph/buffer.c
+++ b/fs/ceph/buffer.c
@@ -9,13 +9,25 @@ struct ceph_buffer *ceph_buffer_new(gfp_t gfp)
b = kmalloc(sizeof(*b), gfp);
if (!b)
return NULL;
- atomic_set(&b->nref, 1);
+ kref_init(&b->kref);
b->vec.iov_base = NULL;
b->vec.iov_len = 0;
b->alloc_len = 0;
return b;
}
+void ceph_buffer_release(struct kref *kref)
+{
+ struct ceph_buffer *b = container_of(kref, struct ceph_buffer, kref);
+ if (b->vec.iov_base) {
+ if (b->is_vmalloc)
+ vfree(b->vec.iov_base);
+ else
+ kfree(b->vec.iov_base);
+ }
+ kfree(b);
+}
+
int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp)
{
b->vec.iov_base = kmalloc(len, gfp | __GFP_NOWARN);