]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_ceph_new: use low-level APIs for lseek
authorShachar Sharon <ssharon@redhat.com>
Thu, 20 Jun 2024 09:23:03 +0000 (12:23 +0300)
committerGünther Deschner <gd@samba.org>
Mon, 29 Jul 2024 14:51:37 +0000 (14:51 +0000)
Implement lseek operation using libcephfs' low-level APIs. Requires
open ceph Fh* associated with fsp (extension).

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 2c96cc924424bbafac95cff24682fddae8969f0d..fbdfe114939987aa3cfabc9876c742d994924dd2 100644 (file)
@@ -907,6 +907,14 @@ static int vfs_ceph_ll_write(const struct vfs_handle_struct *handle,
        return ceph_ll_write(cmount_of(handle), cfh->fh, off, len, data);
 }
 
+static off_t vfs_ceph_ll_lseek(const struct vfs_handle_struct *handle,
+                              const struct vfs_ceph_fh *cfh,
+                              off_t offset,
+                              int whence)
+{
+       return ceph_ll_lseek(cmount_of(handle), cfh->fh, offset, whence);
+}
+
 /* Ceph Inode-refernce get/put wrappers */
 static int vfs_ceph_iget(const struct vfs_handle_struct *handle,
                         uint64_t ino,
@@ -1475,13 +1483,17 @@ static off_t vfs_ceph_lseek(struct vfs_handle_struct *handle,
                            off_t offset,
                            int whence)
 {
-       off_t result = 0;
+       struct vfs_ceph_fh *cfh = NULL;
+       intmax_t result = 0;
 
        DBG_DEBUG("[CEPH] vfs_ceph_lseek\n");
-       result = ceph_lseek(cmount_of(handle),
-                           fsp_get_io_fd(fsp),
-                           offset,
-                           whence);
+       result = vfs_ceph_fetch_io_fh(handle, fsp, &cfh);
+       if (result != 0) {
+               goto out;
+       }
+
+       result = vfs_ceph_ll_lseek(handle, cfh, offset, whence);
+out:
        return lstatus_code(result);
 }