]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs: Add ceph_setlk and ceph_getlk wrapper functions
authorGiorgos Kappes <giorgos@giorgoskappes.com>
Tue, 22 Jul 2025 14:12:58 +0000 (17:12 +0300)
committerJos Collin <jcollin@redhat.com>
Wed, 27 Aug 2025 06:47:54 +0000 (12:17 +0530)
Signed-off-by: Giorgos Kappes <giorgos@giorgoskappes.com>
(cherry picked from commit 6b443ee5a4e5542def2e4fb3a3afa7d6862dd8eb)

src/include/cephfs/libcephfs.h
src/libcephfs.cc

index 230d2f15b92c7059380d2a0626f5d42a65cd0141..8dff1c714551ac1635910f86343950ec0f54effe 100644 (file)
@@ -1276,6 +1276,32 @@ int ceph_utimensat(struct ceph_mount_info *cmount, int dirfd, const char *relpat
 int ceph_flock(struct ceph_mount_info *cmount, int fd, int operation,
               uint64_t owner);
 
+/**
+ * Test the existence of a record lock.
+ *
+ * @param cmount the ceph mount handle to use for performing the lock.
+ * @param fd the open file descriptor to test the existence of a record lock.
+ * @param pointer to an flock structure.
+ * @param owner the user-supplied owner identifier (an arbitrary integer)
+ * @returns 0 on success or negative error code on failure.
+ */ 
+ int ceph_getlk(struct ceph_mount_info *cmount, int fd, struct flock *flock,
+               uint64_t owner);
+
+/**
+ * Set a record lock.
+ *
+ * @param cmount the ceph mount handle to use for performing the lock.
+ * @param fd the open file descriptor to set a record lock
+ * @param pointer to an flock structure.
+ * @param owner the user-supplied owner identifier (an arbitrary integer)
+ * @param sleep the user-supplied sleep flag
+ * @returns 0 on success or negative error code on failure.
+ */ 
+ int ceph_setlk(struct ceph_mount_info *cmount, int fd, struct flock *flock,
+               uint64_t owner, int sleep);
+
 /**
  * Truncate the file to the given size.  If this operation causes the
  * file to expand, the empty bytes will be filled in with zeros.
index be4d6d9beec4d08666f535841cfba1143ed78dae..f4d1e8b68199bf0776b62dba85f1d8d50f665285 100644 (file)
@@ -1405,6 +1405,22 @@ extern "C" int ceph_flock(struct ceph_mount_info *cmount, int fd, int operation,
   return cmount->get_client()->flock(fd, operation, owner);
 }
 
+extern "C" int ceph_getlk(struct ceph_mount_info *cmount, int fd, struct flock *fl,
+                         uint64_t owner)
+{
+  if (!cmount->is_mounted())
+    return -ENOTCONN;
+  return cmount->get_client()->getlk(fd, fl, owner);
+}
+
+extern "C" int ceph_setlk(struct ceph_mount_info *cmount, int fd, struct flock *fl,
+                         uint64_t owner, int sleep)
+{
+  if (!cmount->is_mounted())
+    return -ENOTCONN;
+  return cmount->get_client()->setlk(fd, fl, owner, sleep);
+}
+
 extern "C" int ceph_truncate(struct ceph_mount_info *cmount, const char *path,
                             int64_t size)
 {