All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Paulo Alcantara <pc@manguebit.com>,
	Ronnie Sahlberg <lsahlber@redhat.com>,
	Shyam Prasad N <sprasad@microsoft.com>,
	Tom Talpey <tom@talpey.com>,
	linux-cifs@vger.kernel.org, samba-technical@lists.samba.org
Subject: [PATCH 67/87] fs/smb/client: convert to new inode {a,m}time accessors
Date: Thu, 28 Sep 2023 07:03:16 -0400	[thread overview]
Message-ID: <20230928110413.33032-66-jlayton@kernel.org> (raw)
In-Reply-To: <20230928110413.33032-1-jlayton@kernel.org>

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/smb/client/file.c    | 18 ++++++++++--------
 fs/smb/client/fscache.h |  6 +++---
 fs/smb/client/inode.c   | 17 ++++++++---------
 fs/smb/client/smb2ops.c |  6 ++++--
 4 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 2108b3b40ce9..cf17e3dd703e 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -1085,7 +1085,8 @@ 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_mtime = inode_set_ctime_current(inode);
+				inode_set_mtime_to_ts(inode,
+						      inode_set_ctime_current(inode));
 			}
 			spin_lock(&cinode->deferred_lock);
 			cifs_add_deferred_close(cfile, dclose);
@@ -2596,7 +2597,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_set_ctime_current(inode);
+		simple_inode_init_ts(inode);
 		if ((bytes_written > 0) && (offset))
 			rc = 0;
 		else if (bytes_written < 0)
@@ -4647,11 +4648,13 @@ static void cifs_readahead(struct readahead_control *ractl)
 static int cifs_readpage_worker(struct file *file, struct page *page,
 	loff_t *poffset)
 {
+	struct inode *inode = file_inode(file);
+	struct timespec64 atime, mtime;
 	char *read_data;
 	int rc;
 
 	/* Is the page cached? */
-	rc = cifs_readpage_from_fscache(file_inode(file), page);
+	rc = cifs_readpage_from_fscache(inode, page);
 	if (rc == 0)
 		goto read_complete;
 
@@ -4666,11 +4669,10 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
 		cifs_dbg(FYI, "Bytes read %d\n", rc);
 
 	/* we do not want atime to be less than mtime, it broke some apps */
-	file_inode(file)->i_atime = current_time(file_inode(file));
-	if (timespec64_compare(&(file_inode(file)->i_atime), &(file_inode(file)->i_mtime)))
-		file_inode(file)->i_atime = file_inode(file)->i_mtime;
-	else
-		file_inode(file)->i_atime = current_time(file_inode(file));
+	atime = inode_set_atime_to_ts(inode, current_time(inode));
+	mtime = inode_get_mtime(inode);
+	if (timespec64_compare(&atime, &mtime))
+		inode_set_atime_to_ts(inode, inode_get_mtime(inode));
 
 	if (PAGE_SIZE > rc)
 		memset(read_data + rc, 0, PAGE_SIZE - rc);
diff --git a/fs/smb/client/fscache.h b/fs/smb/client/fscache.h
index 84f3b09367d2..a3d73720914f 100644
--- a/fs/smb/client/fscache.h
+++ b/fs/smb/client/fscache.h
@@ -49,12 +49,12 @@ static inline
 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);
