Skip to contentSkip to conversation

NFS: fix nfs_fetch_iversion()

PATCH In review [email protected] 3 participants 3 messages Mar 24, 2021 – Mar 25, 2021

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 NFS: fix nfs_fetch_iversion()

From: Trond Myklebust <[email protected]>

The change attribute is always set by all NFS client versions so get rid of the open-coded version.

Fixes 3cc55f4434b4 ("nfs: use change attribute for NFS re-exports")
---
 fs/nfs/export.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
fs/nfs/export.c +4 -11
index f2b34cfe286c..b347e3ce0cc8 100644
@@ -171,17 +171,10 @@ static u64 nfs_fetch_iversion(struct inode *inode)
 {
 	struct nfs_server *server = NFS_SERVER(inode);
 
-	/* Is this the right call?: */
-	nfs_revalidate_inode(server, inode);
-	/*
-	 * Also, note we're ignoring any returned error.  That seems to be
-	 * the practice for cache consistency information elsewhere in
-	 * the server, but I'm not sure why.
-	 */
-	if (server->nfs_client->rpc_ops->version >= 4)
-		return inode_peek_iversion_raw(inode);
-	else
-		return time_to_chattr(&inode->i_ctime);
+	if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_CHANGE |
+						   NFS_INO_REVAL_PAGECACHE))
+		__nfs_revalidate_inode(server, inode);
+	return inode_peek_iversion_raw(inode);
 }
 
 const struct export_operations nfs_export_ops = {
Signature · 1 line
2.30.2
#1 lore raw
Quoted 4 lines · On Wed, Mar 24, 2021 at 03:53:53PM -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

The change attribute is always set by all NFS client versions so get rid of the open-coded version.

Thanks!

I'm unclear whether there's a user-visible bug here or whether it's mainly cleanup?

--b.

Quoted 35 lines
Fixes 3cc55f4434b4 ("nfs: use change attribute for NFS re-exports")
---
 fs/nfs/export.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
fs/nfs/export.c +4 -11
index f2b34cfe286c..b347e3ce0cc8 100644
@@ -171,17 +171,10 @@ static u64 nfs_fetch_iversion(struct inode *inode)
 {
 	struct nfs_server *server = NFS_SERVER(inode);
 
-	/* Is this the right call?: */
-	nfs_revalidate_inode(server, inode);
-	/*
-	 * Also, note we're ignoring any returned error.  That seems to be
-	 * the practice for cache consistency information elsewhere in
-	 * the server, but I'm not sure why.
-	 */
-	if (server->nfs_client->rpc_ops->version >= 4)
-		return inode_peek_iversion_raw(inode);
-	else
-		return time_to_chattr(&inode->i_ctime);
+	if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_CHANGE |
+						   NFS_INO_REVAL_PAGECACHE))
+		__nfs_revalidate_inode(server, inode);
+	return inode_peek_iversion_raw(inode);
 }
 
 const struct export_operations nfs_export_ops = {
Signature · 1 line
2.30.2
#2 lore raw
Quoted 12 lines · J. Bruce Fields
Quoted 5 lines · On Wed, Mar 24, 2021 at 03:53:53PM -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

The change attribute is always set by all NFS client versions so get rid
of the open-coded version.

Thanks!

I'm unclear whether there's a user-visible bug here or whether it's mainly cleanup?

It is mainly about ensuring that revalidation is done correctly. It is a performance issue, but is also about ensuring that we all feed into the same validity checking code.

Quoted 43 lines

--b.

Quoted 40 lines
Fixes 3cc55f4434b4 ("nfs: use change attribute for NFS re-

exports")

---
 fs/nfs/export.c | 15 ++++-----------

 1 file changed, 4 insertions(+), 11 deletions(-)
fs/nfs/export.c +0 -0
index f2b34cfe286c..b347e3ce0cc8 100644
@@ -171,17 +171,10 @@ static u64 nfs_fetch_iversion(struct inode
 *inode)
  {
         struct nfs_server *server = NFS_SERVER(inode);


-       /* Is this the right call?: */
-       nfs_revalidate_inode(server, inode);
-       /*
-        * Also, note we're ignoring any returned error.  That seems to be
-        * the practice for cache consistency information elsewhere in
-        * the server, but I'm not sure why.
-        */
-       if (server->nfs_client->rpc_ops->version >= 4)
-               return inode_peek_iversion_raw(inode);
-       else
-               return time_to_chattr(&inode->i_ctime); +       if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_CHANGE | +
NFS_INO_REVAL_PAGECACHE))
+               __nfs_revalidate_inode(server, inode);
+       return inode_peek_iversion_raw(inode);
 }

 const struct export_operations nfs_export_ops = {

Signature · 1 line
2.30.2
Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]