]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: convert struct stat_ex st_ex_calculated_birthtime bool to flags
authorRalph Boehme <slow@samba.org>
Thu, 27 Jun 2019 15:06:46 +0000 (17:06 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 1 Jul 2019 21:43:23 +0000 (21:43 +0000)
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>
source3/include/includes.h
source3/include/vfs.h
source3/lib/system.c
source3/librpc/idl/open_files.idl
source3/modules/vfs_ceph.c
source3/modules/vfs_gpfs.c
source3/smbd/durable.c

index 8f398d0d24bfdb08c625752bcb57c3be4a323d9b..ec486be6efaaf3c8f91d224e37aa377d131ba01c 100644 (file)
@@ -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;
index 39ea04bf266cf00a8d58b9a074e706f6aed04d78..ecac793b93df773760162e183d2f8e438a62d244 100644 (file)
 /* 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
 
index 9dd04ca5e3d25c2a327a2ed5f53073fbd00cff15..4bfe3785118667c8064f08eaae2012850017522f 100644 (file)
@@ -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;
index 5668a0b97e247560ed0186ea3abe56524be9a73d..04305e241648ed0ebd6542a7cbd883d829de5829 100644 (file)
@@ -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 {
index e1f3d757bf1240953b14e4e7840cbb80b3f49af4..e3e9bb65b0732ae5c0e6b00ab4dabf573f26adc9 100644 (file)
@@ -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;
 }
index a1fe91d0df4131efe9640f6dae89175c6e1dc951..4b963edab1111e6c32b5eed003e5a9c1f3556dc6 100644 (file)
@@ -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;
 
index 311f7e598a47b80367142307cdb599a4082826a8..4aa5a2d619ed84b24f70dc8ddd2bb6825d8e9398 100644 (file)
@@ -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;
        }