Commit 94487653 authored by Jeff Layton's avatar Jeff Layton Committed by Christian Brauner

smb: convert to ctime accessor functions

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.
Acked-by: default avatarTom Talpey <tom@talpey.com>
Reviewed-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Acked-by: default avatarSteve French <stfrench@microsoft.com>
Message-Id: <20230705190309.579783-72-jlayton@kernel.org>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent a5845127
...@@ -1085,7 +1085,7 @@ int cifs_close(struct inode *inode, struct file *file) ...@@ -1085,7 +1085,7 @@ int cifs_close(struct inode *inode, struct file *file)
!test_bit(CIFS_INO_CLOSE_ON_LOCK, &cinode->flags) && !test_bit(CIFS_INO_CLOSE_ON_LOCK, &cinode->flags) &&
dclose) { dclose) {
if (test_and_clear_bit(CIFS_INO_MODIFIED_ATTR, &cinode->flags)) { if (test_and_clear_bit(CIFS_INO_MODIFIED_ATTR, &cinode->flags)) {
inode->i_ctime = inode->i_mtime = current_time(inode); inode->i_mtime = inode_set_ctime_current(inode);
} }
spin_lock(&cinode->deferred_lock); spin_lock(&cinode->deferred_lock);
cifs_add_deferred_close(cfile, dclose); cifs_add_deferred_close(cfile, dclose);
...@@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to) ...@@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
write_data, to - from, &offset); write_data, to - from, &offset);
cifsFileInfo_put(open_file); cifsFileInfo_put(open_file);
/* Does mm or vfs already set times? */ /* Does mm or vfs already set times? */
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
if ((bytes_written > 0) && (offset)) if ((bytes_written > 0) && (offset))
rc = 0; rc = 0;
else if (bytes_written < 0) else if (bytes_written < 0)
......
...@@ -50,12 +50,13 @@ void cifs_fscache_fill_coherency(struct inode *inode, ...@@ -50,12 +50,13 @@ void cifs_fscache_fill_coherency(struct inode *inode,
struct cifs_fscache_inode_coherency_data *cd) struct cifs_fscache_inode_coherency_data *cd)
{ {
struct cifsInodeInfo *cifsi = CIFS_I(inode); struct cifsInodeInfo *cifsi = CIFS_I(inode);
struct timespec64 ctime = inode_get_ctime(inode);
memset(cd, 0, sizeof(*cd)); memset(cd, 0, sizeof(*cd));
cd->last_write_time_sec = cpu_to_le64(cifsi->netfs.inode.i_mtime.tv_sec); cd->last_write_time_sec = cpu_to_le64(cifsi->netfs.inode.i_mtime.tv_sec);
cd->last_write_time_nsec = cpu_to_le32(cifsi->netfs.inode.i_mtime.tv_nsec); cd->last_write_time_nsec = cpu_to_le32(cifsi->netfs.inode.i_mtime.tv_nsec);
cd->last_change_time_sec = cpu_to_le64(cifsi->netfs.inode.i_ctime.tv_sec); cd->last_change_time_sec = cpu_to_le64(ctime.tv_sec);
cd->last_change_time_nsec = cpu_to_le32(cifsi->netfs.inode.i_ctime.tv_nsec); cd->last_change_time_nsec = cpu_to_le32(ctime.tv_nsec);
} }
......
...@@ -172,7 +172,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr) ...@@ -172,7 +172,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
else else
inode->i_atime = fattr->cf_atime; inode->i_atime = fattr->cf_atime;
inode->i_mtime = fattr->cf_mtime; inode->i_mtime = fattr->cf_mtime;
inode->i_ctime = fattr->cf_ctime; inode_set_ctime_to_ts(inode, fattr->cf_ctime);
inode->i_rdev = fattr->cf_rdev; inode->i_rdev = fattr->cf_rdev;
cifs_nlink_fattr_to_inode(inode, fattr); cifs_nlink_fattr_to_inode(inode, fattr);
inode->i_uid = fattr->cf_uid; inode->i_uid = fattr->cf_uid;
...@@ -1744,9 +1744,9 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -1744,9 +1744,9 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
cifs_inode = CIFS_I(inode); cifs_inode = CIFS_I(inode);
cifs_inode->time = 0; /* will force revalidate to get info cifs_inode->time = 0; /* will force revalidate to get info
when needed */ when needed */
inode->i_ctime = current_time(inode); inode_set_ctime_current(inode);
} }
dir->i_ctime = dir->i_mtime = current_time(dir); dir->i_mtime = inode_set_ctime_current(dir);
cifs_inode = CIFS_I(dir); cifs_inode = CIFS_I(dir);
CIFS_I(dir)->time = 0; /* force revalidate of dir as well */ CIFS_I(dir)->time = 0; /* force revalidate of dir as well */
unlink_out: unlink_out:
...@@ -2060,8 +2060,8 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry) ...@@ -2060,8 +2060,8 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
*/ */
cifsInode->time = 0; cifsInode->time = 0;
d_inode(direntry)->i_ctime = inode->i_ctime = inode->i_mtime = inode_set_ctime_current(d_inode(direntry));
current_time(inode); inode->i_mtime = inode_set_ctime_current(inode);
rmdir_exit: rmdir_exit:
free_dentry_path(page); free_dentry_path(page);
...@@ -2267,8 +2267,8 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir, ...@@ -2267,8 +2267,8 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
/* force revalidate to go get info when needed */ /* force revalidate to go get info when needed */
CIFS_I(source_dir)->time = CIFS_I(target_dir)->time = 0; CIFS_I(source_dir)->time = CIFS_I(target_dir)->time = 0;
source_dir->i_ctime = source_dir->i_mtime = target_dir->i_ctime = source_dir->i_mtime = target_dir->i_mtime = inode_set_ctime_to_ts(source_dir,
target_dir->i_mtime = current_time(source_dir); inode_set_ctime_current(target_dir));
cifs_rename_exit: cifs_rename_exit:
kfree(info_buf_source); kfree(info_buf_source);
......
...@@ -1396,7 +1396,8 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -1396,7 +1396,8 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,
if (file_inf.LastWriteTime) if (file_inf.LastWriteTime)
inode->i_mtime = cifs_NTtimeToUnix(file_inf.LastWriteTime); inode->i_mtime = cifs_NTtimeToUnix(file_inf.LastWriteTime);
if (file_inf.ChangeTime) if (file_inf.ChangeTime)
inode->i_ctime = cifs_NTtimeToUnix(file_inf.ChangeTime); inode_set_ctime_to_ts(inode,
cifs_NTtimeToUnix(file_inf.ChangeTime));
if (file_inf.LastAccessTime) if (file_inf.LastAccessTime)
inode->i_atime = cifs_NTtimeToUnix(file_inf.LastAccessTime); inode->i_atime = cifs_NTtimeToUnix(file_inf.LastAccessTime);
......
...@@ -4779,7 +4779,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp, ...@@ -4779,7 +4779,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
file_info->LastAccessTime = cpu_to_le64(time); file_info->LastAccessTime = cpu_to_le64(time);
time = ksmbd_UnixTimeToNT(inode->i_mtime); time = ksmbd_UnixTimeToNT(inode->i_mtime);
file_info->LastWriteTime = cpu_to_le64(time); file_info->LastWriteTime = cpu_to_le64(time);
time = ksmbd_UnixTimeToNT(inode->i_ctime); time = ksmbd_UnixTimeToNT(inode_get_ctime(inode));
file_info->ChangeTime = cpu_to_le64(time); file_info->ChangeTime = cpu_to_le64(time);
file_info->DosAttributes = fp->f_ci->m_fattr; file_info->DosAttributes = fp->f_ci->m_fattr;
file_info->Inode = cpu_to_le64(inode->i_ino); file_info->Inode = cpu_to_le64(inode->i_ino);
...@@ -5422,7 +5422,7 @@ int smb2_close(struct ksmbd_work *work) ...@@ -5422,7 +5422,7 @@ int smb2_close(struct ksmbd_work *work)
rsp->LastAccessTime = cpu_to_le64(time); rsp->LastAccessTime = cpu_to_le64(time);
time = ksmbd_UnixTimeToNT(inode->i_mtime); time = ksmbd_UnixTimeToNT(inode->i_mtime);
rsp->LastWriteTime = cpu_to_le64(time); rsp->LastWriteTime = cpu_to_le64(time);
time = ksmbd_UnixTimeToNT(inode->i_ctime); time = ksmbd_UnixTimeToNT(inode_get_ctime(inode));
rsp->ChangeTime = cpu_to_le64(time); rsp->ChangeTime = cpu_to_le64(time);
ksmbd_fd_put(work, fp); ksmbd_fd_put(work, fp);
} else { } else {
...@@ -5644,7 +5644,7 @@ static int set_file_basic_info(struct ksmbd_file *fp, ...@@ -5644,7 +5644,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
if (file_info->ChangeTime) if (file_info->ChangeTime)
attrs.ia_ctime = ksmbd_NTtimeToUnix(file_info->ChangeTime); attrs.ia_ctime = ksmbd_NTtimeToUnix(file_info->ChangeTime);
else else
attrs.ia_ctime = inode->i_ctime; attrs.ia_ctime = inode_get_ctime(inode);
if (file_info->LastWriteTime) { if (file_info->LastWriteTime) {
attrs.ia_mtime = ksmbd_NTtimeToUnix(file_info->LastWriteTime); attrs.ia_mtime = ksmbd_NTtimeToUnix(file_info->LastWriteTime);
...@@ -5689,7 +5689,7 @@ static int set_file_basic_info(struct ksmbd_file *fp, ...@@ -5689,7 +5689,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
return -EACCES; return -EACCES;
inode_lock(inode); inode_lock(inode);
inode->i_ctime = attrs.ia_ctime; inode_set_ctime_to_ts(inode, attrs.ia_ctime);
attrs.ia_valid &= ~ATTR_CTIME; attrs.ia_valid &= ~ATTR_CTIME;
rc = notify_change(idmap, dentry, &attrs, NULL); rc = notify_change(idmap, dentry, &attrs, NULL);
inode_unlock(inode); inode_unlock(inode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment