]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs/client: asynchronous fsync interface
authorVenky Shankar <vshankar@redhat.com>
Mon, 2 Jun 2025 05:03:50 +0000 (05:03 +0000)
committerVenky Shankar <vshankar@redhat.com>
Tue, 9 Sep 2025 04:37:48 +0000 (04:37 +0000)
Mostly for writing test for hunting [0].

[0]: https://tracker.ceph.com/issues/71510

Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/client/Client.cc
src/client/Client.h
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index 0038ae63a5aaadac9b8d1e25f77af04e554fc185..5e38ae702ec01cdbc881dc05d16ed14ccb5d78eb 100644 (file)
@@ -12314,12 +12314,16 @@ void Client::C_nonblocking_fsync_state_advancer::finish(int r)
   state->advance();
 }
 
-void Client::nonblocking_fsync(Inode *in, bool syncdataonly, Context *onfinish)
+int64_t Client::nonblocking_fsync(Inode *in, bool syncdataonly, Context *onfinish)
 {
   C_nonblocking_fsync_state *state = new C_nonblocking_fsync_state(this, in, syncdataonly, onfinish);
 
+  ldout(cct, 10) << __func__ << dendl;
+
+  std::unique_lock cl(client_lock);
   // Kick fsync off...
   state->advance();
+  return 0;
 }
 
 int Client::_fsync(Inode *in, bool syncdataonly)
index 59b3d797e96174e677404abcda447b78b2cc4493..49477ac1cb0a513ae412916e9f89f49553481a0f 100644 (file)
@@ -685,6 +685,7 @@ public:
                             Context *onfinish = nullptr,
                             bufferlist *blp = nullptr,
                             bool do_fsync = false, bool syncdataonly = false);
+  int64_t nonblocking_fsync(Inode *in, bool syncdataonly, Context *onfinish);
   loff_t ll_lseek(Fh *fh, loff_t offset, int whence);
   int ll_flush(Fh *fh);
   int ll_fsync(Fh *fh, bool syncdataonly);
@@ -1775,7 +1776,7 @@ private:
                       int64_t offset, bool write, Context *onfinish = nullptr,
                       bufferlist *blp = nullptr);
   int _flush(Fh *fh);
-  void nonblocking_fsync(Inode *in, bool syncdataonly, Context *onfinish);
+
   int _fsync(Fh *fh, bool syncdataonly);
   int _fsync(Inode *in, bool syncdataonly);
   int _sync_fs();
index 485b51a2ac15a65fdd9b7ff2607ca51163914884..774e0348c1dd1585b31bb6c3417cf1b9f33c3c0a 100644 (file)
@@ -2052,6 +2052,8 @@ int64_t ceph_ll_writev(struct ceph_mount_info *cmount, struct Fh *fh,
                       const struct iovec *iov, int iovcnt, int64_t off);
 int64_t ceph_ll_nonblocking_readv_writev(struct ceph_mount_info *cmount,
                                         struct ceph_ll_io_info *io_info);
+int64_t ceph_ll_nonblocking_fsync(struct ceph_mount_info *cmount,
+                                 Inode *in, struct ceph_ll_io_info *io_info);
 int ceph_ll_close(struct ceph_mount_info *cmount, struct Fh* filehandle);
 int ceph_ll_iclose(struct ceph_mount_info *cmount, struct Inode *in, int mode);
 /**
index 7237571339338218468c4d9921026bd54e00a63d..ebc66f1242e4e8124186bded03eddddd0b702e92 100644 (file)
@@ -2217,6 +2217,15 @@ private:
   }
 };
 
+extern "C" int64_t ceph_ll_nonblocking_fsync(class ceph_mount_info *cmount,
+                                            Inode *in, struct ceph_ll_io_info *io_info)
+{
+  LL_Onfinish *onfinish = new LL_Onfinish(io_info);
+
+  return (cmount->get_client()->nonblocking_fsync(
+                       in, io_info->syncdataonly, onfinish));
+}
+
 extern "C" int64_t ceph_ll_nonblocking_readv_writev(class ceph_mount_info *cmount,
                                                    struct ceph_ll_io_info *io_info)
 {