Don't try NFSv4 if any MNT protocol related options were presented by the user. Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx> --- utils/mount/stropts.c | 52 +++++++++++++++++++++++++++++++++++-------------- 1 files changed, 37 insertions(+), 15 deletions(-) diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c index ceefdb0..0f1061c 100644 --- a/utils/mount/stropts.c +++ b/utils/mount/stropts.c @@ -259,24 +259,11 @@ static int nfs_append_sloppy_option(struct mount_options *options) return 1; } -/* - * Set up mandatory non-version specific NFS mount options. - * - * Returns 1 if successful; otherwise zero. - */ -static int nfs_validate_options(struct nfsmount_info *mi) +static int nfs_set_version(struct nfsmount_info *mi) { - struct sockaddr *sap = (struct sockaddr *)&mi->address; - - if (!nfs_parse_devname(mi->spec, &mi->hostname, NULL)) - return 0; - - mi->salen = sizeof(mi->address); - if (!nfs_name_to_address(mi->hostname, sap, &mi->salen)) - return 0; - if (!nfs_nfs_version(mi->options, &mi->version)) return 0; + if (strncmp(mi->type, "nfs4", 4) == 0) mi->version = 4; else { @@ -284,6 +271,19 @@ static int nfs_validate_options(struct nfsmount_info *mi) if (option && strcmp(option, "rdma") == 0) mi->version = 3; } + + /* + * If we still don't know, check for version-specific + * mount options. + */ + if (mi->version == 0) { + if (po_contains(mi->options, "mounthost") || + po_contains(mi->options, "mountaddr") || + po_contains(mi->options, "mountvers") || + po_contains(mi->options, "mountproto")) + mi->version = 3; + } + /* * Use the default value set in the config file when * the version has not been explicitly set. @@ -293,6 +293,28 @@ static int nfs_validate_options(struct nfsmount_info *mi) mi->version = config_default_vers; } + return 1; +} + +/* + * Set up mandatory non-version specific NFS mount options. + * + * Returns 1 if successful; otherwise zero. + */ +static int nfs_validate_options(struct nfsmount_info *mi) +{ + struct sockaddr *sap = (struct sockaddr *)&mi->address; + + if (!nfs_parse_devname(mi->spec, &mi->hostname, NULL)) + return 0; + + mi->salen = sizeof(mi->address); + if (!nfs_name_to_address(mi->hostname, sap, &mi->salen)) + return 0; + + if (!nfs_set_version(mi)) + return 0; + if (!nfs_append_sloppy_option(mi->options)) return 0; -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html