The VFS inode timestamps are not y2038 safe as they use struct timespec. These will be changed to use struct timespec64 instead and that is y2038 safe. But, since the above data type conversion will break the end file systems, use vfs_time aliases here to access inode times.
This is necessary because we are matching cifs_fattr data type to that of the vfs timestamps.
This change is safe because cifs_fattr is accessed in following ways:
1. Assigning to/ from/ compared with struct inode timestamps, which will match vfs_time alias. 2. Assigned from cifs_NTtimeToUnix(). And, this function does not care about the data type sizes of tv_sec and tv_nsec fields. 3. Assigned from current_fs_time(), which will match vfs_time alias. 4. Assigned from cnvrtDosUnixTm(). And, this function does not care about the data type sizes of tv_sec and tv_nsec fields.
Signed-off-by: Deepa Dinamani deepa.kernel@gmail.com --- fs/cifs/cifsencrypt.c | 2 +- fs/cifs/cifsglob.h | 6 +++--- fs/cifs/cifsproto.h | 6 +++--- fs/cifs/cifssmb.c | 4 ++-- fs/cifs/inode.c | 2 +- fs/cifs/netmisc.c | 10 +++++----- 6 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index f86e07d..ee1e674 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c @@ -460,7 +460,7 @@ find_timestamp(struct cifs_ses *ses) unsigned char *blobptr; unsigned char *blobend; struct ntlmssp2_name *attrptr; - struct timespec ts; + struct vfs_time ts;
if (!ses->auth_key.len || !ses->auth_key.response) return 0; diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index a25b251..b08749e 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -1393,9 +1393,9 @@ struct cifs_fattr { dev_t cf_rdev; unsigned int cf_nlink; unsigned int cf_dtype; - struct timespec cf_atime; - struct timespec cf_mtime; - struct timespec cf_ctime; + struct vfs_time cf_atime; + struct vfs_time cf_mtime; + struct vfs_time cf_ctime; };
static inline void free_dfs_info_param(struct dfs_info3_param *param) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index eed7ff5..93e9638 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -126,9 +126,9 @@ extern enum securityEnum select_sectype(struct TCP_Server_Info *server, enum securityEnum requested); extern int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses, const struct nls_table *nls_cp); -extern struct timespec cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601); -extern u64 cifs_UnixTimeToNT(struct timespec); -extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, +extern struct vfs_time cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601); +extern u64 cifs_UnixTimeToNT(struct vfs_time); +extern struct vfs_time cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset); extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock); extern int cifs_get_writer(struct cifsInodeInfo *cinode); diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 1a9e43d..b3b3fa4 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -478,7 +478,7 @@ decode_lanman_negprot_rsp(struct TCP_Server_Info *server, NEGOTIATE_RSP *pSMBr) * this requirement. */ int val, seconds, remain, result; - struct timespec ts; + struct vfs_time ts; unsigned long utc = get_seconds(); ts = cnvrtDosUnixTm(rsp->SrvTime.Date, rsp->SrvTime.Time, 0); @@ -4000,7 +4000,7 @@ QInfRetry: if (rc) { cifs_dbg(FYI, "Send error in QueryInfo = %d\n", rc); } else if (data) { - struct timespec ts; + struct vfs_time ts; __u32 time = le32_to_cpu(pSMBr->last_write_time);
/* decode response */ diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index fa72359..39068b4 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -110,7 +110,7 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr) }
/* revalidate if mtime or size have changed */ - if (timespec_equal(&inode->i_mtime, &fattr->cf_mtime) && + if (vfs_time_equal(&inode->i_mtime, &fattr->cf_mtime) && cifs_i->server_eof == fattr->cf_eof) { cifs_dbg(FYI, "%s: inode %llu is unchanged\n", __func__, cifs_i->uniqueid); diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index abae6dd..86bc0e5 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c @@ -918,10 +918,10 @@ smbCalcSize(void *buf) * Convert the NT UTC (based 1601-01-01, in hundred nanosecond units) * into Unix UTC (based 1970-01-01, in seconds). */ -struct timespec +struct vfs_time cifs_NTtimeToUnix(__le64 ntutc) { - struct timespec ts; + struct vfs_time ts; /* BB what about the timezone? BB */
/* Subtract the NTFS time offset, then convert to 1s intervals. */ @@ -949,7 +949,7 @@ cifs_NTtimeToUnix(__le64 ntutc)
/* Convert the Unix UTC into NT UTC. */ u64 -cifs_UnixTimeToNT(struct timespec t) +cifs_UnixTimeToNT(struct vfs_time t) { /* Convert to 100ns intervals and then add the NTFS time offset. */ return (u64) t.tv_sec * 10000000 + t.tv_nsec/100 + NTFS_TIME_OFFSET; @@ -959,9 +959,9 @@ static const int total_days_of_prev_months[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
-struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset) +struct vfs_time cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset) { - struct timespec ts; + struct vfs_time ts; int sec, min, days, month, year; u16 date = le16_to_cpu(le_date); u16 time = le16_to_cpu(le_time);