Skip to contentSkip to conversation

NFSv4: retry GETATTR if GET_DIR_DELEGATION failed

PATCH New Olga Kornievskaia 1 participant 1 message Apr 15

Subsystems (2)
lore
Share & tools
lore

Olga Kornievskaia

author reviewer
#0 lore raw

PATCH v2 1/1 NFSv4: retry GETATTR if GET_DIR_DELEGATION failed

Currently, getting a directory delegation is opportinistic and gets added to an existing GETATTR that's trying to retrieve some needed attributes. However, GET_DIRDELEGATION can fail and that currently causes a GETATTR to fail and an error is propagated to the user.

Instead, the original GETATTR should be retried without requesting a directory delegation. Also, now chosing to clear asking for the direct delegation for this specific inode.

Fixes 156b09482933 ("NFS: Request a directory delegation on ACCESS, CREATE, and UNLINK")

-- v2:
BSD server can return NFS4ERR_NOFILEHANDLE when requesting directory delegations on "/" that isn't exported.

---
 fs/nfs/nfs4proc.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/nfs/nfs4proc.c +9 -0
index 91bcf67bd743..83c596a8cc20 100644
@@ -4469,6 +4469,14 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
 		case -ENOTSUPP:
 		case -EOPNOTSUPP:
 			server->caps &= ~NFS_CAP_DIR_DELEG;
+			break;
+		case -NFS4ERR_NOFILEHANDLE:
+		case -NFS4ERR_INVAL:
+		case -NFS4ERR_IO:
+		case -NFS4ERR_DIRDELEG_UNAVAIL:
+		case -NFS4ERR_NOTDIR:
+			clear_bit(NFS_INO_REQ_DIR_DELEG, &(NFS_I(inode)->flags));
+			status = -EAGAIN;
 		}
 	}
 
@@ -4490,6 +4498,7 @@ int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
 		default:
 			err = nfs4_handle_exception(server, err, &exception);
 			break;
+		case -EAGAIN:
 		case -ENOTSUPP:
 		case -EOPNOTSUPP:
 			exception.retry = true;
Signature · 1 line
2.52.0