All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Various attribute revalidation fixups
@ 2018-05-29 15:48 Trond Myklebust
  2018-05-29 15:48 ` [PATCH 1/5] NFS: Fix up sillyrename() Trond Myklebust
  0 siblings, 1 reply; 6+ messages in thread
From: Trond Myklebust @ 2018-05-29 15:48 UTC (permalink / raw
  To: linux-nfs

A set of short patches to fix up various issues with the attribute
revalidation, particularly when holding a delegation.

Trond Myklebust (5):
  NFS: Fix up sillyrename()
  NFS: Set the force revalidate flag if the inode is not completely
    initialised
  NFS: Ensure we revalidate the inode correctly after remove or rename
  NFS: Ensure we revalidate the inode correctly after setacl
  NFS: Fix up nfs_post_op_update_inode() to force ctime updates

 fs/nfs/dir.c      | 18 ++++++++++++++----
 fs/nfs/inode.c    |  7 ++++++-
 fs/nfs/nfs4proc.c |  3 ++-
 fs/nfs/unlink.c   | 10 ++++++++++
 4 files changed, 32 insertions(+), 6 deletions(-)

-- 
2.17.0


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

* [PATCH 1/5] NFS: Fix up sillyrename()
  2018-05-29 15:48 [PATCH 0/5] Various attribute revalidation fixups Trond Myklebust
@ 2018-05-29 15:48 ` Trond Myklebust
  2018-05-29 15:48   ` [PATCH 2/5] NFS: Set the force revalidate flag if the inode is not completely initialised Trond Myklebust
  0 siblings, 1 reply; 6+ messages in thread
From: Trond Myklebust @ 2018-05-29 15:48 UTC (permalink / raw
  To: linux-nfs

From: Trond Myklebust <trond.myklebust@primarydata.com>

Ensure that we register the fact that the inode ctime has changed.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/unlink.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c
index bf54fc9ae135..07f5e29ad7c6 100644
--- a/fs/nfs/unlink.c
+++ b/fs/nfs/unlink.c
@@ -448,6 +448,7 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
 	unsigned char silly[SILLYNAME_LEN + 1];
 	unsigned long long fileid;
 	struct dentry *sdentry;
+	struct inode *inode = d_inode(dentry);
 	struct rpc_task *task;
 	int            error = -EBUSY;
 
@@ -485,6 +486,8 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
 			goto out;
 	} while (d_inode(sdentry) != NULL); /* need negative lookup */
 
+	ihold(inode);
+
 	/* queue unlink first. Can't do this from rpc_release as it
 	 * has to allocate memory
 	 */
@@ -509,6 +512,12 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
 	case 0:
 		/* The rename succeeded */
 		nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
+		spin_lock(&inode->i_lock);
+		NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter();
+		NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE
+			| NFS_INO_INVALID_CTIME
+			| NFS_INO_REVAL_FORCED;
+		spin_unlock(&inode->i_lock);
 		d_move(dentry, sdentry);
 		break;
 	case -ERESTARTSYS:
@@ -519,6 +528,7 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
 	}
 	rpc_put_task(task);
 out_dput:
+	iput(inode);
 	dput(sdentry);
 out:
 	return error;
-- 
2.17.0


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

* [PATCH 2/5] NFS: Set the force revalidate flag if the inode is not completely initialised
  2018-05-29 15:48 ` [PATCH 1/5] NFS: Fix up sillyrename() Trond Myklebust
@ 2018-05-29 15:48   ` Trond Myklebust
  2018-05-29 15:48     ` [PATCH 3/5] NFS: Ensure we revalidate the inode correctly after remove or rename Trond Myklebust
  0 siblings, 1 reply; 6+ messages in thread
From: Trond Myklebust @ 2018-05-29 15:48 UTC (permalink / raw
  To: linux-nfs

From: Trond Myklebust <trond.myklebust@primarydata.com>

Ensure that a delegation doesn't cause us to skip initialising the inode
if it was incomplete when we exited nfs_fhget()

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/inode.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index bd15d0b57626..40a6cf6db4e8 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -448,6 +448,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st
 		/* We can't support update_atime(), since the server will reset it */
 		inode->i_flags |= S_NOATIME|S_NOCMTIME;
 		inode->i_mode = fattr->mode;
+		nfsi->cache_validity = 0;
 		if ((fattr->valid & NFS_ATTR_FATTR_MODE) == 0
 				&& nfs_server_capable(inode, NFS_CAP_MODE))
 			nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER);
@@ -534,6 +535,9 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st
 			inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
 		}
 
+		if (nfsi->cache_validity != 0)
+			nfsi->cache_validity |= NFS_INO_REVAL_FORCED;
+
 		nfs_setsecurity(inode, fattr, label);
 
 		nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
-- 
2.17.0


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

