From d18bdc1c43b8573582bd77d153cd514f881a69b9 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 27 Jun 2019 17:06:46 +0200 Subject: [PATCH] s3: convert struct stat_ex st_ex_calculated_birthtime bool to flags Subsequent commits will add more flags, this paves the way. Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- source3/include/includes.h | 7 +++++-- source3/include/vfs.h | 1 + source3/lib/system.c | 11 ++++++----- source3/librpc/idl/open_files.idl | 2 +- source3/modules/vfs_ceph.c | 2 +- source3/modules/vfs_gpfs.c | 4 ++-- source3/smbd/durable.c | 12 +++++------- 7 files changed, 21 insertions(+), 18 deletions(-) diff --git a/source3/include/includes.h b/source3/include/includes.h index 8f398d0d24b..ec486be6efa 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -190,6 +190,9 @@ typedef uint64_t br_off; #define SOFF_T_R(p, ofs, v) (SIVAL(p,(ofs)+4,(v)&0xFFFFFFFF), SIVAL(p,ofs,(v)>>32)) #define IVAL_TO_SMB_OFF_T(buf,off) ((off_t)(( ((uint64_t)(IVAL((buf),(off)))) & ((uint64_t)0xFFFFFFFF) ))) +/* Is birthtime real, or was it calculated ? */ +#define ST_EX_IFLAG_CALCULATED_BTIME (1 << 0) + /* * Type for stat structure. */ @@ -207,12 +210,12 @@ struct stat_ex { struct timespec st_ex_mtime; struct timespec st_ex_ctime; struct timespec st_ex_btime; /* birthtime */ - /* Is birthtime real, or was it calculated ? */ - bool st_ex_calculated_birthtime; + blksize_t st_ex_blksize; blkcnt_t st_ex_blocks; uint32_t st_ex_flags; + uint32_t st_ex_iflags; }; typedef struct stat_ex SMB_STRUCT_STAT; diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 39ea04bf266..ecac793b93d 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -262,6 +262,7 @@ /* Bump to version 41, Samba 4.11 will ship with that */ /* Version 41 - Remove SMB_VFS_BRL_CANCEL_WINDOWS */ /* Version 41 - Remove unused st_ex_mask from struct stat_ex */ +/* Version 41 - convert struct stat_ex.st_ex_calculated_birthtime to flags */ #define SMB_VFS_INTERFACE_VERSION 41 diff --git a/source3/lib/system.c b/source3/lib/system.c index 9dd04ca5e3d..4bfe3785118 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -291,7 +291,7 @@ static void make_create_timespec(const struct stat *pst, struct stat_ex *dst, dst->st_ex_btime.tv_nsec = 0; } - dst->st_ex_calculated_birthtime = false; + dst->st_ex_iflags &= ~ST_EX_IFLAG_CALCULATED_BTIME; #if defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC) dst->st_ex_btime = pst->st_birthtimespec; @@ -303,7 +303,7 @@ static void make_create_timespec(const struct stat *pst, struct stat_ex *dst, dst->st_ex_btime.tv_nsec = 0; #else dst->st_ex_btime = calc_create_time_stat(pst); - dst->st_ex_calculated_birthtime = true; + dst->st_ex_iflags |= ST_EX_IFLAG_CALCULATED_BTIME; #endif /* Deal with systems that don't initialize birthtime correctly. @@ -311,7 +311,7 @@ static void make_create_timespec(const struct stat *pst, struct stat_ex *dst, */ if (null_timespec(dst->st_ex_btime)) { dst->st_ex_btime = calc_create_time_stat(pst); - dst->st_ex_calculated_birthtime = true; + dst->st_ex_iflags |= ST_EX_IFLAG_CALCULATED_BTIME; } } @@ -327,7 +327,7 @@ void update_stat_ex_mtime(struct stat_ex *dst, dst->st_ex_mtime = write_ts; /* We may have to recalculate btime. */ - if (dst->st_ex_calculated_birthtime) { + if (dst->st_ex_iflags & ST_EX_IFLAG_CALCULATED_BTIME) { dst->st_ex_btime = calc_create_time_stat_ex(dst); } } @@ -336,7 +336,7 @@ void update_stat_ex_create_time(struct stat_ex *dst, struct timespec create_time) { dst->st_ex_btime = create_time; - dst->st_ex_calculated_birthtime = false; + dst->st_ex_iflags &= ~ST_EX_IFLAG_CALCULATED_BTIME; } void init_stat_ex_from_stat (struct stat_ex *dst, @@ -354,6 +354,7 @@ void init_stat_ex_from_stat (struct stat_ex *dst, dst->st_ex_atime = get_atimespec(src); dst->st_ex_mtime = get_mtimespec(src); dst->st_ex_ctime = get_ctimespec(src); + dst->st_ex_iflags = 0; make_create_timespec(src, dst, fake_dir_create_times); #ifdef HAVE_STAT_ST_BLKSIZE dst->st_ex_blksize = src->st_blksize; diff --git a/source3/librpc/idl/open_files.idl b/source3/librpc/idl/open_files.idl index 5668a0b97e2..04305e24164 100644 --- a/source3/librpc/idl/open_files.idl +++ b/source3/librpc/idl/open_files.idl @@ -76,10 +76,10 @@ interface open_files timespec st_ex_mtime; timespec st_ex_ctime; timespec st_ex_btime; - boolean8 st_ex_calculated_birthtime; hyper st_ex_blksize; hyper st_ex_blocks; uint32 st_ex_flags; + uint32 st_ex_iflags; } vfs_default_durable_stat; typedef [public] struct { diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index e1f3d757bf1..e3e9bb65b07 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -704,7 +704,7 @@ static void init_stat_ex_from_ceph_statx(struct stat_ex *dst, const struct ceph_ dst->st_ex_btime = stx->stx_btime; dst->st_ex_ctime = stx->stx_ctime; dst->st_ex_mtime = stx->stx_mtime; - dst->st_ex_calculated_birthtime = false; + dst->st_ex_iflags = 0; dst->st_ex_blksize = stx->stx_blksize; dst->st_ex_blocks = stx->stx_blocks; } diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index a1fe91d0df4..4b963edab11 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1630,7 +1630,7 @@ static NTSTATUS vfs_gpfs_get_dos_attributes(struct vfs_handle_struct *handle, } *dosmode |= vfs_gpfs_winattrs_to_dosmode(attrs.winAttrs); - smb_fname->st.st_ex_calculated_birthtime = false; + smb_fname->st.st_ex_iflags &= ~ST_EX_IFLAG_CALCULATED_BTIME; smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec; smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec; @@ -1689,7 +1689,7 @@ static NTSTATUS vfs_gpfs_fget_dos_attributes(struct vfs_handle_struct *handle, } *dosmode |= vfs_gpfs_winattrs_to_dosmode(attrs.winAttrs); - fsp->fsp_name->st.st_ex_calculated_birthtime = false; + fsp->fsp_name->st.st_ex_iflags &= ~ST_EX_IFLAG_CALCULATED_BTIME; fsp->fsp_name->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec; fsp->fsp_name->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec; diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index 311f7e598a4..4aa5a2d619e 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -118,7 +118,7 @@ NTSTATUS vfs_default_durable_cookie(struct files_struct *fsp, cookie.stat_info.st_ex_mtime = fsp->fsp_name->st.st_ex_mtime; cookie.stat_info.st_ex_ctime = fsp->fsp_name->st.st_ex_ctime; cookie.stat_info.st_ex_btime = fsp->fsp_name->st.st_ex_btime; - cookie.stat_info.st_ex_calculated_birthtime = fsp->fsp_name->st.st_ex_calculated_birthtime; + cookie.stat_info.st_ex_iflags = fsp->fsp_name->st.st_ex_iflags; cookie.stat_info.st_ex_blksize = fsp->fsp_name->st.st_ex_blksize; cookie.stat_info.st_ex_blocks = fsp->fsp_name->st.st_ex_blocks; cookie.stat_info.st_ex_flags = fsp->fsp_name->st.st_ex_flags; @@ -267,7 +267,7 @@ NTSTATUS vfs_default_durable_disconnect(struct files_struct *fsp, cookie.stat_info.st_ex_mtime = fsp->fsp_name->st.st_ex_mtime; cookie.stat_info.st_ex_ctime = fsp->fsp_name->st.st_ex_ctime; cookie.stat_info.st_ex_btime = fsp->fsp_name->st.st_ex_btime; - cookie.stat_info.st_ex_calculated_birthtime = fsp->fsp_name->st.st_ex_calculated_birthtime; + cookie.stat_info.st_ex_iflags = fsp->fsp_name->st.st_ex_iflags; cookie.stat_info.st_ex_blksize = fsp->fsp_name->st.st_ex_blksize; cookie.stat_info.st_ex_blocks = fsp->fsp_name->st.st_ex_blocks; cookie.stat_info.st_ex_flags = fsp->fsp_name->st.st_ex_flags; @@ -445,17 +445,15 @@ static bool vfs_default_durable_reconnect_check_stat( return false; } - if (cookie_st->st_ex_calculated_birthtime != - fsp_st->st_ex_calculated_birthtime) - { + if (cookie_st->st_ex_iflags != fsp_st->st_ex_iflags) { DEBUG(1, ("vfs_default_durable_reconnect (%s): " "stat_ex.%s differs: " "cookie:%llu != stat:%llu, " "denying durable reconnect\n", name, "st_ex_calculated_birthtime", - (unsigned long long)cookie_st->st_ex_calculated_birthtime, - (unsigned long long)fsp_st->st_ex_calculated_birthtime)); + (unsigned long long)cookie_st->st_ex_iflags, + (unsigned long long)fsp_st->st_ex_iflags)); return false; }