Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH v2 06/92] cifs: update the ctime on a partial page write
       [not found] ` <20230705190309.579783-1-jlayton@kernel.org>
@ 2023-07-05 19:00   ` Jeff Layton
       [not found]     ` <CAH2r5mv+Fc9PuNtb8qMTwpb8qrEO2Tta5+o=mxD-2AY0cU5Aeg@mail.gmail.com>
  2023-07-06 15:26     ` Steve French
  2023-07-05 19:01   ` [PATCH v2 74/92] smb: convert to ctime accessor functions Jeff Layton
  1 sibling, 2 replies; 6+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Tom Talpey
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-cifs,
	samba-technical

POSIX says:

    "Upon successful completion, where nbyte is greater than 0, write()
     shall mark for update the last data modification and last file status
     change timestamps of the file..."

Add the missing ctime update.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/smb/client/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 879bc8e6555c..0a5fe8d5314b 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
 					   write_data, to - from, &offset);
 		cifsFileInfo_put(open_file);
 		/* Does mm or vfs already set times? */
-		inode->i_atime = inode->i_mtime = current_time(inode);
+		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
 		if ((bytes_written > 0) && (offset))
 			rc = 0;
 		else if (bytes_written < 0)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 74/92] smb: convert to ctime accessor functions
       [not found] ` <20230705190309.579783-1-jlayton@kernel.org>
  2023-07-05 19:00   ` [PATCH v2 06/92] cifs: update the ctime on a partial page write Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-05 23:01     ` Jeff Layton
  2023-07-06 15:28     ` Steve French
  1 sibling, 2 replies; 6+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Tom Talpey, Namjae Jeon, Sergey Senozhatsky
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-cifs,
	samba-technical

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: Tom Talpey <tom@talpey.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/smb/client/file.c    |  4 ++--
 fs/smb/client/fscache.h |  5 +++--
 fs/smb/client/inode.c   | 14 +++++++-------
 fs/smb/client/smb2ops.c |  3 ++-
 fs/smb/server/smb2pdu.c |  8 ++++----
 5 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 0a5fe8d5314b..689058e1b6e6 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -1085,7 +1085,7 @@ int cifs_close(struct inode *inode, struct file *file)
 		    !test_bit(CIFS_INO_CLOSE_ON_LOCK, &cinode->flags) &&
 		    dclose) {
 			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);
 			cifs_add_deferred_close(cfile, dclose);
@@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
 					   write_data, to - from, &offset);
 		cifsFileInfo_put(open_file);
 		/* 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))
 			rc = 0;
 		else if (bytes_written < 0)
diff --git a/fs/smb/client/fscache.h b/fs/smb/client/fscache.h
index 173999610997..a228964bc2ce 100644
--- a/fs/smb/client/fscache.h
+++ b/fs/smb/client/fscache.h
@@ -50,12 +50,13 @@ void cifs_fscache_fill_coherency(struct inode *inode,
 				 struct cifs_fscache_inode_coherency_data *cd)
 {
 	struct cifsInodeInfo *cifsi = CIFS_I(inode);
+	struct timespec64 ctime = inode_get_ctime(inode);
 
 	memset(cd, 0, sizeof(*cd));
 	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_change_time_sec  = cpu_to_le64(cifsi->netfs.inode.i_ctime.tv_sec);
-	cd->last_change_time_nsec = cpu_to_le32(cifsi->netfs.inode.i_ctime.tv_nsec);
+	cd->last_change_time_sec  = cpu_to_le64(ctime.tv_sec);
+	cd->last_change_time_nsec  = cpu_to_le64(ctime.tv_nsec);
 }
 
 
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index c3eeae07e139..218f03dd3f52 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -172,7 +172,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
 	else
 		inode->i_atime = fattr->cf_atime;
 	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;
 	cifs_nlink_fattr_to_inode(inode, fattr);
 	inode->i_uid = fattr->cf_uid;
@@ -1744,9 +1744,9 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
 		cifs_inode = CIFS_I(inode);
 		cifs_inode->time = 0;	/* will force revalidate to get info
 					   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_I(dir)->time = 0;	/* force revalidate of dir as well */
 unlink_out:
@@ -2060,8 +2060,8 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
 	 */
 	cifsInode->time = 0;
 
-	d_inode(direntry)->i_ctime = inode->i_ctime = inode->i_mtime =
-		current_time(inode);
+	inode_set_ctime_current(d_inode(direntry));
+	inode->i_mtime = inode_set_ctime_current(inode);
 
 rmdir_exit:
 	free_dentry_path(page);
@@ -2267,8 +2267,8 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
 	/* force revalidate to go get info when needed */
 	CIFS_I(source_dir)->time = CIFS_I(target_dir)->time = 0;
 
-	source_dir->i_ctime = source_dir->i_mtime = target_dir->i_ctime =
-		target_dir->i_mtime = current_time(source_dir);
+	source_dir->i_mtime = target_dir->i_mtime = inode_set_ctime_to_ts(source_dir,
+									  inode_set_ctime_current(target_dir));
 
 cifs_rename_exit:
 	kfree(info_buf_source);
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 87abce010974..3cc3c4a71e32 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -1396,7 +1396,8 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,
 	if (file_inf.LastWriteTime)
 		inode->i_mtime = cifs_NTtimeToUnix(file_inf.LastWriteTime);
 	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)
 		inode->i_atime = cifs_NTtimeToUnix(file_inf.LastAccessTime);
 
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index cf8822103f50..f9099831c8ff 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -4779,7 +4779,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
 	file_info->LastAccessTime = cpu_to_le64(time);
 	time = ksmbd_UnixTimeToNT(inode->i_mtime);
 	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->DosAttributes = fp->f_ci->m_fattr;
 	file_info->Inode = cpu_to_le64(inode->i_ino);
@@ -5422,7 +5422,7 @@ int smb2_close(struct ksmbd_work *work)
 		rsp->LastAccessTime = cpu_to_le64(time);
 		time = ksmbd_UnixTimeToNT(inode->i_mtime);
 		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);
 		ksmbd_fd_put(work, fp);
 	} else {
@@ -5644,7 +5644,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
 	if (file_info->ChangeTime)
 		attrs.ia_ctime = ksmbd_NTtimeToUnix(file_info->ChangeTime);
 	else
-		attrs.ia_ctime = inode->i_ctime;
+		attrs.ia_ctime = inode_get_ctime(inode);
 
 	if (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,
 			return -EACCES;
 
 		inode_lock(inode);
-		inode->i_ctime = attrs.ia_ctime;
+		inode_set_ctime_to_ts(inode, attrs.ia_ctime);
 		attrs.ia_valid &= ~ATTR_CTIME;
 		rc = notify_change(idmap, dentry, &attrs, NULL);
 		inode_unlock(inode);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 74/92] smb: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 74/92] smb: convert to ctime accessor functions Jeff Layton
@ 2023-07-05 23:01     ` Jeff Layton
  2023-07-06 15:28     ` Steve French
  1 sibling, 0 replies; 6+ messages in thread
From: Jeff Layton @ 2023-07-05 23:01 UTC (permalink / raw)
  To: Christian Brauner, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Tom Talpey, Namjae Jeon, Sergey Senozhatsky
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-cifs,
	samba-technical

On Wed, 2023-07-05 at 15:01 -0400, Jeff Layton wrote:
> 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: Tom Talpey <tom@talpey.com>
> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/smb/client/file.c    |  4 ++--
>  fs/smb/client/fscache.h |  5 +++--
>  fs/smb/client/inode.c   | 14 +++++++-------
>  fs/smb/client/smb2ops.c |  3 ++-
>  fs/smb/server/smb2pdu.c |  8 ++++----
>  5 files changed, 18 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
> index 0a5fe8d5314b..689058e1b6e6 100644
> --- a/fs/smb/client/file.c
> +++ b/fs/smb/client/file.c
> @@ -1085,7 +1085,7 @@ int cifs_close(struct inode *inode, struct file *file)
>  		    !test_bit(CIFS_INO_CLOSE_ON_LOCK, &cinode->flags) &&
>  		    dclose) {
>  			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);
>  			cifs_add_deferred_close(cfile, dclose);
> @@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
>  					   write_data, to - from, &offset);
>  		cifsFileInfo_put(open_file);
>  		/* 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))
>  			rc = 0;
>  		else if (bytes_written < 0)
> diff --git a/fs/smb/client/fscache.h b/fs/smb/client/fscache.h
> index 173999610997..a228964bc2ce 100644
> --- a/fs/smb/client/fscache.h
> +++ b/fs/smb/client/fscache.h
> @@ -50,12 +50,13 @@ void cifs_fscache_fill_coherency(struct inode *inode,
>  				 struct cifs_fscache_inode_coherency_data *cd)
>  {
>  	struct cifsInodeInfo *cifsi = CIFS_I(inode);
> +	struct timespec64 ctime = inode_get_ctime(inode);
>  
>  	memset(cd, 0, sizeof(*cd));
>  	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_change_time_sec  = cpu_to_le64(cifsi->netfs.inode.i_ctime.tv_sec);
> -	cd->last_change_time_nsec = cpu_to_le32(cifsi->netfs.inode.i_ctime.tv_nsec);
> +	cd->last_change_time_sec  = cpu_to_le64(ctime.tv_sec);
> +	cd->last_change_time_nsec  = cpu_to_le64(ctime.tv_nsec);

Tom pointed out that I made a switch to cpu_to_le64 here. That will need
to be fixed before we merge this. I've fixed this in my "ctime-next"
branch for now (and will collect other fixes there).

>  }
>  
>  
> diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
> index c3eeae07e139..218f03dd3f52 100644
> --- a/fs/smb/client/inode.c
> +++ b/fs/smb/client/inode.c
> @@ -172,7 +172,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
>  	else
>  		inode->i_atime = fattr->cf_atime;
>  	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;
>  	cifs_nlink_fattr_to_inode(inode, fattr);
>  	inode->i_uid = fattr->cf_uid;
> @@ -1744,9 +1744,9 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
>  		cifs_inode = CIFS_I(inode);
>  		cifs_inode->time = 0;	/* will force revalidate to get info
>  					   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_I(dir)->time = 0;	/* force revalidate of dir as well */
>  unlink_out:
> @@ -2060,8 +2060,8 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
>  	 */
>  	cifsInode->time = 0;
>  
> -	d_inode(direntry)->i_ctime = inode->i_ctime = inode->i_mtime =
> -		current_time(inode);
> +	inode_set_ctime_current(d_inode(direntry));
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  
>  rmdir_exit:
>  	free_dentry_path(page);
> @@ -2267,8 +2267,8 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
>  	/* force revalidate to go get info when needed */
>  	CIFS_I(source_dir)->time = CIFS_I(target_dir)->time = 0;
>  
> -	source_dir->i_ctime = source_dir->i_mtime = target_dir->i_ctime =
> -		target_dir->i_mtime = current_time(source_dir);
> +	source_dir->i_mtime = target_dir->i_mtime = inode_set_ctime_to_ts(source_dir,
> +									  inode_set_ctime_current(target_dir));
>  
>  cifs_rename_exit:
>  	kfree(info_buf_source);
> diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
> index 87abce010974..3cc3c4a71e32 100644
> --- a/fs/smb/client/smb2ops.c
> +++ b/fs/smb/client/smb2ops.c
> @@ -1396,7 +1396,8 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,
>  	if (file_inf.LastWriteTime)
>  		inode->i_mtime = cifs_NTtimeToUnix(file_inf.LastWriteTime);
>  	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)
>  		inode->i_atime = cifs_NTtimeToUnix(file_inf.LastAccessTime);
>  
> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index cf8822103f50..f9099831c8ff 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -4779,7 +4779,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
>  	file_info->LastAccessTime = cpu_to_le64(time);
>  	time = ksmbd_UnixTimeToNT(inode->i_mtime);
>  	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->DosAttributes = fp->f_ci->m_fattr;
>  	file_info->Inode = cpu_to_le64(inode->i_ino);
> @@ -5422,7 +5422,7 @@ int smb2_close(struct ksmbd_work *work)
>  		rsp->LastAccessTime = cpu_to_le64(time);
>  		time = ksmbd_UnixTimeToNT(inode->i_mtime);
>  		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);
>  		ksmbd_fd_put(work, fp);
>  	} else {
> @@ -5644,7 +5644,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
>  	if (file_info->ChangeTime)
>  		attrs.ia_ctime = ksmbd_NTtimeToUnix(file_info->ChangeTime);
>  	else
> -		attrs.ia_ctime = inode->i_ctime;
> +		attrs.ia_ctime = inode_get_ctime(inode);
>  
>  	if (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,
>  			return -EACCES;
>  
>  		inode_lock(inode);
> -		inode->i_ctime = attrs.ia_ctime;
> +		inode_set_ctime_to_ts(inode, attrs.ia_ctime);
>  		attrs.ia_valid &= ~ATTR_CTIME;
>  		rc = notify_change(idmap, dentry, &attrs, NULL);
>  		inode_unlock(inode);

-- 
Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 06/92] cifs: update the ctime on a partial page write
       [not found]     ` <CAH2r5mv+Fc9PuNtb8qMTwpb8qrEO2Tta5+o=mxD-2AY0cU5Aeg@mail.gmail.com>
