Whamcloud - gitweb
b=23428 Fix lustre built with --enable-lu_ref
authorMikhail Pershin <tappro@sun.com>
Fri, 13 Aug 2010 05:15:06 +0000 (09:15 +0400)
committerMikhail Pershin <tappro@sun.com>
Fri, 13 Aug 2010 06:46:14 +0000 (10:46 +0400)
Fix issues found with --enable-lu_ref.

i=adilger
i=oleg
i=zam

13 files changed:
lustre/include/lustre_lib.h
lustre/include/obd_support.h
lustre/ldlm/ldlm_lib.c
lustre/ldlm/ldlm_lock.c
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_request.c
lustre/ldlm/ldlm_resource.c
lustre/mdt/mdt_handler.c
lustre/obdclass/lu_ref.c
lustre/obdfilter/filter.c
lustre/ost/ost_handler.c
lustre/ptlrpc/pinger.c
lustre/tests/sanity.sh

index 1af68a6..02cc979 100644 (file)
@@ -92,6 +92,9 @@ int target_handle_dqacq_callback(struct ptlrpc_request *req);
 
 #define OBD_RECOVERY_MAX_TIME (obd_timeout * 18) /* b13079 */
 
 
 #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);
 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);
index 5529026..9d71800 100644 (file)
@@ -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_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
 
 /* LOCKLESS IO */
 #define OBD_FAIL_LDLM_SET_CONTENTION     0x385
index ad7a4ef..f1dbcd2 100644 (file)
@@ -1254,13 +1254,7 @@ static void abort_lock_replay_queue(struct obd_device *obd)
                 target_request_copy_put(req);
         }
 }
                 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,
 
 /* 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.
 
 */
    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;
 {
         struct ptlrpc_request *req, *n;
         cfs_list_t clean_list;
@@ -1308,7 +1302,13 @@ static void target_cleanup_recovery(struct obd_device *obd)
 
         EXIT;
 }
 
         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) */
 
 /* 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;
 }
 
         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) {
 {
         cfs_spin_lock_bh(&obd->obd_processing_task_lock);
         if (obd->obd_recovery_data.trd_processing_task > 0) {
index 1ef0ade..2cdd68b 100644 (file)
@@ -1201,13 +1201,14 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
                         GOTO(out, 0);
         }
 
                         GOTO(out, 0);
         }
 
+        if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_NEW_LOCK))
+                GOTO(out, 0);
+
         RETURN(lock);
 
 out:
         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;
 }
 
         return NULL;
 }
 
index bded12b..81075ee 100644 (file)
@@ -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(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_handle_connect);
+EXPORT_SYMBOL(target_cleanup_recovery);
 EXPORT_SYMBOL(target_destroy_export);
 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);
 EXPORT_SYMBOL(target_send_reply);
 EXPORT_SYMBOL(target_queue_recovery_request);
 EXPORT_SYMBOL(target_handle_ping);
index 13e3a6d..e283eee 100644 (file)
@@ -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) {
         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);
                         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);
         }
 
         cfs_atomic_dec(&imp->imp_replay_inflight);
index 3fa5d26..b10c4b5 100644 (file)
@@ -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);
                 /* 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) {
                 OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res);
                 /* synchronize WRT resource creation */
                 if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) {
index 5ce7b7d..aec469b 100644 (file)
@@ -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);
                 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:
                 rc = 0;
                 break;
         case OBD_IOC_CHANGELOG_REG:
index b7bc320..fdaac5f 100644 (file)
@@ -70,8 +70,8 @@
                   lu_ref_print(__ref);                  \
                   cfs_spin_unlock(&__ref->lf_guard);    \
                   lu_ref_print_all();                   \
                   lu_ref_print(__ref);                  \
                   cfs_spin_unlock(&__ref->lf_guard);    \
                   lu_ref_print_all();                   \
-                  cfs_spin_lock(&__ref->lf_guard);      \
                   LASSERT(0);                           \
                   LASSERT(0);                           \
+                  cfs_spin_lock(&__ref->lf_guard);      \
           }                                             \
   } while (0)
 
           }                                             \
   } while (0)
 
index 83453db..a731840 100644 (file)
@@ -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);
         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);
         }
 
                 RETURN(0);
         }
 
index e0ccbb4..b549391 100644 (file)
@@ -2622,7 +2622,12 @@ static int ost_cleanup(struct obd_device *obd)
 
         ping_evictor_stop();
 
 
         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);
 
         cfs_down(&ost->ost_health_sem);
         ptlrpc_unregister_service(ost->ost_service);
index 821f55c..6724762 100644 (file)
@@ -599,7 +599,7 @@ int ping_evictor_wake(struct obd_export *exp)
 
         obd = class_exp2obd(exp);
         if (cfs_list_empty(&obd->obd_evict_list)) {
 
         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);
                 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);
 
                 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");
 
         }
         CDEBUG(D_HA, "Exiting Ping Evictor\n");
 
index 5ac946d..4b70d66 100755 (executable)
@@ -3897,6 +3897,14 @@ test_74b() { # bug 13310
 }
 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
 
 }
 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
 }
 num_inodes() {
        awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
 }