mirror of
https://github.com/samba-team/samba.git
synced 2025-01-25 06:04:04 +03:00
vfs_ceph_new: use low-level APIs for fntimes
Implement fntimes hook using libcephfs' low-level APIs. Convert smb_file_time to ceph_statx plus proper field mask on-the-fly upon issuing low-level call to libcephfs. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15686 Signed-off-by: Shachar Sharon <ssharon@redhat.com> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
This commit is contained in:
parent
cb14d3630d
commit
20b7d2bfe0
@ -628,6 +628,39 @@ static int vfs_ceph_ll_fchmod(struct vfs_handle_struct *handle,
|
|||||||
cfh->uperm);
|
cfh->uperm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int vfs_ceph_ll_futimes(struct vfs_handle_struct *handle,
|
||||||
|
const struct vfs_ceph_fh *cfh,
|
||||||
|
const struct smb_file_time *ft)
|
||||||
|
{
|
||||||
|
struct ceph_statx stx = {0};
|
||||||
|
int mask = 0;
|
||||||
|
|
||||||
|
if (!is_omit_timespec(&ft->atime)) {
|
||||||
|
stx.stx_atime = ft->atime;
|
||||||
|
mask |= CEPH_SETATTR_ATIME;
|
||||||
|
}
|
||||||
|
if (!is_omit_timespec(&ft->mtime)) {
|
||||||
|
stx.stx_mtime = ft->mtime;
|
||||||
|
mask |= CEPH_SETATTR_MTIME;
|
||||||
|
}
|
||||||
|
if (!is_omit_timespec(&ft->ctime)) {
|
||||||
|
stx.stx_ctime = ft->ctime;
|
||||||
|
mask |= CEPH_SETATTR_CTIME;
|
||||||
|
}
|
||||||
|
if (!is_omit_timespec(&ft->create_time)) {
|
||||||
|
stx.stx_btime = ft->create_time;
|
||||||
|
mask |= CEPH_SETATTR_BTIME;
|
||||||
|
}
|
||||||
|
if (!mask) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ceph_ll_setattr(cmount_of(handle),
|
||||||
|
cfh->iref.inode,
|
||||||
|
&stx,
|
||||||
|
mask,
|
||||||
|
cfh->uperm);
|
||||||
|
}
|
||||||
|
|
||||||
static int vfs_ceph_ll_releasedir(const struct vfs_handle_struct *handle,
|
static int vfs_ceph_ll_releasedir(const struct vfs_handle_struct *handle,
|
||||||
const struct vfs_ceph_fh *dircfh)
|
const struct vfs_ceph_fh *dircfh)
|
||||||
{
|
{
|
||||||
@ -1640,51 +1673,28 @@ static int vfs_ceph_fntimes(struct vfs_handle_struct *handle,
|
|||||||
files_struct *fsp,
|
files_struct *fsp,
|
||||||
struct smb_file_time *ft)
|
struct smb_file_time *ft)
|
||||||
{
|
{
|
||||||
struct ceph_statx stx = { 0 };
|
struct vfs_ceph_fh *cfh = NULL;
|
||||||
int result;
|
int result;
|
||||||
int mask = 0;
|
|
||||||
|
|
||||||
if (!is_omit_timespec(&ft->atime)) {
|
result = vfs_ceph_fetch_fh(handle, fsp, &cfh);
|
||||||
stx.stx_atime = ft->atime;
|
if (result != 0) {
|
||||||
mask |= CEPH_SETATTR_ATIME;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!is_omit_timespec(&ft->mtime)) {
|
|
||||||
stx.stx_mtime = ft->mtime;
|
result = vfs_ceph_ll_futimes(handle, cfh, ft);
|
||||||
mask |= CEPH_SETATTR_MTIME;
|
if (result != 0) {
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_omit_timespec(&ft->create_time)) {
|
if (!is_omit_timespec(&ft->create_time)) {
|
||||||
stx.stx_btime = ft->create_time;
|
set_create_timespec_ea(fsp, ft->create_time);
|
||||||
mask |= CEPH_SETATTR_BTIME;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mask) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fsp->fsp_flags.is_pathref) {
|
|
||||||
/*
|
|
||||||
* We can use an io_fd to set xattrs.
|
|
||||||
*/
|
|
||||||
result = ceph_fsetattrx(cmount_of(handle),
|
|
||||||
fsp_get_io_fd(fsp),
|
|
||||||
&stx,
|
|
||||||
mask);
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* This is no longer a handle based call.
|
|
||||||
*/
|
|
||||||
result = ceph_setattrx(cmount_of(handle),
|
|
||||||
fsp->fsp_name->base_name,
|
|
||||||
&stx,
|
|
||||||
mask,
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG_DEBUG("[CEPH] ntimes(%p, %s, {%ld, %ld, %ld, %ld}) = %d\n",
|
DBG_DEBUG("[CEPH] ntimes(%p, %s, {%ld, %ld, %ld, %ld}) = %d\n",
|
||||||
handle, fsp_str_dbg(fsp), ft->mtime.tv_sec, ft->atime.tv_sec,
|
handle, fsp_str_dbg(fsp), ft->mtime.tv_sec, ft->atime.tv_sec,
|
||||||
ft->ctime.tv_sec, ft->create_time.tv_sec, result);
|
ft->ctime.tv_sec, ft->create_time.tv_sec, result);
|
||||||
|
out:
|
||||||
return result;
|
return status_code(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfs_ceph_unlinkat(struct vfs_handle_struct *handle,
|
static int vfs_ceph_unlinkat(struct vfs_handle_struct *handle,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user