vfs_ceph: use 'file descriptor' version xattr functions when possible
authorYan, Zheng <zyan@redhat.com>
Thu, 2 Apr 2015 02:11:02 +0000 (10:11 +0800)
committerMichael Adam <obnox@samba.org>
Thu, 2 Apr 2015 12:02:18 +0000 (14:02 +0200)
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@redhat.com>
Reviewed-by: Ira Cooper <ira@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source3/modules/vfs_ceph.c

index b3e334effcbdac199c8f694d1c60d5e70e5f966d..e9f000ccd1654ab4d834bfbc9d687322ec0d990d 100644 (file)
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
 
+#ifndef LIBCEPHFS_VERSION
+#define LIBCEPHFS_VERSION(maj, min, extra) ((maj << 16) + (min << 8) + extra)
+#define LIBCEPHFS_VERSION_CODE LIBCEPHFS_VERSION(0, 0, 0)
+#endif
+
 /*
  * Use %llu whenever we have a 64bit unsigned int, and cast to (long long unsigned)
  */
@@ -1071,7 +1076,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 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 +1121,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 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 +1147,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 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 +1169,12 @@ 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 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);
 }