diff mbox

[RFC,2/2] exportfs: vet exports for subtree checking when testing the export fails

Message ID 1447865430-28434-2-git-send-email-jeff.layton@primarydata.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Layton Nov. 18, 2015, 4:50 p.m. UTC
I have a proposed kernel patch that would allow filesystems (such as
NFS) to opt out of subtree checking when they are exported. We do want
to warn people at export time however if that doesn't work. If we issued
a test_export that fails and don't have NFSEXP_NOSUBTREECHECK already set
in it, then try it again with that set. If that works then we know that
the filesystem requires NFSEXP_NOSUBTREECHECK be set.

Cc: Neil Brown <neilb@suse.de>
Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
---
 utils/exportfs/exportfs.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

Comments

J. Bruce Fields Nov. 18, 2015, 6:05 p.m. UTC | #1
On Wed, Nov 18, 2015 at 11:50:30AM -0500, Jeff Layton wrote:
> I have a proposed kernel patch that would allow filesystems (such as
> NFS) to opt out of subtree checking when they are exported. We do want
> to warn people at export time however if that doesn't work. If we issued
> a test_export that fails and don't have NFSEXP_NOSUBTREECHECK already set
> in it, then try it again with that set. If that works then we know that
> the filesystem requires NFSEXP_NOSUBTREECHECK be set.

Makes sense to me, ACK.--b.

> 
> Cc: Neil Brown <neilb@suse.de>
> Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
> ---
>  utils/exportfs/exportfs.c | 25 ++++++++++++++++++-------
>  1 file changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
> index cac01fc25f9a..1b704e85c024 100644
> --- a/utils/exportfs/exportfs.c
> +++ b/utils/exportfs/exportfs.c
> @@ -557,6 +557,20 @@ static int test_export(char *path, int opts)
>  }
>  
>  static void
> +validate_subtree_check(nfs_export *exp)
> +{
> +	char *path = exp->m_export.e_path;
> +
> +	if (!(exp->m_export.e_flags & NFSEXP_NOSUBTREECHECK)) {
> +		if (test_export(path, exp->m_export.e_flags | NFSEXP_NOSUBTREECHECK)) {
> +			xlog(L_ERROR, "%s does not support subtree checking", path);
> +			return;
> +		}
> +	}
> +	xlog(L_ERROR, "%s does not support NFS export", path);
> +}
> +
> +static void
>  validate_export(nfs_export *exp)
>  {
>  	/* Check that the given export point is potentially exportable.
> @@ -587,16 +601,13 @@ validate_export(nfs_export *exp)
>  
>  	if ((exp->m_export.e_flags & NFSEXP_FSID) || exp->m_export.e_uuid ||
>  	    fs_has_fsid) {
> -		if ( !test_export(path, exp->m_export.e_flags)) {
> -			xlog(L_ERROR, "%s does not support NFS export", path);
> -			return;
> -		}
> -	} else if ( ! test_export(path, exp->m_export.e_flags)) {
> +		if (!test_export(path, exp->m_export.e_flags))
> +			validate_subtree_check(exp);
> +	} else if (!test_export(path, exp->m_export.e_flags)) {
>  		if (test_export(path, exp->m_export.e_flags & NFSEXP_FSID))
>  			xlog(L_ERROR, "%s requires fsid= for NFS export", path);
>  		else
> -			xlog(L_ERROR, "%s does not support NFS export", path);
> -		return;
> +			validate_subtree_check(exp);
>  
>  	}
>  }
> -- 
> 2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index cac01fc25f9a..1b704e85c024 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -557,6 +557,20 @@  static int test_export(char *path, int opts)
 }
 
 static void
+validate_subtree_check(nfs_export *exp)
+{
+	char *path = exp->m_export.e_path;
+
+	if (!(exp->m_export.e_flags & NFSEXP_NOSUBTREECHECK)) {
+		if (test_export(path, exp->m_export.e_flags | NFSEXP_NOSUBTREECHECK)) {
+			xlog(L_ERROR, "%s does not support subtree checking", path);
+			return;
+		}
+	}
+	xlog(L_ERROR, "%s does not support NFS export", path);
+}
+
+static void
 validate_export(nfs_export *exp)
 {
 	/* Check that the given export point is potentially exportable.
@@ -587,16 +601,13 @@  validate_export(nfs_export *exp)
 
 	if ((exp->m_export.e_flags & NFSEXP_FSID) || exp->m_export.e_uuid ||
 	    fs_has_fsid) {
-		if ( !test_export(path, exp->m_export.e_flags)) {
-			xlog(L_ERROR, "%s does not support NFS export", path);
-			return;
-		}
-	} else if ( ! test_export(path, exp->m_export.e_flags)) {
+		if (!test_export(path, exp->m_export.e_flags))
+			validate_subtree_check(exp);
+	} else if (!test_export(path, exp->m_export.e_flags)) {
 		if (test_export(path, exp->m_export.e_flags & NFSEXP_FSID))
 			xlog(L_ERROR, "%s requires fsid= for NFS export", path);
 		else
-			xlog(L_ERROR, "%s does not support NFS export", path);
-		return;
+			validate_subtree_check(exp);
 
 	}
 }