]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Client: Add Client::setlk and Client::getlk functions
authorGiorgos Kappes <giorgos@giorgoskappes.com>
Tue, 17 Dec 2024 14:01:07 +0000 (16:01 +0200)
committerGiorgos Kappes <giorgos@giorgoskappes.com>
Tue, 22 Jul 2025 16:01:46 +0000 (19:01 +0300)
Also, removed CEPHFS_* errno's from setlk() and getlk() as Ceph has moved away from them.

Signed-off-by: Giorgos Kappes <giorgos@giorgoskappes.com>
src/client/Client.cc
src/client/Client.h

index 35baf658cf3a1601914ddd4a27b1624dcd761a83..766e957249ff9f7d2ef9f7375609f5b83665fa11 100644 (file)
@@ -9158,6 +9158,43 @@ int Client::flock(int fd, int operation, uint64_t owner)
   return _flock(f, operation, owner);
 }
 
+int Client::getlk(int fd, struct flock *fl, uint64_t owner)
+{
+  RWRef_t mref_reader(mount_state, CLIENT_MOUNTING);
+  if (!mref_reader.is_state_satisfied())
+    return -ENOTCONN;
+
+  tout(cct) << __func__ << std::endl;
+  tout(cct) << fd << std::endl;
+  tout(cct) << owner << std::endl;
+
+  std::scoped_lock lock(client_lock);
+  Fh *fh = get_filehandle(fd);
+  if (!fh)
+    return -EBADF;
+
+  return _getlk(fh, fl, owner);
+}
+
+int Client::setlk(int fd, struct flock *fl, uint64_t owner, int sleep)
+{
+  RWRef_t mref_reader(mount_state, CLIENT_MOUNTING);
+  if (!mref_reader.is_state_satisfied())
+    return -ENOTCONN;
+
+  tout(cct) << __func__ << std::endl;
+  tout(cct) << fd << std::endl;
+  tout(cct) << owner << std::endl;
+  tout(cct) << sleep << std::endl;
+
+  std::scoped_lock lock(client_lock);
+  Fh *fh = get_filehandle(fd);
+  if (!fh)
+    return -EBADF;
+
+  return _setlk(fh, fl, owner, sleep);
+}
+
 int Client::opendir(const char *relpath, dir_result_t **dirpp, const UserPerm& perms)
 {
   RWRef_t mref_reader(mount_state, CLIENT_MOUNTING);
index 52b23288ea8f994a7f177276dc84db3d2ec0caef..fd406dd6ebccd8bfe4ed5a0d9de9cbbafb2bde34 100644 (file)
@@ -478,7 +478,9 @@ public:
                 const UserPerm& perms);
   int flock(int fd, int operation, uint64_t owner);
   int truncate(const char *path, loff_t size, const UserPerm& perms);
-
+  int getlk(int fd, struct flock *fl, uint64_t owner);
+  int setlk(int fd, struct flock *fl, uint64_t owner, int sleep);
+  
   // file ops
   int mknod(const char *path, mode_t mode, const UserPerm& perms, dev_t rdev=0);