vfs_ceph: Implement SMB_VFS_FGET_DOS_ATTRIBUTES to preserve create_time master
authorAnoop C S <anoopcs@samba.org>
Thu, 21 Mar 2024 11:19:04 +0000 (16:49 +0530)
committerAnoop C S <anoopcs@samba.org>
Mon, 1 Apr 2024 10:23:18 +0000 (15:53 +0530)
In order to avoid the dependency on dos attribute for create_time we now
preserve the btime before parsing dos attribute which may update btime
from its value with an old one unless we explicitly reset dos attribute
with new create_time in SMB_VFS_FNTIMES implementation. Therefore have
an implementation for SMB_VFS_FGET_DOS_ATTRIBUTES to save and restore
updated create_time.

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_ceph.c

index c9ee5414f038a3ea5a0b6ffb9fee9ee5e4e5702f..6dae8a5f9e84bba51e352d325e9b62db90385438 100644 (file)
@@ -1569,6 +1569,29 @@ static const char *cephwrap_connectpath(
        return handle->conn->connectpath;
 }
 
+static NTSTATUS cephwrap_fget_dos_attributes(struct vfs_handle_struct *handle,
+                                            struct files_struct *fsp,
+                                            uint32_t *dosmode)
+{
+       struct timespec saved_btime = fsp->fsp_name->st.st_ex_btime;
+       NTSTATUS status;
+
+       status = fget_ea_dos_attribute(fsp, dosmode);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       /*
+        * Restore previously stored btime from statx timestamps as it should be
+        * the only source of truth. create_time from dos attribute, if any, may
+        * have older values which isn't trustworthy to be looked at for other
+        * open file handle operations.
+        */
+       fsp->fsp_name->st.st_ex_btime = saved_btime;
+
+       return NT_STATUS_OK;
+}
+
 /****************************************************************
  Extended attribute operations.
 *****************************************************************/
@@ -1933,6 +1956,7 @@ static struct vfs_fn_pointers ceph_fns = {
        .fchflags_fn = cephwrap_fchflags,
        .get_real_filename_at_fn = cephwrap_get_real_filename_at,
        .connectpath_fn = cephwrap_connectpath,
+       .fget_dos_attributes_fn = cephwrap_fget_dos_attributes,
 
        /* EA operations. */
        .getxattrat_send_fn = vfs_not_implemented_getxattrat_send,