[PATCH] Use activate_mm() in fs/aio.c:use_mm()
[deliverable/linux.git] / fs / ocfs2 / dlm / dlmdebug.c
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
41 #include "dlmdomain.h"
42
43 #define MLOG_MASK_PREFIX ML_DLM
44 #include "cluster/masklog.h"
45
46 void dlm_print_one_lock_resource(struct dlm_lock_resource *res)
47 {
48 mlog(ML_NOTICE, "lockres: %.*s, owner=%u, state=%u\n",
49 res->lockname.len, res->lockname.name,
50 res->owner, res->state);
51 spin_lock(&res->spinlock);
52 __dlm_print_one_lock_resource(res);
53 spin_unlock(&res->spinlock);
54 }
55
56 void __dlm_print_one_lock_resource(struct dlm_lock_resource *res)
57 {
58 struct list_head *iter2;
59 struct dlm_lock *lock;
60
61 assert_spin_locked(&res->spinlock);
62
63 mlog(ML_NOTICE, "lockres: %.*s, owner=%u, state=%u\n",
64 res->lockname.len, res->lockname.name,
65 res->owner, res->state);
66 mlog(ML_NOTICE, " last used: %lu, on purge list: %s\n",
67 res->last_used, list_empty(&res->purge) ? "no" : "yes");
68 mlog(ML_NOTICE, " granted queue: \n");
69 list_for_each(iter2, &res->granted) {
70 lock = list_entry(iter2, struct dlm_lock, list);
71 spin_lock(&lock->spinlock);
72 mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, "
73 "cookie=%u:%llu, ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n",
74 lock->ml.type, lock->ml.convert_type, lock->ml.node,
75 dlm_get_lock_cookie_node(lock->ml.cookie),
76 dlm_get_lock_cookie_seq(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=%u:%llu, ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n",
89 lock->ml.type, lock->ml.convert_type, lock->ml.node,
90 dlm_get_lock_cookie_node(lock->ml.cookie),
91 dlm_get_lock_cookie_seq(lock->ml.cookie),
92 list_empty(&lock->ast_list) ? 'y' : 'n',
93 lock->ast_pending ? 'y' : 'n',
94 list_empty(&lock->bast_list) ? 'y' : 'n',
95 lock->bast_pending ? 'y' : 'n');
96 spin_unlock(&lock->spinlock);
97 }
98 mlog(ML_NOTICE, " blocked queue: \n");
99 list_for_each(iter2, &res->blocked) {
100 lock = list_entry(iter2, struct dlm_lock, list);
101 spin_lock(&lock->spinlock);
102 mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, "
103 "cookie=%u:%llu, ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n",
104 lock->ml.type, lock->ml.convert_type, lock->ml.node,
105 dlm_get_lock_cookie_node(lock->ml.cookie),
106 dlm_get_lock_cookie_seq(lock->ml.cookie),
107 list_empty(&lock->ast_list) ? 'y' : 'n',
108 lock->ast_pending ? 'y' : 'n',
109 list_empty(&lock->bast_list) ? 'y' : 'n',
110 lock->bast_pending ? 'y' : 'n');
111 spin_unlock(&lock->spinlock);
112 }
113 }
114
115 void dlm_print_one_lock(struct dlm_lock *lockid)
116 {
117 dlm_print_one_lock_resource(lockid->lockres);
118 }
119 EXPORT_SYMBOL_GPL(dlm_print_one_lock);
120
121 #if 0
122 void dlm_dump_lock_resources(struct dlm_ctxt *dlm)
123 {
124 struct dlm_lock_resource *res;
125 struct hlist_node *iter;
126 struct hlist_head *bucket;
127 int i;
128
129 mlog(ML_NOTICE, "struct dlm_ctxt: %s, node=%u, key=%u\n",
130 dlm->name, dlm->node_num, dlm->key);
131 if (!dlm || !dlm->name) {
132 mlog(ML_ERROR, "dlm=%p\n", dlm);
133 return;
134 }
135
136 spin_lock(&dlm->spinlock);
137 for (i=0; i<DLM_HASH_BUCKETS; i++) {
138 bucket = dlm_lockres_hash(dlm, i);
139 hlist_for_each_entry(res, iter, bucket, hash_node)
140 dlm_print_one_lock_resource(res);
141 }
142 spin_unlock(&dlm->spinlock);
143 }
144 #endif /* 0 */
145
146 static const char *dlm_errnames[] = {
147 [DLM_NORMAL] = "DLM_NORMAL",
148 [DLM_GRANTED] = "DLM_GRANTED",
149 [DLM_DENIED] = "DLM_DENIED",
150 [DLM_DENIED_NOLOCKS] = "DLM_DENIED_NOLOCKS",
151 [DLM_WORKING] = "DLM_WORKING",
152 [DLM_BLOCKED] = "DLM_BLOCKED",
153 [DLM_BLOCKED_ORPHAN] = "DLM_BLOCKED_ORPHAN",
154 [DLM_DENIED_GRACE_PERIOD] = "DLM_DENIED_GRACE_PERIOD",
155 [DLM_SYSERR] = "DLM_SYSERR",
156 [DLM_NOSUPPORT] = "DLM_NOSUPPORT",
157 [DLM_CANCELGRANT] = "DLM_CANCELGRANT",
158 [DLM_IVLOCKID] = "DLM_IVLOCKID",
159 [DLM_SYNC] = "DLM_SYNC",
160 [DLM_BADTYPE] = "DLM_BADTYPE",
161 [DLM_BADRESOURCE] = "DLM_BADRESOURCE",
162 [DLM_MAXHANDLES] = "DLM_MAXHANDLES",
163 [DLM_NOCLINFO] = "DLM_NOCLINFO",
164 [DLM_NOLOCKMGR] = "DLM_NOLOCKMGR",
165 [DLM_NOPURGED] = "DLM_NOPURGED",
166 [DLM_BADARGS] = "DLM_BADARGS",
167 [DLM_VOID] = "DLM_VOID",
168 [DLM_NOTQUEUED] = "DLM_NOTQUEUED",
169 [DLM_IVBUFLEN] = "DLM_IVBUFLEN",
170 [DLM_CVTUNGRANT] = "DLM_CVTUNGRANT",
171 [DLM_BADPARAM] = "DLM_BADPARAM",
172 [DLM_VALNOTVALID] = "DLM_VALNOTVALID",
173 [DLM_REJECTED] = "DLM_REJECTED",
174 [DLM_ABORT] = "DLM_ABORT",
175 [DLM_CANCEL] = "DLM_CANCEL",
176 [DLM_IVRESHANDLE] = "DLM_IVRESHANDLE",
177 [DLM_DEADLOCK] = "DLM_DEADLOCK",
178 [DLM_DENIED_NOASTS] = "DLM_DENIED_NOASTS",
179 [DLM_FORWARD] = "DLM_FORWARD",
180 [DLM_TIMEOUT] = "DLM_TIMEOUT",
181 [DLM_IVGROUPID] = "DLM_IVGROUPID",
182 [DLM_VERS_CONFLICT] = "DLM_VERS_CONFLICT",
183 [DLM_BAD_DEVICE_PATH] = "DLM_BAD_DEVICE_PATH",
184 [DLM_NO_DEVICE_PERMISSION] = "DLM_NO_DEVICE_PERMISSION",
185 [DLM_NO_CONTROL_DEVICE ] = "DLM_NO_CONTROL_DEVICE ",
186 [DLM_RECOVERING] = "DLM_RECOVERING",
187 [DLM_MIGRATING] = "DLM_MIGRATING",
188 [DLM_MAXSTATS] = "DLM_MAXSTATS",
189 };
190
191 static const char *dlm_errmsgs[] = {
192 [DLM_NORMAL] = "request in progress",
193 [DLM_GRANTED] = "request granted",
194 [DLM_DENIED] = "request denied",
195 [DLM_DENIED_NOLOCKS] = "request denied, out of system resources",
196 [DLM_WORKING] = "async request in progress",
197 [DLM_BLOCKED] = "lock request blocked",
198 [DLM_BLOCKED_ORPHAN] = "lock request blocked by a orphan lock",
199 [DLM_DENIED_GRACE_PERIOD] = "topological change in progress",
200 [DLM_SYSERR] = "system error",
201 [DLM_NOSUPPORT] = "unsupported",
202 [DLM_CANCELGRANT] = "can't cancel convert: already granted",
203 [DLM_IVLOCKID] = "bad lockid",
204 [DLM_SYNC] = "synchronous request granted",
205 [DLM_BADTYPE] = "bad resource type",
206 [DLM_BADRESOURCE] = "bad resource handle",
207 [DLM_MAXHANDLES] = "no more resource handles",
208 [DLM_NOCLINFO] = "can't contact cluster manager",
209 [DLM_NOLOCKMGR] = "can't contact lock manager",
210 [DLM_NOPURGED] = "can't contact purge daemon",
211 [DLM_BADARGS] = "bad api args",
212 [DLM_VOID] = "no status",
213 [DLM_NOTQUEUED] = "NOQUEUE was specified and request failed",
214 [DLM_IVBUFLEN] = "invalid resource name length",
215 [DLM_CVTUNGRANT] = "attempted to convert ungranted lock",
216 [DLM_BADPARAM] = "invalid lock mode specified",
217 [DLM_VALNOTVALID] = "value block has been invalidated",
218 [DLM_REJECTED] = "request rejected, unrecognized client",
219 [DLM_ABORT] = "blocked lock request cancelled",
220 [DLM_CANCEL] = "conversion request cancelled",
221 [DLM_IVRESHANDLE] = "invalid resource handle",
222 [DLM_DEADLOCK] = "deadlock recovery refused this request",
223 [DLM_DENIED_NOASTS] = "failed to allocate AST",
224 [DLM_FORWARD] = "request must wait for primary's response",
225 [DLM_TIMEOUT] = "timeout value for lock has expired",
226 [DLM_IVGROUPID] = "invalid group specification",
227 [DLM_VERS_CONFLICT] = "version conflicts prevent request handling",
228 [DLM_BAD_DEVICE_PATH] = "Locks device does not exist or path wrong",
229 [DLM_NO_DEVICE_PERMISSION] = "Client has insufficient perms for device",
230 [DLM_NO_CONTROL_DEVICE] = "Cannot set options on opened device ",
231 [DLM_RECOVERING] = "lock resource being recovered",
232 [DLM_MIGRATING] = "lock resource being migrated",
233 [DLM_MAXSTATS] = "invalid error number",
234 };
235
236 const char *dlm_errmsg(enum dlm_status err)
237 {
238 if (err >= DLM_MAXSTATS || err < 0)
239 return dlm_errmsgs[DLM_MAXSTATS];
240 return dlm_errmsgs[err];
241 }
242 EXPORT_SYMBOL_GPL(dlm_errmsg);
243
244 const char *dlm_errname(enum dlm_status err)
245 {
246 if (err >= DLM_MAXSTATS || err < 0)
247 return dlm_errnames[DLM_MAXSTATS];
248 return dlm_errnames[err];
249 }
250 EXPORT_SYMBOL_GPL(dlm_errname);
This page took 0.03664 seconds and 5 git commands to generate.