From: Scott Mayhew <smayhew@redhat.com>
To: linux-nfs@vger.kernel.org
Subject: [nfs-utils PATCH 1/4] mount.nfs: avoid unnecessary duplication of options passed to mount(2)
Date: Tue, 13 Aug 2013 15:20:26 -0400 [thread overview]
Message-ID: <1376421629-21382-2-git-send-email-smayhew@redhat.com> (raw)
In-Reply-To: <1376421629-21382-1-git-send-email-smayhew@redhat.com>
The nfsmount.conf file has the following format:
[ section "arg" ]
tag = value
conf_get_tag_list() currently doesn't check the arg field so we wind up
getting all the options that fall under a particular section value,
instead of just the ones that match the specific "arg" field. As a
result, we wind up passing options to the mount syscall multiple times.
For example, if we have three different server sections, and each
section has an Nfsvers tag, then the string we pass to the mount syscall
will have three occurrences of the nfsvers option.
Note that the call to conf_get_section() in conf_parse_mntopts() will
ensure that we never pass the wrong value for an option, but we should
still avoid sending duplicate options if it's at all possible.
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
support/include/conffile.h | 2 +-
support/nfs/conffile.c | 4 +++-
utils/mount/configfile.c | 2 +-
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/support/include/conffile.h b/support/include/conffile.h
index ce7aa21..05ea5d2 100644
--- a/support/include/conffile.h
+++ b/support/include/conffile.h
@@ -54,7 +54,7 @@ extern int conf_end(int, int);
extern void conf_free_list(struct conf_list *);
extern struct sockaddr *conf_get_address(char *, char *);
extern struct conf_list *conf_get_list(char *, char *);
-extern struct conf_list *conf_get_tag_list(char *);
+extern struct conf_list *conf_get_tag_list(char *, char *);
extern int conf_get_num(char *, char *, int);
extern char *conf_get_str(char *, char *);
extern char *conf_get_section(char *, char *, char *);
diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index 5015e94..c3434d5 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -565,7 +565,7 @@ cleanup:
}
struct conf_list *
-conf_get_tag_list(char *section)
+conf_get_tag_list(char *section, char *arg)
{
struct conf_list *list = 0;
struct conf_list_node *node;
@@ -579,6 +579,8 @@ conf_get_tag_list(char *section)
cb = LIST_FIRST(&conf_bindings[conf_hash (section)]);
for (; cb; cb = LIST_NEXT(cb, link)) {
if (strcasecmp (section, cb->section) == 0) {
+ if (arg != NULL && strcasecmp(arg, cb->arg) != 0)
+ continue;
list->cnt++;
node = calloc(1, sizeof *node);
if (!node)
diff --git a/utils/mount/configfile.c b/utils/mount/configfile.c
index 6f2ee75..1f1b6e7 100644
--- a/utils/mount/configfile.c
+++ b/utils/mount/configfile.c
@@ -286,7 +286,7 @@ conf_parse_mntopts(char *section, char *arg, char *opts)
char *nvalue, *ptr;
int argtype;
- list = conf_get_tag_list(section);
+ list = conf_get_tag_list(section, arg);
TAILQ_FOREACH(node, &list->fields, link) {
/*
* Do not overwrite options if already exists
--
1.7.11.7
next prev parent reply other threads:[~2013-08-13 19:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-13 19:20 [nfs-utils PATCH 0/4] Improve nfsmount.conf configuration parsing Scott Mayhew
2013-08-13 19:20 ` Scott Mayhew [this message]
2013-08-13 19:30 ` [nfs-utils PATCH 1/4] mount.nfs: avoid unnecessary duplication of options passed to mount(2) Chuck Lever
2013-08-13 22:39 ` Scott Mayhew
2013-08-14 1:29 ` Chuck Lever
2013-08-14 14:24 ` Scott Mayhew
2013-08-13 19:20 ` [nfs-utils PATCH 2/4] mount.nfs: avoid sending conflicting mount options Scott Mayhew
2013-08-13 19:20 ` [nfs-utils PATCH 3/4] mount.nfs: improve handling of MNT_NOARG type options Scott Mayhew
2013-08-13 19:32 ` Chuck Lever
2013-08-13 22:45 ` Scott Mayhew
2013-08-14 1:46 ` Chuck Lever
2013-08-13 19:20 ` [nfs-utils PATCH 4/4] mount.nfs: clean up conf_parse_mntopts() Scott Mayhew
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1376421629-21382-2-git-send-email-smayhew@redhat.com \
--to=smayhew@redhat.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).