mount.nfs: Refactor mount version and protocol autonegotiation
Clean up.
I'm beginning to agree with Bruce and Steve's assessment that the
fallthrough switch case in nfs_try_mount() is more difficult to read
and understand than it needs to be. The logic that manages
negotiating NFS version and protocol settings is getting more complex
over time anyway.
So let's split the autonegotiation piece out of nfs_try_mount().
We can reduce indenting, and use cleaner switch-based logic. Also,
adding more comments can only help.
Neil also suggested replacing the pre-call "errno = 0" trick. The
lower-level functions may try to mount several times (given a list of
addresses to try). errno could be set by any of those. The mount
request will succeed at some point, and "success" is returned, but
errno is still set to some non-zero value.
The kernel version check in nfs_try_mount() is more or less loop
invariant: it's impossible for the result of that test to change
between retries. So we should be able to safely move it to the logic
that sets the initial value of mi->version.
This patch is not supposed to cause a behavioral change.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>