summaryrefslogtreecommitdiff
path: root/usr/src/cmd/dfs.cmds
diff options
context:
space:
mode:
authordougm <none@none>2006-11-09 15:45:20 -0800
committerdougm <none@none>2006-11-09 15:45:20 -0800
commit7d968cb8b4b6274092771b93e94bf88d1ee31c6c (patch)
tree476010535f36a83447224756e72768b22ee3f31f /usr/src/cmd/dfs.cmds
parentfd40619a1a5e6f09a373e8fe546645fe58d17440 (diff)
downloadillumos-gate-7d968cb8b4b6274092771b93e94bf88d1ee31c6c.tar.gz
6489898 sharemgr too slow when just using "-h" option
6489911 sharemgr startup of large number of ZFS shares is too slow 6490058 sharemgr: *sharemgr start -a* command dumped a core
Diffstat (limited to 'usr/src/cmd/dfs.cmds')
-rw-r--r--usr/src/cmd/dfs.cmds/sharemgr/commands.c77
-rw-r--r--usr/src/cmd/dfs.cmds/sharemgr/sharemgr_main.c25
2 files changed, 59 insertions, 43 deletions
diff --git a/usr/src/cmd/dfs.cmds/sharemgr/commands.c b/usr/src/cmd/dfs.cmds/sharemgr/commands.c
index 33a4a8eb25..ce70a92386 100644
--- a/usr/src/cmd/dfs.cmds/sharemgr/commands.c
+++ b/usr/src/cmd/dfs.cmds/sharemgr/commands.c
@@ -227,22 +227,44 @@ check_authorizations(char *instname, int flags)
}
/*
- * enable_all_groups(list, setstate, online, update)
- * Given a list of groups, enable each one found. If update is
- * not NULL, then update all the shares for the protocol that was
- * passed in.
+ * enable_group(group, updateproto)
+ *
+ * enable all the shares in the specified group. This is a helper for
+ * enable_all_groups in order to simplify regular and subgroup (zfs)
+ * disabling. Group has already been checked for non-NULL.
*/
-static int
-enable_all_groups(struct list *work, int setstate, int online, char *update)
+
+static void
+enable_group(sa_group_t group, char *updateproto)
{
sa_share_t share;
+
+ for (share = sa_get_share(group, NULL);
+ share != NULL;
+ share = sa_get_next_share(share)) {
+ if (updateproto != NULL)
+ (void) sa_update_legacy(share, updateproto);
+ (void) sa_enable_share(share, NULL);
+ }
+}
+
+/*
+ * enable_all_groups(list, setstate, online, updateproto)
+ * Given a list of groups, enable each one found. If updateproto
+ * is not NULL, then update all the shares for the protocol that
+ * was passed in.
+ */
+static int
+enable_all_groups(struct list *work, int setstate, int online,
+ char *updateproto)
+{
int ret = SA_OK;
char instance[SA_MAX_NAME_LEN + sizeof (SA_SVC_FMRI_BASE) + 1];
char *state;
char *name;
char *zfs = NULL;
- int dozfs = 0;
sa_group_t group;
+ sa_group_t subgroup;
while (work != NULL && ret == SA_OK) {
group = (sa_group_t)work->item;
@@ -256,16 +278,24 @@ enable_all_groups(struct list *work, int setstate, int online, char *update)
if (ret == SA_OK) {
/* if itemdata == NULL then the whole group */
if (work->itemdata == NULL) {
- for (share = sa_get_share(group, NULL);
- share != NULL; share = sa_get_next_share(share)) {
- if (update != NULL)
- (void) sa_update_legacy(share, update);
- ret = sa_enable_share(share, NULL);
+ zfs = sa_get_group_attr(group, "zfs");
+ /*
+ * if the share is managed by ZFS, don't
+ * update any of the protocols since ZFS is
+ * handling this. updateproto will contain
+ * the name of the protocol that we want to
+ * update legacy files for.
+ */
+ enable_group(group, zfs == NULL ? updateproto : NULL);
+ for (subgroup = sa_get_sub_group(group); subgroup != NULL;
+ subgroup = sa_get_next_group(subgroup)) {
+ /* never update legacy for ZFS subgroups */
+ enable_group(subgroup, NULL);
}
}
if (online) {
- name = sa_get_group_attr(group, "name");
zfs = sa_get_group_attr(group, "zfs");
+ name = sa_get_group_attr(group, "name");
if (name != NULL) {
if (zfs == NULL) {
(void) snprintf(instance, sizeof (instance),
@@ -278,20 +308,12 @@ enable_all_groups(struct list *work, int setstate, int online, char *update)
free(state);
}
} else {
- dozfs++;
sa_free_attr_string(zfs);
zfs = NULL;
}
if (name != NULL)
sa_free_attr_string(name);
}
- } else {
- zfs = sa_get_group_attr(group, "zfs");
- if (zfs != NULL) {
- dozfs++;
- sa_free_attr_string(zfs);
- zfs = NULL;
- }
}
work = work->next;
}
@@ -299,19 +321,6 @@ enable_all_groups(struct list *work, int setstate, int online, char *update)
if (ret == SA_OK) {
ret = sa_update_config();
}
- /* do ZFS last to allow everything to get updated */
- if (ret == SA_OK && dozfs) {
- FILE *sys;
- int err;
- sys = popen(ZFS_SHAREALL, "r");
- if (sys != NULL) {
- err = pclose(sys);
- if (err != 0)
- ret = SA_SYSTEM_ERR;
- } else {
- ret = SA_SYSTEM_ERR;
- }
- }
return (ret);
}
diff --git a/usr/src/cmd/dfs.cmds/sharemgr/sharemgr_main.c b/usr/src/cmd/dfs.cmds/sharemgr/sharemgr_main.c
index 8c57470d96..16e7ac891f 100644
--- a/usr/src/cmd/dfs.cmds/sharemgr/sharemgr_main.c
+++ b/usr/src/cmd/dfs.cmds/sharemgr/sharemgr_main.c
@@ -67,15 +67,6 @@ main(int argc, char *argv[])
(void) textdomain(TEXT_DOMAIN);
/*
- * initialize the plugin architecture.
- * Plugins are needed in the event of a global help
- * request.
- */
-
- sa_init(SA_INIT_SHARE_API);
- optind = 1; /* reset to beginning */
-
- /*
* parse enough of command line to get protocol, if any.
* Note that options need to come "after" the subcommand.
*/
@@ -108,7 +99,23 @@ main(int argc, char *argv[])
/*
* now have enough to parse rest of command line
+ *
+ * First, initialize the plugin architecture.
+ * Plugins are needed in the event of a global help
+ * request.
+ *
+ * reset optind to 1 so the parsing that takes place in
+ * sa_init() will work correctly.
+ */
+
+ optind = 1;
+ sa_init(SA_INIT_SHARE_API);
+
+ /*
+ * reset optind again since we will start parsing all over in
+ * the sub-commands.
*/
+ optind = 1;
rval = run_command(command, argc, argv, protocol);
sa_fini();