From a6527b28ba2082a445fbf584909a7791ce407ef3 Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Fri, 13 Aug 2010 09:15:06 +0400 Subject: [PATCH] b=23428 Fix lustre built with --enable-lu_ref Fix issues found with --enable-lu_ref. i=adilger i=oleg i=zam --- lustre/include/lustre_lib.h | 3 +++ lustre/include/obd_support.h | 1 + lustre/ldlm/ldlm_lib.c | 20 ++++++++++---------- lustre/ldlm/ldlm_lock.c | 9 +++++---- lustre/ldlm/ldlm_lockd.c | 3 +++ lustre/ldlm/ldlm_request.c | 4 ++-- lustre/ldlm/ldlm_resource.c | 2 ++ lustre/mdt/mdt_handler.c | 2 +- lustre/obdclass/lu_ref.c | 2 +- lustre/obdfilter/filter.c | 2 +- lustre/ost/ost_handler.c | 7 ++++++- lustre/ptlrpc/pinger.c | 4 ++-- lustre/tests/sanity.sh | 8 ++++++++ 13 files changed, 45 insertions(+), 22 deletions(-) diff --git a/lustre/include/lustre_lib.h b/lustre/include/lustre_lib.h index 1af68a6..02cc979 100644 --- a/lustre/include/lustre_lib.h +++ b/lustre/include/lustre_lib.h @@ -92,6 +92,9 @@ int target_handle_dqacq_callback(struct ptlrpc_request *req); #define OBD_RECOVERY_MAX_TIME (obd_timeout * 18) /* b13079 */ +void target_cancel_recovery_timer(struct obd_device *obd); +void target_stop_recovery_thread(struct obd_device *obd); +void target_cleanup_recovery(struct obd_device *obd); int target_queue_recovery_request(struct ptlrpc_request *req, struct obd_device *obd); void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id); diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 5529026..9d71800 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -307,6 +307,7 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317 #define OBD_FAIL_LDLM_CP_BL_RACE 0x318 +#define OBD_FAIL_LDLM_NEW_LOCK 0x319 /* LOCKLESS IO */ #define OBD_FAIL_LDLM_SET_CONTENTION 0x385 diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index ad7a4ef..f1dbcd2 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -1254,13 +1254,7 @@ static void abort_lock_replay_queue(struct obd_device *obd) target_request_copy_put(req); } } - -/* obd_processing_task_lock should be held */ -static void target_cancel_recovery_timer(struct obd_device *obd) -{ - CDEBUG(D_HA, "%s: cancel recovery timer\n", obd->obd_name); - cfs_timer_disarm(&obd->obd_recovery_timer); -} +#endif /* Called from a cleanup function if the device is being cleaned up forcefully. The exports should all have been disconnected already, @@ -1271,7 +1265,7 @@ static void target_cancel_recovery_timer(struct obd_device *obd) Because the obd_stopping flag is set, no new requests should be received. */ -static void target_cleanup_recovery(struct obd_device *obd) +void target_cleanup_recovery(struct obd_device *obd) { struct ptlrpc_request *req, *n; cfs_list_t clean_list; @@ -1308,7 +1302,13 @@ static void target_cleanup_recovery(struct obd_device *obd) EXIT; } -#endif + +/* obd_processing_task_lock should be held */ +void target_cancel_recovery_timer(struct obd_device *obd) +{ + CDEBUG(D_HA, "%s: cancel recovery timer\n", obd->obd_name); + cfs_timer_disarm(&obd->obd_recovery_timer); +} /* extend = 1 means require at least "duration" seconds left in the timer, extend = 0 means set the total duration (start_recovery_timer) */ @@ -1840,7 +1840,7 @@ static int target_start_recovery_thread(struct lu_target *lut, return rc; } -static void target_stop_recovery_thread(struct obd_device *obd) +void target_stop_recovery_thread(struct obd_device *obd) { cfs_spin_lock_bh(&obd->obd_processing_task_lock); if (obd->obd_recovery_data.trd_processing_task > 0) { diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 1ef0ade..2cdd68b 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -1201,13 +1201,14 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, GOTO(out, 0); } + if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_NEW_LOCK)) + GOTO(out, 0); + RETURN(lock); out: - if (lock->l_lvb_data) - OBD_FREE(lock->l_lvb_data, lvb_len); - ldlm_interval_free(ldlm_interval_detach(lock)); - OBD_SLAB_FREE(lock, ldlm_lock_slab, sizeof(*lock)); + ldlm_lock_destroy(lock); + LDLM_LOCK_RELEASE(lock); return NULL; } diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index bded12b..81075ee 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -2699,8 +2699,11 @@ EXPORT_SYMBOL(client_obd_cleanup); EXPORT_SYMBOL(client_connect_import); EXPORT_SYMBOL(client_disconnect_export); EXPORT_SYMBOL(server_disconnect_export); +EXPORT_SYMBOL(target_stop_recovery_thread); EXPORT_SYMBOL(target_handle_connect); +EXPORT_SYMBOL(target_cleanup_recovery); EXPORT_SYMBOL(target_destroy_export); +EXPORT_SYMBOL(target_cancel_recovery_timer); EXPORT_SYMBOL(target_send_reply); EXPORT_SYMBOL(target_queue_recovery_request); EXPORT_SYMBOL(target_handle_ping); diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 13e3a6d..e283eee 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -2128,11 +2128,11 @@ int ldlm_replay_locks(struct obd_import *imp) cfs_list_for_each_entry_safe(lock, next, &list, l_pending_chain) { cfs_list_del_init(&lock->l_pending_chain); if (rc) { - LDLM_LOCK_PUT(lock); + LDLM_LOCK_RELEASE(lock); continue; /* or try to do the rest? */ } rc = replay_one_lock(imp, lock); - LDLM_LOCK_PUT(lock); + LDLM_LOCK_RELEASE(lock); } cfs_atomic_dec(&imp->imp_replay_inflight); diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index 3fa5d26..b10c4b5 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -864,6 +864,8 @@ ldlm_resource_add(struct ldlm_namespace *ns, struct ldlm_resource *parent, /* someone won the race and added the resource before */ ldlm_resource_getref(old_res); cfs_spin_unlock(&ns->ns_hash_lock); + /* clean lu_ref for failed resource */ + lu_ref_fini(&res->lr_reference); OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res); /* synchronize WRT resource creation */ if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) { diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 5ce7b7d..aec469b 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -5499,7 +5499,7 @@ static int mdt_iocontrol(unsigned int cmd, struct obd_export *exp, int len, break; case OBD_IOC_ABORT_RECOVERY: CERROR("Aborting recovery for device %s\n", obd->obd_name); - target_recovery_fini(obd); + target_stop_recovery_thread(obd); rc = 0; break; case OBD_IOC_CHANGELOG_REG: diff --git a/lustre/obdclass/lu_ref.c b/lustre/obdclass/lu_ref.c index b7bc320..fdaac5f 100644 --- a/lustre/obdclass/lu_ref.c +++ b/lustre/obdclass/lu_ref.c @@ -70,8 +70,8 @@ lu_ref_print(__ref); \ cfs_spin_unlock(&__ref->lf_guard); \ lu_ref_print_all(); \ - cfs_spin_lock(&__ref->lf_guard); \ LASSERT(0); \ + cfs_spin_lock(&__ref->lf_guard); \ } \ } while (0) diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 83453db..a731840 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -4474,7 +4474,7 @@ int filter_iocontrol(unsigned int cmd, struct obd_export *exp, switch (cmd) { case OBD_IOC_ABORT_RECOVERY: { LCONSOLE_WARN("%s: Aborting recovery.\n", obd->obd_name); - target_recovery_fini(obd); + target_stop_recovery_thread(obd); RETURN(0); } diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index e0ccbb4..b549391 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -2622,7 +2622,12 @@ static int ost_cleanup(struct obd_device *obd) ping_evictor_stop(); - LASSERT(obd->obd_recovering == 0); + cfs_spin_lock_bh(&obd->obd_processing_task_lock); + if (obd->obd_recovering) { + target_cancel_recovery_timer(obd); + obd->obd_recovering = 0; + } + cfs_spin_unlock_bh(&obd->obd_processing_task_lock); cfs_down(&ost->ost_health_sem); ptlrpc_unregister_service(ost->ost_service); diff --git a/lustre/ptlrpc/pinger.c b/lustre/ptlrpc/pinger.c index 821f55c..6724762 100644 --- a/lustre/ptlrpc/pinger.c +++ b/lustre/ptlrpc/pinger.c @@ -599,7 +599,7 @@ int ping_evictor_wake(struct obd_export *exp) obd = class_exp2obd(exp); if (cfs_list_empty(&obd->obd_evict_list)) { - class_incref(obd, __FUNCTION__, cfs_current()); + class_incref(obd, "evictor", obd); cfs_list_add(&obd->obd_evict_list, &pet_list); } cfs_spin_unlock(&pet_lock); @@ -682,7 +682,7 @@ static int ping_evictor_main(void *arg) cfs_list_del_init(&obd->obd_evict_list); cfs_spin_unlock(&pet_lock); - class_decref(obd, __FUNCTION__, cfs_current()); + class_decref(obd, "evictor", obd); } CDEBUG(D_HA, "Exiting Ping Evictor\n"); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 5ac946d..4b70d66 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -3897,6 +3897,14 @@ test_74b() { # bug 13310 } run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)" +test_74c() { +#define OBD_FAIL_LDLM_NEW_LOCK + lctl set_param fail_loc=0x80000319 + touch $DIR/$tfile && error "Touch successful" + true +} +run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)" + num_inodes() { awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo } -- 1.8.3.1