* [PATCH 3/5] NFS: Ensure we revalidate the inode correctly after remove or rename
  2018-05-29 15:48   ` [PATCH 2/5] NFS: Set the force revalidate flag if the inode is not completely initialised Trond Myklebust
@ 2018-05-29 15:48     ` Trond Myklebust
  2018-05-29 15:48       ` [PATCH 4/5] NFS: Ensure we revalidate the inode correctly after setacl Trond Myklebust
  0 siblings, 1 reply; 6+ messages in thread
From: Trond Myklebust @ 2018-05-29 15:48 UTC (permalink / raw
  To: linux-nfs

From: Trond Myklebust <trond.myklebust@primarydata.com>

We may need to revalidate the change attribute, ctime and the nlinks count.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/dir.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index ed20ff51f865..8c51083e1456 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1284,11 +1284,13 @@ static void nfs_drop_nlink(struct inode *inode)
 {
 	spin_lock(&inode->i_lock);
 	/* drop the inode if we're reasonably sure this is the last link */
-	if (inode->i_nlink == 1)
-		clear_nlink(inode);
+	if (inode->i_nlink > 0)
+		drop_nlink(inode);
+	NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter();
 	NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE
 		| NFS_INO_INVALID_CTIME
-		| NFS_INO_INVALID_OTHER;
+		| NFS_INO_INVALID_OTHER
+		| NFS_INO_REVAL_FORCED;
 	spin_unlock(&inode->i_lock);
 }
 
@@ -2071,7 +2073,15 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	} else
 		error = task->tk_status;
 	rpc_put_task(task);
-	nfs_mark_for_revalidate(old_inode);
+	/* Ensure the inode attributes are revalidated */
+	if (error == 0) {
+		spin_lock(&old_inode->i_lock);
+		NFS_I(old_inode)->attr_gencount = nfs_inc_attr_generation_counter();
+		NFS_I(old_inode)->cache_validity |= NFS_INO_INVALID_CHANGE
+			| NFS_INO_INVALID_CTIME
+			| NFS_INO_REVAL_FORCED;
+		spin_unlock(&old_inode->i_lock);
+	}
 out:
 	if (rehash)
 		d_rehash(rehash);
-- 
2.17.0


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

* [PATCH 4/5] NFS: Ensure we revalidate the inode correctly after setacl
  2018-05-29 15:48     ` [PATCH 3/5] NFS: Ensure we revalidate the inode correctly after remove or rename Trond Myklebust
@ 2018-05-29 15:48       ` Trond Myklebust
  2018-05-29 15:48         ` [PATCH 5/5] NFS: Fix up nfs_post_op_update_inode() to force ctime updates Trond Myklebust
  0 siblings, 1 reply; 6+ messages in thread
From: Trond Myklebust @ 2018-05-29 15:48 UTC (permalink / raw
  To: linux-nfs

From: Trond Myklebust <trond.myklebust@primarydata.com>

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/nfs4proc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 844eafbf1564..07a7f2d8f3e2 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5390,7 +5390,8 @@ static int __nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t bufl
 	 */
 	spin_lock(&inode->i_lock);
 	NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE
-		| NFS_INO_INVALID_CTIME;
+		| NFS_INO_INVALID_CTIME
+		| NFS_INO_REVAL_FORCED;
 	spin_unlock(&inode->i_lock);
 	nfs_access_zap_cache(inode);
 	nfs_zap_acl_cache(inode);
-- 
2.17.0


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

* [PATCH 5/5] NFS: Fix up nfs_post_op_update_inode() to force ctime updates
  2018-05-29 15:48       ` [PATCH 4/5] NFS: Ensure we revalidate the inode correctly after setacl Trond Myklebust
@ 2018-05-29 15:48         ` Trond Myklebust
  0 siblings, 0 replies; 6+ messages in thread
From: Trond Myklebust @ 2018-05-29 15:48 UTC (permalink / raw
  To: linux-nfs

We do not want to ignore ctime updates that originate from functions
such as link().

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 40a6cf6db4e8..5de724b1b90c 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1633,7 +1633,8 @@ int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 	nfs_fattr_set_barrier(fattr);
 	status = nfs_post_op_update_inode_locked(inode, fattr,
 			NFS_INO_INVALID_CHANGE
-			| NFS_INO_INVALID_CTIME);
+			| NFS_INO_INVALID_CTIME
+			| NFS_INO_REVAL_FORCED);
 	spin_unlock(&inode->i_lock);
 
 	return status;
-- 
2.17.0


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

end of thread, other threads:[~2018-05-29 15:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-29 15:48 [PATCH 0/5] Various attribute revalidation fixups Trond Myklebust
2018-05-29 15:48 ` [PATCH 1/5] NFS: Fix up sillyrename() Trond Myklebust
2018-05-29 15:48   ` [PATCH 2/5] NFS: Set the force revalidate flag if the inode is not completely initialised Trond Myklebust
2018-05-29 15:48     ` [PATCH 3/5] NFS: Ensure we revalidate the inode correctly after remove or rename Trond Myklebust
2018-05-29 15:48       ` [PATCH 4/5] NFS: Ensure we revalidate the inode correctly after setacl Trond Myklebust
2018-05-29 15:48         ` [PATCH 5/5] NFS: Fix up nfs_post_op_update_inode() to force ctime updates Trond Myklebust

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.