Merge PR #61116 into main

* refs/pull/61116/head:

Reviewed-by: Venky Shankar <vshankar@redhat.com>
Reviewed-by: Patrick Donnelly <pdonnell@ibm.com>
This commit is contained in:
Venky Shankar 2025-08-11 12:23:41 +05:30
commit 783bf4834f
8 changed files with 1112 additions and 1 deletions

View File

@ -230,6 +230,7 @@ Gary Lowell <gary.lowell@inktank.com> <glowell@inktank.com>
Gaurav Kumar Garg <garg.gaurav52@gmail.com> <ggarg@redhat.com>
Gerben Meijer <gerben@daybyday.nl> <infernix@gmail.com>
Germain Chipaux <germain.chipaux@gmail.com>
Giorgos Kappes <giorgos@polytropo.io> <giorgos@giorgoskappes.com>
Gong Chuang <gong.chuang@zte.com.cn>
Greg Farnum <gfarnum@redhat.com>
Greg Farnum <gfarnum@redhat.com> <gfarnum@GF-Macbook.local>

View File

@ -575,6 +575,7 @@ Pacific Northwest National Laboratory <contact@pnl.gov> Scott Devoid <devoid@anl
Piston Cloud Computing <info@pistoncloud.com> Mike Lundy <mike@fluffypenguin.org>
Platform.sh <contact@platform.sh> Simon Ruggier <simon@platform.sh>
Pogoapp <contact@pogoapp.com> Paul Meserve <paul@pogodan.com>
Polytropo Systems <info@polytropo.io> Giorgos Kappes <giorgos@polytropo.io>
Profihost <contact@profihost.ag> Stefan Priebe <s.priebe@profihost.ag>
ProphetStor <contact@prphetstor.com> Rick Chen <rick.chen@prophetstor.com>
Proxmox <contact@proxmox.com> Dominik Csapak <d.csapak@proxmox.com>

View File

@ -9164,6 +9164,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);

View 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);

View 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.

View File

@ -1406,6 +1406,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)
{

View File

@ -24,6 +24,7 @@ if(WITH_LIBCEPHFS)
multiclient.cc
flock.cc
recordlock.cc
recordlock_hl.cc
acl.cc
main.cc
deleg.cc

File diff suppressed because it is too large Load Diff