]> 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)
committerJos Collin <jcollin@redhat.com>
Wed, 27 Aug 2025 06:47:54 +0000 (12:17 +0530)
Also, removed CEPHFS_* errno's from setlk() and getlk() as Ceph has moved away from them.

Signed-off-by: Giorgos Kappes <giorgos@giorgoskappes.com>
(cherry picked from commit 22e5db4dc71409d0b1befe676d345a490a77d346)

src/client/Client.cc
src/client/Client.h

index 9674f1e88b3b37bafec61098cf1268f0dc3763aa..bacb191e1643dac8a27e10998f26add1f5a39812 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 97f035c3bc61cfa100b59dbbcf2275e40c4297aa..808aac28532840371823c237a4862d56463f69a7 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);