Skip to content

Commit dbc48a4

Browse files
anoopcs9gd
authored andcommitted
vfs_ceph_new: Add path based fallback for SMB_VFS_FNTIMES
Fallback mechanism was missing in vfs_ceph_fntimes() for path based call. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15834 Signed-off-by: Anoop C S <[email protected]> Reviewed-by: Guenther Deschner <[email protected]> Autobuild-User(master): Günther Deschner <[email protected]> Autobuild-Date(master): Mon Mar 17 20:48:55 UTC 2025 on atb-devel-224
1 parent 9c019ec commit dbc48a4

File tree

1 file changed

+84
-24
lines changed

1 file changed

+84
-24
lines changed

source3/modules/vfs_ceph_new.c

Lines changed: 84 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,67 @@ static int vfs_ceph_ll_fchmod(struct vfs_handle_struct *handle,
10171017
cfh->uperm);
10181018
}
10191019

1020+
static void vfs_ceph_fill_statx_mask_from_ft(const struct smb_file_time *ft,
1021+
struct ceph_statx *stx,
1022+
int *mask)
1023+
{
1024+
if (!is_omit_timespec(&ft->atime)) {
1025+
stx->stx_atime = ft->atime;
1026+
*mask |= CEPH_SETATTR_ATIME;
1027+
}
1028+
if (!is_omit_timespec(&ft->mtime)) {
1029+
stx->stx_mtime = ft->mtime;
1030+
*mask |= CEPH_SETATTR_MTIME;
1031+
}
1032+
if (!is_omit_timespec(&ft->ctime)) {
1033+
stx->stx_ctime = ft->ctime;
1034+
*mask |= CEPH_SETATTR_CTIME;
1035+
}
1036+
if (!is_omit_timespec(&ft->create_time)) {
1037+
stx->stx_btime = ft->create_time;
1038+
*mask |= CEPH_SETATTR_BTIME;
1039+
}
1040+
}
1041+
1042+
static int vfs_ceph_ll_utimes(struct vfs_handle_struct *handle,
1043+
const struct vfs_ceph_iref *iref,
1044+
const struct smb_file_time *ft)
1045+
{
1046+
struct ceph_statx stx = {0};
1047+
struct UserPerm *uperm = NULL;
1048+
int ret = -1;
1049+
int mask = 0;
1050+
struct vfs_ceph_config *config = NULL;
1051+
1052+
SMB_VFS_HANDLE_GET_DATA(handle, config, struct vfs_ceph_config,
1053+
return -ENOMEM);
1054+
1055+
vfs_ceph_fill_statx_mask_from_ft(ft, &stx, &mask);
1056+
if (!mask) {
1057+
return 0;
1058+
}
1059+
1060+
DBG_DEBUG("[CEPH] ceph_ll_setattr: ino=%" PRIu64 " mtime=%" PRIu64
1061+
" atime=%" PRIu64 " ctime=%" PRIu64 " btime=%" PRIu64 "\n",
1062+
iref->ino,
1063+
full_timespec_to_nt_time(&stx.stx_mtime),
1064+
full_timespec_to_nt_time(&stx.stx_atime),
1065+
full_timespec_to_nt_time(&stx.stx_ctime),
1066+
full_timespec_to_nt_time(&stx.stx_btime));
1067+
1068+
uperm = vfs_ceph_userperm_new(config, handle->conn);
1069+
if (uperm == NULL) {
1070+
return -ENOMEM;
1071+
}
1072+
ret = config->ceph_ll_setattr_fn(config->mount,
1073+
iref->inode,
1074+
&stx,
1075+
mask,
1076+
uperm);
1077+
vfs_ceph_userperm_del(config, uperm);
1078+
return ret;
1079+
}
1080+
10201081
static int vfs_ceph_ll_futimes(struct vfs_handle_struct *handle,
10211082
const struct vfs_ceph_fh *cfh,
10221083
const struct smb_file_time *ft)
@@ -1028,22 +1089,7 @@ static int vfs_ceph_ll_futimes(struct vfs_handle_struct *handle,
10281089
SMB_VFS_HANDLE_GET_DATA(handle, config, struct vfs_ceph_config,
10291090
return -ENOMEM);
10301091

1031-
if (!is_omit_timespec(&ft->atime)) {
1032-
stx.stx_atime = ft->atime;
1033-
mask |= CEPH_SETATTR_ATIME;
1034-
}
1035-
if (!is_omit_timespec(&ft->mtime)) {
1036-
stx.stx_mtime = ft->mtime;
1037-
mask |= CEPH_SETATTR_MTIME;
1038-
}
1039-
if (!is_omit_timespec(&ft->ctime)) {
1040-
stx.stx_ctime = ft->ctime;
1041-
mask |= CEPH_SETATTR_CTIME;
1042-
}
1043-
if (!is_omit_timespec(&ft->create_time)) {
1044-
stx.stx_btime = ft->create_time;
1045-
mask |= CEPH_SETATTR_BTIME;
1046-
}
1092+
vfs_ceph_fill_statx_mask_from_ft(ft, &stx, &mask);
10471093
if (!mask) {
10481094
return 0;
10491095
}
@@ -3105,18 +3151,32 @@ static int vfs_ceph_fntimes(struct vfs_handle_struct *handle,
31053151
files_struct *fsp,
31063152
struct smb_file_time *ft)
31073153
{
3108-
struct vfs_ceph_fh *cfh = NULL;
31093154
int result;
31103155

31113156
START_PROFILE(syscall_fntimes);
3112-
result = vfs_ceph_fetch_fh(handle, fsp, &cfh);
3113-
if (result != 0) {
3114-
goto out;
3115-
}
31163157

3117-
result = vfs_ceph_ll_futimes(handle, cfh, ft);
3118-
if (result != 0) {
3119-
goto out;
3158+
if (!fsp->fsp_flags.is_pathref) {
3159+
struct vfs_ceph_fh *cfh = NULL;
3160+
3161+
result = vfs_ceph_fetch_io_fh(handle, fsp, &cfh);
3162+
if (result != 0) {
3163+
goto out;
3164+
}
3165+
3166+
result = vfs_ceph_ll_futimes(handle, cfh, ft);
3167+
} else {
3168+
struct vfs_ceph_iref iref = {0};
3169+
3170+
result = vfs_ceph_iget(handle,
3171+
fsp->fsp_name->base_name,
3172+
0,
3173+
&iref);
3174+
if (result != 0) {
3175+
goto out;
3176+
}
3177+
3178+
result = vfs_ceph_ll_utimes(handle, &iref, ft);
3179+
vfs_ceph_iput(handle, &iref);
31203180
}
31213181

31223182
if (!is_omit_timespec(&ft->create_time)) {

0 commit comments

Comments
 (0)