@ 2023-07-06  7:11       ` Christian Brauner
  0 siblings, 0 replies; 6+ messages in thread
From: Christian Brauner @ 2023-07-06  7:11 UTC (permalink / raw)
  To: Steve French
  Cc: Jeff Layton, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Tom Talpey, Al Viro, Jan Kara, linux-fsdevel,
	linux-kernel, linux-cifs, samba-technical

On Wed, Jul 05, 2023 at 11:50:15PM -0500, Steve French wrote:
> this looks useful (although we have a few more serious problems where we
> don't keep the cached mtime/ctime/size for files that have RW or RWH leases
> so can update the mtime/ctime/size from the server version of it which can
> be stale in cases where we are caching writes (with leases).
> 
> Which tree do you want this patch to go through?

Plan is to take it all through the vfs tree.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 06/92] cifs: update the ctime on a partial page write
  2023-07-05 19:00   ` [PATCH v2 06/92] cifs: update the ctime on a partial page write Jeff Layton
       [not found]     ` <CAH2r5mv+Fc9PuNtb8qMTwpb8qrEO2Tta5+o=mxD-2AY0cU5Aeg@mail.gmail.com>
@ 2023-07-06 15:26     ` Steve French
  1 sibling, 0 replies; 6+ messages in thread
From: Steve French @ 2023-07-06 15:26 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Tom Talpey, Al Viro, Jan Kara, linux-fsdevel,
	linux-kernel, linux-cifs, samba-technical

