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>
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 074ee42..db68468 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -383,8 +383,10 @@
}
__ceph_destroy_xattrs(ci);
- ceph_buffer_put(ci->i_xattrs.blob);
- ceph_buffer_put(ci->i_xattrs.prealloc_blob);
+ if (ci->i_xattrs.blob)
+ ceph_buffer_put(ci->i_xattrs.blob);
+ if (ci->i_xattrs.prealloc_blob)
+ ceph_buffer_put(ci->i_xattrs.prealloc_blob);
kmem_cache_free(ceph_inode_cachep, ci);
}
@@ -526,7 +528,7 @@
* bytes are the xattr count).
*/
if (iinfo->xattr_len > 4) {
- xattr_blob = ceph_buffer_new_alloc(iinfo->xattr_len, GFP_NOFS);
+ xattr_blob = ceph_buffer_new(iinfo->xattr_len, GFP_NOFS);
if (!xattr_blob)
pr_err("fill_inode ENOMEM xattr blob %d bytes\n",
iinfo->xattr_len);
@@ -715,7 +717,8 @@
err = 0;
out:
- ceph_buffer_put(xattr_blob);
+ if (xattr_blob)
+ ceph_buffer_put(xattr_blob);
return err;
}