+	struct timespec64 mtime = inode_get_mtime(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_write_time_sec   = cpu_to_le64(mtime.tv_sec);
+	cd->last_write_time_nsec  = cpu_to_le32(mtime.tv_nsec);
 	cd->last_change_time_sec  = cpu_to_le64(ctime.tv_sec);
 	cd->last_change_time_nsec = cpu_to_le32(ctime.tv_nsec);
 }
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index d7c302442c1e..3abfe77bfa46 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -82,6 +82,7 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
 {
 	struct cifs_fscache_inode_coherency_data cd;
 	struct cifsInodeInfo *cifs_i = CIFS_I(inode);
+	struct timespec64 mtime;
 
 	cifs_dbg(FYI, "%s: revalidating inode %llu\n",
 		 __func__, cifs_i->uniqueid);
@@ -101,7 +102,8 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
 
 	 /* revalidate if mtime or size have changed */
 	fattr->cf_mtime = timestamp_truncate(fattr->cf_mtime, inode);
-	if (timespec64_equal(&inode->i_mtime, &fattr->cf_mtime) &&
+	mtime = inode_get_mtime(inode);
+	if (timespec64_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);
@@ -164,10 +166,10 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
 	fattr->cf_ctime = timestamp_truncate(fattr->cf_ctime, inode);
 	/* we do not want atime to be less than mtime, it broke some apps */
 	if (timespec64_compare(&fattr->cf_atime, &fattr->cf_mtime) < 0)
-		inode->i_atime = fattr->cf_mtime;
+		inode_set_atime_to_ts(inode, fattr->cf_mtime);
 	else
-		inode->i_atime = fattr->cf_atime;
-	inode->i_mtime = fattr->cf_mtime;
+		inode_set_atime_to_ts(inode, fattr->cf_atime);
+	inode_set_mtime_to_ts(inode, fattr->cf_mtime);
 	inode_set_ctime_to_ts(inode, fattr->cf_ctime);
 	inode->i_rdev = fattr->cf_rdev;
 	cifs_nlink_fattr_to_inode(inode, fattr);
@@ -1816,7 +1818,7 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
 					   when needed */
 		inode_set_ctime_current(inode);
 	}
-	dir->i_mtime = inode_set_ctime_current(dir);
+	inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
 	cifs_inode = CIFS_I(dir);
 	CIFS_I(dir)->time = 0;	/* force revalidate of dir as well */
 unlink_out:
@@ -2131,7 +2133,7 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
 	cifsInode->time = 0;
 
 	inode_set_ctime_current(d_inode(direntry));
-	inode->i_mtime = inode_set_ctime_current(inode);
+	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 
 rmdir_exit:
 	free_dentry_path(page);
@@ -2337,9 +2339,6 @@ 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_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);
 	free_dentry_path(page2);
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 9aeecee6b91b..f4849a8ad40b 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -1403,12 +1403,14 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,
 
 	/* Creation time should not need to be updated on close */
 	if (file_inf.LastWriteTime)
-		inode->i_mtime = cifs_NTtimeToUnix(file_inf.LastWriteTime);
+		inode_set_mtime_to_ts(inode,
+				      cifs_NTtimeToUnix(file_inf.LastWriteTime));
 	if (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);
