[PATCH 1/2] vfs_ceph: refactor usage of ceph_f{get, get, remove, list}xattr()
Yan, Zheng
zyan at redhat.com
Tue Feb 16 06:56:38 UTC 2016
move ceph_f{get,get,remove,list}xattr() related code into helper
functions. This is preparation for later ACL patch.
Signed-off-by: Yan, Zheng <zyan at redhat.com>
---
source3/modules/vfs_ceph.c | 74 ++++++++++++++++++++++++++++++++--------------
1 file changed, 52 insertions(+), 22 deletions(-)
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index d51499d..bbf7f32 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -1043,7 +1043,54 @@ static const char *cephwrap_connectpath(struct vfs_handle_struct *handle,
Extended attribute operations.
*****************************************************************/
-static ssize_t cephwrap_getxattr(struct vfs_handle_struct *handle,const char *path, const char *name, void *value, size_t size)
+static int __ceph_fgetxattr(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ const char *name, void *value, size_t size)
+{
+#if LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0,94,0)
+ return ceph_fgetxattr(handle->data, fsp->fh->fd, name, value, size);
+#else
+ return ceph_getxattr(handle->data, fsp->fsp_name->base_name,
+ name, value, size);
+#endif
+}
+
+static int __ceph_fsetxattr(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ const char *name, const void *value, size_t size,
+ int flags)
+{
+#if LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0,94,0)
+ return ceph_fsetxattr(handle->data, fsp->fh->fd, name, value, size,
+ flags);
+#else
+ return ceph_setxattr(handle->data, fsp->fsp_name->base_name,
+ name, value, size, flags);
+#endif
+}
+
+static int __ceph_fremovexattr(struct vfs_handle_struct *handle,
+ struct files_struct *fsp, const char *name)
+{
+#if LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0,94,0)
+ return ceph_fremovexattr(handle->data, fsp->fh->fd, name);
+#else
+ return ceph_removexattr(handle->data, fsp->fsp_name->base_name, name);
+#endif
+}
+
+static int __ceph_flistxattr(struct vfs_handle_struct *handle,
+ struct files_struct *fsp, char *list, size_t size)
+{
+#if LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0,94,0)
+ return ceph_flistxattr(handle->data, fsp->fh->fd, list, size);
+#else
+ return ceph_listxattr(handle->data, fsp->fsp_name->base_name,
+ list, size);
+#endif
+}
+
+static ssize_t cephwrap_getxattr(struct vfs_handle_struct *handle, const char *path, const char *name, void *value, size_t size)
{
int ret;
DEBUG(10, ("[CEPH] getxattr(%p, %s, %s, %p, %llu)\n", handle, path, name, value, llu(size)));
@@ -1060,11 +1107,7 @@ 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
+ ret = __ceph_fgetxattr(handle, fsp, name, value, size);
DEBUG(10, ("[CEPH] fgetxattr(...) = %d\n", ret));
if (ret < 0) {
WRAP_RETURN(ret);
@@ -1105,11 +1148,7 @@ 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
+ ret = __ceph_flistxattr(handle, fsp, list, size);
DEBUG(10, ("[CEPH] flistxattr(...) = %d\n", ret));
if (ret < 0) {
WRAP_RETURN(ret);
@@ -1131,11 +1170,7 @@ 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
+ ret = __ceph_fremovexattr(handle, fsp, name);
DEBUG(10, ("[CEPH] fremovexattr(...) = %d\n", ret));
WRAP_RETURN(ret);
}
@@ -1153,12 +1188,7 @@ 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
+ ret = __ceph_fsetxattr(handle, fsp, name, value, size, flags);
DEBUG(10, ("[CEPH] fsetxattr(...) = %d\n", ret));
WRAP_RETURN(ret);
}
--
2.5.0
More information about the samba-technical
mailing list