Skip to contentSkip to conversation

mountd: Ignore transient and non-fatal filesystem errors in nfsd_export

PATCH In review [email protected] 4 participants 5 messages Sep 8, 2020 – Sep 18, 2020

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 mountd: Ignore transient and non-fatal filesystem errors in nfsd_export

From: Trond Myklebust <[email protected]>

If the mount point check in nfsd_export fails due to a transient error, then ignore it to avoid spurious NFSERR_STALE errors being returned by knfsd.

---
 utils/mountd/cache.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
utils/mountd/cache.c +8 -2
index 6cba2883026f..93e868341d15 100644
@@ -1411,7 +1411,10 @@ static void nfsd_export(int f)
 
 		if (mp && !*mp)
 			mp = found->m_export.e_path;
-		if (mp && !is_mountpoint(mp))
+		errno = 0;
+		if (mp && !is_mountpoint(mp)) {
+			if (errno != 0 && !path_lookup_error(errno))
+				goto out;
 			/* Exportpoint is not mounted, so tell kernel it is
 			 * not available.
 			 * This will cause it not to appear in the V4 Pseudo-root
@@ -1420,9 +1423,12 @@ static void nfsd_export(int f)
 			 * And filehandle for this mountpoint from an earlier
 			 * mount will block in nfsd.fh lookup.
 			 */
+			xlog(L_WARNING,
+			     "Cannot export path '%s': not a mountpoint",
+			     path);
 			dump_to_cache(f, buf, sizeof(buf), dom, path,
 				      NULL, 60);
-		else if (dump_to_cache(f, buf, sizeof(buf), dom, path,
+		} else if (dump_to_cache(f, buf, sizeof(buf), dom, path,
 					 &found->m_export, 0) < 0) {
 			xlog(L_WARNING,
 			     "Cannot export %s, possibly unsupported filesystem"
Signature · 1 line
2.26.2
#1 lore raw
Quoted 5 lines · On Tue, Sep 08, 2020 at 05:19:58PM -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

If the mount point check in nfsd_export fails due to a transient error, then ignore it to avoid spurious NFSERR_STALE errors being returned by knfsd.

What sort of transient errors?

I guess this makes the upcall (and the original rpc) eventually time out?

--b.

Quoted 38 lines
---
 utils/mountd/cache.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
utils/mountd/cache.c +8 -2
index 6cba2883026f..93e868341d15 100644
@@ -1411,7 +1411,10 @@ static void nfsd_export(int f)
 
 		if (mp && !*mp)
 			mp = found->m_export.e_path;
-		if (mp && !is_mountpoint(mp))
+		errno = 0;
+		if (mp && !is_mountpoint(mp)) {
+			if (errno != 0 && !path_lookup_error(errno))
+				goto out;
 			/* Exportpoint is not mounted, so tell kernel it is
 			 * not available.
 			 * This will cause it not to appear in the V4 Pseudo-root
@@ -1420,9 +1423,12 @@ static void nfsd_export(int f)
 			 * And filehandle for this mountpoint from an earlier
 			 * mount will block in nfsd.fh lookup.
 			 */
+			xlog(L_WARNING,
+			     "Cannot export path '%s': not a mountpoint",
+			     path);
 			dump_to_cache(f, buf, sizeof(buf), dom, path,
 				      NULL, 60);
-		else if (dump_to_cache(f, buf, sizeof(buf), dom, path,
+		} else if (dump_to_cache(f, buf, sizeof(buf), dom, path,
 					 &found->m_export, 0) < 0) {
 			xlog(L_WARNING,
 			     "Cannot export %s, possibly unsupported filesystem"
Signature · 1 line
2.26.2
#2 lore raw
Quoted 9 lines · J. Bruce Fields
Quoted 7 lines · On Tue, Sep 08, 2020 at 05:19:58PM -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

If the mount point check in nfsd_export fails due to a transient error,
then ignore it to avoid spurious NFSERR_STALE errors being returned by
knfsd.

Quoted 4 lines

What sort of transient errors?

I guess this makes the upcall (and the original rpc) eventually time out?

The point here is that is_mountpoint() is making the assumption that _any_ error from stat() can be used to infer that there is nothing mounted. In reality, only a subset of errors allow it to make that assumption (specifically the errors ELOOP, ENAMETOOLONG, ENOENT, and ENOTDIR).

In our case, we're seeing a problem when the underlying filesystem is a soft mounted NFSv4.2 client (i.e. we're running our Hammerspace use case of proxying NFSv4.2 to legacy NFSv3 clients) and that NFS4.2 mount times out due to a reboot of the underlying server, for instance.

So, yes, in that case we want the upcall to time out instead of poking knfsd into declaring that the directory is stale.

Quoted 46 lines

--b.

Quoted 43 lines
---
 utils/mountd/cache.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
utils/mountd/cache.c +4 -1
index 6cba2883026f..93e868341d15 100644
@@ -1411,7 +1411,10 @@ static void nfsd_export(int f)
 
 		if (mp && !*mp)
 			mp = found->m_export.e_path;
-		if (mp && !is_mountpoint(mp))
+		errno = 0;
+		if (mp && !is_mountpoint(mp)) {
+			if (errno != 0 && !path_lookup_error(errno))
+				goto out;
 			/* Exportpoint is not mounted, so tell kernel

it is

utils/mountd/cache.c +0 -0
 			 * not available.
 			 * This will cause it not to appear in the V4

Pseudo-root

utils/mountd/cache.c +0 -0
@@ -1420,9 +1423,12 @@ static void nfsd_export(int f)
 			 * And filehandle for this mountpoint from an

earlier

utils/mountd/cache.c +2 -0
 			 * mount will block in nfsd.fh lookup.
 			 */
+			xlog(L_WARNING,
+			     "Cannot export path '%s': not a

mountpoint",

utils/mountd/cache.c +2 -1
+			     path);
 			dump_to_cache(f, buf, sizeof(buf), dom, path,
 				      NULL, 60);
-		else if (dump_to_cache(f, buf, sizeof(buf), dom, path,
+		} else if (dump_to_cache(f, buf, sizeof(buf), dom,

path,

utils/mountd/cache.c +0 -0
 					 &found->m_export, 0) < 0) {
 			xlog(L_WARNING,
 			     "Cannot export %s, possibly unsupported

filesystem"

Signature · 1 line
2.26.2
Signature · 5 lines
Trond Myklebust
CTO, Hammerspace Inc
4984 El Camino Real, Suite 208
Los Altos, CA 94022
www.hammer.space
#3 lore raw
Quoted 21 lines · Trond Myklebust
Quoted 9 lines · J. Bruce Fields
Quoted 7 lines · On Tue, Sep 08, 2020 at 05:19:58PM -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

If the mount point check in nfsd_export fails due to a transient error,
then ignore it to avoid spurious NFSERR_STALE errors being returned by
knfsd.

Quoted 4 lines

What sort of transient errors?

I guess this makes the upcall (and the original rpc) eventually time out?

The point here is that is_mountpoint() is making the assumption that _any_ error from stat() can be used to infer that there is nothing mounted. In reality, only a subset of errors allow it to make that assumption (specifically the errors ELOOP, ENAMETOOLONG, ENOENT, and ENOTDIR).

Quoted 7 lines

In our case, we're seeing a problem when the underlying filesystem is a soft mounted NFSv4.2 client (i.e. we're running our Hammerspace use case of proxying NFSv4.2 to legacy NFSv3 clients) and that NFS4.2 mount times out due to a reboot of the underlying server, for instance.

So, yes, in that case we want the upcall to time out instead of poking knfsd into declaring that the directory is stale.

Thanks for the explanation, I guess I agree that's the best you can do in that situation.

--b.

Quoted 50 lines
Quoted 43 lines
Quoted 43 lines
---
 utils/mountd/cache.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
utils/mountd/cache.c +4 -1
index 6cba2883026f..93e868341d15 100644
@@ -1411,7 +1411,10 @@ static void nfsd_export(int f)
 
 		if (mp && !*mp)
 			mp = found->m_export.e_path;
-		if (mp && !is_mountpoint(mp))
+		errno = 0;
+		if (mp && !is_mountpoint(mp)) {
+			if (errno != 0 && !path_lookup_error(errno))
+				goto out;
 			/* Exportpoint is not mounted, so tell kernel

it is

utils/mountd/cache.c +0 -0
 			 * not available.
 			 * This will cause it not to appear in the V4

Pseudo-root

utils/mountd/cache.c +0 -0
@@ -1420,9 +1423,12 @@ static void nfsd_export(int f)
 			 * And filehandle for this mountpoint from an

earlier

utils/mountd/cache.c +2 -0
 			 * mount will block in nfsd.fh lookup.
 			 */
+			xlog(L_WARNING,
+			     "Cannot export path '%s': not a

mountpoint",

utils/mountd/cache.c +2 -1
+			     path);
 			dump_to_cache(f, buf, sizeof(buf), dom, path,
 				      NULL, 60);
-		else if (dump_to_cache(f, buf, sizeof(buf), dom, path,
+		} else if (dump_to_cache(f, buf, sizeof(buf), dom,

path,

utils/mountd/cache.c +0 -0
 					 &found->m_export, 0) < 0) {
 			xlog(L_WARNING,
 			     "Cannot export %s, possibly unsupported

filesystem"

Signature · 1 line
2.26.2
Signature · 5 lines
Trond Myklebust
CTO, Hammerspace Inc
4984 El Camino Real, Suite 208
Los Altos, CA 94022
www.hammer.space
#4 lore raw
In reply to [email protected]
Quoted 7 lines · On 9/8/20 5:19 PM, [email protected] wrote:

From: Trond Myklebust <[email protected]>

If the mount point check in nfsd_export fails due to a transient error, then ignore it to avoid spurious NFSERR_STALE errors being returned by knfsd.

Committed... (tag: nfs-utils-2-5-2-rc5)

steved.

Quoted 35 lines
---
 utils/mountd/cache.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
utils/mountd/cache.c +8 -2
index 6cba2883026f..93e868341d15 100644
@@ -1411,7 +1411,10 @@ static void nfsd_export(int f)
 
 		if (mp && !*mp)
 			mp = found->m_export.e_path;
-		if (mp && !is_mountpoint(mp))
+		errno = 0;
+		if (mp && !is_mountpoint(mp)) {
+			if (errno != 0 && !path_lookup_error(errno))
+				goto out;
 			/* Exportpoint is not mounted, so tell kernel it is
 			 * not available.
 			 * This will cause it not to appear in the V4 Pseudo-root
@@ -1420,9 +1423,12 @@ static void nfsd_export(int f)
 			 * And filehandle for this mountpoint from an earlier
 			 * mount will block in nfsd.fh lookup.
 			 */
+			xlog(L_WARNING,
+			     "Cannot export path '%s': not a mountpoint",
+			     path);
 			dump_to_cache(f, buf, sizeof(buf), dom, path,
 				      NULL, 60);
-		else if (dump_to_cache(f, buf, sizeof(buf), dom, path,
+		} else if (dump_to_cache(f, buf, sizeof(buf), dom, path,
 					 &found->m_export, 0) < 0) {
 			xlog(L_WARNING,
 			     "Cannot export %s, possibly unsupported filesystem"