]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_ceph_new: use low-level APIs for fdopendir
authorShachar Sharon <ssharon@redhat.com>
Tue, 18 Jun 2024 14:20:59 +0000 (17:20 +0300)
committerGünther Deschner <gd@samba.org>
Mon, 29 Jul 2024 14:51:37 +0000 (14:51 +0000)
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 <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/modules/vfs_ceph_new.c

index 8d3fad5ff29c3226f5fc8fc49f59f1c339dbc231..30b9ef2248d5c4e60ab1d811041111e09fea0403 100644 (file)
@@ -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;
 }