Reviewed-by: Steve French <stfrench@microsoft.com>

On Wed, Jul 5, 2023 at 2:04 PM Jeff Layton <jlayton@kernel.org> wrote:
>
> POSIX says:
>
>     "Upon successful completion, where nbyte is greater than 0, write()
>      shall mark for update the last data modification and last file status
>      change timestamps of the file..."
>
> Add the missing ctime update.
>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/smb/client/file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
> index 879bc8e6555c..0a5fe8d5314b 100644
> --- a/fs/smb/client/file.c
> +++ b/fs/smb/client/file.c
> @@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
>                                            write_data, to - from, &offset);
>                 cifsFileInfo_put(open_file);
>                 /* Does mm or vfs already set times? */
> -               inode->i_atime = inode->i_mtime = current_time(inode);
> +               inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
>                 if ((bytes_written > 0) && (offset))
>                         rc = 0;
>                 else if (bytes_written < 0)
> --
> 2.41.0
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 74/92] smb: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 74/92] smb: convert to ctime accessor functions Jeff Layton
  2023-07-05 23:01     ` Jeff Layton
@ 2023-07-06 15:28     ` Steve French
  1 sibling, 0 replies; 6+ messages in thread
From: Steve French @ 2023-07-06 15:28 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Tom Talpey, Namjae Jeon, Sergey Senozhatsky,
	Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-cifs,
	samba-technical

