@@ -259,8 +259,10 @@ cifs_fscache_inode_get_aux(const void *cookie_netfs_data, void *buffer,
memset(&auxdata, 0, sizeof(auxdata));
auxdata.eof = cifsi->server_eof;
- auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
- auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
+ auxdata.last_write_time =
+ vfs_time_to_timespec(cifsi->vfs_inode.i_mtime);
+ auxdata.last_change_time =
+ vfs_time_to_timespec(cifsi->vfs_inode.i_ctime);
if (maxbuf > sizeof(auxdata))
maxbuf = sizeof(auxdata);
@@ -283,8 +285,10 @@ fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
memset(&auxdata, 0, sizeof(auxdata));
auxdata.eof = cifsi->server_eof;
- auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
- auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
+ auxdata.last_write_time =
+ vfs_time_to_timespec(cifsi->vfs_inode.i_mtime);
+ auxdata.last_change_time =
+ vfs_time_to_timespec(cifsi->vfs_inode.i_ctime);
if (memcmp(data, &auxdata, datalen) != 0)
return FSCACHE_CHECKAUX_OBSOLETE;
@@ -92,6 +92,7 @@ static void
cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
{
struct cifsInodeInfo *cifs_i = CIFS_I(inode);
+ struct timespec mtime;
cifs_dbg(FYI, "%s: revalidating inode %llu\n",
__func__, cifs_i->uniqueid);
@@ -109,8 +110,9 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
return;
}
+ mtime = vfs_time_to_timespec(inode->i_mtime);
/* revalidate if mtime or size have changed */
- if (timespec_equal(&inode->i_mtime, &fattr->cf_mtime) &&
+ if (timespec_equal(&mtime, &fattr->cf_mtime) &&
cifs_i->server_eof == fattr->cf_eof) {
cifs_dbg(FYI, "%s: inode %llu is unchanged\n",
__func__, cifs_i->uniqueid);
@@ -159,9 +161,9 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
cifs_revalidate_cache(inode, fattr);
spin_lock(&inode->i_lock);
- inode->i_atime = fattr->cf_atime;
- inode->i_mtime = fattr->cf_mtime;
- inode->i_ctime = fattr->cf_ctime;
+ inode->i_atime = timespec_to_vfs_time(fattr->cf_atime);
+ inode->i_mtime = timespec_to_vfs_time(fattr->cf_mtime);
+ inode->i_ctime = timespec_to_vfs_time(fattr->cf_ctime);
inode->i_rdev = fattr->cf_rdev;
cifs_nlink_fattr_to_inode(inode, fattr);
inode->i_uid = fattr->cf_uid;
@@ -1066,15 +1068,15 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid,
if (attrs->ia_valid & ATTR_ATIME) {
set_time = true;
- info_buf.LastAccessTime =
- cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_atime));
+ info_buf.LastAccessTime = cpu_to_le64(
+ cifs_UnixTimeToNT(vfs_time_to_timespec(attrs->ia_atime)));
} else
info_buf.LastAccessTime = 0;
if (attrs->ia_valid & ATTR_MTIME) {
set_time = true;
- info_buf.LastWriteTime =
- cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_mtime));
+ info_buf.LastWriteTime = cpu_to_le64(
+ cifs_UnixTimeToNT(vfs_time_to_timespec(attrs->ia_mtime)));
} else
info_buf.LastWriteTime = 0;
@@ -1086,8 +1088,8 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid,
*/
if (set_time && (attrs->ia_valid & ATTR_CTIME)) {
cifs_dbg(FYI, "CIFS - CTIME changed\n");
- info_buf.ChangeTime =
- cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_ctime));
+ info_buf.ChangeTime = cpu_to_le64(
+ cifs_UnixTimeToNT(vfs_time_to_timespec(attrs->ia_ctime)));
} else
info_buf.ChangeTime = 0;
@@ -2193,17 +2195,20 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
args->gid = INVALID_GID; /* no change */
if (attrs->ia_valid & ATTR_ATIME)
- args->atime = cifs_UnixTimeToNT(attrs->ia_atime);
+ args->atime = cifs_UnixTimeToNT(
+ vfs_time_to_timespec(attrs->ia_atime));
else
args->atime = NO_CHANGE_64;
if (attrs->ia_valid & ATTR_MTIME)
- args->mtime = cifs_UnixTimeToNT(attrs->ia_mtime);
+ args->mtime = cifs_UnixTimeToNT(
+ vfs_time_to_timespec(attrs->ia_mtime));
else
args->mtime = NO_CHANGE_64;
if (attrs->ia_valid & ATTR_CTIME)
- args->ctime = cifs_UnixTimeToNT(attrs->ia_ctime);
+ args->ctime = cifs_UnixTimeToNT(
+ vfs_time_to_timespec(attrs->ia_ctime));
else
args->ctime = NO_CHANGE_64;
This is preparation to make vfs inode timestamps y2038 safe. 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 access functions to access inode times. Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com> --- fs/cifs/cache.c | 12 ++++++++---- fs/cifs/inode.c | 31 ++++++++++++++++++------------- 2 files changed, 26 insertions(+), 17 deletions(-)