All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <cel@kernel.org>
To: NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: <linux-nfs@vger.kernel.org>, Chuck Lever <chuck.lever@oracle.com>
Subject: [PATCH v6 3/6] NFSD: Recover from vfs_getattr() failure in nfsd_file_get_dio_attrs()
Date: Wed,  8 Oct 2025 09:52:27 -0400	[thread overview]
Message-ID: <20251008135230.2629-4-cel@kernel.org> (raw)
In-Reply-To: <20251008135230.2629-1-cel@kernel.org>

From: Chuck Lever <chuck.lever@oracle.com>

A vfs_getattr() failure is rare but not totally impossible. It
typically means nfsd_do_file_acquire() raced with the file system
being shut down. Ensure the nfsd_file is not leaked in this case.

Fixes: d11f6cd1bb4a ("NFSD: filecache: add STATX_DIOALIGN and STATX_DIO_READ_ALIGN support")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfsd/filecache.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index a238b6725008..482feb0b55ad 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -1198,8 +1198,11 @@ nfsd_file_do_acquire(struct svc_rqst *rqstp, struct net *net,
 			}
 			status = nfserrno(ret);
 			trace_nfsd_file_open(nf, status);
-			if (status == nfs_ok)
+			if (status == nfs_ok) {
 				status = nfsd_file_get_dio_attrs(fhp, nf);
+				if (status != nfs_ok)
+					goto construction_err;
+			}
 		}
 	} else
 		status = nfserr_jukebox;
-- 
2.51.0


  parent reply	other threads:[~2025-10-08 13:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-08 13:52 [PATCH v6 0/6] NFSD direct I/O read Chuck Lever
2025-10-08 13:52 ` [PATCH v6 1/6] nfsd: fix refcount leak in nfsd_set_fh_dentry() Chuck Lever
2025-10-08 14:13   ` Chuck Lever
2025-10-08 13:52 ` [PATCH v6 2/6] NFSD: Prevent a NULL pointer dereference in fh_getattr() Chuck Lever
2025-10-08 13:52 ` Chuck Lever [this message]
2025-10-08 15:03   ` [PATCH v6 3/6] NFSD: Recover from vfs_getattr() failure in nfsd_file_get_dio_attrs() Jeff Layton
2025-10-08 15:08     ` Chuck Lever
2025-10-08 13:52 ` [PATCH v6 4/6] NFSD: pass nfsd_file to nfsd_iter_read() Chuck Lever
2025-10-08 13:52 ` [PATCH v6 5/6] NFSD: Relocate the xdr_reserve_space_vec() call site Chuck Lever
2025-10-08 13:52 ` [PATCH v6 6/6] NFSD: Implement NFSD_IO_DIRECT for NFS READ Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251008135230.2629-4-cel@kernel.org \
    --to=cel@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=dai.ngo@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.