From 61a8f13f4f26ec0e93b9159ab93db792808f6587 Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 30 Sep 2005 22:40:52 +0000 Subject: [PATCH] b=9445 r=adilger remove mds and client cleanup logs --- lustre/include/linux/obd_class.h | 4 +--- lustre/llite/llite_lib.c | 41 ++++++++++++++-------------------------- lustre/lov/lov_obd.c | 20 +++++++++++++++++--- lustre/mds/handler.c | 40 ++++++++++++++++++++------------------- lustre/obdclass/class_obd.c | 1 + lustre/obdclass/obd_config.c | 41 ++++++++++++++++++++++++++++++++++++++++ lustre/utils/lconf | 28 --------------------------- 7 files changed, 95 insertions(+), 80 deletions(-) diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 70839ab..3fe5746 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -160,9 +160,7 @@ int class_disconnect(struct obd_export *exp); void class_fail_export(struct obd_export *exp); void class_disconnect_exports(struct obd_device *obddev); void class_disconnect_stale_exports(struct obd_device *obddev); -/* generic operations shared by various OBD types */ -int class_multi_setup(struct obd_device *obddev, uint32_t len, void *data); -int class_multi_cleanup(struct obd_device *obddev); +void class_manual_cleanup(struct obd_device *obd); /* obdo.c */ #ifdef __KERNEL__ diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 8fb9a24..864232d 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -684,32 +684,12 @@ out: static void lustre_manual_cleanup(struct ll_sb_info *sbi) { - struct lustre_cfg *lcfg; - struct lustre_cfg_bufs bufs; struct obd_device *obd; int next = 0; - while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL){ - int err; - - /* the lcfg is almost the same for both ops */ - lustre_cfg_bufs_reset(&bufs, obd->obd_name); - lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); - - err = class_process_config(lcfg); - if (err) { - CERROR("cleanup failed: %s\n", obd->obd_name); - //continue; - } - - lcfg->lcfg_command = LCFG_DETACH; - err = class_process_config(lcfg); - lustre_cfg_free(lcfg); - if (err) { - CERROR("detach failed: %s\n", obd->obd_name); - //continue; - } - } + while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) !=NULL) { + class_manual_cleanup(obd); + } if (sbi->ll_lmd != NULL) class_del_profile(sbi->ll_lmd->lmd_profile); @@ -818,14 +798,21 @@ void lustre_put_super(struct super_block *sb) { struct obd_device *obd; struct ll_sb_info *sbi = ll_s2sbi(sb); - int force_umount = 0; + int force = 0; ENTRY; CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb); obd = class_exp2obd(sbi->ll_mdc_exp); - if (obd) - force_umount = obd->obd_no_recov; - obd = NULL; + if (obd) { + int next = 0; + /* We need to set force before the lov_disconnect in + lustre_common_put_super, since l_d cleans up osc's as well. */ + force = obd->obd_no_recov; + while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) + !=NULL) { + obd->obd_force = force; + } + } lustre_common_put_super(sb); diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 9913e50..32ab6e7 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -265,9 +265,13 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) RETURN(0); } +static int +lov_del_obd(struct obd_device *obd, struct obd_uuid *uuidp, int index, int gen); + static int lov_disconnect(struct obd_export *exp) { struct obd_device *obd = class_exp2obd(exp); + struct obd_device *osc_obd; struct lov_obd *lov = &obd->u.lov; struct lov_tgt_desc *tgt; int rc, i; @@ -284,8 +288,18 @@ static int lov_disconnect(struct obd_export *exp) RETURN(rc); for (i = 0, tgt = lov->tgts; i < lov->desc.ld_tgt_count; i++, tgt++) { - if (tgt->ltd_exp) - lov_disconnect_obd(obd, tgt); + if (tgt->ltd_exp) { + osc_obd = class_exp2obd(tgt->ltd_exp); + /* Disconnect and delete from list */ + lov_del_obd(obd, &tgt->uuid, i, tgt->ltd_gen); + /* Cleanup the osc now - can't do it from + lov_cleanup because we just lost our only reference + to it. */ + /* Use lov's force/fail flags. */ + osc_obd->obd_force = obd->obd_force; + osc_obd->obd_fail = obd->obd_fail; + class_manual_cleanup(osc_obd); + } } RETURN(rc); @@ -592,7 +606,7 @@ static int lov_setup(struct obd_device *obd, obd_count len, void *buf) /* Allocate space for target list */ if (desc->ld_tgt_count) count = desc->ld_tgt_count; - lov->bufsize = sizeof(struct lov_tgt_desc) * count; + lov->bufsize = sizeof(struct lov_tgt_desc) * max(count, 1); OBD_ALLOC(lov->tgts, lov->bufsize); if (lov->tgts == NULL) { CERROR("Out of memory\n"); diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 173932f..97a3642 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -1477,7 +1477,7 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf) CDEBUG(D_SUPER, "%s: mnt = %p\n", lustre_cfg_string(lcfg, 1), mnt); LASSERT(!lvfs_check_rdonly(lvfs_sbdev(mnt->mnt_sb))); - + sema_init(&mds->mds_orphan_recovery_sem, 1); sema_init(&mds->mds_epoch_sem, 1); spin_lock_init(&mds->mds_transno_lock); @@ -1673,7 +1673,7 @@ int mds_postrecov(struct obd_device *obd) 0, NULL); if (rc) GOTO(out, rc); - + rc = llog_connect(llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT), obd->u.mds.mds_lov_desc.ld_tgt_count, NULL, NULL, NULL); @@ -1682,7 +1682,7 @@ int mds_postrecov(struct obd_device *obd) obd->obd_name, rc); GOTO(out, rc); } - + /* remove the orphaned precreated objects */ rc = mds_lov_clearorphans(mds, NULL /* all OSTs */); if (rc) { @@ -1704,28 +1704,30 @@ err_llog: int mds_lov_clean(struct obd_device *obd) { struct mds_obd *mds = &obd->u.mds; + struct obd_device *osc = mds->mds_osc_obd; + ENTRY; if (mds->mds_profile) { - char * cln_prof; - struct config_llog_instance cfg; - struct lvfs_run_ctxt saved; - int len = strlen(mds->mds_profile) + sizeof("-clean") + 1; + class_del_profile(mds->mds_profile); + OBD_FREE(mds->mds_profile, strlen(mds->mds_profile) + 1); + mds->mds_profile = NULL; + } - OBD_ALLOC(cln_prof, len); - sprintf(cln_prof, "%s-clean", mds->mds_profile); + /* There better be a lov */ + if (!osc) + RETURN(0); - cfg.cfg_instance = NULL; - cfg.cfg_uuid = mds->mds_lov_uuid; + obd_register_observer(osc, NULL); - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - class_config_parse_llog(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT), - cln_prof, &cfg); - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); + /* Give lov our same shutdown flags */ + osc->obd_force = obd->obd_force; + osc->obd_fail = obd->obd_fail; + + /* Cleanup the lov */ + obd_disconnect(mds->mds_osc_exp); + class_manual_cleanup(osc); + mds->mds_osc_exp = NULL; - OBD_FREE(cln_prof, len); - OBD_FREE(mds->mds_profile, strlen(mds->mds_profile) + 1); - mds->mds_profile = NULL; - } RETURN(0); } diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 1ed52d0..d4916b1 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -428,6 +428,7 @@ EXPORT_SYMBOL(class_attach); EXPORT_SYMBOL(class_setup); EXPORT_SYMBOL(class_cleanup); EXPORT_SYMBOL(class_detach); +EXPORT_SYMBOL(class_manual_cleanup); #ifdef LPROCFS int obd_proc_read_version(char *page, char **start, off_t off, int count, diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 10a352b..e4ef852 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -876,3 +876,44 @@ parse_out: RETURN(rc); } + +/* Cleanup and detach */ +void class_manual_cleanup(struct obd_device *obd) +{ + struct lustre_cfg *lcfg; + struct lustre_cfg_bufs bufs; + int err; + char flags[3]=""; + ENTRY; + + if (!obd) { + CERROR("empty cleanup\n"); + EXIT; + return; + } + + if (obd->obd_force) + strcat(flags, "F"); + if (obd->obd_fail) + strcat(flags, "A"); + + CDEBUG(D_CONFIG, "Manual cleanup of %s (flags='%s')\n", + obd->obd_name, flags); + + lustre_cfg_bufs_reset(&bufs, obd->obd_name); + lustre_cfg_bufs_set_string(&bufs, 1, flags); + lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); + + err = class_process_config(lcfg); + if (err) + CERROR("cleanup failed %d: %s\n", err, obd->obd_name); + + /* the lcfg is almost the same for both ops */ + lcfg->lcfg_command = LCFG_DETACH; + err = class_process_config(lcfg); + lustre_cfg_free(lcfg); + if (err) + CERROR("detach failed %d: %s\n", err, obd->obd_name); + EXIT; +} + diff --git a/lustre/utils/lconf b/lustre/utils/lconf index 878d521..47e91f6 100755 --- a/lustre/utils/lconf +++ b/lustre/utils/lconf @@ -1816,14 +1816,6 @@ class MDSDEV(Module): client.prepare() lctl.mount_option(self.name, client.get_name(), "") lctl.end_record() - - config.cleanup = 1 - lctl.clear_log(self.name, self.name + '-clean') - lctl.record(self.name, self.name + '-clean') - client.cleanup() - lctl.del_mount_option(self.name) - lctl.end_record() - config.cleanup = 0 config.record = 0 # record logs for each client @@ -1863,26 +1855,6 @@ class MDSDEV(Module): client_name, self.name)) if config.verbose: for s in out: log("record> ", string.strip(s)) - ret, out = run (sys.argv[0], - noexec_opt[old_noexec == 1], - "--cleanup -v --record --nomod", - "--record_log", client_name + "-clean", - "--record_device", self.name, - "--node", client_name, - config_options) - if ret: - # In this case, although 0-conf mount works but 0-conf umount - # doesn't work. As a boring result, the user is forced to - # cleanup client service manually again and again. So I prefer - # deleting these two llogs together and let the user write_conf. - lctl.clear_log(self.name, client_name) - lctl.clear_log(self.name, client_name + '-clean') - print out - self.cleanup() - panic("Record client log %s on %s failed" %( - client_name + '-clean', self.name)) - if config.verbose: - for s in out: log("record> ", string.strip(s)) config.noexec = old_noexec try: lctl.cleanup(self.name, self.uuid, config.force, config.failover) -- 1.8.3.1