* [RFC PATCH 1/2] exportfs: pass export option flags to the kernel when testing export
@ 2015-11-18 16:50 Jeff Layton
2015-11-18 16:50 ` [RFC PATCH 2/2] exportfs: vet exports for subtree checking when testing the export fails Jeff Layton
2015-11-18 19:16 ` [RFC PATCH 1/2] exportfs: pass export option flags to the kernel when testing export Jeff Layton
0 siblings, 2 replies; 5+ messages in thread
From: Jeff Layton @ 2015-11-18 16:50 UTC (permalink / raw)
To: steved; +Cc: neilb, linux-nfs, bfields
test_export takes a flag that just says whether to pass in the fsid or
not. This means that all we can test is the NFSEXP_FSIDi flag.
Instead of doing that, pass in the actual export options that we
intend to use (sometimes or'ed with NFSEXP_FSID to test whether that
might be the reason for the failure).
This allows us to test the actual export options that we plan to use,
and can allow the kernel to vet them properly before mount time.
The rationale here is a patch that I have that will add the ability
for filesystems to opt out of subtree checking when they can't
properly support it.
Cc: Neil Brown <neilb@suse.de>
Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
---
utils/exportfs/exportfs.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index c7a79a69b5d6..cac01fc25f9a 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -531,7 +531,7 @@ static int can_test(void)
return 1;
}
-static int test_export(char *path, int with_fsid)
+static int test_export(char *path, int opts)
{
/* beside max path, buf size should take protocol str into account */
char buf[NFS_MAXPATHLEN+1+64] = { 0 };
@@ -545,7 +545,7 @@ static int test_export(char *path, int with_fsid)
qword_add(&bp, &len, path);
if (len < 1)
return 0;
- snprintf(bp, len, " 3 %d 65534 65534 0\n", with_fsid ? NFSEXP_FSID : 0);
+ snprintf(bp, len, " 3 %d 65534 65534 0\n", opts);
fd = open("/proc/net/rpc/nfsd.export/channel", O_WRONLY);
if (fd < 0)
return 0;
@@ -587,12 +587,12 @@ 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, 1)) {
+ 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, 0)) {
- if (test_export(path, 1))
+ } 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);
--
2.4.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [RFC PATCH 2/2] exportfs: vet exports for subtree checking when testing the export fails
2015-11-18 16:50 [RFC PATCH 1/2] exportfs: pass export option flags to the kernel when testing export Jeff Layton
@ 2015-11-18 16:50 ` Jeff Layton
2015-11-18 18:05 ` J. Bruce Fields
2015-11-18 19:16 ` [RFC PATCH 1/2] exportfs: pass export option flags to the kernel when testing export Jeff Layton
1 sibling, 1 reply; 5+ messages in thread
From: Jeff Layton @ 2015-11-18 16:50 UTC (permalink / raw)
To: steved; +Cc: neilb, linux-nfs, bfields
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(-)
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 2/2] exportfs: vet exports for subtree checking when testing the export fails
2015-11-18 16:50 ` [RFC PATCH 2/2] exportfs: vet exports for subtree checking when testing the export fails Jeff Layton
@ 2015-11-18 18:05 ` J. Bruce Fields
0 siblings, 0 replies; 5+ messages in thread
From: J. Bruce Fields @ 2015-11-18 18:05 UTC (permalink / raw)
To: Jeff Layton; +Cc: steved, neilb, linux-nfs
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 1/2] exportfs: pass export option flags to the kernel when testing export
2015-11-18 16:50 [RFC PATCH 1/2] exportfs: pass export option flags to the kernel when testing export Jeff Layton
2015-11-18 16:50 ` [RFC PATCH 2/2] exportfs: vet exports for subtree checking when testing the export fails Jeff Layton
@ 2015-11-18 19:16 ` Jeff Layton
2015-11-18 19:19 ` Steve Dickson
1 sibling, 1 reply; 5+ messages in thread
From: Jeff Layton @ 2015-11-18 19:16 UTC (permalink / raw)
To: steved; +Cc: neilb, linux-nfs, bfields
On Wed, 18 Nov 2015 11:50:29 -0500
Jeff Layton <jlayton@poochiereds.net> wrote:
> test_export takes a flag that just says whether to pass in the fsid or
> not. This means that all we can test is the NFSEXP_FSIDi flag.
>
> Instead of doing that, pass in the actual export options that we
> intend to use (sometimes or'ed with NFSEXP_FSID to test whether that
> might be the reason for the failure).
>
> This allows us to test the actual export options that we plan to use,
> and can allow the kernel to vet them properly before mount time.
>
> The rationale here is a patch that I have that will add the ability
> for filesystems to opt out of subtree checking when they can't
> properly support it.
>
> Cc: Neil Brown <neilb@suse.de>
> Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
> ---
> utils/exportfs/exportfs.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
> index c7a79a69b5d6..cac01fc25f9a 100644
> --- a/utils/exportfs/exportfs.c
> +++ b/utils/exportfs/exportfs.c
> @@ -531,7 +531,7 @@ static int can_test(void)
> return 1;
> }
>
> -static int test_export(char *path, int with_fsid)
> +static int test_export(char *path, int opts)
> {
> /* beside max path, buf size should take protocol str into account */
> char buf[NFS_MAXPATHLEN+1+64] = { 0 };
> @@ -545,7 +545,7 @@ static int test_export(char *path, int with_fsid)
> qword_add(&bp, &len, path);
> if (len < 1)
> return 0;
> - snprintf(bp, len, " 3 %d 65534 65534 0\n", with_fsid ? NFSEXP_FSID : 0);
> + snprintf(bp, len, " 3 %d 65534 65534 0\n", opts);
> fd = open("/proc/net/rpc/nfsd.export/channel", O_WRONLY);
> if (fd < 0)
> return 0;
> @@ -587,12 +587,12 @@ 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, 1)) {
> + 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, 0)) {
> - if (test_export(path, 1))
> + } else if ( ! test_export(path, exp->m_export.e_flags)) {
> + if (test_export(path, exp->m_export.e_flags & NFSEXP_FSID))
Duh, that should of course be "exp->m_export.e_flags | NFSEXP_FSID".
I'll plan to resend after I wait a bit for others to comment. Please
don't merge this as-is though -- it obviously needs better testing.
We might be able to simplify the above logic a little too...hmmm...
> xlog(L_ERROR, "%s requires fsid= for NFS export", path);
> else
> xlog(L_ERROR, "%s does not support NFS export", path);
--
Jeff Layton <jlayton@poochiereds.net>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 1/2] exportfs: pass export option flags to the kernel when testing export
2015-11-18 19:16 ` [RFC PATCH 1/2] exportfs: pass export option flags to the kernel when testing export Jeff Layton
@ 2015-11-18 19:19 ` Steve Dickson
0 siblings, 0 replies; 5+ messages in thread
From: Steve Dickson @ 2015-11-18 19:19 UTC (permalink / raw)
To: Jeff Layton; +Cc: neilb, linux-nfs, bfields
On 11/18/2015 02:16 PM, Jeff Layton wrote:
> On Wed, 18 Nov 2015 11:50:29 -0500
> Jeff Layton <jlayton@poochiereds.net> wrote:
>
>> test_export takes a flag that just says whether to pass in the fsid or
>> not. This means that all we can test is the NFSEXP_FSIDi flag.
>>
>> Instead of doing that, pass in the actual export options that we
>> intend to use (sometimes or'ed with NFSEXP_FSID to test whether that
>> might be the reason for the failure).
>>
>> This allows us to test the actual export options that we plan to use,
>> and can allow the kernel to vet them properly before mount time.
>>
>> The rationale here is a patch that I have that will add the ability
>> for filesystems to opt out of subtree checking when they can't
>> properly support it.
>>
>> Cc: Neil Brown <neilb@suse.de>
>> Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
>> ---
>> utils/exportfs/exportfs.c | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
>> index c7a79a69b5d6..cac01fc25f9a 100644
>> --- a/utils/exportfs/exportfs.c
>> +++ b/utils/exportfs/exportfs.c
>> @@ -531,7 +531,7 @@ static int can_test(void)
>> return 1;
>> }
>>
>> -static int test_export(char *path, int with_fsid)
>> +static int test_export(char *path, int opts)
>> {
>> /* beside max path, buf size should take protocol str into account */
>> char buf[NFS_MAXPATHLEN+1+64] = { 0 };
>> @@ -545,7 +545,7 @@ static int test_export(char *path, int with_fsid)
>> qword_add(&bp, &len, path);
>> if (len < 1)
>> return 0;
>> - snprintf(bp, len, " 3 %d 65534 65534 0\n", with_fsid ? NFSEXP_FSID : 0);
>> + snprintf(bp, len, " 3 %d 65534 65534 0\n", opts);
>> fd = open("/proc/net/rpc/nfsd.export/channel", O_WRONLY);
>> if (fd < 0)
>> return 0;
>> @@ -587,12 +587,12 @@ 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, 1)) {
>> + 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, 0)) {
>> - if (test_export(path, 1))
>> + } else if ( ! test_export(path, exp->m_export.e_flags)) {
>> + if (test_export(path, exp->m_export.e_flags & NFSEXP_FSID))
>
> Duh, that should of course be "exp->m_export.e_flags | NFSEXP_FSID".
> I'll plan to resend after I wait a bit for others to comment. Please
> don't merge this as-is though -- it obviously needs better testing.
>
> We might be able to simplify the above logic a little too...hmmm...
That logic did look a bit odd... I'll wait for the next version....
steved.
>
>> xlog(L_ERROR, "%s requires fsid= for NFS export", path);
>> else
>> xlog(L_ERROR, "%s does not support NFS export", path);
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-11-18 19:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-18 16:50 [RFC PATCH 1/2] exportfs: pass export option flags to the kernel when testing export Jeff Layton
2015-11-18 16:50 ` [RFC PATCH 2/2] exportfs: vet exports for subtree checking when testing the export fails Jeff Layton
2015-11-18 18:05 ` J. Bruce Fields
2015-11-18 19:16 ` [RFC PATCH 1/2] exportfs: pass export option flags to the kernel when testing export Jeff Layton
2015-11-18 19:19 ` Steve Dickson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).