From: Shachar Sharon Date: Tue, 18 Jun 2024 14:20:59 +0000 (+0300) Subject: vfs_ceph_new: use low-level APIs for fdopendir X-Git-Tag: tdb-1.4.12~72 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a8a7339c6b7a6866399fd6c409228267a585740f;p=thirdparty%2Fsamba.git vfs_ceph_new: use low-level APIs for fdopendir Implement fdopendir using libcephfs low-level API and cached (via fsp) open file-handle. Embed the result within cached vfs_ceph_fh so it may be used properly by closedir. 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 8d3fad5ff29..30b9ef2248d 100644 --- a/source3/modules/vfs_ceph_new.c +++ b/source3/modules/vfs_ceph_new.c @@ -711,6 +711,15 @@ static int vfs_ceph_ll_open(const struct vfs_handle_struct *handle, return ret; } +static int vfs_ceph_ll_opendir(const struct vfs_handle_struct *handle, + struct vfs_ceph_fh *cfh) +{ + return ceph_ll_opendir(cmount_of(handle), + cfh->iref.inode, + &cfh->dirp.cdr, + cfh->uperm); +} + /* Ceph Inode-refernce get/put wrappers */ static int vfs_ceph_iget(const struct vfs_handle_struct *handle, uint64_t ino, @@ -908,24 +917,25 @@ static DIR *vfs_ceph_fdopendir(struct vfs_handle_struct *handle, uint32_t attributes) { int ret = 0; - struct ceph_dir_result *result = NULL; + void *result = NULL; + struct vfs_ceph_fh *cfh = NULL; -#ifdef HAVE_CEPH_FDOPENDIR - int dirfd = fsp_get_io_fd(fsp); - DBG_DEBUG("[CEPH] fdopendir(%p, %d)\n", handle, dirfd); - ret = ceph_fdopendir(cmount_of(handle), dirfd, &result); -#else DBG_DEBUG("[CEPH] fdopendir(%p, %p)\n", handle, fsp); - ret = ceph_opendir(cmount_of(handle), - fsp->fsp_name->base_name, - &result); -#endif - if (ret < 0) { - result = NULL; - errno = -ret; /* We return result which is NULL in this case */ + ret = vfs_ceph_fetch_fh(handle, fsp, &cfh); + if (ret != 0) { + goto out; } + ret = vfs_ceph_ll_opendir(handle, cfh); + if (ret != 0) { + goto out; + } + result = &cfh->dirp; +out: DBG_DEBUG("[CEPH] fdopendir(...) = %d\n", ret); + if (ret != 0) { + errno = -ret; + } return (DIR *)result; }