]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_ceph_new: use low-level APIs for fsync
authorShachar Sharon <ssharon@redhat.com>
Thu, 20 Jun 2024 09:43:39 +0000 (12:43 +0300)
committerGünther Deschner <gd@samba.org>
Mon, 29 Jul 2024 14:51:37 +0000 (14:51 +0000)
Implement fsync 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 fbdfe114939987aa3cfabc9876c742d994924dd2..68e514599ab6fbc49da381765ad414d4f5ee0ae0 100644 (file)
@@ -915,6 +915,13 @@ static off_t vfs_ceph_ll_lseek(const struct vfs_handle_struct *handle,
        return ceph_ll_lseek(cmount_of(handle), cfh->fh, offset, whence);
 }
 
+static int vfs_ceph_ll_fsync(const struct vfs_handle_struct *handle,
+                            const struct vfs_ceph_fh *cfh,
+                            int syncdataonly)
+{
+       return ceph_ll_fsync(cmount_of(handle), cfh->fh, syncdataonly);
+}
+
 /* Ceph Inode-refernce get/put wrappers */
 static int vfs_ceph_iget(const struct vfs_handle_struct *handle,
                         uint64_t ino,
@@ -1577,6 +1584,7 @@ static struct tevent_req *vfs_ceph_fsync_send(struct vfs_handle_struct *handle,
                                        struct tevent_context *ev,
                                        files_struct *fsp)
 {
+       struct vfs_ceph_fh *cfh = NULL;
        struct tevent_req *req = NULL;
        struct vfs_aio_state *state = NULL;
        int ret = -1;
@@ -1588,9 +1596,14 @@ static struct tevent_req *vfs_ceph_fsync_send(struct vfs_handle_struct *handle,
                return NULL;
        }
 
-       /* Make sync call. */
-       ret = ceph_fsync(cmount_of(handle), fsp_get_io_fd(fsp), false);
+       ret = vfs_ceph_fetch_io_fh(handle, fsp, &cfh);
+       if (ret != 0) {
+               tevent_req_error(req, -ret);
+               return tevent_req_post(req, ev);
+       }
 
+       /* Make sync call. */
+       ret = vfs_ceph_ll_fsync(handle, cfh, false);
        if (ret != 0) {
                /* ceph_fsync returns -errno on error. */
                tevent_req_error(req, -ret);