Acked-by: Steve French <stfrench@microsoft.com>

On Wed, Jul 5, 2023 at 2:42 PM Jeff Layton <jlayton@kernel.org> wrote:
>
> 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: Tom Talpey <tom@talpey.com>
> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/smb/client/file.c    |  4 ++--
>  fs/smb/client/fscache.h |  5 +++--
>  fs/smb/client/inode.c   | 14 +++++++-------
>  fs/smb/client/smb2ops.c |  3 ++-
>  fs/smb/server/smb2pdu.c |  8 ++++----
>  5 files changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
> index 0a5fe8d5314b..689058e1b6e6 100644
> --- a/fs/smb/client/file.c
> +++ b/fs/smb/client/file.c
> @@ -1085,7 +1085,7 @@ int cifs_close(struct inode *inode, struct file *file)
>                     !test_bit(CIFS_INO_CLOSE_ON_LOCK, &cinode->flags) &&
>                     dclose) {
>                         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);
>                         cifs_add_deferred_close(cfile, dclose);
> @@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
>                                            write_data, to - from, &offset);
>                 cifsFileInfo_put(open_file);
>                 /* 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))
>                         rc = 0;
>                 else if (bytes_written < 0)
> diff --git a/fs/smb/client/fscache.h b/fs/smb/client/fscache.h
> index 173999610997..a228964bc2ce 100644
> --- a/fs/smb/client/fscache.h
> +++ b/fs/smb/client/fscache.h
> @@ -50,12 +50,13 @@ void cifs_fscache_fill_coherency(struct inode *inode,
>                                  struct cifs_fscache_inode_coherency_data *cd)
>  {
>         struct cifsInodeInfo *cifsi = CIFS_I(inode);
> +       struct timespec64 ctime = inode_get_ctime(inode);
>
>         memset(cd, 0, sizeof(*cd));
>         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_change_time_sec  = cpu_to_le64(cifsi->netfs.inode.i_ctime.tv_sec);
> -       cd->last_change_time_nsec = cpu_to_le32(cifsi->netfs.inode.i_ctime.tv_nsec);
> +       cd->last_change_time_sec  = cpu_to_le64(ctime.tv_sec);
> +       cd->last_change_time_nsec  = cpu_to_le64(ctime.tv_nsec);
>  }
>
>
> diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
> index c3eeae07e139..218f03dd3f52 100644
> --- a/fs/smb/client/inode.c
> +++ b/fs/smb/client/inode.c
> @@ -172,7 +172,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
>         else
>                 inode->i_atime = fattr->cf_atime;
>         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;
>         cifs_nlink_fattr_to_inode(inode, fattr);
>         inode->i_uid = fattr->cf_uid;
> @@ -1744,9 +1744,9 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
>                 cifs_inode = CIFS_I(inode);
>                 cifs_inode->time = 0;   /* will force revalidate to get info
>                                            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_I(dir)->time = 0;  /* force revalidate of dir as well */
>  unlink_out:
> @@ -2060,8 +2060,8 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
>          */
>         cifsInode->time = 0;
>
> -       d_inode(direntry)->i_ctime = inode->i_ctime = inode->i_mtime =
> -               current_time(inode);
> +       inode_set_ctime_current(d_inode(direntry));
> +       inode->i_mtime = inode_set_ctime_current(inode);
>
>  rmdir_exit:
>         free_dentry_path(page);
> @@ -2267,8 +2267,8 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
>         /* force revalidate to go get info when needed */
>         CIFS_I(source_dir)->time = CIFS_I(target_dir)->time = 0;
>
> -       source_dir->i_ctime = source_dir->i_mtime = target_dir->i_ctime =
> -               target_dir->i_mtime = current_time(source_dir);
> +       source_dir->i_mtime = target_dir->i_mtime = inode_set_ctime_to_ts(source_dir,
> +                                                                         inode_set_ctime_current(target_dir));
>
>  cifs_rename_exit:
>         kfree(info_buf_source);
> diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
> index 87abce010974..3cc3c4a71e32 100644
> --- a/fs/smb/client/smb2ops.c
> +++ b/fs/smb/client/smb2ops.c
> @@ -1396,7 +1396,8 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,
>         if (file_inf.LastWriteTime)
>                 inode->i_mtime = cifs_NTtimeToUnix(file_inf.LastWriteTime);
>         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)
>                 inode->i_atime = cifs_NTtimeToUnix(file_inf.LastAccessTime);
>
> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index cf8822103f50..f9099831c8ff 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -4779,7 +4779,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
>         file_info->LastAccessTime = cpu_to_le64(time);
>         time = ksmbd_UnixTimeToNT(inode->i_mtime);
>         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->DosAttributes = fp->f_ci->m_fattr;
>         file_info->Inode = cpu_to_le64(inode->i_ino);
> @@ -5422,7 +5422,7 @@ int smb2_close(struct ksmbd_work *work)
>                 rsp->LastAccessTime = cpu_to_le64(time);
>                 time = ksmbd_UnixTimeToNT(inode->i_mtime);
>                 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);
>                 ksmbd_fd_put(work, fp);
>         } else {
> @@ -5644,7 +5644,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
>         if (file_info->ChangeTime)
>                 attrs.ia_ctime = ksmbd_NTtimeToUnix(file_info->ChangeTime);
>         else
> -               attrs.ia_ctime = inode->i_ctime;
> +               attrs.ia_ctime = inode_get_ctime(inode);
>
>         if (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,
>                         return -EACCES;
>
>                 inode_lock(inode);
> -               inode->i_ctime = attrs.ia_ctime;
> +               inode_set_ctime_to_ts(inode, attrs.ia_ctime);
>                 attrs.ia_valid &= ~ATTR_CTIME;
>                 rc = notify_change(idmap, dentry, &attrs, NULL);
>                 inode_unlock(inode);
> --
> 2.41.0
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-06 15:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230705185755.579053-1-jlayton@kernel.org>
     [not found] ` <20230705190309.579783-1-jlayton@kernel.org>
2023-07-05 19:00   ` [PATCH v2 06/92] cifs: update the ctime on a partial page write Jeff Layton
     [not found]     ` <CAH2r5mv+Fc9PuNtb8qMTwpb8qrEO2Tta5+o=mxD-2AY0cU5Aeg@mail.gmail.com>
2023-07-06  7:11       ` Christian Brauner
2023-07-06 15:26     ` Steve French
2023-07-05 19:01   ` [PATCH v2 74/92] smb: convert to ctime accessor functions Jeff Layton
2023-07-05 23:01     ` Jeff Layton
2023-07-06 15:28     ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox