mount.nfs: Refactor mount version and protocol autonegotiation
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 7 lines · On Tue, 31 Aug 2010 17:21:31 -0400 Chuck Lever <[email protected]> wrote:
The logic that manages negotiating NFS version and protocol settings is getting more complex over time, so let's split this out of
nfs_try_mount().This should make Bruce a little happier, as it eliminates the silent switch case fall through in
nfs_try_mount(). And it should help Neil fix some bugs he's found in this logic.
Hi Chuck,
thanks for these..
One question....
.....
Quoted 5 lines
(quoted diff) +5
-0+{ + int result; + + /* + * Before 2.6.32, the kernel NFS client didn't support
Review
Quoted 10 lines
(quoted diff) +10
-0+ * "-t nfs vers=4" mounts, so NFS version 4 cannot be + * included when autonegotiating while running on + * those kernels. + */ + if (linux_version_code() <= MAKE_VERSION(2, 6, 31)) + goto fall_back; + + errno = 0; + result = nfs_try_mount_v4(mi); + switch (errno) {
Should we not have e.g.
if (result)
return result;
before the switch(errno)?? Typically errno is 'undefined' in no error is reported.
I realise the current code doesn't have that test either, but I still think it is wrong not to.
Thanks
NeilBrown
Quoted 47 lines
(quoted diff) +23
-14+ case EPROTONOSUPPORT: + /* A clear indication that the server or our + * client does not support NFS version 4. */ + goto fall_back; + case ENOENT: + /* Legacy Linux servers don't export an NFS + * version 4 pseudoroot. */ + goto fall_back; + case EPERM: + /* Linux servers prior to 2.6.25 may return + * EPERM when NFS version 4 is not supported. */ + goto fall_back; + default: + return result; + } + +fall_back: + return nfs_try_mount_v3v2(mi); +} + +/* * This is a single pass through the fg/bg loop. * * Returns TRUE if successful, otherwise FALSE.@@ -758,20 +801,8 @@ static int nfs_try_mount(struct nfsmount_info *mi) switch (mi->version) { case 0: - if (linux_version_code() > MAKE_VERSION(2, 6, 31)) { - errno = 0; - result = nfs_try_mount_v4(mi); - if (errno != EPROTONOSUPPORT) { - /* - * To deal with legacy Linux servers that don't - * automatically export a pseudo root, retry - * ENOENT errors using version 3. And for - * Linux servers prior to 2.6.25, retry EPERM - */ - if (errno != ENOENT && errno != EPERM) - break; - } - } + result = nfs_autonegotiate(mi); + break; case 2: case 3: result = nfs_try_mount_v3v2(mi);
Quoted 34 lines · Neil Brown
Quoted 7 lines · On Tue, 31 Aug 2010 17:21:31 -0400 Chuck Lever <[email protected]> wrote:
The logic that manages negotiating NFS version and protocol settings is getting more complex over time, so let's split this out of
nfs_try_mount().This should make Bruce a little happier, as it eliminates the silent switch case fall through in
nfs_try_mount(). And it should help Neil fix some bugs he's found in this logic.Hi Chuck,
thanks for these..
One question.........
Quoted 5 lines
(quoted diff) +5
-0+{ + int result; + + /* + * Before 2.6.32, the kernel NFS client didn't supportReview
Quoted 10 lines
(quoted diff) +10
-0+ * "-t nfs vers=4" mounts, so NFS version 4 cannot be + * included when autonegotiating while running on + * those kernels. + */ + if (linux_version_code() <= MAKE_VERSION(2, 6, 31)) + goto fall_back; + + errno = 0; + result = nfs_try_mount_v4(mi); + switch (errno) {Should we not have e.g.
Quoted 8 lines
if (result)
return result;before the switch(errno)?? Typically errno is 'undefined' in no error is reported.
I realise the current code doesn't have that test either, but I still think it is wrong not to.
We have
errno = 0;
just before the nfs_try_mount_v4(mi); call. This defines the value of errno even if nothing in nfs_try_mount_v4() sets it.
Perhaps that violates Bruce's "too subtle" rule and I should replace it with your suggested post-call check?
Quoted 53 lines
Thanks
NeilBrownQuoted 47 lines
(quoted diff) +23
-14+ case EPROTONOSUPPORT: + /* A clear indication that the server or our + * client does not support NFS version 4. */ + goto fall_back; + case ENOENT: + /* Legacy Linux servers don't export an NFS + * version 4 pseudoroot. */ + goto fall_back; + case EPERM: + /* Linux servers prior to 2.6.25 may return + * EPERM when NFS version 4 is not supported. */ + goto fall_back; + default: + return result; + } + +fall_back: + return nfs_try_mount_v3v2(mi); +} + +/* * This is a single pass through the fg/bg loop. * * Returns TRUE if successful, otherwise FALSE.@@ -758,20 +801,8 @@ static int nfs_try_mount(struct nfsmount_info *mi) switch (mi->version) { case 0: - if (linux_version_code() > MAKE_VERSION(2, 6, 31)) { - errno = 0; - result = nfs_try_mount_v4(mi); - if (errno != EPROTONOSUPPORT) { - /* - * To deal with legacy Linux servers that don't - * automatically export a pseudo root, retry - * ENOENT errors using version 3. And for - * Linux servers prior to 2.6.25, retry EPERM - */ - if (errno != ENOENT && errno != EPERM) - break; - } - } + result = nfs_autonegotiate(mi); + break; case 2: case 3: result = nfs_try_mount_v3v2(mi);
Signature · 1 line
chuck[dot]lever[at]oracle[dot]com
Quoted 43 lines · On Thu, 9 Sep 2010 13:27:38 -0400 Chuck Lever <[email protected]> wrote:
Quoted 40 lines · Neil Brown
Quoted 7 lines · On Tue, 31 Aug 2010 17:21:31 -0400 Chuck Lever <[email protected]> wrote:
The logic that manages negotiating NFS version and protocol settings is getting more complex over time, so let's split this out of
nfs_try_mount().This should make Bruce a little happier, as it eliminates the silent switch case fall through in
nfs_try_mount(). And it should help Neil fix some bugs he's found in this logic.Hi Chuck,
thanks for these..
One question.........
Quoted 5 lines
(quoted diff) +5
-0+{ + int result; + + /* + * Before 2.6.32, the kernel NFS client didn't supportReview
Quoted 10 lines
(quoted diff) +10
-0+ * "-t nfs vers=4" mounts, so NFS version 4 cannot be + * included when autonegotiating while running on + * those kernels. + */ + if (linux_version_code() <= MAKE_VERSION(2, 6, 31)) + goto fall_back; + + errno = 0; + result = nfs_try_mount_v4(mi); + switch (errno) {Should we not have e.g.
if (result)
return result;before the switch(errno)?? Typically errno is 'undefined' in no error is reported.
Quoted 8 lines
Quoted 2 lines
I realise the current code doesn't have that test either, but I still think it is wrong not to.
We have
errno = 0;just before the
nfs_try_mount_v4(mi); call. This defines the value of errno even if nothing innfs_try_mount_v4()sets it.
True, but what if something in nfs_try_mount_v4 does set it, but success is finally returned? That is certainly possible if mi has multiple addresses and the first is unreachable.
I think you must *never* test errno unless the most recent call reported an error.
Quoted 2 lines
Perhaps that violates Bruce's "too subtle" rule and I should replace it with your suggested post-call check?
He's like a guardian angel sitting on you shoulder whispering "too subtle" all the time :-) Definitely true this time.
Thanks,
NeilBrown
Quoted 55 lines
Quoted 54 lines
Thanks
NeilBrownQuoted 47 lines
(quoted diff) +23
-14+ case EPROTONOSUPPORT: + /* A clear indication that the server or our + * client does not support NFS version 4. */ + goto fall_back; + case ENOENT: + /* Legacy Linux servers don't export an NFS + * version 4 pseudoroot. */ + goto fall_back; + case EPERM: + /* Linux servers prior to 2.6.25 may return + * EPERM when NFS version 4 is not supported. */ + goto fall_back; + default: + return result; + } + +fall_back: + return nfs_try_mount_v3v2(mi); +} + +/* * This is a single pass through the fg/bg loop. * * Returns TRUE if successful, otherwise FALSE.@@ -758,20 +801,8 @@ static int nfs_try_mount(struct nfsmount_info *mi) switch (mi->version) { case 0: - if (linux_version_code() > MAKE_VERSION(2, 6, 31)) { - errno = 0; - result = nfs_try_mount_v4(mi); - if (errno != EPROTONOSUPPORT) { - /* - * To deal with legacy Linux servers that don't - * automatically export a pseudo root, retry - * ENOENT errors using version 3. And for - * Linux servers prior to 2.6.25, retry EPERM - */ - if (errno != ENOENT && errno != EPERM) - break; - } - } + result = nfs_autonegotiate(mi); + break; case 2: case 3: result = nfs_try_mount_v3v2(mi);
Quoted 7 lines · Neil Brown
Quoted 2 lines · On Thu, 9 Sep 2010 13:27:38 -0400 Chuck Lever <[email protected]> wrote:
Perhaps that violates Bruce's "too subtle" rule and I should replace it with your suggested post-call check?
He's like a guardian angel sitting on you shoulder whispering "too subtle" all the time :-) Definitely true this time.
The mind boggles at the thought of Bruce perching on anyone's shoulder...
Cheers
Trond
A message that is not in the archive (sent off-list or not yet received): 1284068734.14656.39.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org
Quoted 11 lines · Trond Myklebust
Quoted 7 lines · Neil Brown
Quoted 2 lines · On Thu, 9 Sep 2010 13:27:38 -0400 Chuck Lever <[email protected]> wrote:
Perhaps that violates Bruce's "too subtle" rule and I should replace it with your suggested post-call check?
He's like a guardian angel sitting on you shoulder whispering "too subtle" all the time :-) Definitely true this time.
The mind boggles at the thought of Bruce perching on anyone's shoulder...
Would somebody please just offer me a chair?
--b.