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