From: Giorgos Kappes Date: Tue, 17 Dec 2024 14:01:07 +0000 (+0200) Subject: Client: Add Client::setlk and Client::getlk functions X-Git-Tag: testing/wip-jcollin-testing-20250827.105003-tentacle~3^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=942c6168688ee552f202b8493e25e68df9f9d647;p=ceph-ci.git Client: Add Client::setlk and Client::getlk functions Also, removed CEPHFS_* errno's from setlk() and getlk() as Ceph has moved away from them. Signed-off-by: Giorgos Kappes (cherry picked from commit 22e5db4dc71409d0b1befe676d345a490a77d346) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 9674f1e88b3..bacb191e164 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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); diff --git a/src/client/Client.h b/src/client/Client.h index 97f035c3bc6..808aac28532 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -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);