All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Steve Dickson <steved@redhat.com>
Cc: linux-nfs@vger.kernel.org, Trond Myklebust <trondmy@hammerspace.com>
Subject: [PATCH 3/3 RFC] export: nfsd_fh - always an answer to a well-formed question.
Date: Wed, 11 Oct 2023 15:58:02 +1100	[thread overview]
Message-ID: <20231011051131.24667-4-neilb@suse.de> (raw)
In-Reply-To: <20231011051131.24667-1-neilb@suse.de>

When the kernel asks mountd for some information it is important that
mountd reply as the kernel will not ask again.
When we don't have a useful reply we want the kernel to see this
as a transient failure.  This not currently (v6.6) any way to
communicate a transient failure.  The best we can do is give a
negative answer which is already expired.  This will at least
allow the kernel to ask again.

The kernel needs to be enhanced to not treat an entry that is already
expired as ever reliable.

Signed-off-by: NeilBrown <neilb@suse.de>
---
 support/export/cache.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/support/export/cache.c b/support/export/cache.c
index 5307f6c8d872..74cacea9f0cc 100644
--- a/support/export/cache.c
+++ b/support/export/cache.c
@@ -894,7 +894,7 @@ static void nfsd_fh(int f)
 		 * quiet rather than returning stale yet
 		 */
 		if (dev_missing)
-			goto out;
+			goto out_delay;
 	} else if (found->e_mountpoint &&
 	    !is_mountpoint(found->e_mountpoint[0]?
 			   found->e_mountpoint:
@@ -904,8 +904,7 @@ static void nfsd_fh(int f)
 		   xlog(L_WARNING, "%s not exported as %d not a mountpoint",
 		   found->e_path, found->e_mountpoint);
 		 */
-		/* FIXME we need to make sure we re-visit this later */
-		goto out;
+		goto out_delay;
 	}
 
 	bp = buf; blen = sizeof(buf);
@@ -934,6 +933,26 @@ out:
 	nfs_freeaddrinfo(ai);
 	free(dom);
 	xlog(D_CALL, "nfsd_fh: found %p path %s", found, found ? found->e_path : NULL);
+	return;
+
+out_delay:
+	/* We don't have a definitely answer to give the kernel - maybe we will later.
+	 * This could be because an export marked "mountpoint" isn't a mountpoint, or
+	 * because a mountpoint fails with a strange error like ETIMEDOUT as is possible
+	 * with an NFS mount marked "softerr" which is being re-exported.
+	 * If we tell the kernel nothing, it will never ask again, so we have
+	 * to give some answer.  A negative answer that has already expired
+	 * is the best we can do.
+	 */
+	bp = buf; blen = sizeof(buf);
+	qword_add(&bp, &blen, dom);
+	qword_addint(&bp, &blen, fsidtype);
+	qword_addhex(&bp, &blen, fsid, fsidlen);
+	qword_addint(&bp, &blen, time(NULL) - 1);
+	qword_addeol(&bp, &blen);
+	if (blen <= 0 || cache_write(f, buf, bp - buf) != bp - buf)
+		xlog(L_ERROR, "nfsd_fh: error writing reply");
+	xlog(D_AUTH, "unknown access to %s", *dom == '$' ? dom+1 : dom);
 }
 
 #ifdef HAVE_JUNCTION_SUPPORT
-- 
2.42.0


      parent reply	other threads:[~2023-10-11  5:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11  4:57 [PATCH 0/3 nfs-utils] fixes for error handling in nfsd_fh NeilBrown
2023-10-11  4:58 ` [PATCH 1/3] export: fix handling of error from match_fsid() NeilBrown
2023-10-11  4:58 ` [PATCH 2/3] export: add EACCES to the list of known path_lookup_error() errors NeilBrown
2023-10-11  4:58 ` NeilBrown [this message]

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=20231011051131.24667-4-neilb@suse.de \
    --to=neilb@suse.de \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    --cc=trondmy@hammerspace.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.