Skip to contentSkip to conversation

NFSD: Fix nfs4_delegation_stat()

PATCH In review [email protected] 2 participants 2 messages Sep 9, 2024

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 NFSD: Fix nfs4_delegation_stat()

From: Chuck Lever <[email protected]>

The xfstests workflow on NFSv4.2 exhausts the capacity of both the main and scratch devices (backed by xfs) about half-way through each test run.

Deleting all visible files on both devices frees only a little bit of space. The test exports can be unshared but not unmounted (EBUSY). Looks like unlinked but still open files, maybe.

Bisected to commit c495f65ad2ff ("nfsd: fix initial getattr on write delegation")

Ensure nfsd_file objects acquired by find_rw_file() are released.

Fixes c495f65ad2ff ("nfsd: fix initial getattr on write delegation")
---
 fs/nfsd/nfs4state.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Tested, problem no longer reproducible. I intend to squash this into c495f65ad2ff.

fs/nfsd/nfs4state.c +7 -5
index 252297b98a2e..cb5a9ab451c5 100644
@@ -5920,6 +5920,7 @@ nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh,
 {
 	struct nfsd_file *nf = find_rw_file(dp->dl_stid.sc_file);
 	struct path path;
+	int rc;
 
 	if (!nf)
 		return false;
@@ -5927,11 +5928,12 @@ nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh,
 	path.mnt = currentfh->fh_export->ex_path.mnt;
 	path.dentry = file_dentry(nf->nf_file);
 
-	if (vfs_getattr(&path, stat,
-			(STATX_SIZE | STATX_CTIME | STATX_CHANGE_COOKIE),
-			AT_STATX_SYNC_AS_STAT))
-		return false;
-	return true;
+	rc = vfs_getattr(&path, stat,
+			 (STATX_SIZE | STATX_CTIME | STATX_CHANGE_COOKIE),
+			 AT_STATX_SYNC_AS_STAT);
+
+	nfsd_file_put(nf);
+	return rc == 0;
 }
 
 /*
Signature · 1 line
2.45.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 44 lines · On Mon, 2024-09-09 at 10:15 -0400, [email protected] wrote:

From: Chuck Lever <[email protected]>

The xfstests workflow on NFSv4.2 exhausts the capacity of both the main and scratch devices (backed by xfs) about half-way through each test run.

Deleting all visible files on both devices frees only a little bit of space. The test exports can be unshared but not unmounted (EBUSY). Looks like unlinked but still open files, maybe.

Bisected to commit c495f65ad2ff ("nfsd: fix initial getattr on write delegation")

Ensure nfsd_file objects acquired by find_rw_file() are released.

Fixes c495f65ad2ff ("nfsd: fix initial getattr on write delegation")
---
 fs/nfsd/nfs4state.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Tested, problem no longer reproducible. I intend to squash this into c495f65ad2ff.

fs/nfsd/nfs4state.c +1 -4
index 252297b98a2e..cb5a9ab451c5 100644
@@ -5920,6 +5920,7 @@ nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh,
 {
 	struct nfsd_file *nf = find_rw_file(dp->dl_stid.sc_file);
 	struct path path;
+	int rc;
 
 	if (!nf)
 		return false;
@@ -5927,11 +5928,12 @@ nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh,
 	path.mnt = currentfh->fh_export->ex_path.mnt;
 	path.dentry = file_dentry(nf->nf_file);
 
-	if (vfs_getattr(&path, stat,
-			(STATX_SIZE | STATX_CTIME | STATX_CHANGE_COOKIE),
-			AT_STATX_SYNC_AS_STAT))
-		return false;

fs/nfsd/nfs4state.c nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh, · line 5939

Quoted 10 lines
fs/nfsd/nfs4state.c +6 -1
-	return true;
+	rc = vfs_getattr(&path, stat,
+			 (STATX_SIZE | STATX_CTIME | STATX_CHANGE_COOKIE),
+			 AT_STATX_SYNC_AS_STAT);
+
+	nfsd_file_put(nf);
+	return rc == 0;
 }
 
 /*

Mea culpa!