From: Shachar Sharon Date: Sun, 23 Jun 2024 09:47:19 +0000 (+0300) Subject: vfs_ceph_new: use low-level APIs for renameat X-Git-Tag: tdb-1.4.12~59 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=83011357fb834e92505f17d6f65d5f32e3d37ec0;p=thirdparty%2Fsamba.git vfs_ceph_new: use low-level APIs for renameat Implement renameat operations using libcephfs' low-level APIs. Requires both directories to have valid inode-ref associated with their fsp extension. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15686 Signed-off-by: Shachar Sharon Reviewed-by: Guenther Deschner Reviewed-by: Anoop C S --- diff --git a/source3/modules/vfs_ceph_new.c b/source3/modules/vfs_ceph_new.c index fcce851c5f9..986c66372a4 100644 --- a/source3/modules/vfs_ceph_new.c +++ b/source3/modules/vfs_ceph_new.c @@ -956,6 +956,20 @@ static int vfs_ceph_ll_link(const struct vfs_handle_struct *handle, dircfh->uperm); } +static int vfs_ceph_ll_rename(const struct vfs_handle_struct *handle, + const struct vfs_ceph_fh *parent, + const char *name, + const struct vfs_ceph_fh *newparent, + const char *newname) +{ + return ceph_ll_rename(cmount_of(handle), + parent->iref.inode, + name, + newparent->iref.inode, + newname, + newparent->uperm); +} + /* Ceph Inode-refernce get/put wrappers */ static int vfs_ceph_iget(const struct vfs_handle_struct *handle, uint64_t ino, @@ -1573,8 +1587,8 @@ static int vfs_ceph_renameat(struct vfs_handle_struct *handle, files_struct *dstfsp, const struct smb_filename *smb_fname_dst) { - struct smb_filename *full_fname_src = NULL; - struct smb_filename *full_fname_dst = NULL; + struct vfs_ceph_fh *src_dircfh = NULL; + struct vfs_ceph_fh *dst_dircfh = NULL; int result = -1; DBG_DEBUG("[CEPH] vfs_ceph_renameat\n"); @@ -1583,29 +1597,22 @@ static int vfs_ceph_renameat(struct vfs_handle_struct *handle, return result; } - full_fname_src = full_path_from_dirfsp_atname(talloc_tos(), - srcfsp, - smb_fname_src); - if (full_fname_src == NULL) { - errno = ENOMEM; - return -1; - } - full_fname_dst = full_path_from_dirfsp_atname(talloc_tos(), - dstfsp, - smb_fname_dst); - if (full_fname_dst == NULL) { - TALLOC_FREE(full_fname_src); - errno = ENOMEM; - return -1; + result = vfs_ceph_fetch_fh(handle, srcfsp, &src_dircfh); + if (result != 0) { + goto out; } - result = ceph_rename(cmount_of(handle), - full_fname_src->base_name, - full_fname_dst->base_name); - - TALLOC_FREE(full_fname_src); - TALLOC_FREE(full_fname_dst); + result = vfs_ceph_fetch_fh(handle, dstfsp, &dst_dircfh); + if (result != 0) { + goto out; + } + result = vfs_ceph_ll_rename(handle, + src_dircfh, + smb_fname_src->base_name, + dst_dircfh, + smb_fname_dst->base_name); +out: return status_code(result); }