From: Venky Shankar Date: Mon, 2 Jun 2025 05:03:50 +0000 (+0000) Subject: libcephfs/client: asynchronous fsync interface X-Git-Tag: v21.0.0~50^2~65^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c88a21c30d8b265adb152f631d2629d29539f7b7;p=ceph.git libcephfs/client: asynchronous fsync interface Mostly for writing test for hunting [0]. [0]: https://tracker.ceph.com/issues/71510 Signed-off-by: Venky Shankar --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 0038ae63a5aa..5e38ae702ec0 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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) diff --git a/src/client/Client.h b/src/client/Client.h index 59b3d797e961..49477ac1cb0a 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -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(); diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index 485b51a2ac15..774e0348c1dd 100644 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -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); /** diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 723757133933..ebc66f1242e4 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -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) {