Kurt Hackel | 6714d8e | 2005-12-15 14:31:23 -0800 | [diff] [blame] | 1 | /* -*- mode: c; c-basic-offset: 8; -*- |
| 2 | * vim: noexpandtab sw=8 ts=8 sts=0: |
| 3 | * |
| 4 | * dlmdebug.c |
| 5 | * |
| 6 | * debug functionality for the dlm |
| 7 | * |
| 8 | * Copyright (C) 2004 Oracle. All rights reserved. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public |
| 12 | * License as published by the Free Software Foundation; either |
| 13 | * version 2 of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public |
| 21 | * License along with this program; if not, write to the |
| 22 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 23 | * Boston, MA 021110-1307, USA. |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #include <linux/types.h> |
| 28 | #include <linux/slab.h> |
| 29 | #include <linux/highmem.h> |
| 30 | #include <linux/utsname.h> |
| 31 | #include <linux/sysctl.h> |
| 32 | #include <linux/spinlock.h> |
| 33 | |
| 34 | #include "cluster/heartbeat.h" |
| 35 | #include "cluster/nodemanager.h" |
| 36 | #include "cluster/tcp.h" |
| 37 | |
| 38 | #include "dlmapi.h" |
| 39 | #include "dlmcommon.h" |
| 40 | #include "dlmdebug.h" |
| 41 | |
| 42 | #include "dlmdomain.h" |
| 43 | #include "dlmdebug.h" |
| 44 | |
| 45 | #define MLOG_MASK_PREFIX ML_DLM |
| 46 | #include "cluster/masklog.h" |
| 47 | |
| 48 | void dlm_print_one_lock_resource(struct dlm_lock_resource *res) |
| 49 | { |
| 50 | mlog(ML_NOTICE, "lockres: %.*s, owner=%u, state=%u\n", |
| 51 | res->lockname.len, res->lockname.name, |
| 52 | res->owner, res->state); |
| 53 | spin_lock(&res->spinlock); |
| 54 | __dlm_print_one_lock_resource(res); |
| 55 | spin_unlock(&res->spinlock); |
| 56 | } |
| 57 | |
| 58 | void __dlm_print_one_lock_resource(struct dlm_lock_resource *res) |
| 59 | { |
| 60 | struct list_head *iter2; |
| 61 | struct dlm_lock *lock; |
| 62 | |
| 63 | assert_spin_locked(&res->spinlock); |
| 64 | |
| 65 | mlog(ML_NOTICE, "lockres: %.*s, owner=%u, state=%u\n", |
| 66 | res->lockname.len, res->lockname.name, |
| 67 | res->owner, res->state); |
| 68 | mlog(ML_NOTICE, " last used: %lu, on purge list: %s\n", |
| 69 | res->last_used, list_empty(&res->purge) ? "no" : "yes"); |
| 70 | mlog(ML_NOTICE, " granted queue: \n"); |
| 71 | list_for_each(iter2, &res->granted) { |
| 72 | lock = list_entry(iter2, struct dlm_lock, list); |
| 73 | spin_lock(&lock->spinlock); |
| 74 | mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, " |
| 75 | "cookie=%"MLFu64", ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n", |
| 76 | lock->ml.type, lock->ml.convert_type, lock->ml.node, lock->ml.cookie, |
| 77 | list_empty(&lock->ast_list) ? 'y' : 'n', |
| 78 | lock->ast_pending ? 'y' : 'n', |
| 79 | list_empty(&lock->bast_list) ? 'y' : 'n', |
| 80 | lock->bast_pending ? 'y' : 'n'); |
| 81 | spin_unlock(&lock->spinlock); |
| 82 | } |
| 83 | mlog(ML_NOTICE, " converting queue: \n"); |
| 84 | list_for_each(iter2, &res->converting) { |
| 85 | lock = list_entry(iter2, struct dlm_lock, list); |
| 86 | spin_lock(&lock->spinlock); |
| 87 | mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, " |
| 88 | "cookie=%"MLFu64", ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n", |
| 89 | lock->ml.type, lock->ml.convert_type, lock->ml.node, lock->ml.cookie, |
| 90 | list_empty(&lock->ast_list) ? 'y' : 'n', |
| 91 | lock->ast_pending ? 'y' : 'n', |
| 92 | list_empty(&lock->bast_list) ? 'y' : 'n', |
| 93 | lock->bast_pending ? 'y' : 'n'); |
| 94 | spin_unlock(&lock->spinlock); |
| 95 | } |
| 96 | mlog(ML_NOTICE, " blocked queue: \n"); |
| 97 | list_for_each(iter2, &res->blocked) { |
| 98 | lock = list_entry(iter2, struct dlm_lock, list); |
| 99 | spin_lock(&lock->spinlock); |
| 100 | mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, " |
| 101 | "cookie=%"MLFu64", ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n", |
| 102 | lock->ml.type, lock->ml.convert_type, lock->ml.node, lock->ml.cookie, |
| 103 | list_empty(&lock->ast_list) ? 'y' : 'n', |
| 104 | lock->ast_pending ? 'y' : 'n', |
| 105 | list_empty(&lock->bast_list) ? 'y' : 'n', |
| 106 | lock->bast_pending ? 'y' : 'n'); |
| 107 | spin_unlock(&lock->spinlock); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | void dlm_print_one_lock(struct dlm_lock *lockid) |
| 112 | { |
| 113 | dlm_print_one_lock_resource(lockid->lockres); |
| 114 | } |
| 115 | EXPORT_SYMBOL_GPL(dlm_print_one_lock); |
| 116 | |
| 117 | void dlm_dump_lock_resources(struct dlm_ctxt *dlm) |
| 118 | { |
| 119 | struct dlm_lock_resource *res; |
Mark Fasheh | 81f2094 | 2006-02-28 17:31:22 -0800 | [diff] [blame] | 120 | struct hlist_node *iter; |
| 121 | struct hlist_head *bucket; |
Kurt Hackel | 6714d8e | 2005-12-15 14:31:23 -0800 | [diff] [blame] | 122 | int i; |
| 123 | |
| 124 | mlog(ML_NOTICE, "struct dlm_ctxt: %s, node=%u, key=%u\n", |
| 125 | dlm->name, dlm->node_num, dlm->key); |
| 126 | if (!dlm || !dlm->name) { |
| 127 | mlog(ML_ERROR, "dlm=%p\n", dlm); |
| 128 | return; |
| 129 | } |
| 130 | |
| 131 | spin_lock(&dlm->spinlock); |
Mark Fasheh | 81f2094 | 2006-02-28 17:31:22 -0800 | [diff] [blame] | 132 | for (i=0; i<DLM_HASH_BUCKETS; i++) { |
| 133 | bucket = &(dlm->lockres_hash[i]); |
| 134 | hlist_for_each_entry(res, iter, bucket, hash_node) |
Kurt Hackel | 6714d8e | 2005-12-15 14:31:23 -0800 | [diff] [blame] | 135 | dlm_print_one_lock_resource(res); |
Kurt Hackel | 6714d8e | 2005-12-15 14:31:23 -0800 | [diff] [blame] | 136 | } |
| 137 | spin_unlock(&dlm->spinlock); |
| 138 | } |
| 139 | |
| 140 | static const char *dlm_errnames[] = { |
| 141 | [DLM_NORMAL] = "DLM_NORMAL", |
| 142 | [DLM_GRANTED] = "DLM_GRANTED", |
| 143 | [DLM_DENIED] = "DLM_DENIED", |
| 144 | [DLM_DENIED_NOLOCKS] = "DLM_DENIED_NOLOCKS", |
| 145 | [DLM_WORKING] = "DLM_WORKING", |
| 146 | [DLM_BLOCKED] = "DLM_BLOCKED", |
| 147 | [DLM_BLOCKED_ORPHAN] = "DLM_BLOCKED_ORPHAN", |
| 148 | [DLM_DENIED_GRACE_PERIOD] = "DLM_DENIED_GRACE_PERIOD", |
| 149 | [DLM_SYSERR] = "DLM_SYSERR", |
| 150 | [DLM_NOSUPPORT] = "DLM_NOSUPPORT", |
| 151 | [DLM_CANCELGRANT] = "DLM_CANCELGRANT", |
| 152 | [DLM_IVLOCKID] = "DLM_IVLOCKID", |
| 153 | [DLM_SYNC] = "DLM_SYNC", |
| 154 | [DLM_BADTYPE] = "DLM_BADTYPE", |
| 155 | [DLM_BADRESOURCE] = "DLM_BADRESOURCE", |
| 156 | [DLM_MAXHANDLES] = "DLM_MAXHANDLES", |
| 157 | [DLM_NOCLINFO] = "DLM_NOCLINFO", |
| 158 | [DLM_NOLOCKMGR] = "DLM_NOLOCKMGR", |
| 159 | [DLM_NOPURGED] = "DLM_NOPURGED", |
| 160 | [DLM_BADARGS] = "DLM_BADARGS", |
| 161 | [DLM_VOID] = "DLM_VOID", |
| 162 | [DLM_NOTQUEUED] = "DLM_NOTQUEUED", |
| 163 | [DLM_IVBUFLEN] = "DLM_IVBUFLEN", |
| 164 | [DLM_CVTUNGRANT] = "DLM_CVTUNGRANT", |
| 165 | [DLM_BADPARAM] = "DLM_BADPARAM", |
| 166 | [DLM_VALNOTVALID] = "DLM_VALNOTVALID", |
| 167 | [DLM_REJECTED] = "DLM_REJECTED", |
| 168 | [DLM_ABORT] = "DLM_ABORT", |
| 169 | [DLM_CANCEL] = "DLM_CANCEL", |
| 170 | [DLM_IVRESHANDLE] = "DLM_IVRESHANDLE", |
| 171 | [DLM_DEADLOCK] = "DLM_DEADLOCK", |
| 172 | [DLM_DENIED_NOASTS] = "DLM_DENIED_NOASTS", |
| 173 | [DLM_FORWARD] = "DLM_FORWARD", |
| 174 | [DLM_TIMEOUT] = "DLM_TIMEOUT", |
| 175 | [DLM_IVGROUPID] = "DLM_IVGROUPID", |
| 176 | [DLM_VERS_CONFLICT] = "DLM_VERS_CONFLICT", |
| 177 | [DLM_BAD_DEVICE_PATH] = "DLM_BAD_DEVICE_PATH", |
| 178 | [DLM_NO_DEVICE_PERMISSION] = "DLM_NO_DEVICE_PERMISSION", |
| 179 | [DLM_NO_CONTROL_DEVICE ] = "DLM_NO_CONTROL_DEVICE ", |
| 180 | [DLM_RECOVERING] = "DLM_RECOVERING", |
| 181 | [DLM_MIGRATING] = "DLM_MIGRATING", |
| 182 | [DLM_MAXSTATS] = "DLM_MAXSTATS", |
| 183 | }; |
| 184 | |
| 185 | static const char *dlm_errmsgs[] = { |
| 186 | [DLM_NORMAL] = "request in progress", |
| 187 | [DLM_GRANTED] = "request granted", |
| 188 | [DLM_DENIED] = "request denied", |
| 189 | [DLM_DENIED_NOLOCKS] = "request denied, out of system resources", |
| 190 | [DLM_WORKING] = "async request in progress", |
| 191 | [DLM_BLOCKED] = "lock request blocked", |
| 192 | [DLM_BLOCKED_ORPHAN] = "lock request blocked by a orphan lock", |
| 193 | [DLM_DENIED_GRACE_PERIOD] = "topological change in progress", |
| 194 | [DLM_SYSERR] = "system error", |
| 195 | [DLM_NOSUPPORT] = "unsupported", |
| 196 | [DLM_CANCELGRANT] = "can't cancel convert: already granted", |
| 197 | [DLM_IVLOCKID] = "bad lockid", |
| 198 | [DLM_SYNC] = "synchronous request granted", |
| 199 | [DLM_BADTYPE] = "bad resource type", |
| 200 | [DLM_BADRESOURCE] = "bad resource handle", |
| 201 | [DLM_MAXHANDLES] = "no more resource handles", |
| 202 | [DLM_NOCLINFO] = "can't contact cluster manager", |
| 203 | [DLM_NOLOCKMGR] = "can't contact lock manager", |
| 204 | [DLM_NOPURGED] = "can't contact purge daemon", |
| 205 | [DLM_BADARGS] = "bad api args", |
| 206 | [DLM_VOID] = "no status", |
| 207 | [DLM_NOTQUEUED] = "NOQUEUE was specified and request failed", |
| 208 | [DLM_IVBUFLEN] = "invalid resource name length", |
| 209 | [DLM_CVTUNGRANT] = "attempted to convert ungranted lock", |
| 210 | [DLM_BADPARAM] = "invalid lock mode specified", |
| 211 | [DLM_VALNOTVALID] = "value block has been invalidated", |
| 212 | [DLM_REJECTED] = "request rejected, unrecognized client", |
| 213 | [DLM_ABORT] = "blocked lock request cancelled", |
| 214 | [DLM_CANCEL] = "conversion request cancelled", |
| 215 | [DLM_IVRESHANDLE] = "invalid resource handle", |
| 216 | [DLM_DEADLOCK] = "deadlock recovery refused this request", |
| 217 | [DLM_DENIED_NOASTS] = "failed to allocate AST", |
| 218 | [DLM_FORWARD] = "request must wait for primary's response", |
| 219 | [DLM_TIMEOUT] = "timeout value for lock has expired", |
| 220 | [DLM_IVGROUPID] = "invalid group specification", |
| 221 | [DLM_VERS_CONFLICT] = "version conflicts prevent request handling", |
| 222 | [DLM_BAD_DEVICE_PATH] = "Locks device does not exist or path wrong", |
| 223 | [DLM_NO_DEVICE_PERMISSION] = "Client has insufficient perms for device", |
| 224 | [DLM_NO_CONTROL_DEVICE] = "Cannot set options on opened device ", |
| 225 | [DLM_RECOVERING] = "lock resource being recovered", |
| 226 | [DLM_MIGRATING] = "lock resource being migrated", |
| 227 | [DLM_MAXSTATS] = "invalid error number", |
| 228 | }; |
| 229 | |
| 230 | const char *dlm_errmsg(enum dlm_status err) |
| 231 | { |
| 232 | if (err >= DLM_MAXSTATS || err < 0) |
| 233 | return dlm_errmsgs[DLM_MAXSTATS]; |
| 234 | return dlm_errmsgs[err]; |
| 235 | } |
| 236 | EXPORT_SYMBOL_GPL(dlm_errmsg); |
| 237 | |
| 238 | const char *dlm_errname(enum dlm_status err) |
| 239 | { |
| 240 | if (err >= DLM_MAXSTATS || err < 0) |
| 241 | return dlm_errnames[DLM_MAXSTATS]; |
| 242 | return dlm_errnames[err]; |
| 243 | } |
| 244 | EXPORT_SYMBOL_GPL(dlm_errname); |