[PATCH 1/2] vfs_ceph: use 'file descriptor' version xattr functions when possible

Yan, Zheng zyan at redhat.com
Tue Mar 31 07:02:02 MDT 2015


libcephfs version 0.94 adds 'file descriptor' version xattr functions.
This patch makes corresponding samba VFS callbacks use these new
functions.

Signed-off-by: Yan, Zheng <zyan at redhat.com>
---
 source3/modules/vfs_ceph.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index b3e334e..3b165d1 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -1071,7 +1071,11 @@ static ssize_t cephwrap_fgetxattr(struct vfs_handle_struct *handle, struct files
 {
 	int ret;
 	DEBUG(10, ("[CEPH] fgetxattr(%p, %p, %s, %p, %llu)\n", handle, fsp, name, value, llu(size)));
+#if defined(LIBCEPHFS_VERSION) && LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0, 94, 0)
+	ret = ceph_fgetxattr(handle->data, fsp->fh->fd, name, value, size);
+#else
 	ret = ceph_getxattr(handle->data, fsp->fsp_name->base_name, name, value, size);
+#endif
 	DEBUG(10, ("[CEPH] fgetxattr(...) = %d\n", ret));
 	if (ret < 0) {
 		WRAP_RETURN(ret);
@@ -1112,7 +1116,11 @@ static ssize_t cephwrap_flistxattr(struct vfs_handle_struct *handle, struct file
 {
 	int ret;
 	DEBUG(10, ("[CEPH] flistxattr(%p, %p, %s, %llu)\n", handle, fsp, list, llu(size)));
+#if defined(LIBCEPHFS_VERSION) && LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0, 94, 0)
+	ret = ceph_flistxattr(handle->data, fsp->fh->fd, list, size);
+#else
 	ret = ceph_listxattr(handle->data, fsp->fsp_name->base_name, list, size);
+#endif
 	DEBUG(10, ("[CEPH] flistxattr(...) = %d\n", ret));
 	if (ret < 0) {
 		WRAP_RETURN(ret);
@@ -1134,7 +1142,11 @@ static int cephwrap_fremovexattr(struct vfs_handle_struct *handle, struct files_
 {
 	int ret;
 	DEBUG(10, ("[CEPH] fremovexattr(%p, %p, %s)\n", handle, fsp, name));
+#if defined(LIBCEPHFS_VERSION) && LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0, 94, 0)
+	ret = ceph_fremovexattr(handle->data, fsp->fh->fd, name);
+#else
 	ret = ceph_removexattr(handle->data, fsp->fsp_name->base_name, name);
+#endif
 	DEBUG(10, ("[CEPH] fremovexattr(...) = %d\n", ret));
 	WRAP_RETURN(ret);
 }
@@ -1152,7 +1164,11 @@ static int cephwrap_fsetxattr(struct vfs_handle_struct *handle, struct files_str
 {
 	int ret;
 	DEBUG(10, ("[CEPH] fsetxattr(%p, %p, %s, %p, %llu, %d)\n", handle, fsp, name, value, llu(size), flags));
+#if defined(LIBCEPHFS_VERSION) && LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0, 94, 0)
+	ret = ceph_fsetxattr(handle->data, fsp->fh->fd, name, value, size, flags);
+#else
 	ret = ceph_setxattr(handle->data, fsp->fsp_name->base_name, name, value, size, flags);
+#endif
 	DEBUG(10, ("[CEPH] fsetxattr(...) = %d\n", ret));
 	WRAP_RETURN(ret);
 }
-- 
1.9.3



More information about the samba-technical mailing list