From: nathan Date: Mon, 12 Dec 2005 22:36:21 +0000 (+0000) Subject: Branch b1_4_mountconf X-Git-Tag: v1_8_0_110~486^4~103 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=efa59b4cb2c636916b3fe759c428ebca67371401;p=fs%2Flustre-release.git Branch b1_4_mountconf b=9889 fix bugs revealed by huanghua's inspection --- diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index fbd8dcf..d76457f 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -385,7 +385,7 @@ extern struct super_operations lustre_super_operations; char *ll_read_opt(const char *opt, char *data); int ll_set_opt(const char *opt, char *data, int fl); -void ll_options(char *options, char **ost, char **mds, int *flags); +void ll_options(char *options, int *flags); void ll_lli_init(struct ll_inode_info *lli); int ll_fill_super(struct super_block *sb); void ll_put_super(struct super_block *sb); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 423a82a..89af4ff 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -425,7 +425,7 @@ int ll_set_opt(const char *opt, char *data, int fl) RETURN(fl); } -void ll_options(char *options, char **ost, char **mdc, int *flags) +void ll_options(char *options, int *flags) { int tmp; char *this_char; @@ -449,10 +449,6 @@ void ll_options(char *options, char **ost, char **mdc, int *flags) #endif { CDEBUG(D_SUPER, "this_char %s\n", this_char); - if (!*ost && (*ost = ll_read_opt(LUSTRE_OSC_NAME, this_char))) - continue; - if (!*mdc && (*mdc = ll_read_opt(LUSTRE_MDC_NAME, this_char))) - continue; tmp = ll_set_opt("nolock", this_char, LL_SBI_NOLCK); if (tmp) { *flags |= tmp; @@ -515,7 +511,7 @@ int ll_fill_super(struct super_block *sb) if (!sbi) RETURN(-ENOMEM); - ll_options(lsi->lsi_lmd->lmd_opts, &osc, &mdc, &sbi->ll_flags); + ll_options(lsi->lsi_lmd->lmd_opts, &sbi->ll_flags); /* Generate a string unique to this super, in case some joker tries to mount the same fs at two mount points. @@ -538,14 +534,17 @@ int ll_fill_super(struct super_block *sb) } CERROR("Found profile %s: mdc=%s osc=%s\n", profilenm, lprof->lp_mdc, lprof->lp_osc); + OBD_ALLOC(osc, strlen(lprof->lp_osc) + strlen(ll_instance) + 2); + if (!osc) + GOTO(out_free, err = -ENOMEM); + sprintf(osc, "%s-%s", lprof->lp_osc, ll_instance); + OBD_ALLOC(mdc, strlen(lprof->lp_mdc) + strlen(ll_instance) + 2); - if (!osc || !mdc) + if (!mdc) GOTO(out_free, err = -ENOMEM); - - sprintf(osc, "%s-%s", lprof->lp_osc, ll_instance); sprintf(mdc, "%s-%s", lprof->lp_mdc, ll_instance); /* connections, registrations, sb setup */ diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index e73eeb3..6d39e7c 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -528,7 +528,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, OBD_ALLOC(lprof, sizeof(*lprof)); if (lprof == NULL) - GOTO(out, err = -ENOMEM); + RETURN(-ENOMEM); INIT_LIST_HEAD(&lprof->lp_list); LASSERT(proflen == (strlen(prof) + 1)); @@ -539,7 +539,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, LASSERT(osclen == (strlen(osc) + 1)); OBD_ALLOC(lprof->lp_osc, osclen); - if (lprof->lp_profile == NULL) + if (lprof->lp_osc == NULL) GOTO(out, err = -ENOMEM); memcpy(lprof->lp_osc, osc, osclen); @@ -552,9 +552,17 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, } list_add(&lprof->lp_list, &lustre_profile_list); + RETURN(err); out: - RETURN(err); + if (lprof->lp_mdc) + OBD_FREE(lprof->lp_mdc, mdclen); + if (lprof->lp_osc) + OBD_FREE(lprof->lp_osc, osclen); + if (lprof->lp_profile) + OBD_FREE(lprof->lp_profile, proflen); + OBD_FREE(lprof, sizeof(*lprof)); + RETURN(err); } void class_del_profile(char *prof) diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c index 4efa7fa..3245351 100644 --- a/lustre/utils/mount_lustre.c +++ b/lustre/utils/mount_lustre.c @@ -225,6 +225,9 @@ int parse_options(char *orig_options, int *flagp) *flagp = 0; nextopt = orig_options; while ((opt = strsep(&nextopt, ","))) { + if (!*opt) + /* empty option */ + continue; if (parse_one_option(opt, flagp) > 0) continue; /* no mount flags set, so pass this on as an option */ @@ -232,6 +235,7 @@ int parse_options(char *orig_options, int *flagp) strcat(options, ","); strcat(options, opt); } + /* options will always be <= orig_options */ strcpy(orig_options, options); free(options); return 0; @@ -240,7 +244,8 @@ int parse_options(char *orig_options, int *flagp) int main(int argc, char *const argv[]) { - char *source, *target, *options = "", *optcopy; + char default_options[] = ""; + char *source, *target, *options = default_options, *optcopy; int i, nargs = 3, opt, rc, flags, optlen; static struct option long_opt[] = { {"fake", 0, 0, 'f'}, @@ -331,7 +336,7 @@ int main(int argc, char *const argv[]) /* In Linux 2.4, the target device doesn't get passed to any of our functions. So we'll stick it on the end of the options. */ - optlen = strlen(options) + strlen(",device=") + strlen(source); + optlen = strlen(options) + strlen(",device=") + strlen(source) + 1; optcopy = malloc(optlen); strcpy(optcopy, options); if (*optcopy)