]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/ocfs2/dlm/dlmdomain.c
ocfs2/dlm: Track number of mles
[linux-2.6-omap-h63xx.git] / fs / ocfs2 / dlm / dlmdomain.c
index 0879d86113e347d2706d215223b81bda575cc002..0479bdf91c2b926b6df4d803ab125c36f026fd8c 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/spinlock.h>
 #include <linux/delay.h>
 #include <linux/err.h>
+#include <linux/debugfs.h>
 
 #include "cluster/heartbeat.h"
 #include "cluster/nodemanager.h"
@@ -40,8 +41,8 @@
 
 #include "dlmapi.h"
 #include "dlmcommon.h"
-
 #include "dlmdomain.h"
+#include "dlmdebug.h"
 
 #include "dlmver.h"
 
@@ -298,9 +299,14 @@ static int dlm_wait_on_domain_helper(const char *domain)
 
 static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm)
 {
+       dlm_destroy_debugfs_subroot(dlm);
+
        if (dlm->lockres_hash)
                dlm_free_pagevec((void **)dlm->lockres_hash, DLM_HASH_PAGES);
 
+       if (dlm->master_hash)
+               dlm_free_pagevec((void **)dlm->master_hash, DLM_HASH_PAGES);
+
        if (dlm->name)
                kfree(dlm->name);
 
@@ -395,6 +401,7 @@ static void dlm_destroy_dlm_worker(struct dlm_ctxt *dlm)
 static void dlm_complete_dlm_shutdown(struct dlm_ctxt *dlm)
 {
        dlm_unregister_domain_handlers(dlm);
+       dlm_debug_shutdown(dlm);
        dlm_complete_thread(dlm);
        dlm_complete_recovery_thread(dlm);
        dlm_destroy_dlm_worker(dlm);
@@ -644,6 +651,7 @@ int dlm_shutting_down(struct dlm_ctxt *dlm)
 void dlm_unregister_domain(struct dlm_ctxt *dlm)
 {
        int leave = 0;
+       struct dlm_lock_resource *res;
 
        spin_lock(&dlm_domain_lock);
        BUG_ON(dlm->dlm_state != DLM_CTXT_JOINED);
@@ -673,6 +681,15 @@ void dlm_unregister_domain(struct dlm_ctxt *dlm)
                        msleep(500);
                        mlog(0, "%s: more migration to do\n", dlm->name);
                }
+
+               /* This list should be empty. If not, print remaining lockres */
+               if (!list_empty(&dlm->tracking_list)) {
+                       mlog(ML_ERROR, "Following lockres' are still on the "
+                            "tracking list:\n");
+                       list_for_each_entry(res, &dlm->tracking_list, tracking)
+                               dlm_print_one_lock_resource(res);
+               }
+
                dlm_mark_domain_leaving(dlm);
                dlm_leave_domain(dlm);
                dlm_complete_dlm_shutdown(dlm);
@@ -1405,6 +1422,12 @@ static int dlm_join_domain(struct dlm_ctxt *dlm)
                goto bail;
        }
 
+       status = dlm_debug_init(dlm);
+       if (status < 0) {
+               mlog_errno(status);
+               goto bail;
+       }
+
        status = dlm_launch_thread(dlm);
        if (status < 0) {
                mlog_errno(status);
@@ -1472,6 +1495,7 @@ bail:
 
        if (status) {
                dlm_unregister_domain_handlers(dlm);
+               dlm_debug_shutdown(dlm);
                dlm_complete_thread(dlm);
                dlm_complete_recovery_thread(dlm);
                dlm_destroy_dlm_worker(dlm);
@@ -1484,6 +1508,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
                                u32 key)
 {
        int i;
+       int ret;
        struct dlm_ctxt *dlm = NULL;
 
        dlm = kzalloc(sizeof(*dlm), GFP_KERNEL);
@@ -1512,13 +1537,38 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
        for (i = 0; i < DLM_HASH_BUCKETS; i++)
                INIT_HLIST_HEAD(dlm_lockres_hash(dlm, i));
 
+       dlm->master_hash = (struct hlist_head **)
+                               dlm_alloc_pagevec(DLM_HASH_PAGES);
+       if (!dlm->master_hash) {
+               mlog_errno(-ENOMEM);
+               dlm_free_pagevec((void **)dlm->lockres_hash, DLM_HASH_PAGES);
+               kfree(dlm->name);
+               kfree(dlm);
+               dlm = NULL;
+               goto leave;
+       }
+
+       for (i = 0; i < DLM_HASH_BUCKETS; i++)
+               INIT_HLIST_HEAD(dlm_master_hash(dlm, i));
+
        strcpy(dlm->name, domain);
        dlm->key = key;
        dlm->node_num = o2nm_this_node();
 
+       ret = dlm_create_debugfs_subroot(dlm);
+       if (ret < 0) {
+               dlm_free_pagevec((void **)dlm->master_hash, DLM_HASH_PAGES);
+               dlm_free_pagevec((void **)dlm->lockres_hash, DLM_HASH_PAGES);
+               kfree(dlm->name);
+               kfree(dlm);
+               dlm = NULL;
+               goto leave;
+       }
+
        spin_lock_init(&dlm->spinlock);
        spin_lock_init(&dlm->master_lock);
        spin_lock_init(&dlm->ast_lock);
+       spin_lock_init(&dlm->track_lock);
        INIT_LIST_HEAD(&dlm->list);
        INIT_LIST_HEAD(&dlm->dirty_list);
        INIT_LIST_HEAD(&dlm->reco.resources);
@@ -1526,6 +1576,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
        INIT_LIST_HEAD(&dlm->reco.node_data);
        INIT_LIST_HEAD(&dlm->purge_list);
        INIT_LIST_HEAD(&dlm->dlm_domain_handlers);
+       INIT_LIST_HEAD(&dlm->tracking_list);
        dlm->reco.state = 0;
 
        INIT_LIST_HEAD(&dlm->pending_asts);
@@ -1546,7 +1597,6 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
        init_waitqueue_head(&dlm->reco.event);
        init_waitqueue_head(&dlm->ast_wq);
        init_waitqueue_head(&dlm->migration_wq);
-       INIT_LIST_HEAD(&dlm->master_list);
        INIT_LIST_HEAD(&dlm->mle_hb_events);
 
        dlm->joining_node = DLM_LOCK_RES_OWNER_UNKNOWN;
@@ -1558,6 +1608,11 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
        atomic_set(&dlm->remote_resources, 0);
        atomic_set(&dlm->unknown_resources, 0);
 
+       for (i = 0; i < DLM_MLE_NUM_TYPES; ++i) {
+               atomic_set(&dlm->mle_tot_count[i], 0);
+               atomic_set(&dlm->mle_cur_count[i], 0);
+       }
+
        spin_lock_init(&dlm->work_lock);
        INIT_LIST_HEAD(&dlm->work_list);
        INIT_WORK(&dlm->dispatched_work, dlm_dispatch_work);
@@ -1816,21 +1871,49 @@ static int __init dlm_init(void)
        dlm_print_version();
 
        status = dlm_init_mle_cache();
-       if (status)
-               return -1;
+       if (status) {
+               mlog(ML_ERROR, "Could not create o2dlm_mle slabcache\n");
+               goto error;
+       }
+
+       status = dlm_init_master_caches();
+       if (status) {
+               mlog(ML_ERROR, "Could not create o2dlm_lockres and "
+                    "o2dlm_lockname slabcaches\n");
+               goto error;
+       }
+
+       status = dlm_init_lock_cache();
+       if (status) {
+               mlog(ML_ERROR, "Count not create o2dlm_lock slabcache\n");
+               goto error;
+       }
 
        status = dlm_register_net_handlers();
        if (status) {
-               dlm_destroy_mle_cache();
-               return -1;
+               mlog(ML_ERROR, "Unable to register network handlers\n");
+               goto error;
        }
 
+       status = dlm_create_debugfs_root();
+       if (status)
+               goto error;
+
        return 0;
+error:
+       dlm_unregister_net_handlers();
+       dlm_destroy_lock_cache();
+       dlm_destroy_master_caches();
+       dlm_destroy_mle_cache();
+       return -1;
 }
 
 static void __exit dlm_exit (void)
 {
+       dlm_destroy_debugfs_root();
        dlm_unregister_net_handlers();
+       dlm_destroy_lock_cache();
+       dlm_destroy_master_caches();
        dlm_destroy_mle_cache();
 }