mirror of
https://github.com/samba-team/samba.git
synced 2025-02-23 09:57:40 +03:00
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 <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
a5f4e33f87
commit
d18bdc1c43
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user