mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 07:01:23 +00:00
ceph: use kref for ceph_buffer
Signed-off-by: Sage Weil <sage@newdream.net>
This commit is contained in:
parent
2f2ffd3582
commit
dd26d857a7
2 changed files with 20 additions and 12 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue