ocfs2: trivial fix for s/migrate/migration/ in dlmrecovery.c logging
[safe/jmp/linux-2.6] / fs / ocfs2 / dlm / dlmdebug.c
index 53a9e60..df52f70 100644 (file)
@@ -44,7 +44,8 @@
 #define MLOG_MASK_PREFIX ML_DLM
 #include "cluster/masklog.h"
 
-int stringify_lockname(const char *lockname, int locklen, char *buf, int len);
+static int stringify_lockname(const char *lockname, int locklen, char *buf,
+                             int len);
 
 void dlm_print_one_lock_resource(struct dlm_lock_resource *res)
 {
@@ -58,23 +59,23 @@ static void dlm_print_lockres_refmap(struct dlm_lock_resource *res)
        int bit;
        assert_spin_locked(&res->spinlock);
 
-       printk(KERN_NOTICE "  refmap nodes: [ ");
+       printk("  refmap nodes: [ ");
        bit = 0;
        while (1) {
                bit = find_next_bit(res->refmap, O2NM_MAX_NODES, bit);
                if (bit >= O2NM_MAX_NODES)
                        break;
-               printk(KERN_NOTICE "%u ", bit);
+               printk("%u ", bit);
                bit++;
        }
-       printk(KERN_NOTICE "], inflight=%u\n", res->inflight_locks);
+       printk("], inflight=%u\n", res->inflight_locks);
 }
 
 static void __dlm_print_lock(struct dlm_lock *lock)
 {
        spin_lock(&lock->spinlock);
 
-       printk(KERN_NOTICE "    type=%d, conv=%d, node=%u, cookie=%u:%llu, "
+       printk("    type=%d, conv=%d, node=%u, cookie=%u:%llu, "
               "ref=%u, ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c), "
               "pending=(conv=%c,lock=%c,cancel=%c,unlock=%c)\n",
               lock->ml.type, lock->ml.convert_type, lock->ml.node,
@@ -103,30 +104,30 @@ void __dlm_print_one_lock_resource(struct dlm_lock_resource *res)
 
        stringify_lockname(res->lockname.name, res->lockname.len,
                           buf, sizeof(buf) - 1);
-       printk(KERN_NOTICE "lockres: %s, owner=%u, state=%u\n",
+       printk("lockres: %s, owner=%u, state=%u\n",
               buf, res->owner, res->state);
-       printk(KERN_NOTICE "  last used: %lu, refcnt: %u, on purge list: %s\n",
+       printk("  last used: %lu, refcnt: %u, on purge list: %s\n",
               res->last_used, atomic_read(&res->refs.refcount),
               list_empty(&res->purge) ? "no" : "yes");
-       printk(KERN_NOTICE "  on dirty list: %s, on reco list: %s, "
+       printk("  on dirty list: %s, on reco list: %s, "
               "migrating pending: %s\n",
               list_empty(&res->dirty) ? "no" : "yes",
               list_empty(&res->recovering) ? "no" : "yes",
               res->migration_pending ? "yes" : "no");
-       printk(KERN_NOTICE "  inflight locks: %d, asts reserved: %d\n",
+       printk("  inflight locks: %d, asts reserved: %d\n",
               res->inflight_locks, atomic_read(&res->asts_reserved));
        dlm_print_lockres_refmap(res);
-       printk(KERN_NOTICE "  granted queue:\n");
+       printk("  granted queue:\n");
        list_for_each(iter2, &res->granted) {
                lock = list_entry(iter2, struct dlm_lock, list);
                __dlm_print_lock(lock);
        }
-       printk(KERN_NOTICE "  converting queue:\n");
+       printk("  converting queue:\n");
        list_for_each(iter2, &res->converting) {
                lock = list_entry(iter2, struct dlm_lock, list);
                __dlm_print_lock(lock);
        }
-       printk(KERN_NOTICE "  blocked queue:\n");
+       printk("  blocked queue:\n");
        list_for_each(iter2, &res->blocked) {
                lock = list_entry(iter2, struct dlm_lock, list);
                __dlm_print_lock(lock);
@@ -251,7 +252,8 @@ EXPORT_SYMBOL_GPL(dlm_errname);
  *
  * For more on lockname formats, please refer to dlmglue.c and ocfs2_lockid.h.
  */
-int stringify_lockname(const char *lockname, int locklen, char *buf, int len)
+static int stringify_lockname(const char *lockname, int locklen, char *buf,
+                             int len)
 {
        int out = 0;
        __be64 inode_blkno_be;
@@ -285,18 +287,8 @@ static int stringify_nodemap(unsigned long *nodemap, int maxnodes,
 static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len)
 {
        int out = 0;
-       unsigned int namelen;
-       const char *name;
        char *mle_type;
 
-       if (mle->type != DLM_MLE_MASTER) {
-               namelen = mle->u.name.len;
-               name = mle->u.name.name;
-       } else {
-               namelen = mle->u.res->lockname.len;
-               name = mle->u.res->lockname.name;
-       }
-
        if (mle->type == DLM_MLE_BLOCK)
                mle_type = "BLK";
        else if (mle->type == DLM_MLE_MASTER)
@@ -304,7 +296,7 @@ static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len)
        else
                mle_type = "MIG";
 
-       out += stringify_lockname(name, namelen, buf + out, len - out);
+       out += stringify_lockname(mle->mname, mle->mnamelen, buf + out, len - out);
        out += snprintf(buf + out, len - out,
                        "\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n",
                        mle_type, mle->master, mle->new_master,
@@ -368,7 +360,7 @@ static void dlm_debug_free(struct kref *kref)
        kfree(dc);
 }
 
-void dlm_debug_put(struct dlm_debug_ctxt *dc)
+static void dlm_debug_put(struct dlm_debug_ctxt *dc)
 {
        if (dc)
                kref_put(&dc->debug_refcnt, dlm_debug_free);
@@ -499,23 +491,33 @@ static struct file_operations debug_purgelist_fops = {
 static int debug_mle_print(struct dlm_ctxt *dlm, struct debug_buffer *db)
 {
        struct dlm_master_list_entry *mle;
-       int out = 0;
-       unsigned long total = 0;
+       struct hlist_head *bucket;
+       struct hlist_node *list;
+       int i, out = 0;
+       unsigned long total = 0, longest = 0, bktcnt;
 
        out += snprintf(db->buf + out, db->len - out,
                        "Dumping MLEs for Domain: %s\n", dlm->name);
 
        spin_lock(&dlm->master_lock);
-       list_for_each_entry(mle, &dlm->master_list, list) {
-               ++total;
-               if (db->len - out < 200)
-                       continue;
-               out += dump_mle(mle, db->buf + out, db->len - out);
+       for (i = 0; i < DLM_HASH_BUCKETS; i++) {
+               bucket = dlm_master_hash(dlm, i);
+               hlist_for_each(list, bucket) {
+                       mle = hlist_entry(list, struct dlm_master_list_entry,
+                                         master_hash_node);
+                       ++total;
+                       ++bktcnt;
+                       if (db->len - out < 200)
+                               continue;
+                       out += dump_mle(mle, db->buf + out, db->len - out);
+               }
+               longest = max(longest, bktcnt);
+               bktcnt = 0;
        }
        spin_unlock(&dlm->master_lock);
 
        out += snprintf(db->buf + out, db->len - out,
-                       "Total on list: %ld\n", total);
+                       "Total: %ld, Longest: %ld\n", total, longest);
        return out;
 }
 
@@ -628,43 +630,38 @@ static void *lockres_seq_start(struct seq_file *m, loff_t *pos)
 {
        struct debug_lockres *dl = m->private;
        struct dlm_ctxt *dlm = dl->dl_ctxt;
+       struct dlm_lock_resource *oldres = dl->dl_res;
        struct dlm_lock_resource *res = NULL;
+       struct list_head *track_list;
 
-       spin_lock(&dlm->spinlock);
+       spin_lock(&dlm->track_lock);
+       if (oldres)
+               track_list = &oldres->tracking;
+       else
+               track_list = &dlm->tracking_list;
 
-       if (dl->dl_res) {
-               list_for_each_entry(res, &dl->dl_res->tracking, tracking) {
-                       if (dl->dl_res) {
-                               dlm_lockres_put(dl->dl_res);
-                               dl->dl_res = NULL;
-                       }
-                       if (&res->tracking == &dlm->tracking_list) {
-                               mlog(0, "End of list found, %p\n", res);
-                               dl = NULL;
-                               break;
-                       }
-                       dlm_lockres_get(res);
-                       dl->dl_res = res;
-                       break;
-               }
-       } else {
-               if (!list_empty(&dlm->tracking_list)) {
-                       list_for_each_entry(res, &dlm->tracking_list, tracking)
-                               break;
+       list_for_each_entry(res, track_list, tracking) {
+               if (&res->tracking == &dlm->tracking_list)
+                       res = NULL;
+               else
                        dlm_lockres_get(res);
-                       dl->dl_res = res;
-               } else
-                       dl = NULL;
+               break;
        }
+       spin_unlock(&dlm->track_lock);
 
-       if (dl) {
-               spin_lock(&dl->dl_res->spinlock);
-               dump_lockres(dl->dl_res, dl->dl_buf, dl->dl_len - 1);
-               spin_unlock(&dl->dl_res->spinlock);
-       }
+       if (oldres)
+               dlm_lockres_put(oldres);
 
-       spin_unlock(&dlm->spinlock);
+       dl->dl_res = res;
 
+       if (res) {
+               spin_lock(&res->spinlock);
+               dump_lockres(res, dl->dl_buf, dl->dl_len - 1);
+               spin_unlock(&res->spinlock);
+       } else
+               dl = NULL;
+
+       /* passed to seq_show */
        return dl;
 }
 
@@ -759,12 +756,8 @@ static int debug_state_print(struct dlm_ctxt *dlm, struct debug_buffer *db)
        int out = 0;
        struct dlm_reco_node_data *node;
        char *state;
-       int lres, rres, ures, tres;
-
-       lres = atomic_read(&dlm->local_resources);
-       rres = atomic_read(&dlm->remote_resources);
-       ures = atomic_read(&dlm->unknown_resources);
-       tres = lres + rres + ures;
+       int cur_mles = 0, tot_mles = 0;
+       int i;
 
        spin_lock(&dlm->spinlock);
 
@@ -807,21 +800,48 @@ static int debug_state_print(struct dlm_ctxt *dlm, struct debug_buffer *db)
                                 db->buf + out, db->len - out);
        out += snprintf(db->buf + out, db->len - out, "\n");
 
-       /* Mastered Resources Total: xxx  Locally: xxx  Remotely: ... */
+       /* Lock Resources: xxx (xxx) */
+       out += snprintf(db->buf + out, db->len - out,
+                       "Lock Resources: %d (%d)\n",
+                       atomic_read(&dlm->res_cur_count),
+                       atomic_read(&dlm->res_tot_count));
+
+       for (i = 0; i < DLM_MLE_NUM_TYPES; ++i)
+               tot_mles += atomic_read(&dlm->mle_tot_count[i]);
+
+       for (i = 0; i < DLM_MLE_NUM_TYPES; ++i)
+               cur_mles += atomic_read(&dlm->mle_cur_count[i]);
+
+       /* MLEs: xxx (xxx) */
+       out += snprintf(db->buf + out, db->len - out,
+                       "MLEs: %d (%d)\n", cur_mles, tot_mles);
+
+       /*  Blocking: xxx (xxx) */
+       out += snprintf(db->buf + out, db->len - out,
+                       "  Blocking: %d (%d)\n",
+                       atomic_read(&dlm->mle_cur_count[DLM_MLE_BLOCK]),
+                       atomic_read(&dlm->mle_tot_count[DLM_MLE_BLOCK]));
+
+       /*  Mastery: xxx (xxx) */
+       out += snprintf(db->buf + out, db->len - out,
+                       "  Mastery: %d (%d)\n",
+                       atomic_read(&dlm->mle_cur_count[DLM_MLE_MASTER]),
+                       atomic_read(&dlm->mle_tot_count[DLM_MLE_MASTER]));
+
+       /*  Migration: xxx (xxx) */
        out += snprintf(db->buf + out, db->len - out,
-                       "Mastered Resources Total: %d  Locally: %d  "
-                       "Remotely: %d  Unknown: %d\n",
-                       tres, lres, rres, ures);
+                       "  Migration: %d (%d)\n",
+                       atomic_read(&dlm->mle_cur_count[DLM_MLE_MIGRATION]),
+                       atomic_read(&dlm->mle_tot_count[DLM_MLE_MIGRATION]));
 
        /* Lists: Dirty=Empty  Purge=InUse  PendingASTs=Empty  ... */
        out += snprintf(db->buf + out, db->len - out,
                        "Lists: Dirty=%s  Purge=%s  PendingASTs=%s  "
-                       "PendingBASTs=%s  Master=%s\n",
+                       "PendingBASTs=%s\n",
                        (list_empty(&dlm->dirty_list) ? "Empty" : "InUse"),
                        (list_empty(&dlm->purge_list) ? "Empty" : "InUse"),
                        (list_empty(&dlm->pending_asts) ? "Empty" : "InUse"),
-                       (list_empty(&dlm->pending_basts) ? "Empty" : "InUse"),
-                       (list_empty(&dlm->master_list) ? "Empty" : "InUse"));
+                       (list_empty(&dlm->pending_basts) ? "Empty" : "InUse"));
 
        /* Purge Count: xxx  Refs: xxx */
        out += snprintf(db->buf + out, db->len - out,