From ffc7207d50ee1b8508213ad86345937f9887e9ca Mon Sep 17 00:00:00 2001 From: Sidharth Anupkrishnan Date: Wed, 26 Jun 2019 18:59:06 +0530 Subject: [PATCH] libcephfs: Add lazyio_propogate and lazyio_synchronize methods to libcephfs Signed-off-by: Sidharth Anupkrishnan (cherry picked from commit e0722de187d095caa1e5aea549a98cc0ce5b21c4) --- src/include/cephfs/libcephfs.h | 22 ++++++++++++++++++++++ src/libcephfs.cc | 17 +++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index 36f4c0315d673..6cc5c111b3fcc 100755 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -1110,6 +1110,28 @@ int ceph_fallocate(struct ceph_mount_info *cmount, int fd, int mode, */ int ceph_lazyio(struct ceph_mount_info *cmount, int fd, int enable); + +/** + * Flushes the write buffer for the file thereby propogating the buffered write to the file. + * + * @param cmount the ceph mount handle to use for performing the fsync. + * @param fd the file descriptor of the file to sync. + * @param offset a boolean to enable lazyio or disable lazyio. + * @returns 0 on success or a negative error code on failure. + */ +int ceph_lazyio_propogate(struct ceph_mount_info *cmount, int fd, int64_t offset, size_t count); + + +/** + * Flushes the write buffer for the file and invalidate the read cache. This allows a subsequent read operation to read and cache data directly from the file and hence everyone's propogated writes would be visible. + * + * @param cmount the ceph mount handle to use for performing the fsync. + * @param fd the file descriptor of the file to sync. + * @param offset a boolean to enable lazyio or disable lazyio. + * @returns 0 on success or a negative error code on failure. + */ +int ceph_lazyio_synchronize(struct ceph_mount_info *cmount, int fd, int64_t offset, size_t count); + /** @} file */ /** diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 0f23fa8e120a8..2e3002b8b0ea6 100755 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -1079,6 +1079,23 @@ extern "C" int ceph_lazyio(class ceph_mount_info *cmount, return (cmount->get_client()->lazyio(fd, enable)); } +extern "C" int ceph_lazyio_propogate(class ceph_mount_info *cmount, + int fd, int64_t offset, size_t count) +{ + if (!cmount->is_mounted()) + return -ENOTCONN; + return (cmount->get_client()->lazyio_propogate(fd, offset, count)); +} + +extern "C" int ceph_lazyio_synchronize(class ceph_mount_info *cmount, + int fd, int64_t offset, size_t count) +{ + if (!cmount->is_mounted()) + return -ENOTCONN; + return (cmount->get_client()->lazyio_synchronize(fd, offset, count)); +} + + extern "C" int ceph_sync_fs(struct ceph_mount_info *cmount) { if (!cmount->is_mounted()) -- 2.39.5