@@ -1017,6 +1017,67 @@ static int vfs_ceph_ll_fchmod(struct vfs_handle_struct *handle,
1017
1017
cfh -> uperm );
1018
1018
}
1019
1019
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
+
1020
1081
static int vfs_ceph_ll_futimes (struct vfs_handle_struct * handle ,
1021
1082
const struct vfs_ceph_fh * cfh ,
1022
1083
const struct smb_file_time * ft )
@@ -1028,22 +1089,7 @@ static int vfs_ceph_ll_futimes(struct vfs_handle_struct *handle,
1028
1089
SMB_VFS_HANDLE_GET_DATA (handle , config , struct vfs_ceph_config ,
1029
1090
return - ENOMEM );
1030
1091
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 );
1047
1093
if (!mask ) {
1048
1094
return 0 ;
1049
1095
}
@@ -3105,18 +3151,32 @@ static int vfs_ceph_fntimes(struct vfs_handle_struct *handle,
3105
3151
files_struct * fsp ,
3106
3152
struct smb_file_time * ft )
3107
3153
{
3108
- struct vfs_ceph_fh * cfh = NULL ;
3109
3154
int result ;
3110
3155
3111
3156
START_PROFILE (syscall_fntimes );
3112
- result = vfs_ceph_fetch_fh (handle , fsp , & cfh );
3113
- if (result != 0 ) {
3114
- goto out ;
3115
- }
3116
3157
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 );
3120
3180
}
3121
3181
3122
3182
if (!is_omit_timespec (& ft -> create_time )) {
0 commit comments