+		inode_set_atime_to_ts(inode,
+				      cifs_NTtimeToUnix(file_inf.LastAccessTime));
 
 	/*
 	 * i_blocks is not related to (i_size / i_blksize),
-- 
2.41.0


  parent reply	other threads:[~2023-09-28 11:10 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28 11:02 [PATCH 00/87] fs: new accessor methods for atime and mtime Jeff Layton
2023-09-28 11:02 ` Jeff Layton
2023-09-28 11:02 ` Jeff Layton
2023-09-28 11:02 ` Jeff Layton
2023-09-28 11:02 ` Jeff Layton
2023-09-28 11:02 ` [f2fs-dev] " Jeff Layton
2023-09-28 11:02 ` [PATCH 02/87] fs: convert core infrastructure to new {a,m}time accessors Jeff Layton
2023-09-28 11:02   ` [PATCH 03/87] arch/powerpc/platforms/cell/spufs: convert to new inode " Jeff Layton
2023-09-28 11:02     ` Jeff Layton
2023-09-28 11:02   ` [PATCH 04/87] arch/s390/hypfs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 05/87] drivers/android: " Jeff Layton
2023-09-28 11:02   ` [PATCH 06/87] drivers/char: " Jeff Layton
2023-09-28 11:02   ` [PATCH 07/87] drivers/infiniband/hw/qib: " Jeff Layton
2023-09-28 11:02   ` [PATCH 08/87] drivers/misc/ibmasm: " Jeff Layton
2023-09-28 11:02   ` [PATCH 09/87] drivers/misc: " Jeff Layton
2023-09-28 11:02   ` [PATCH 10/87] drivers/platform/x86: " Jeff Layton
2023-09-28 12:34     ` Hans de Goede
2023-09-28 11:02   ` [PATCH 11/87] drivers/tty: " Jeff Layton
2023-09-28 12:13     ` Greg KH
2023-09-28 12:23       ` Jeff Layton
2023-09-28 11:02   ` [PATCH 12/87] drivers/usb/core: " Jeff Layton
2023-09-28 11:02   ` [PATCH 13/87] drivers/usb/gadget/function: " Jeff Layton
2023-09-28 11:02   ` [PATCH 14/87] drivers/usb/gadget/legacy: " Jeff Layton
2023-09-28 11:02   ` [PATCH 15/87] fs/9p: " Jeff Layton
2023-09-28 11:02   ` [PATCH 16/87] fs/adfs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 17/87] fs/affs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 18/87] fs/afs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 19/87] fs/autofs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 20/87] fs/befs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 21/87] fs/bfs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 22/87] fs/btrfs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 23/87] fs/ceph: " Jeff Layton
2023-09-28 11:02   ` [PATCH 24/87] fs/coda: " Jeff Layton
2023-09-28 11:02   ` [PATCH 25/87] fs/configfs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 26/87] fs/cramfs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 27/87] fs/debugfs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 28/87] fs/devpts: " Jeff Layton
2023-09-28 11:02   ` [PATCH 29/87] fs/efivarfs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 30/87] fs/efs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 31/87] fs/erofs: " Jeff Layton
2023-09-28 11:02     ` Jeff Layton
2023-09-28 11:02   ` [PATCH 32/87] fs/exfat: " Jeff Layton
2023-09-28 11:02   ` [PATCH 33/87] fs/ext2: " Jeff Layton
2023-09-28 11:02   ` [PATCH 34/87] fs/ext4: " Jeff Layton
2023-09-28 11:02   ` [f2fs-dev] [PATCH 35/87] fs/f2fs: convert to new inode {a, m}time accessors Jeff Layton
2023-09-28 11:02     ` [PATCH 35/87] fs/f2fs: convert to new inode {a,m}time accessors Jeff Layton
2023-09-28 11:02   ` [PATCH 36/87] fs/fat: " Jeff Layton
2023-09-28 11:02   ` [PATCH 37/87] fs/freevxfs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 38/87] fs/fuse: " Jeff Layton
2023-09-28 11:02   ` [PATCH 39/87] fs/gfs2: " Jeff Layton
2023-09-28 11:02   ` [PATCH 40/87] fs/hfs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 41/87] fs/hfsplus: " Jeff Layton
2023-09-28 11:02   ` [PATCH 42/87] fs/hostfs: " Jeff Layton
2023-09-28 11:02     ` Jeff Layton
2023-09-28 11:02   ` [PATCH 43/87] fs/hpfs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 44/87] fs/hugetlbfs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 45/87] fs/isofs: " Jeff Layton
2023-09-28 11:02   ` [PATCH 46/87] fs/jffs2: " Jeff Layton
2023-09-28 11:02     ` Jeff Layton
2023-09-28 11:02   ` [PATCH 47/87] fs/jfs: " Jeff Layton
2023-10-03 16:33     ` [Jfs-discussion] [PATCH 47/87] fs/jfs: convert to new inode {a, m}time accessors Dave Kleikamp
2023-09-28 11:02   ` [PATCH 48/87] fs/kernfs: convert to new inode {a,m}time accessors Jeff Layton
2023-09-28 11:02   ` [PATCH 49/87] fs/minix: " Jeff Layton
2023-09-28 11:02   ` [PATCH 50/87] fs/nfs: " Jeff Layton
2023-09-28 11:03   ` [PATCH 51/87] fs/nfsd: " Jeff Layton
2023-09-28 13:56     ` Chuck Lever
2023-09-28 14:09       ` Jeff Layton
2023-09-28 14:33         ` Chuck Lever
2023-09-28 11:03   ` [PATCH 52/87] fs/nilfs2: " Jeff Layton
2023-09-28 11:03     ` Jeff Layton
2023-09-28 11:03   ` [PATCH 53/87] fs/ntfs: " Jeff Layton
2023-09-28 11:03   ` [PATCH 54/87] fs/ntfs3: " Jeff Layton
2023-09-28 11:03   ` [PATCH 55/87] fs/ocfs2: " Jeff Layton
2023-09-28 11:03   ` [PATCH 56/87] fs/omfs: " Jeff Layton
2023-09-28 11:03   ` [PATCH 57/87] fs/openpromfs: " Jeff Layton
2023-09-28 11:03   ` [PATCH 58/87] fs/orangefs: " Jeff Layton
2023-09-28 11:03   ` [PATCH 59/87] fs/overlayfs: " Jeff Layton
2023-09-28 11:03   ` [PATCH 60/87] fs/proc: " Jeff Layton
2023-09-28 11:03   ` [PATCH 61/87] fs/pstore: " Jeff Layton
2023-09-28 11:03   ` [PATCH 62/87] fs/qnx4: " Jeff Layton
2023-09-28 12:41     ` Anders Larsen
2023-09-28 11:03   ` [PATCH 63/87] fs/qnx6: " Jeff Layton
2023-09-28 11:03   ` [PATCH 64/87] fs/ramfs: " Jeff Layton
2023-09-28 11:03   ` [PATCH 65/87] fs/reiserfs: " Jeff Layton
2023-09-28 11:03   ` [PATCH 66/87] fs/romfs: " Jeff Layton
2023-09-28 11:03   ` Jeff Layton [this message]
2023-09-28 11:03   ` [PATCH 68/87] fs/smb/server: " Jeff Layton
2023-09-28 11:03   ` [PATCH 69/87] fs/squashfs: " Jeff Layton
2023-09-28 11:03   ` [PATCH 70/87] fs/sysv: " Jeff Layton
2023-09-28 11:03   ` [PATCH 71/87] fs/tracefs: " Jeff Layton
2023-09-28 11:03   ` [PATCH 72/87] fs/ubifs: " Jeff Layton
2023-09-28 11:03     ` Jeff Layton
2023-09-28 11:03   ` [PATCH 73/87] fs/udf: " Jeff Layton
2023-09-28 11:03   ` [PATCH 74/87] fs/ufs: " Jeff Layton
2023-09-28 11:03   ` [PATCH 75/87] fs/vboxsf: " Jeff Layton
2023-09-28 11:03   ` [PATCH 76/87] fs/xfs: " Jeff Layton
2023-09-28 11:03   ` [PATCH 77/87] fs/zonefs: " Jeff Layton
2023-09-28 11:03   ` [PATCH 78/87] ipc: " Jeff Layton
2023-09-28 11:03   ` [PATCH 79/87] kernel/bpf: " Jeff Layton
2023-09-28 11:03   ` [PATCH 80/87] mm: " Jeff Layton
2023-09-28 11:03   ` [PATCH 81/87] net/sunrpc: " Jeff Layton
2023-09-28 11:03   ` [PATCH 82/87] security/apparmor: " Jeff Layton
2023-09-28 11:03   ` [PATCH 83/87] security/selinux: " Jeff Layton
2023-10-03 19:53     ` Paul Moore
2023-09-28 11:03   ` [PATCH 84/87] security: " Jeff Layton
2023-10-03 23:41     ` Paul Moore
2023-09-28 11:03 ` [PATCH 01/87] fs: new accessor methods for atime and mtime Jeff Layton
2023-09-28 11:03   ` Jeff Layton
2023-09-28 11:03   ` Jeff Layton
2023-09-28 11:03   ` Jeff Layton
2023-09-28 11:03   ` Jeff Layton
2023-09-28 11:03   ` [f2fs-dev] " Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230928110413.33032-66-jlayton@kernel.org \
    --to=jlayton@kernel.org \
    --cc=brauner@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lsahlber@redhat.com \
    --cc=pc@manguebit.com \
    --cc=samba-technical@lists.samba.org \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.