From: rread Date: Wed, 1 Oct 2003 23:51:15 +0000 (+0000) Subject: * Add a MOUNTOPT config record in the config log. This is saved as a X-Git-Tag: v1_7_0_51~2^7~479 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=510f39f03f9c77649ef81ca2aab5b8c105a3d89b;p=fs%2Flustre-release.git * Add a MOUNTOPT config record in the config log. This is saved as a profile, which ll_fill_super uses to determine which MDC and LOV devices to connect to. * Lconf creates a cleanup log, too., * replay-single.sh updated to use current 0-conf scheme. It isn't pretty yet, but getting there. --- diff --git a/lustre/include/linux/lustre_cfg.h b/lustre/include/linux/lustre_cfg.h index 59f92b8..cfe6cd9 100644 --- a/lustre/include/linux/lustre_cfg.h +++ b/lustre/include/linux/lustre_cfg.h @@ -33,6 +33,8 @@ enum lcfg_command_type { LCFG_LOV_SET_CONFIG = 0x00cf005, LCFG_ADD_UUID = 0x00cf006, LCFG_DEL_UUID = 0x00cf007, + LCFG_MOUNTOPT = 0x00cf008, + LCFG_DEL_MOUNTOPT = 0x00cf009, }; struct lustre_cfg { diff --git a/lustre/obdclass/config.c b/lustre/obdclass/config.c index 2f90157..3a97022 100644 --- a/lustre/obdclass/config.c +++ b/lustre/obdclass/config.c @@ -324,6 +324,70 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) RETURN(err); } +LIST_HEAD(lustre_profile_list); + +struct lustre_profile *class_get_profile(char * prof) +{ + struct lustre_profile *lprof; + + list_for_each_entry(lprof, &lustre_profile_list, lp_list) { + if (!strcmp(lprof->lp_profile, prof)) { + RETURN(lprof); + } + } + RETURN(NULL); +} + +int class_add_profile(int proflen, char *prof, + int osclen, char *osc, + int mdclen, char *mdc) +{ + struct lustre_profile *lprof; + int err = 0; + + OBD_ALLOC(lprof, sizeof(*prof)); + if (lprof == NULL) + GOTO(out, err = -ENOMEM); + INIT_LIST_HEAD(&lprof->lp_list); + + LASSERT(proflen == (strlen(prof) + 1)); + OBD_ALLOC(lprof->lp_profile, proflen); + if (lprof->lp_profile == NULL) + GOTO(out, err = -ENOMEM); + memcpy(lprof->lp_profile, prof, proflen); + + LASSERT(osclen == (strlen(osc) + 1)); + OBD_ALLOC(lprof->lp_osc, osclen); + if (lprof->lp_profile == NULL) + GOTO(out, err = -ENOMEM); + memcpy(lprof->lp_osc, osc, osclen); + + LASSERT(mdclen == (strlen(mdc) + 1)); + OBD_ALLOC(lprof->lp_mdc, mdclen); + if (lprof->lp_mdc == NULL) + GOTO(out, err = -ENOMEM); + memcpy(lprof->lp_mdc, mdc, mdclen); + + list_add(&lprof->lp_list, &lustre_profile_list); + +out: + RETURN(err); +} + +void class_del_profile(char *prof) +{ + struct lustre_profile *lprof; + + lprof = class_get_profile(prof); + if (lprof) { + list_del(&lprof->lp_list); + OBD_FREE(lprof->lp_profile, strlen(lprof->lp_profile) + 1); + OBD_FREE(lprof->lp_osc, strlen(lprof->lp_osc) + 1); + OBD_FREE(lprof->lp_mdc, strlen(lprof->lp_mdc) + 1); + OBD_FREE(lprof, sizeof *lprof); + } +} + int class_process_config(int len, char *data) { char *buf; @@ -334,7 +398,7 @@ int class_process_config(int len, char *data) lustre_cfg_getdata(&buf, len, data); lcfg = (struct lustre_cfg* ) buf; - CERROR("processing cmd: %x\n", lcfg->lcfg_command); + CDEBUG(D_IOCTL, "processing cmd: %x\n", lcfg->lcfg_command); /* Commands that don't need a device */ switch(lcfg->lcfg_command) { @@ -359,6 +423,23 @@ int class_process_config(int len, char *data) err = class_del_uuid(lcfg->lcfg_inlbuf1); GOTO(out, err); } + case LCFG_MOUNTOPT: { + CDEBUG(D_IOCTL, "mountopt: profile %s osc %s mdc %s\n", + lcfg->lcfg_inlbuf1, lcfg->lcfg_inlbuf2, lcfg->lcfg_inlbuf3); + /* set these mount options somewhere, so ll_fill_super + * can find them. */ + err = class_add_profile(lcfg->lcfg_inllen1, lcfg->lcfg_inlbuf1, + lcfg->lcfg_inllen2, lcfg->lcfg_inlbuf2, + lcfg->lcfg_inllen3, lcfg->lcfg_inlbuf3); + GOTO(out, err); + } + case LCFG_DEL_MOUNTOPT: { + CDEBUG(D_IOCTL, "mountopt: profile %s\n", lcfg->lcfg_inlbuf1); + /* set these mount options somewhere, so ll_fill_super + * can find them. */ + class_del_profile(lcfg->lcfg_inlbuf1); + GOTO(out, err = 0); + } } diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index 510cd42..41a697a 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -422,3 +422,56 @@ out: free(uuidarray); return rc; } + +int jt_lcfg_mount_option(int argc, char **argv) +{ + int rc; + struct lustre_cfg lcfg; + + LCFG_INIT(lcfg, LCFG_MOUNTOPT); + + if (argc != 4) + return CMD_HELP; + + /* profile name */ + lcfg.lcfg_inllen1 = strlen(argv[1]) + 1; + lcfg.lcfg_inlbuf1 = argv[1]; + /* osc name */ + lcfg.lcfg_inllen2 = strlen(argv[2]) + 1; + lcfg.lcfg_inlbuf2 = argv[2]; + /* mdc name */ + lcfg.lcfg_inllen3 = strlen(argv[3]) + 1; + lcfg.lcfg_inlbuf3 = argv[3]; + + rc = lcfg_ioctl(argv[0], OBD_DEV_ID, &lcfg); + if (rc < 0) { + fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), + strerror(rc = errno)); + } + + return rc; +} + +int jt_lcfg_del_mount_option(int argc, char **argv) +{ + int rc; + struct lustre_cfg lcfg; + + LCFG_INIT(lcfg, LCFG_DEL_MOUNTOPT); + + if (argc != 2) + return CMD_HELP; + + /* profile name */ + lcfg.lcfg_inllen1 = strlen(argv[1]) + 1; + lcfg.lcfg_inlbuf1 = argv[1]; + + rc = lcfg_ioctl(argv[0], OBD_DEV_ID, &lcfg); + if (rc < 0) { + fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), + strerror(rc = errno)); + } + + return rc; +} +