Commit | Line | Data |
---|---|---|
6714d8e8 KH |
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 | * | |
c834cdb1 | 8 | * Copyright (C) 2004, 2008 Oracle. All rights reserved. |
6714d8e8 KH |
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> | |
6325b4a2 | 33 | #include <linux/debugfs.h> |
6714d8e8 KH |
34 | |
35 | #include "cluster/heartbeat.h" | |
36 | #include "cluster/nodemanager.h" | |
37 | #include "cluster/tcp.h" | |
38 | ||
39 | #include "dlmapi.h" | |
40 | #include "dlmcommon.h" | |
6714d8e8 | 41 | #include "dlmdomain.h" |
6325b4a2 | 42 | #include "dlmdebug.h" |
6714d8e8 KH |
43 | |
44 | #define MLOG_MASK_PREFIX ML_DLM | |
45 | #include "cluster/masklog.h" | |
46 | ||
95642e56 AB |
47 | static int stringify_lockname(const char *lockname, int locklen, char *buf, |
48 | int len); | |
c834cdb1 | 49 | |
6714d8e8 KH |
50 | void dlm_print_one_lock_resource(struct dlm_lock_resource *res) |
51 | { | |
6714d8e8 KH |
52 | spin_lock(&res->spinlock); |
53 | __dlm_print_one_lock_resource(res); | |
54 | spin_unlock(&res->spinlock); | |
55 | } | |
56 | ||
ba2bf218 KH |
57 | static void dlm_print_lockres_refmap(struct dlm_lock_resource *res) |
58 | { | |
59 | int bit; | |
60 | assert_spin_locked(&res->spinlock); | |
61 | ||
8f50eb97 | 62 | printk(" refmap nodes: [ "); |
ba2bf218 KH |
63 | bit = 0; |
64 | while (1) { | |
65 | bit = find_next_bit(res->refmap, O2NM_MAX_NODES, bit); | |
66 | if (bit >= O2NM_MAX_NODES) | |
67 | break; | |
8f50eb97 | 68 | printk("%u ", bit); |
ba2bf218 KH |
69 | bit++; |
70 | } | |
8f50eb97 | 71 | printk("], inflight=%u\n", res->inflight_locks); |
c834cdb1 SM |
72 | } |
73 | ||
74 | static void __dlm_print_lock(struct dlm_lock *lock) | |
75 | { | |
76 | spin_lock(&lock->spinlock); | |
77 | ||
8f50eb97 | 78 | printk(" type=%d, conv=%d, node=%u, cookie=%u:%llu, " |
c834cdb1 SM |
79 | "ref=%u, ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c), " |
80 | "pending=(conv=%c,lock=%c,cancel=%c,unlock=%c)\n", | |
81 | lock->ml.type, lock->ml.convert_type, lock->ml.node, | |
82 | dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), | |
83 | dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)), | |
84 | atomic_read(&lock->lock_refs.refcount), | |
85 | (list_empty(&lock->ast_list) ? 'y' : 'n'), | |
86 | (lock->ast_pending ? 'y' : 'n'), | |
87 | (list_empty(&lock->bast_list) ? 'y' : 'n'), | |
88 | (lock->bast_pending ? 'y' : 'n'), | |
89 | (lock->convert_pending ? 'y' : 'n'), | |
90 | (lock->lock_pending ? 'y' : 'n'), | |
91 | (lock->cancel_pending ? 'y' : 'n'), | |
92 | (lock->unlock_pending ? 'y' : 'n')); | |
93 | ||
94 | spin_unlock(&lock->spinlock); | |
ba2bf218 KH |
95 | } |
96 | ||
6714d8e8 KH |
97 | void __dlm_print_one_lock_resource(struct dlm_lock_resource *res) |
98 | { | |
99 | struct list_head *iter2; | |
100 | struct dlm_lock *lock; | |
c834cdb1 | 101 | char buf[DLM_LOCKID_NAME_MAX]; |
6714d8e8 KH |
102 | |
103 | assert_spin_locked(&res->spinlock); | |
104 | ||
c834cdb1 SM |
105 | stringify_lockname(res->lockname.name, res->lockname.len, |
106 | buf, sizeof(buf) - 1); | |
8f50eb97 | 107 | printk("lockres: %s, owner=%u, state=%u\n", |
c834cdb1 | 108 | buf, res->owner, res->state); |
8f50eb97 | 109 | printk(" last used: %lu, refcnt: %u, on purge list: %s\n", |
c834cdb1 SM |
110 | res->last_used, atomic_read(&res->refs.refcount), |
111 | list_empty(&res->purge) ? "no" : "yes"); | |
8f50eb97 | 112 | printk(" on dirty list: %s, on reco list: %s, " |
c834cdb1 SM |
113 | "migrating pending: %s\n", |
114 | list_empty(&res->dirty) ? "no" : "yes", | |
115 | list_empty(&res->recovering) ? "no" : "yes", | |
116 | res->migration_pending ? "yes" : "no"); | |
8f50eb97 | 117 | printk(" inflight locks: %d, asts reserved: %d\n", |
c834cdb1 | 118 | res->inflight_locks, atomic_read(&res->asts_reserved)); |
ba2bf218 | 119 | dlm_print_lockres_refmap(res); |
8f50eb97 | 120 | printk(" granted queue:\n"); |
6714d8e8 KH |
121 | list_for_each(iter2, &res->granted) { |
122 | lock = list_entry(iter2, struct dlm_lock, list); | |
c834cdb1 | 123 | __dlm_print_lock(lock); |
6714d8e8 | 124 | } |
8f50eb97 | 125 | printk(" converting queue:\n"); |
6714d8e8 KH |
126 | list_for_each(iter2, &res->converting) { |
127 | lock = list_entry(iter2, struct dlm_lock, list); | |
c834cdb1 | 128 | __dlm_print_lock(lock); |
6714d8e8 | 129 | } |
8f50eb97 | 130 | printk(" blocked queue:\n"); |
6714d8e8 KH |
131 | list_for_each(iter2, &res->blocked) { |
132 | lock = list_entry(iter2, struct dlm_lock, list); | |
c834cdb1 | 133 | __dlm_print_lock(lock); |
6714d8e8 KH |
134 | } |
135 | } | |
136 | ||
137 | void dlm_print_one_lock(struct dlm_lock *lockid) | |
138 | { | |
139 | dlm_print_one_lock_resource(lockid->lockres); | |
140 | } | |
141 | EXPORT_SYMBOL_GPL(dlm_print_one_lock); | |
142 | ||
6714d8e8 KH |
143 | static const char *dlm_errnames[] = { |
144 | [DLM_NORMAL] = "DLM_NORMAL", | |
145 | [DLM_GRANTED] = "DLM_GRANTED", | |
146 | [DLM_DENIED] = "DLM_DENIED", | |
147 | [DLM_DENIED_NOLOCKS] = "DLM_DENIED_NOLOCKS", | |
148 | [DLM_WORKING] = "DLM_WORKING", | |
149 | [DLM_BLOCKED] = "DLM_BLOCKED", | |
150 | [DLM_BLOCKED_ORPHAN] = "DLM_BLOCKED_ORPHAN", | |
151 | [DLM_DENIED_GRACE_PERIOD] = "DLM_DENIED_GRACE_PERIOD", | |
152 | [DLM_SYSERR] = "DLM_SYSERR", | |
153 | [DLM_NOSUPPORT] = "DLM_NOSUPPORT", | |
154 | [DLM_CANCELGRANT] = "DLM_CANCELGRANT", | |
155 | [DLM_IVLOCKID] = "DLM_IVLOCKID", | |
156 | [DLM_SYNC] = "DLM_SYNC", | |
157 | [DLM_BADTYPE] = "DLM_BADTYPE", | |
158 | [DLM_BADRESOURCE] = "DLM_BADRESOURCE", | |
159 | [DLM_MAXHANDLES] = "DLM_MAXHANDLES", | |
160 | [DLM_NOCLINFO] = "DLM_NOCLINFO", | |
161 | [DLM_NOLOCKMGR] = "DLM_NOLOCKMGR", | |
162 | [DLM_NOPURGED] = "DLM_NOPURGED", | |
163 | [DLM_BADARGS] = "DLM_BADARGS", | |
164 | [DLM_VOID] = "DLM_VOID", | |
165 | [DLM_NOTQUEUED] = "DLM_NOTQUEUED", | |
166 | [DLM_IVBUFLEN] = "DLM_IVBUFLEN", | |
167 | [DLM_CVTUNGRANT] = "DLM_CVTUNGRANT", | |
168 | [DLM_BADPARAM] = "DLM_BADPARAM", | |
169 | [DLM_VALNOTVALID] = "DLM_VALNOTVALID", | |
170 | [DLM_REJECTED] = "DLM_REJECTED", | |
171 | [DLM_ABORT] = "DLM_ABORT", | |
172 | [DLM_CANCEL] = "DLM_CANCEL", | |
173 | [DLM_IVRESHANDLE] = "DLM_IVRESHANDLE", | |
174 | [DLM_DEADLOCK] = "DLM_DEADLOCK", | |
175 | [DLM_DENIED_NOASTS] = "DLM_DENIED_NOASTS", | |
176 | [DLM_FORWARD] = "DLM_FORWARD", | |
177 | [DLM_TIMEOUT] = "DLM_TIMEOUT", | |
178 | [DLM_IVGROUPID] = "DLM_IVGROUPID", | |
179 | [DLM_VERS_CONFLICT] = "DLM_VERS_CONFLICT", | |
180 | [DLM_BAD_DEVICE_PATH] = "DLM_BAD_DEVICE_PATH", | |
181 | [DLM_NO_DEVICE_PERMISSION] = "DLM_NO_DEVICE_PERMISSION", | |
182 | [DLM_NO_CONTROL_DEVICE ] = "DLM_NO_CONTROL_DEVICE ", | |
183 | [DLM_RECOVERING] = "DLM_RECOVERING", | |
184 | [DLM_MIGRATING] = "DLM_MIGRATING", | |
185 | [DLM_MAXSTATS] = "DLM_MAXSTATS", | |
186 | }; | |
187 | ||
188 | static const char *dlm_errmsgs[] = { | |
189 | [DLM_NORMAL] = "request in progress", | |
190 | [DLM_GRANTED] = "request granted", | |
191 | [DLM_DENIED] = "request denied", | |
192 | [DLM_DENIED_NOLOCKS] = "request denied, out of system resources", | |
193 | [DLM_WORKING] = "async request in progress", | |
194 | [DLM_BLOCKED] = "lock request blocked", | |
195 | [DLM_BLOCKED_ORPHAN] = "lock request blocked by a orphan lock", | |
196 | [DLM_DENIED_GRACE_PERIOD] = "topological change in progress", | |
197 | [DLM_SYSERR] = "system error", | |
198 | [DLM_NOSUPPORT] = "unsupported", | |
199 | [DLM_CANCELGRANT] = "can't cancel convert: already granted", | |
200 | [DLM_IVLOCKID] = "bad lockid", | |
201 | [DLM_SYNC] = "synchronous request granted", | |
202 | [DLM_BADTYPE] = "bad resource type", | |
203 | [DLM_BADRESOURCE] = "bad resource handle", | |
204 | [DLM_MAXHANDLES] = "no more resource handles", | |
205 | [DLM_NOCLINFO] = "can't contact cluster manager", | |
206 | [DLM_NOLOCKMGR] = "can't contact lock manager", | |
207 | [DLM_NOPURGED] = "can't contact purge daemon", | |
208 | [DLM_BADARGS] = "bad api args", | |
209 | [DLM_VOID] = "no status", | |
210 | [DLM_NOTQUEUED] = "NOQUEUE was specified and request failed", | |
211 | [DLM_IVBUFLEN] = "invalid resource name length", | |
212 | [DLM_CVTUNGRANT] = "attempted to convert ungranted lock", | |
213 | [DLM_BADPARAM] = "invalid lock mode specified", | |
214 | [DLM_VALNOTVALID] = "value block has been invalidated", | |
215 | [DLM_REJECTED] = "request rejected, unrecognized client", | |
216 | [DLM_ABORT] = "blocked lock request cancelled", | |
217 | [DLM_CANCEL] = "conversion request cancelled", | |
218 | [DLM_IVRESHANDLE] = "invalid resource handle", | |
219 | [DLM_DEADLOCK] = "deadlock recovery refused this request", | |
220 | [DLM_DENIED_NOASTS] = "failed to allocate AST", | |
221 | [DLM_FORWARD] = "request must wait for primary's response", | |
222 | [DLM_TIMEOUT] = "timeout value for lock has expired", | |
223 | [DLM_IVGROUPID] = "invalid group specification", | |
224 | [DLM_VERS_CONFLICT] = "version conflicts prevent request handling", | |
225 | [DLM_BAD_DEVICE_PATH] = "Locks device does not exist or path wrong", | |
226 | [DLM_NO_DEVICE_PERMISSION] = "Client has insufficient perms for device", | |
227 | [DLM_NO_CONTROL_DEVICE] = "Cannot set options on opened device ", | |
228 | [DLM_RECOVERING] = "lock resource being recovered", | |
229 | [DLM_MIGRATING] = "lock resource being migrated", | |
230 | [DLM_MAXSTATS] = "invalid error number", | |
231 | }; | |
232 | ||
233 | const char *dlm_errmsg(enum dlm_status err) | |
234 | { | |
235 | if (err >= DLM_MAXSTATS || err < 0) | |
236 | return dlm_errmsgs[DLM_MAXSTATS]; | |
237 | return dlm_errmsgs[err]; | |
238 | } | |
239 | EXPORT_SYMBOL_GPL(dlm_errmsg); | |
240 | ||
241 | const char *dlm_errname(enum dlm_status err) | |
242 | { | |
243 | if (err >= DLM_MAXSTATS || err < 0) | |
244 | return dlm_errnames[DLM_MAXSTATS]; | |
245 | return dlm_errnames[err]; | |
246 | } | |
247 | EXPORT_SYMBOL_GPL(dlm_errname); | |
6325b4a2 | 248 | |
4e3d24ed SM |
249 | /* NOTE: This function converts a lockname into a string. It uses knowledge |
250 | * of the format of the lockname that should be outside the purview of the dlm. | |
251 | * We are adding only to make dlm debugging slightly easier. | |
252 | * | |
253 | * For more on lockname formats, please refer to dlmglue.c and ocfs2_lockid.h. | |
254 | */ | |
95642e56 AB |
255 | static int stringify_lockname(const char *lockname, int locklen, char *buf, |
256 | int len) | |
4e3d24ed SM |
257 | { |
258 | int out = 0; | |
259 | __be64 inode_blkno_be; | |
260 | ||
261 | #define OCFS2_DENTRY_LOCK_INO_START 18 | |
262 | if (*lockname == 'N') { | |
263 | memcpy((__be64 *)&inode_blkno_be, | |
264 | (char *)&lockname[OCFS2_DENTRY_LOCK_INO_START], | |
265 | sizeof(__be64)); | |
266 | out += snprintf(buf + out, len - out, "%.*s%08x", | |
267 | OCFS2_DENTRY_LOCK_INO_START - 1, lockname, | |
268 | (unsigned int)be64_to_cpu(inode_blkno_be)); | |
269 | } else | |
270 | out += snprintf(buf + out, len - out, "%.*s", | |
271 | locklen, lockname); | |
272 | return out; | |
273 | } | |
274 | ||
e5a0334c SM |
275 | static int stringify_nodemap(unsigned long *nodemap, int maxnodes, |
276 | char *buf, int len) | |
277 | { | |
278 | int out = 0; | |
279 | int i = -1; | |
280 | ||
281 | while ((i = find_next_bit(nodemap, maxnodes, i + 1)) < maxnodes) | |
282 | out += snprintf(buf + out, len - out, "%d ", i); | |
283 | ||
284 | return out; | |
285 | } | |
286 | ||
287 | static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len) | |
288 | { | |
289 | int out = 0; | |
290 | unsigned int namelen; | |
f77a9a78 | 291 | unsigned char *name; |
e5a0334c SM |
292 | char *mle_type; |
293 | ||
294 | if (mle->type != DLM_MLE_MASTER) { | |
f77a9a78 SM |
295 | name = mle->u.mlename.name; |
296 | namelen = mle->u.mlename.len; | |
e5a0334c | 297 | } else { |
f77a9a78 SM |
298 | name = (unsigned char *)mle->u.mleres->lockname.name; |
299 | namelen = mle->u.mleres->lockname.len; | |
e5a0334c SM |
300 | } |
301 | ||
302 | if (mle->type == DLM_MLE_BLOCK) | |
303 | mle_type = "BLK"; | |
304 | else if (mle->type == DLM_MLE_MASTER) | |
305 | mle_type = "MAS"; | |
306 | else | |
307 | mle_type = "MIG"; | |
308 | ||
309 | out += stringify_lockname(name, namelen, buf + out, len - out); | |
310 | out += snprintf(buf + out, len - out, | |
311 | "\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n", | |
312 | mle_type, mle->master, mle->new_master, | |
313 | !list_empty(&mle->hb_events), | |
314 | !!mle->inuse, | |
315 | atomic_read(&mle->mle_refs.refcount)); | |
316 | ||
317 | out += snprintf(buf + out, len - out, "Maybe="); | |
318 | out += stringify_nodemap(mle->maybe_map, O2NM_MAX_NODES, | |
319 | buf + out, len - out); | |
320 | out += snprintf(buf + out, len - out, "\n"); | |
321 | ||
322 | out += snprintf(buf + out, len - out, "Vote="); | |
323 | out += stringify_nodemap(mle->vote_map, O2NM_MAX_NODES, | |
324 | buf + out, len - out); | |
325 | out += snprintf(buf + out, len - out, "\n"); | |
326 | ||
327 | out += snprintf(buf + out, len - out, "Response="); | |
328 | out += stringify_nodemap(mle->response_map, O2NM_MAX_NODES, | |
329 | buf + out, len - out); | |
330 | out += snprintf(buf + out, len - out, "\n"); | |
331 | ||
332 | out += snprintf(buf + out, len - out, "Node="); | |
333 | out += stringify_nodemap(mle->node_map, O2NM_MAX_NODES, | |
334 | buf + out, len - out); | |
335 | out += snprintf(buf + out, len - out, "\n"); | |
336 | ||
337 | out += snprintf(buf + out, len - out, "\n"); | |
338 | ||
339 | return out; | |
340 | } | |
341 | ||
342 | void dlm_print_one_mle(struct dlm_master_list_entry *mle) | |
343 | { | |
344 | char *buf; | |
345 | ||
346 | buf = (char *) get_zeroed_page(GFP_NOFS); | |
347 | if (buf) { | |
348 | dump_mle(mle, buf, PAGE_SIZE - 1); | |
349 | free_page((unsigned long)buf); | |
350 | } | |
351 | } | |
352 | ||
353 | #ifdef CONFIG_DEBUG_FS | |
354 | ||
355 | static struct dentry *dlm_debugfs_root = NULL; | |
356 | ||
6325b4a2 | 357 | #define DLM_DEBUGFS_DIR "o2dlm" |
007dce53 | 358 | #define DLM_DEBUGFS_DLM_STATE "dlm_state" |
4e3d24ed | 359 | #define DLM_DEBUGFS_LOCKING_STATE "locking_state" |
d0129ace | 360 | #define DLM_DEBUGFS_MLE_STATE "mle_state" |
7209300a | 361 | #define DLM_DEBUGFS_PURGE_LIST "purge_list" |
007dce53 SM |
362 | |
363 | /* begin - utils funcs */ | |
364 | static void dlm_debug_free(struct kref *kref) | |
365 | { | |
366 | struct dlm_debug_ctxt *dc; | |
367 | ||
368 | dc = container_of(kref, struct dlm_debug_ctxt, debug_refcnt); | |
369 | ||
370 | kfree(dc); | |
371 | } | |
372 | ||
95642e56 | 373 | static void dlm_debug_put(struct dlm_debug_ctxt *dc) |
007dce53 SM |
374 | { |
375 | if (dc) | |
376 | kref_put(&dc->debug_refcnt, dlm_debug_free); | |
377 | } | |
378 | ||
379 | static void dlm_debug_get(struct dlm_debug_ctxt *dc) | |
380 | { | |
381 | kref_get(&dc->debug_refcnt); | |
382 | } | |
383 | ||
007dce53 SM |
384 | static struct debug_buffer *debug_buffer_allocate(void) |
385 | { | |
386 | struct debug_buffer *db = NULL; | |
387 | ||
388 | db = kzalloc(sizeof(struct debug_buffer), GFP_KERNEL); | |
389 | if (!db) | |
390 | goto bail; | |
391 | ||
392 | db->len = PAGE_SIZE; | |
393 | db->buf = kmalloc(db->len, GFP_KERNEL); | |
394 | if (!db->buf) | |
395 | goto bail; | |
396 | ||
397 | return db; | |
398 | bail: | |
399 | kfree(db); | |
400 | return NULL; | |
401 | } | |
402 | ||
403 | static ssize_t debug_buffer_read(struct file *file, char __user *buf, | |
404 | size_t nbytes, loff_t *ppos) | |
405 | { | |
406 | struct debug_buffer *db = file->private_data; | |
407 | ||
408 | return simple_read_from_buffer(buf, nbytes, ppos, db->buf, db->len); | |
409 | } | |
410 | ||
411 | static loff_t debug_buffer_llseek(struct file *file, loff_t off, int whence) | |
412 | { | |
413 | struct debug_buffer *db = file->private_data; | |
414 | loff_t new = -1; | |
415 | ||
416 | switch (whence) { | |
417 | case 0: | |
418 | new = off; | |
419 | break; | |
420 | case 1: | |
421 | new = file->f_pos + off; | |
422 | break; | |
423 | } | |
424 | ||
425 | if (new < 0 || new > db->len) | |
426 | return -EINVAL; | |
427 | ||
428 | return (file->f_pos = new); | |
429 | } | |
430 | ||
431 | static int debug_buffer_release(struct inode *inode, struct file *file) | |
432 | { | |
433 | struct debug_buffer *db = (struct debug_buffer *)file->private_data; | |
434 | ||
435 | if (db) | |
436 | kfree(db->buf); | |
437 | kfree(db); | |
438 | ||
439 | return 0; | |
440 | } | |
441 | /* end - util funcs */ | |
442 | ||
7209300a SM |
443 | /* begin - purge list funcs */ |
444 | static int debug_purgelist_print(struct dlm_ctxt *dlm, struct debug_buffer *db) | |
445 | { | |
446 | struct dlm_lock_resource *res; | |
447 | int out = 0; | |
448 | unsigned long total = 0; | |
449 | ||
450 | out += snprintf(db->buf + out, db->len - out, | |
451 | "Dumping Purgelist for Domain: %s\n", dlm->name); | |
452 | ||
453 | spin_lock(&dlm->spinlock); | |
454 | list_for_each_entry(res, &dlm->purge_list, purge) { | |
455 | ++total; | |
456 | if (db->len - out < 100) | |
457 | continue; | |
458 | spin_lock(&res->spinlock); | |
459 | out += stringify_lockname(res->lockname.name, | |
460 | res->lockname.len, | |
461 | db->buf + out, db->len - out); | |
462 | out += snprintf(db->buf + out, db->len - out, "\t%ld\n", | |
463 | (jiffies - res->last_used)/HZ); | |
464 | spin_unlock(&res->spinlock); | |
465 | } | |
466 | spin_unlock(&dlm->spinlock); | |
467 | ||
468 | out += snprintf(db->buf + out, db->len - out, | |
469 | "Total on list: %ld\n", total); | |
470 | ||
471 | return out; | |
472 | } | |
473 | ||
474 | static int debug_purgelist_open(struct inode *inode, struct file *file) | |
475 | { | |
476 | struct dlm_ctxt *dlm = inode->i_private; | |
477 | struct debug_buffer *db; | |
478 | ||
479 | db = debug_buffer_allocate(); | |
480 | if (!db) | |
481 | goto bail; | |
482 | ||
483 | db->len = debug_purgelist_print(dlm, db); | |
484 | ||
485 | file->private_data = db; | |
486 | ||
487 | return 0; | |
488 | bail: | |
489 | return -ENOMEM; | |
490 | } | |
491 | ||
492 | static struct file_operations debug_purgelist_fops = { | |
493 | .open = debug_purgelist_open, | |
494 | .release = debug_buffer_release, | |
495 | .read = debug_buffer_read, | |
496 | .llseek = debug_buffer_llseek, | |
497 | }; | |
498 | /* end - purge list funcs */ | |
499 | ||
d0129ace | 500 | /* begin - debug mle funcs */ |
d0129ace SM |
501 | static int debug_mle_print(struct dlm_ctxt *dlm, struct debug_buffer *db) |
502 | { | |
503 | struct dlm_master_list_entry *mle; | |
2ed6c750 SM |
504 | struct hlist_head *bucket; |
505 | struct hlist_node *list; | |
506 | int i, out = 0; | |
d0129ace SM |
507 | unsigned long total = 0; |
508 | ||
509 | out += snprintf(db->buf + out, db->len - out, | |
510 | "Dumping MLEs for Domain: %s\n", dlm->name); | |
511 | ||
512 | spin_lock(&dlm->master_lock); | |
2ed6c750 SM |
513 | for (i = 0; i < DLM_HASH_BUCKETS; i++) { |
514 | bucket = dlm_master_hash(dlm, i); | |
515 | hlist_for_each(list, bucket) { | |
516 | mle = hlist_entry(list, struct dlm_master_list_entry, | |
517 | master_hash_node); | |
518 | ++total; | |
519 | if (db->len - out < 200) | |
520 | continue; | |
521 | out += dump_mle(mle, db->buf + out, db->len - out); | |
522 | } | |
d0129ace SM |
523 | } |
524 | spin_unlock(&dlm->master_lock); | |
525 | ||
526 | out += snprintf(db->buf + out, db->len - out, | |
527 | "Total on list: %ld\n", total); | |
528 | return out; | |
529 | } | |
530 | ||
531 | static int debug_mle_open(struct inode *inode, struct file *file) | |
532 | { | |
533 | struct dlm_ctxt *dlm = inode->i_private; | |
534 | struct debug_buffer *db; | |
535 | ||
536 | db = debug_buffer_allocate(); | |
537 | if (!db) | |
538 | goto bail; | |
539 | ||
540 | db->len = debug_mle_print(dlm, db); | |
541 | ||
542 | file->private_data = db; | |
543 | ||
544 | return 0; | |
545 | bail: | |
546 | return -ENOMEM; | |
547 | } | |
548 | ||
549 | static struct file_operations debug_mle_fops = { | |
550 | .open = debug_mle_open, | |
551 | .release = debug_buffer_release, | |
552 | .read = debug_buffer_read, | |
553 | .llseek = debug_buffer_llseek, | |
554 | }; | |
555 | ||
556 | /* end - debug mle funcs */ | |
557 | ||
4e3d24ed SM |
558 | /* begin - debug lockres funcs */ |
559 | static int dump_lock(struct dlm_lock *lock, int list_type, char *buf, int len) | |
560 | { | |
561 | int out; | |
562 | ||
563 | #define DEBUG_LOCK_VERSION 1 | |
564 | spin_lock(&lock->spinlock); | |
565 | out = snprintf(buf, len, "LOCK:%d,%d,%d,%d,%d,%d:%lld,%d,%d,%d,%d,%d," | |
566 | "%d,%d,%d,%d\n", | |
567 | DEBUG_LOCK_VERSION, | |
568 | list_type, lock->ml.type, lock->ml.convert_type, | |
569 | lock->ml.node, | |
570 | dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)), | |
571 | dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)), | |
572 | !list_empty(&lock->ast_list), | |
573 | !list_empty(&lock->bast_list), | |
574 | lock->ast_pending, lock->bast_pending, | |
575 | lock->convert_pending, lock->lock_pending, | |
576 | lock->cancel_pending, lock->unlock_pending, | |
577 | atomic_read(&lock->lock_refs.refcount)); | |
578 | spin_unlock(&lock->spinlock); | |
579 | ||
580 | return out; | |
581 | } | |
582 | ||
583 | static int dump_lockres(struct dlm_lock_resource *res, char *buf, int len) | |
584 | { | |
585 | struct dlm_lock *lock; | |
586 | int i; | |
587 | int out = 0; | |
588 | ||
589 | out += snprintf(buf + out, len - out, "NAME:"); | |
590 | out += stringify_lockname(res->lockname.name, res->lockname.len, | |
591 | buf + out, len - out); | |
592 | out += snprintf(buf + out, len - out, "\n"); | |
593 | ||
594 | #define DEBUG_LRES_VERSION 1 | |
595 | out += snprintf(buf + out, len - out, | |
596 | "LRES:%d,%d,%d,%ld,%d,%d,%d,%d,%d,%d,%d\n", | |
597 | DEBUG_LRES_VERSION, | |
598 | res->owner, res->state, res->last_used, | |
599 | !list_empty(&res->purge), | |
600 | !list_empty(&res->dirty), | |
601 | !list_empty(&res->recovering), | |
602 | res->inflight_locks, res->migration_pending, | |
603 | atomic_read(&res->asts_reserved), | |
604 | atomic_read(&res->refs.refcount)); | |
605 | ||
606 | /* refmap */ | |
607 | out += snprintf(buf + out, len - out, "RMAP:"); | |
608 | out += stringify_nodemap(res->refmap, O2NM_MAX_NODES, | |
609 | buf + out, len - out); | |
610 | out += snprintf(buf + out, len - out, "\n"); | |
611 | ||
612 | /* lvb */ | |
613 | out += snprintf(buf + out, len - out, "LVBX:"); | |
614 | for (i = 0; i < DLM_LVB_LEN; i++) | |
615 | out += snprintf(buf + out, len - out, | |
616 | "%02x", (unsigned char)res->lvb[i]); | |
617 | out += snprintf(buf + out, len - out, "\n"); | |
618 | ||
619 | /* granted */ | |
620 | list_for_each_entry(lock, &res->granted, list) | |
621 | out += dump_lock(lock, 0, buf + out, len - out); | |
622 | ||
623 | /* converting */ | |
624 | list_for_each_entry(lock, &res->converting, list) | |
625 | out += dump_lock(lock, 1, buf + out, len - out); | |
626 | ||
627 | /* blocked */ | |
628 | list_for_each_entry(lock, &res->blocked, list) | |
629 | out += dump_lock(lock, 2, buf + out, len - out); | |
630 | ||
631 | out += snprintf(buf + out, len - out, "\n"); | |
632 | ||
633 | return out; | |
634 | } | |
635 | ||
636 | static void *lockres_seq_start(struct seq_file *m, loff_t *pos) | |
637 | { | |
638 | struct debug_lockres *dl = m->private; | |
639 | struct dlm_ctxt *dlm = dl->dl_ctxt; | |
b0d4f817 | 640 | struct dlm_lock_resource *oldres = dl->dl_res; |
4e3d24ed | 641 | struct dlm_lock_resource *res = NULL; |
b0d4f817 | 642 | struct list_head *track_list; |
4e3d24ed | 643 | |
b0d4f817 SM |
644 | spin_lock(&dlm->track_lock); |
645 | if (oldres) | |
646 | track_list = &oldres->tracking; | |
647 | else | |
648 | track_list = &dlm->tracking_list; | |
4e3d24ed | 649 | |
b0d4f817 SM |
650 | list_for_each_entry(res, track_list, tracking) { |
651 | if (&res->tracking == &dlm->tracking_list) | |
652 | res = NULL; | |
653 | else | |
4e3d24ed | 654 | dlm_lockres_get(res); |
b0d4f817 | 655 | break; |
4e3d24ed | 656 | } |
b0d4f817 | 657 | spin_unlock(&dlm->track_lock); |
4e3d24ed | 658 | |
b0d4f817 SM |
659 | if (oldres) |
660 | dlm_lockres_put(oldres); | |
4e3d24ed | 661 | |
b0d4f817 SM |
662 | dl->dl_res = res; |
663 | ||
664 | if (res) { | |
665 | spin_lock(&res->spinlock); | |
666 | dump_lockres(res, dl->dl_buf, dl->dl_len - 1); | |
667 | spin_unlock(&res->spinlock); | |
668 | } else | |
669 | dl = NULL; | |
4e3d24ed | 670 | |
b0d4f817 | 671 | /* passed to seq_show */ |
4e3d24ed SM |
672 | return dl; |
673 | } | |
674 | ||
675 | static void lockres_seq_stop(struct seq_file *m, void *v) | |
676 | { | |
677 | } | |
678 | ||
679 | static void *lockres_seq_next(struct seq_file *m, void *v, loff_t *pos) | |
680 | { | |
681 | return NULL; | |
682 | } | |
683 | ||
684 | static int lockres_seq_show(struct seq_file *s, void *v) | |
685 | { | |
686 | struct debug_lockres *dl = (struct debug_lockres *)v; | |
687 | ||
688 | seq_printf(s, "%s", dl->dl_buf); | |
689 | ||
690 | return 0; | |
691 | } | |
692 | ||
693 | static struct seq_operations debug_lockres_ops = { | |
694 | .start = lockres_seq_start, | |
695 | .stop = lockres_seq_stop, | |
696 | .next = lockres_seq_next, | |
697 | .show = lockres_seq_show, | |
698 | }; | |
699 | ||
700 | static int debug_lockres_open(struct inode *inode, struct file *file) | |
701 | { | |
702 | struct dlm_ctxt *dlm = inode->i_private; | |
703 | int ret = -ENOMEM; | |
704 | struct seq_file *seq; | |
705 | struct debug_lockres *dl = NULL; | |
706 | ||
707 | dl = kzalloc(sizeof(struct debug_lockres), GFP_KERNEL); | |
708 | if (!dl) { | |
709 | mlog_errno(ret); | |
710 | goto bail; | |
711 | } | |
712 | ||
713 | dl->dl_len = PAGE_SIZE; | |
714 | dl->dl_buf = kmalloc(dl->dl_len, GFP_KERNEL); | |
715 | if (!dl->dl_buf) { | |
716 | mlog_errno(ret); | |
717 | goto bail; | |
718 | } | |
719 | ||
720 | ret = seq_open(file, &debug_lockres_ops); | |
721 | if (ret) { | |
722 | mlog_errno(ret); | |
723 | goto bail; | |
724 | } | |
725 | ||
726 | seq = (struct seq_file *) file->private_data; | |
727 | seq->private = dl; | |
728 | ||
729 | dlm_grab(dlm); | |
730 | dl->dl_ctxt = dlm; | |
731 | ||
732 | return 0; | |
733 | bail: | |
734 | if (dl) | |
735 | kfree(dl->dl_buf); | |
736 | kfree(dl); | |
737 | return ret; | |
738 | } | |
739 | ||
740 | static int debug_lockres_release(struct inode *inode, struct file *file) | |
741 | { | |
742 | struct seq_file *seq = (struct seq_file *)file->private_data; | |
743 | struct debug_lockres *dl = (struct debug_lockres *)seq->private; | |
744 | ||
745 | if (dl->dl_res) | |
746 | dlm_lockres_put(dl->dl_res); | |
747 | dlm_put(dl->dl_ctxt); | |
748 | kfree(dl->dl_buf); | |
749 | return seq_release_private(inode, file); | |
750 | } | |
751 | ||
752 | static struct file_operations debug_lockres_fops = { | |
753 | .open = debug_lockres_open, | |
754 | .release = debug_lockres_release, | |
755 | .read = seq_read, | |
756 | .llseek = seq_lseek, | |
757 | }; | |
758 | /* end - debug lockres funcs */ | |
759 | ||
007dce53 SM |
760 | /* begin - debug state funcs */ |
761 | static int debug_state_print(struct dlm_ctxt *dlm, struct debug_buffer *db) | |
762 | { | |
763 | int out = 0; | |
764 | struct dlm_reco_node_data *node; | |
765 | char *state; | |
e64ff146 SM |
766 | int cur_mles = 0, tot_mles = 0; |
767 | int i; | |
007dce53 SM |
768 | |
769 | spin_lock(&dlm->spinlock); | |
770 | ||
771 | switch (dlm->dlm_state) { | |
772 | case DLM_CTXT_NEW: | |
773 | state = "NEW"; break; | |
774 | case DLM_CTXT_JOINED: | |
775 | state = "JOINED"; break; | |
776 | case DLM_CTXT_IN_SHUTDOWN: | |
777 | state = "SHUTDOWN"; break; | |
778 | case DLM_CTXT_LEAVING: | |
779 | state = "LEAVING"; break; | |
780 | default: | |
781 | state = "UNKNOWN"; break; | |
782 | } | |
783 | ||
784 | /* Domain: xxxxxxxxxx Key: 0xdfbac769 */ | |
785 | out += snprintf(db->buf + out, db->len - out, | |
786 | "Domain: %s Key: 0x%08x\n", dlm->name, dlm->key); | |
787 | ||
788 | /* Thread Pid: xxx Node: xxx State: xxxxx */ | |
789 | out += snprintf(db->buf + out, db->len - out, | |
790 | "Thread Pid: %d Node: %d State: %s\n", | |
791 | dlm->dlm_thread_task->pid, dlm->node_num, state); | |
792 | ||
793 | /* Number of Joins: xxx Joining Node: xxx */ | |
794 | out += snprintf(db->buf + out, db->len - out, | |
795 | "Number of Joins: %d Joining Node: %d\n", | |
796 | dlm->num_joins, dlm->joining_node); | |
797 | ||
798 | /* Domain Map: xx xx xx */ | |
799 | out += snprintf(db->buf + out, db->len - out, "Domain Map: "); | |
800 | out += stringify_nodemap(dlm->domain_map, O2NM_MAX_NODES, | |
801 | db->buf + out, db->len - out); | |
802 | out += snprintf(db->buf + out, db->len - out, "\n"); | |
803 | ||
804 | /* Live Map: xx xx xx */ | |
805 | out += snprintf(db->buf + out, db->len - out, "Live Map: "); | |
806 | out += stringify_nodemap(dlm->live_nodes_map, O2NM_MAX_NODES, | |
807 | db->buf + out, db->len - out); | |
808 | out += snprintf(db->buf + out, db->len - out, "\n"); | |
809 | ||
e64ff146 SM |
810 | /* Lock Resources: xxx (xxx) */ |
811 | out += snprintf(db->buf + out, db->len - out, | |
812 | "Lock Resources: %d (%d)\n", | |
813 | atomic_read(&dlm->res_cur_count), | |
814 | atomic_read(&dlm->res_tot_count)); | |
815 | ||
816 | for (i = 0; i < DLM_MLE_NUM_TYPES; ++i) | |
817 | tot_mles += atomic_read(&dlm->mle_tot_count[i]); | |
818 | ||
819 | for (i = 0; i < DLM_MLE_NUM_TYPES; ++i) | |
820 | cur_mles += atomic_read(&dlm->mle_cur_count[i]); | |
821 | ||
822 | /* MLEs: xxx (xxx) */ | |
823 | out += snprintf(db->buf + out, db->len - out, | |
824 | "MLEs: %d (%d)\n", cur_mles, tot_mles); | |
825 | ||
826 | /* Blocking: xxx (xxx) */ | |
827 | out += snprintf(db->buf + out, db->len - out, | |
828 | " Blocking: %d (%d)\n", | |
829 | atomic_read(&dlm->mle_cur_count[DLM_MLE_BLOCK]), | |
830 | atomic_read(&dlm->mle_tot_count[DLM_MLE_BLOCK])); | |
831 | ||
832 | /* Mastery: xxx (xxx) */ | |
833 | out += snprintf(db->buf + out, db->len - out, | |
834 | " Mastery: %d (%d)\n", | |
835 | atomic_read(&dlm->mle_cur_count[DLM_MLE_MASTER]), | |
836 | atomic_read(&dlm->mle_tot_count[DLM_MLE_MASTER])); | |
837 | ||
838 | /* Migration: xxx (xxx) */ | |
839 | out += snprintf(db->buf + out, db->len - out, | |
840 | " Migration: %d (%d)\n", | |
841 | atomic_read(&dlm->mle_cur_count[DLM_MLE_MIGRATION]), | |
842 | atomic_read(&dlm->mle_tot_count[DLM_MLE_MIGRATION])); | |
843 | ||
007dce53 SM |
844 | /* Lists: Dirty=Empty Purge=InUse PendingASTs=Empty ... */ |
845 | out += snprintf(db->buf + out, db->len - out, | |
846 | "Lists: Dirty=%s Purge=%s PendingASTs=%s " | |
2ed6c750 | 847 | "PendingBASTs=%s\n", |
007dce53 SM |
848 | (list_empty(&dlm->dirty_list) ? "Empty" : "InUse"), |
849 | (list_empty(&dlm->purge_list) ? "Empty" : "InUse"), | |
850 | (list_empty(&dlm->pending_asts) ? "Empty" : "InUse"), | |
2ed6c750 | 851 | (list_empty(&dlm->pending_basts) ? "Empty" : "InUse")); |
007dce53 SM |
852 | |
853 | /* Purge Count: xxx Refs: xxx */ | |
854 | out += snprintf(db->buf + out, db->len - out, | |
855 | "Purge Count: %d Refs: %d\n", dlm->purge_count, | |
856 | atomic_read(&dlm->dlm_refs.refcount)); | |
857 | ||
858 | /* Dead Node: xxx */ | |
859 | out += snprintf(db->buf + out, db->len - out, | |
860 | "Dead Node: %d\n", dlm->reco.dead_node); | |
861 | ||
862 | /* What about DLM_RECO_STATE_FINALIZE? */ | |
863 | if (dlm->reco.state == DLM_RECO_STATE_ACTIVE) | |
864 | state = "ACTIVE"; | |
865 | else | |
866 | state = "INACTIVE"; | |
867 | ||
868 | /* Recovery Pid: xxxx Master: xxx State: xxxx */ | |
869 | out += snprintf(db->buf + out, db->len - out, | |
870 | "Recovery Pid: %d Master: %d State: %s\n", | |
871 | dlm->dlm_reco_thread_task->pid, | |
872 | dlm->reco.new_master, state); | |
873 | ||
874 | /* Recovery Map: xx xx */ | |
875 | out += snprintf(db->buf + out, db->len - out, "Recovery Map: "); | |
876 | out += stringify_nodemap(dlm->recovery_map, O2NM_MAX_NODES, | |
877 | db->buf + out, db->len - out); | |
878 | out += snprintf(db->buf + out, db->len - out, "\n"); | |
879 | ||
880 | /* Recovery Node State: */ | |
881 | out += snprintf(db->buf + out, db->len - out, "Recovery Node State:\n"); | |
882 | list_for_each_entry(node, &dlm->reco.node_data, list) { | |
883 | switch (node->state) { | |
884 | case DLM_RECO_NODE_DATA_INIT: | |
885 | state = "INIT"; | |
886 | break; | |
887 | case DLM_RECO_NODE_DATA_REQUESTING: | |
888 | state = "REQUESTING"; | |
889 | break; | |
890 | case DLM_RECO_NODE_DATA_DEAD: | |
891 | state = "DEAD"; | |
892 | break; | |
893 | case DLM_RECO_NODE_DATA_RECEIVING: | |
894 | state = "RECEIVING"; | |
895 | break; | |
896 | case DLM_RECO_NODE_DATA_REQUESTED: | |
897 | state = "REQUESTED"; | |
898 | break; | |
899 | case DLM_RECO_NODE_DATA_DONE: | |
900 | state = "DONE"; | |
901 | break; | |
902 | case DLM_RECO_NODE_DATA_FINALIZE_SENT: | |
903 | state = "FINALIZE-SENT"; | |
904 | break; | |
905 | default: | |
906 | state = "BAD"; | |
907 | break; | |
908 | } | |
909 | out += snprintf(db->buf + out, db->len - out, "\t%u - %s\n", | |
910 | node->node_num, state); | |
911 | } | |
912 | ||
913 | spin_unlock(&dlm->spinlock); | |
914 | ||
915 | return out; | |
916 | } | |
917 | ||
918 | static int debug_state_open(struct inode *inode, struct file *file) | |
919 | { | |
920 | struct dlm_ctxt *dlm = inode->i_private; | |
921 | struct debug_buffer *db = NULL; | |
922 | ||
923 | db = debug_buffer_allocate(); | |
924 | if (!db) | |
925 | goto bail; | |
926 | ||
927 | db->len = debug_state_print(dlm, db); | |
928 | ||
929 | file->private_data = db; | |
930 | ||
931 | return 0; | |
932 | bail: | |
933 | return -ENOMEM; | |
934 | } | |
935 | ||
936 | static struct file_operations debug_state_fops = { | |
937 | .open = debug_state_open, | |
938 | .release = debug_buffer_release, | |
939 | .read = debug_buffer_read, | |
940 | .llseek = debug_buffer_llseek, | |
941 | }; | |
942 | /* end - debug state funcs */ | |
943 | ||
944 | /* files in subroot */ | |
945 | int dlm_debug_init(struct dlm_ctxt *dlm) | |
946 | { | |
947 | struct dlm_debug_ctxt *dc = dlm->dlm_debug_ctxt; | |
948 | ||
949 | /* for dumping dlm_ctxt */ | |
950 | dc->debug_state_dentry = debugfs_create_file(DLM_DEBUGFS_DLM_STATE, | |
951 | S_IFREG|S_IRUSR, | |
952 | dlm->dlm_debugfs_subroot, | |
953 | dlm, &debug_state_fops); | |
954 | if (!dc->debug_state_dentry) { | |
955 | mlog_errno(-ENOMEM); | |
956 | goto bail; | |
957 | } | |
958 | ||
4e3d24ed SM |
959 | /* for dumping lockres */ |
960 | dc->debug_lockres_dentry = | |
961 | debugfs_create_file(DLM_DEBUGFS_LOCKING_STATE, | |
962 | S_IFREG|S_IRUSR, | |
963 | dlm->dlm_debugfs_subroot, | |
964 | dlm, &debug_lockres_fops); | |
965 | if (!dc->debug_lockres_dentry) { | |
966 | mlog_errno(-ENOMEM); | |
967 | goto bail; | |
968 | } | |
969 | ||
d0129ace SM |
970 | /* for dumping mles */ |
971 | dc->debug_mle_dentry = debugfs_create_file(DLM_DEBUGFS_MLE_STATE, | |
972 | S_IFREG|S_IRUSR, | |
973 | dlm->dlm_debugfs_subroot, | |
974 | dlm, &debug_mle_fops); | |
975 | if (!dc->debug_mle_dentry) { | |
976 | mlog_errno(-ENOMEM); | |
977 | goto bail; | |
978 | } | |
979 | ||
7209300a SM |
980 | /* for dumping lockres on the purge list */ |
981 | dc->debug_purgelist_dentry = | |
982 | debugfs_create_file(DLM_DEBUGFS_PURGE_LIST, | |
983 | S_IFREG|S_IRUSR, | |
984 | dlm->dlm_debugfs_subroot, | |
985 | dlm, &debug_purgelist_fops); | |
986 | if (!dc->debug_purgelist_dentry) { | |
987 | mlog_errno(-ENOMEM); | |
988 | goto bail; | |
989 | } | |
990 | ||
007dce53 SM |
991 | dlm_debug_get(dc); |
992 | return 0; | |
993 | ||
994 | bail: | |
995 | dlm_debug_shutdown(dlm); | |
996 | return -ENOMEM; | |
997 | } | |
998 | ||
999 | void dlm_debug_shutdown(struct dlm_ctxt *dlm) | |
1000 | { | |
1001 | struct dlm_debug_ctxt *dc = dlm->dlm_debug_ctxt; | |
1002 | ||
1003 | if (dc) { | |
7209300a SM |
1004 | if (dc->debug_purgelist_dentry) |
1005 | debugfs_remove(dc->debug_purgelist_dentry); | |
d0129ace SM |
1006 | if (dc->debug_mle_dentry) |
1007 | debugfs_remove(dc->debug_mle_dentry); | |
4e3d24ed SM |
1008 | if (dc->debug_lockres_dentry) |
1009 | debugfs_remove(dc->debug_lockres_dentry); | |
007dce53 SM |
1010 | if (dc->debug_state_dentry) |
1011 | debugfs_remove(dc->debug_state_dentry); | |
1012 | dlm_debug_put(dc); | |
1013 | } | |
1014 | } | |
6325b4a2 SM |
1015 | |
1016 | /* subroot - domain dir */ | |
1017 | int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm) | |
1018 | { | |
1019 | dlm->dlm_debugfs_subroot = debugfs_create_dir(dlm->name, | |
1020 | dlm_debugfs_root); | |
1021 | if (!dlm->dlm_debugfs_subroot) { | |
1022 | mlog_errno(-ENOMEM); | |
1023 | goto bail; | |
1024 | } | |
1025 | ||
007dce53 SM |
1026 | dlm->dlm_debug_ctxt = kzalloc(sizeof(struct dlm_debug_ctxt), |
1027 | GFP_KERNEL); | |
1028 | if (!dlm->dlm_debug_ctxt) { | |
1029 | mlog_errno(-ENOMEM); | |
1030 | goto bail; | |
1031 | } | |
1032 | kref_init(&dlm->dlm_debug_ctxt->debug_refcnt); | |
1033 | ||
6325b4a2 SM |
1034 | return 0; |
1035 | bail: | |
1036 | dlm_destroy_debugfs_subroot(dlm); | |
1037 | return -ENOMEM; | |
1038 | } | |
1039 | ||
1040 | void dlm_destroy_debugfs_subroot(struct dlm_ctxt *dlm) | |
1041 | { | |
1042 | if (dlm->dlm_debugfs_subroot) | |
1043 | debugfs_remove(dlm->dlm_debugfs_subroot); | |
1044 | } | |
1045 | ||
1046 | /* debugfs root */ | |
1047 | int dlm_create_debugfs_root(void) | |
1048 | { | |
1049 | dlm_debugfs_root = debugfs_create_dir(DLM_DEBUGFS_DIR, NULL); | |
1050 | if (!dlm_debugfs_root) { | |
1051 | mlog_errno(-ENOMEM); | |
1052 | return -ENOMEM; | |
1053 | } | |
1054 | return 0; | |
1055 | } | |
1056 | ||
1057 | void dlm_destroy_debugfs_root(void) | |
1058 | { | |
1059 | if (dlm_debugfs_root) | |
1060 | debugfs_remove(dlm_debugfs_root); | |
1061 | } | |
1062 | #endif /* CONFIG_DEBUG_FS */ |