From: yury Date: Wed, 17 Dec 2008 16:26:32 +0000 (+0000) Subject: b=17466 X-Git-Tag: v1_9_130~18 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=02d8c2fa5c63271d01818d24c86a80d7d63a6e00 b=17466 r=shadow,deen - ports test_61d from 1.6.x to HEAD + fixes error case handling and does some cleanups. --- diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 568f692..00527cb 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -269,8 +269,9 @@ static int mds_lov_early_clean(struct obd_device *obd) static int mds_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { - int rc = 0; struct mds_obd *mds = &obd->u.mds; + struct llog_ctxt *ctxt; + int rc = 0; ENTRY; switch (stage) { @@ -281,8 +282,12 @@ static int mds_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) down_write(&mds->mds_notify_lock); mds_lov_disconnect(obd); mds_lov_clean(obd); - llog_cleanup(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT)); - llog_cleanup(llog_get_context(obd, LLOG_LOVEA_ORIG_CTXT)); + ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); + if (ctxt) + llog_cleanup(ctxt); + ctxt = llog_get_context(obd, LLOG_LOVEA_ORIG_CTXT); + if (ctxt) + llog_cleanup(ctxt); rc = obd_llog_finish(obd, 0); mds->mds_osc_exp = NULL; up_write(&mds->mds_notify_lock); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 4a7dbe5..eaed597 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -4114,7 +4114,7 @@ static int mdt_obd_llog_setup(struct obd_device *obd, obd->obd_fsops = fsfilt_get_ops(MT_STR(lsi->lsi_ldd)); if (IS_ERR(obd->obd_fsops)) - return (int) PTR_ERR(obd->obd_fsops); + return PTR_ERR(obd->obd_fsops); rc = fsfilt_setup(obd, lsi->lsi_srv_mnt->mnt_sb); if (rc) { @@ -4130,7 +4130,7 @@ static int mdt_obd_llog_setup(struct obd_device *obd, rc = llog_setup(obd, &obd->obd_olg, LLOG_CONFIG_ORIG_CTXT, obd, 0, NULL, &llog_lvfs_ops); if (rc) { - CERROR("llog setup failed: %d\n", rc); + CERROR("llog_setup() failed: %d\n", rc); fsfilt_put_ops(obd->obd_fsops); } @@ -4145,17 +4145,19 @@ static void mdt_obd_llog_cleanup(struct obd_device *obd) if (ctxt) llog_cleanup(ctxt); - if (obd->obd_fsops) + if (obd->obd_fsops) { fsfilt_put_ops(obd->obd_fsops); + obd->obd_fsops = NULL; + } } static void mdt_fini(const struct lu_env *env, struct mdt_device *m) { - struct md_device *next = m->mdt_child; - struct lu_device *d = &m->mdt_md_dev.md_lu_dev; - struct lu_site *ls = d->ld_site; + struct md_device *next = m->mdt_child; + struct lu_device *d = &m->mdt_md_dev.md_lu_dev; + struct lu_site *ls = d->ld_site; struct obd_device *obd = mdt2obd_dev(m); - int waited = 0; + int waited = 0; ENTRY; /* At this point, obd exports might still be on the "obd_zombie_exports" @@ -4208,7 +4210,10 @@ static void mdt_fini(const struct lu_env *env, struct mdt_device *m) mdt_seq_fini_cli(m); mdt_fld_fini(env, m); mdt_procfs_fini(m); - lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry); + if (obd->obd_proc_exports_entry) { + lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry); + obd->obd_proc_exports_entry = NULL; + } lprocfs_free_per_client_stats(obd); lprocfs_free_obd_stats(obd); ptlrpc_lprocfs_unregister_obd(d->ld_obd); @@ -4220,7 +4225,9 @@ static void mdt_fini(const struct lu_env *env, struct mdt_device *m) cfs_timer_disarm(&m->mdt_ck_timer); mdt_ck_thread_stop(m); - /* finish the stack */ + /* + * Finish the stack + */ mdt_stack_fini(env, m, md2lu_dev(m->mdt_child)); if (ls) { @@ -4563,8 +4570,10 @@ err_fini_stack: mdt_stack_fini(env, m, md2lu_dev(m->mdt_child)); err_fini_proc: mdt_procfs_fini(m); - if (obd->obd_proc_exports_entry) + if (obd->obd_proc_exports_entry) { lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry); + obd->obd_proc_exports_entry = NULL; + } ptlrpc_lprocfs_unregister_obd(obd); lprocfs_obd_cleanup(obd); err_fini_site: diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 3ac423a..de0a7bf 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -94,9 +94,11 @@ int mdt_procfs_init(struct mdt_device *mdt, const char *name) int mdt_procfs_fini(struct mdt_device *mdt) { struct lu_device *ld = &mdt->mdt_md_dev.md_lu_dev; - lu_time_fini(&ld->ld_site->ls_time_stats); - lu_time_fini(&mdt->mdt_stats); - mdt->mdt_proc_entry = NULL; + if (mdt->mdt_proc_entry) { + lu_time_fini(&ld->ld_site->ls_time_stats); + lu_time_fini(&mdt->mdt_stats); + mdt->mdt_proc_entry = NULL; + } RETURN(0); } diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index bf696c1..447a2a9 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -1120,6 +1120,12 @@ static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, &llog_client_ops); if (rc == 0) { ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT); + if (!ctxt) { + ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); + if (ctxt) + llog_cleanup(ctxt); + RETURN(-ENODEV); + } llog_initiator_connect(ctxt); llog_ctxt_put(ctxt); } else { diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 2de3465..63f443a 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -60,6 +60,8 @@ struct list_head obd_zombie_imports; struct list_head obd_zombie_exports; spinlock_t obd_zombie_impexp_lock; static void obd_zombie_impexp_notify(void); +static void obd_zombie_export_add(struct obd_export *exp); +static void obd_zombie_import_add(struct obd_import *imp); int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c); @@ -704,6 +706,32 @@ struct obd_import *class_conn2cliimp(struct lustre_handle *conn) } /* Export management functions */ +static void class_export_destroy(struct obd_export *exp) +{ + struct obd_device *obd = exp->exp_obd; + ENTRY; + + LASSERT (atomic_read(&exp->exp_refcount) == 0); + + CDEBUG(D_IOCTL, "destroying export %p/%s for %s\n", exp, + exp->exp_client_uuid.uuid, obd->obd_name); + + LASSERT(obd != NULL); + + /* "Local" exports (lctl, LOV->{mdc,osc}) have no connection. */ + if (exp->exp_connection) + ptlrpc_put_connection_superhack(exp->exp_connection); + + LASSERT(list_empty(&exp->exp_outstanding_replies)); + LASSERT(list_empty(&exp->exp_req_replay_queue)); + LASSERT(list_empty(&exp->exp_queued_rpc)); + obd_destroy_export(exp); + class_decref(obd, "export", exp); + + OBD_FREE_RCU(exp, sizeof(*exp), &exp->exp_handle); + EXIT; +} + static void export_handle_addref(void *export) { class_export_get(export); @@ -727,47 +755,13 @@ void class_export_put(struct obd_export *exp) LASSERT(atomic_read(&exp->exp_refcount) < 0x5a5a5a); if (atomic_dec_and_test(&exp->exp_refcount)) { - LASSERT (list_empty(&exp->exp_obd_chain)); - CDEBUG(D_IOCTL, "final put %p/%s\n", exp, exp->exp_client_uuid.uuid); - - spin_lock(&obd_zombie_impexp_lock); - list_add(&exp->exp_obd_chain, &obd_zombie_exports); - spin_unlock(&obd_zombie_impexp_lock); - - if (obd_zombie_impexp_notify != NULL) - obd_zombie_impexp_notify(); + obd_zombie_export_add(exp); } } EXPORT_SYMBOL(class_export_put); -static void class_export_destroy(struct obd_export *exp) -{ - struct obd_device *obd = exp->exp_obd; - ENTRY; - - LASSERT (atomic_read(&exp->exp_refcount) == 0); - - CDEBUG(D_IOCTL, "destroying export %p/%s for %s\n", exp, - exp->exp_client_uuid.uuid, obd->obd_name); - - LASSERT(obd != NULL); - - /* "Local" exports (lctl, LOV->{mdc,osc}) have no connection. */ - if (exp->exp_connection) - ptlrpc_put_connection_superhack(exp->exp_connection); - - LASSERT(list_empty(&exp->exp_outstanding_replies)); - LASSERT(list_empty(&exp->exp_req_replay_queue)); - LASSERT(list_empty(&exp->exp_queued_rpc)); - obd_destroy_export(exp); - class_decref(obd, "export", exp); - - OBD_FREE_RCU(exp, sizeof(*exp), &exp->exp_handle); - EXIT; -} - /* Creates a new export, adds it to the hash table, and returns a * pointer to it. The refcount is 2: one for the hash reference, and * one for the pointer returned by this function. */ @@ -848,6 +842,33 @@ void class_unlink_export(struct obd_export *exp) EXPORT_SYMBOL(class_unlink_export); /* Import management functions */ +void class_import_destroy(struct obd_import *imp) +{ + ENTRY; + + CDEBUG(D_IOCTL, "destroying import %p for %s\n", imp, + imp->imp_obd->obd_name); + + LASSERT(atomic_read(&imp->imp_refcount) == 0); + + ptlrpc_put_connection_superhack(imp->imp_connection); + + while (!list_empty(&imp->imp_conn_list)) { + struct obd_import_conn *imp_conn; + + imp_conn = list_entry(imp->imp_conn_list.next, + struct obd_import_conn, oic_item); + list_del_init(&imp_conn->oic_item); + ptlrpc_put_connection_superhack(imp_conn->oic_conn); + OBD_FREE(imp_conn, sizeof(*imp_conn)); + } + + LASSERT(imp->imp_sec == NULL); + class_decref(imp->imp_obd, "import", imp); + OBD_FREE_RCU(imp, sizeof(*imp), &imp->imp_handle); + EXIT; +} + static void import_handle_addref(void *import) { class_import_get(import); @@ -865,59 +886,27 @@ struct obd_import *class_import_get(struct obd_import *import) } EXPORT_SYMBOL(class_import_get); -void class_import_put(struct obd_import *import) +void class_import_put(struct obd_import *imp) { ENTRY; - LASSERT(atomic_read(&import->imp_refcount) > 0); - LASSERT(atomic_read(&import->imp_refcount) < 0x5a5a5a); - LASSERT(list_empty(&import->imp_zombie_chain)); + LASSERT(atomic_read(&imp->imp_refcount) > 0); + LASSERT(atomic_read(&imp->imp_refcount) < 0x5a5a5a); + LASSERT(list_empty(&imp->imp_zombie_chain)); - CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", import, - atomic_read(&import->imp_refcount) - 1, - import->imp_obd->obd_name); - - if (atomic_dec_and_test(&import->imp_refcount)) { - CDEBUG(D_INFO, "final put import %p\n", import); - spin_lock(&obd_zombie_impexp_lock); - list_add(&import->imp_zombie_chain, &obd_zombie_imports); - spin_unlock(&obd_zombie_impexp_lock); + CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", imp, + atomic_read(&imp->imp_refcount) - 1, + imp->imp_obd->obd_name); - if (obd_zombie_impexp_notify != NULL) - obd_zombie_impexp_notify(); + if (atomic_dec_and_test(&imp->imp_refcount)) { + CDEBUG(D_INFO, "final put import %p\n", imp); + obd_zombie_import_add(imp); } EXIT; } EXPORT_SYMBOL(class_import_put); -void class_import_destroy(struct obd_import *import) -{ - ENTRY; - - CDEBUG(D_IOCTL, "destroying import %p for %s\n", import, - import->imp_obd->obd_name); - - LASSERT(atomic_read(&import->imp_refcount) == 0); - - ptlrpc_put_connection_superhack(import->imp_connection); - - while (!list_empty(&import->imp_conn_list)) { - struct obd_import_conn *imp_conn; - - imp_conn = list_entry(import->imp_conn_list.next, - struct obd_import_conn, oic_item); - list_del(&imp_conn->oic_item); - ptlrpc_put_connection_superhack(imp_conn->oic_conn); - OBD_FREE(imp_conn, sizeof(*imp_conn)); - } - - LASSERT(import->imp_sec == NULL); - class_decref(import->imp_obd, "import", import); - OBD_FREE_RCU(import, sizeof(*import), &import->imp_handle); - EXIT; -} - static void init_imp_at(struct imp_at *at) { int i; at_init(&at->iat_net_latency, 0, 0); @@ -1313,14 +1302,14 @@ void obd_zombie_impexp_cull(void) ENTRY; do { - spin_lock (&obd_zombie_impexp_lock); + spin_lock(&obd_zombie_impexp_lock); import = NULL; if (!list_empty(&obd_zombie_imports)) { import = list_entry(obd_zombie_imports.next, struct obd_import, imp_zombie_chain); - list_del(&import->imp_zombie_chain); + list_del_init(&import->imp_zombie_chain); } export = NULL; @@ -1349,7 +1338,7 @@ static unsigned long obd_zombie_flags; static cfs_waitq_t obd_zombie_waitq; enum { - OBD_ZOMBIE_STOP = 1 + OBD_ZOMBIE_STOP = 1 << 1 }; /** @@ -1370,6 +1359,32 @@ static int obd_zombie_impexp_check(void *arg) } /** + * Add export to the obd_zombe thread and notify it. + */ +static void obd_zombie_export_add(struct obd_export *exp) { + spin_lock(&obd_zombie_impexp_lock); + LASSERT(list_empty(&exp->exp_obd_chain)); + list_add(&exp->exp_obd_chain, &obd_zombie_exports); + spin_unlock(&obd_zombie_impexp_lock); + + if (obd_zombie_impexp_notify != NULL) + obd_zombie_impexp_notify(); +} + +/** + * Add import to the obd_zombe thread and notify it. + */ +static void obd_zombie_import_add(struct obd_import *imp) { + spin_lock(&obd_zombie_impexp_lock); + LASSERT(list_empty(&imp->imp_zombie_chain)); + list_add(&imp->imp_zombie_chain, &obd_zombie_imports); + spin_unlock(&obd_zombie_impexp_lock); + + if (obd_zombie_impexp_notify != NULL) + obd_zombie_impexp_notify(); +} + +/** * notify import/export destroy thread about new zombie. */ static void obd_zombie_impexp_notify(void) @@ -1398,7 +1413,6 @@ static int obd_zombie_is_idle(void) void obd_zombie_barrier(void) { struct l_wait_info lwi = { 0 }; - l_wait_event(obd_zombie_waitq, obd_zombie_is_idle(), &lwi); } EXPORT_SYMBOL(obd_zombie_barrier); @@ -1422,10 +1436,14 @@ static int obd_zombie_impexp_thread(void *unused) while(!test_bit(OBD_ZOMBIE_STOP, &obd_zombie_flags)) { struct l_wait_info lwi = { 0 }; - l_wait_event(obd_zombie_waitq, !obd_zombie_impexp_check(NULL), &lwi); - + l_wait_event(obd_zombie_waitq, + !obd_zombie_impexp_check(NULL), &lwi); obd_zombie_impexp_cull(); - /* Notify obd_zombie_barrier callers that queues may be empty */ + + /* + * Notify obd_zombie_barrier callers that queues + * may be empty. + */ cfs_waitq_signal(&obd_zombie_waitq); } @@ -1484,7 +1502,6 @@ int obd_zombie_impexp_init(void) liblustre_register_idle_callback("obd_zombi_impexp_check", &obd_zombie_impexp_check, NULL); rc = 0; - #endif RETURN(rc); } diff --git a/lustre/obdclass/llog_obd.c b/lustre/obdclass/llog_obd.c index 7ff434a..ca20d5d 100644 --- a/lustre/obdclass/llog_obd.c +++ b/lustre/obdclass/llog_obd.c @@ -66,15 +66,16 @@ static struct llog_ctxt* llog_new_ctxt(struct obd_device *obd) static void llog_ctxt_destroy(struct llog_ctxt *ctxt) { - if (ctxt->loc_exp) + if (ctxt->loc_exp) { class_export_put(ctxt->loc_exp); + ctxt->loc_exp = NULL; + } if (ctxt->loc_imp) { class_import_put(ctxt->loc_imp); ctxt->loc_imp = NULL; } LASSERT(ctxt->loc_llcd == NULL); OBD_FREE_PTR(ctxt); - return; } int __llog_ctxt_put(struct llog_ctxt *ctxt) @@ -119,19 +120,25 @@ int llog_cleanup(struct llog_ctxt *ctxt) int rc, idx; ENTRY; - if (!ctxt) { - CERROR("No ctxt\n"); - RETURN(-ENODEV); - } + LASSERT(ctxt != NULL); + LASSERT(ctxt != LP_POISON); olg = ctxt->loc_olg; + LASSERT(olg != NULL); + LASSERT(olg != LP_POISON); + idx = ctxt->loc_idx; - /* banlance the ctxt get when calling llog_cleanup */ + /* + * Banlance the ctxt get when calling llog_cleanup() + */ + LASSERT(atomic_read(&ctxt->loc_refcount) < 0x5a5a5a); LASSERT(atomic_read(&ctxt->loc_refcount) > 1); llog_ctxt_put(ctxt); - /* try to free the ctxt */ + /* + * Try to free the ctxt. + */ rc = __llog_ctxt_put(ctxt); if (rc) CERROR("Error %d while cleaning up ctxt %p\n", @@ -149,58 +156,64 @@ int llog_setup_named(struct obd_device *obd, struct obd_llog_group *olg, struct llog_logid *logid, const char *logname, struct llog_operations *op) { - int rc = 0; struct llog_ctxt *ctxt; + int rc = 0; ENTRY; if (index < 0 || index >= LLOG_MAX_CTXTS) - RETURN(-EFAULT); + RETURN(-EINVAL); LASSERT(olg != NULL); ctxt = llog_new_ctxt(obd); if (!ctxt) - GOTO(out, rc = -ENOMEM); + RETURN(-ENOMEM); ctxt->loc_obd = obd; - ctxt->loc_exp = class_export_get(disk_obd->obd_self_export); ctxt->loc_olg = olg; ctxt->loc_idx = index; ctxt->loc_logops = op; sema_init(&ctxt->loc_sem, 1); + ctxt->loc_exp = class_export_get(disk_obd->obd_self_export); rc = llog_group_set_ctxt(olg, ctxt, index); if (rc) { llog_ctxt_destroy(ctxt); if (rc == -EEXIST) { - /* sanity check */ ctxt = llog_group_get_ctxt(olg, index); - - /* mds_lov_update_mds might call here multiple times. - * So if the llog is already set up then don't to do - * it again. */ - CDEBUG(D_CONFIG, "obd %s ctxt %d already set up\n", - obd->obd_name, index); - LASSERT(ctxt->loc_olg == olg); - LASSERT(ctxt->loc_obd == obd); - LASSERT(ctxt->loc_exp == disk_obd->obd_self_export); - LASSERT(ctxt->loc_logops == op); - llog_ctxt_put(ctxt); + if (ctxt) { + /* + * mds_lov_update_desc() might call here multiple + * times. So if the llog is already set up then + * don't to do it again. + */ + CDEBUG(D_CONFIG, "obd %s ctxt %d already set up\n", + obd->obd_name, index); + LASSERT(ctxt->loc_olg == olg); + LASSERT(ctxt->loc_obd == obd); + LASSERT(ctxt->loc_exp == disk_obd->obd_self_export); + LASSERT(ctxt->loc_logops == op); + llog_ctxt_put(ctxt); + } rc = 0; } - GOTO(out, rc); + RETURN(rc); } - if (op->lop_setup) { - rc = op->lop_setup(obd, olg, index, disk_obd, count, logid, - logname); - if (rc) { - CERROR("obd %s ctxt %d lop_setup=%p failed %d\n", - obd->obd_name, index, op->lop_setup, rc); - llog_ctxt_put(ctxt); - } + if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LLOG_SETUP)) { + rc = -ENOTSUPP; + } else { + if (op->lop_setup) + rc = op->lop_setup(obd, olg, index, disk_obd, count, + logid, logname); } -out: + + if (rc) { + CERROR("obd %s ctxt %d lop_setup=%p failed %d\n", + obd->obd_name, index, op->lop_setup, rc); + llog_ctxt_put(ctxt); + } + RETURN(rc); } EXPORT_SYMBOL(llog_setup_named); @@ -335,8 +348,8 @@ int llog_obd_origin_setup(struct obd_device *obd, struct obd_llog_group *olg, LASSERT(olg != NULL); ctxt = llog_group_get_ctxt(olg, index); - - LASSERT(ctxt); + if (!ctxt) + RETURN(-ENODEV); llog_gen_init(ctxt); if (logid && logid->lgl_oid) { @@ -358,10 +371,11 @@ int llog_obd_origin_setup(struct obd_device *obd, struct obd_llog_group *olg, rc = llog_process(handle, (llog_cb_t)cat_cancel_cb, NULL, NULL); if (rc) - CERROR("llog_process with cat_cancel_cb failed: %d\n", rc); + CERROR("llog_process() with cat_cancel_cb failed: %d\n", rc); + GOTO(out, rc); out: llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_obd_origin_setup); diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index ba5b2cc..a6f0311 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -882,6 +882,7 @@ int lprocfs_obd_cleanup(struct obd_device *obd) /* Should be no exports left */ LASSERT(obd->obd_proc_exports_entry->subdir == NULL); lprocfs_remove(&obd->obd_proc_exports_entry); + obd->obd_proc_exports_entry = NULL; } lprocfs_remove(&obd->obd_proc_entry); return 0; diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 36cb74c..eb8d415 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -397,8 +397,10 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) RETURN(0); err_exp: - class_unlink_export(obd->obd_self_export); - obd->obd_self_export = NULL; + if (obd->obd_self_export) { + class_unlink_export(obd->obd_self_export); + obd->obd_self_export = NULL; + } err_hash: if (obd->obd_uuid_hash) { lustre_hash_exit(obd->obd_uuid_hash); @@ -497,7 +499,7 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) /* Leave this on forever */ obd->obd_stopping = 1; spin_unlock(&obd->obd_dev_lock); - + if (lcfg->lcfg_bufcount >= 2 && LUSTRE_CFG_BUFLEN(lcfg, 1) > 0) { for (flag = lustre_cfg_string(lcfg, 1); *flag != 0; flag++) switch (*flag) { @@ -514,32 +516,22 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) obd_iocontrol(OBD_IOC_SYNC, obd->obd_self_export, 0, NULL, NULL); - /* Set the obd readonly if we can */ + /* Set the obd readonly if we can */ obd_iocontrol(OBD_IOC_SET_READONLY, obd->obd_self_export, 0, NULL, NULL); } break; default: - CERROR("unrecognised flag '%c'\n", - *flag); + CERROR("Unrecognised flag '%c'\n", *flag); } } + LASSERT(obd->obd_self_export); + /* The three references that should be remaining are the * obd_self_export and the attach and setup references. */ if (atomic_read(&obd->obd_refcount) > 3) { -#if 0 /* We should never fail to cleanup with mountconf */ - if (!(obd->obd_fail || obd->obd_force)) { - CERROR("OBD %s is still busy with %d references\n" - "You should stop active file system users," - " or use the --force option to cleanup.\n", - obd->obd_name, atomic_read(&obd->obd_refcount)); - dump_exports(obd); - /* Allow a failed cleanup to try again. */ - obd->obd_stopping = 0; - } -#endif /* refcounf - 3 might be the number of real exports (excluding self export). But class_incref is called by other things as well, so don't count on it. */ @@ -548,16 +540,24 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) dump_exports(obd); class_disconnect_exports(obd); } - LASSERT(obd->obd_self_export); /* destroy an uuid-export hash body */ - lustre_hash_exit(obd->obd_uuid_hash); + if (obd->obd_uuid_hash) { + lustre_hash_exit(obd->obd_uuid_hash); + obd->obd_uuid_hash = NULL; + } /* destroy a nid-export hash body */ - lustre_hash_exit(obd->obd_nid_hash); + if (obd->obd_nid_hash) { + lustre_hash_exit(obd->obd_nid_hash); + obd->obd_nid_hash = NULL; + } /* destroy a nid-stats hash body */ - lustre_hash_exit(obd->obd_nid_stats_hash); + if (obd->obd_nid_stats_hash) { + lustre_hash_exit(obd->obd_nid_stats_hash); + obd->obd_nid_stats_hash = NULL; + } /* Precleanup, we must make sure all exports get destroyed. */ err = obd_precleanup(obd, OBD_CLEANUP_EXPORTS); @@ -620,7 +620,7 @@ void class_decref(struct obd_device *obd, const char *scope, const void *source) obd->obd_name, err); } if (OBP(obd, detach)) { - err = OBP(obd,detach)(obd); + err = OBP(obd, detach)(obd); if (err) CERROR("Detach returned %d\n", err); } @@ -1360,10 +1360,10 @@ parse_out: /* Cleanup and detach */ int class_manual_cleanup(struct obd_device *obd) { - struct lustre_cfg *lcfg; - struct lustre_cfg_bufs bufs; - int rc; - char flags[3]=""; + char flags[3] = ""; + struct lustre_cfg *lcfg; + struct lustre_cfg_bufs bufs; + int rc; ENTRY; if (!obd) { @@ -1382,6 +1382,8 @@ int class_manual_cleanup(struct obd_device *obd) lustre_cfg_bufs_reset(&bufs, obd->obd_name); lustre_cfg_bufs_set_string(&bufs, 1, flags); lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); + if (!lcfg) + RETURN(-ENOMEM); rc = class_process_config(lcfg); if (rc) { diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 6b270a6..65c0be4 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -3683,7 +3683,7 @@ static int osc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, &catid->lci_logid, &osc_mds_ost_orig_logops); if (rc) { CERROR("failed LLOG_MDS_OST_ORIG_CTXT\n"); - GOTO (out, rc); + GOTO(out, rc); } rc = llog_setup(obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, tgt, count, diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh index 3a7e638..1a40330 100755 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -1487,6 +1487,16 @@ test_61c() { } run_test 61c "test race mds llog sync vs llog cleanup" +test_61d() { # bug 16002 # bug 17466 +#define OBD_FAIL_OBD_LLOG_SETUP 0x605 + shutdown_facet $SINGLEMDS + do_facet $SINGLEMDS "lctl set_param fail_loc=0x605" + start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS && error "mds start should have failed" + do_facet $SINGLEMDS "lctl set_param fail_loc=0" + start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS || error "cannot restart mds" +} +run_test 61d "error in llog_setup should cleanup the llog context correctly" + test_62() { # Bug 15756 - don't mis-drop resent replay mkdir -p $DIR/$tdir replay_barrier $SINGLEMDS