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

Ira Cooper ira at samba.org
Thu Apr 2 05:19:31 MDT 2015


Reviewed-by: Ira Cooper <ira at samba.org>

On Thu, Apr 02, 2015 at 10:11:02AM +0800, Yan, Zheng wrote:
> 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 | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
> index b3e334e..e9f000c 100644
> --- a/source3/modules/vfs_ceph.c
> +++ b/source3/modules/vfs_ceph.c
> @@ -40,6 +40,11 @@
>  #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);
>  }
> -- 
> 1.9.3
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20150402/60901d7d/attachment.pgp>


More information about the samba-technical mailing list