Skip to contentSkip to conversation

NFSv4: Keep delegation post REMOVE in case server supports preserved-unliked

RFC PATCH New Sagi Grimberg 1 participant 1 message Apr 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 NFSv4: Keep delegation post REMOVE in case server supports preserved-unliked

If the server returns NFS4_OPEN_RESULT_PRESERVE_UNLINKED, it means that the file handle is kept alive for as long as the file is opened (or its delegation is held). Hence, we can skip re-opening the file and returning the delegation in this case.

---
 fs/nfs/nfs4proc.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
fs/nfs/nfs4proc.c +10 -3
index 91bcf67bd743..129424eacf99 100644
@@ -4921,10 +4921,17 @@ static int nfs4_proc_remove(struct inode *dir, struct dentry *dentry)
 	int err;
 
 	if (inode) {
-		if (inode->i_nlink == 1)
-			nfs4_inode_return_delegation(inode);
-		else
+		/*
+		 * nlink > 1 or server supports NFS_INO_PRESERVE_UNLINKED
+		 * the inode is not going away. we're promised to keep the
+		 * inode alive past REMOVE for as long as any client reference
+		 * remains. So we can keep the delegation around.
+		 */
+		if (inode->i_nlink > 1 ||
+		    test_bit(NFS_INO_PRESERVE_UNLINKED, &NFS_I(inode)->flags))
 			nfs4_inode_make_writeable(inode);
+		else
+			nfs4_inode_return_delegation(inode);
 	}
 	do {
 		err = _nfs4_proc_remove(dir, &dentry->d_name, NF4REG);
Signature · 1 line
2.43.0