aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/dlm/dlmcommon.h2
-rw-r--r--fs/ocfs2/dlm/dlmdebug.c50
-rw-r--r--fs/ocfs2/dlm/dlmdebug.h54
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c21
4 files changed, 125 insertions, 2 deletions
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h
index cc31abeadb8e..6a491403bbfb 100644
--- a/fs/ocfs2/dlm/dlmcommon.h
+++ b/fs/ocfs2/dlm/dlmcommon.h
@@ -123,6 +123,8 @@ struct dlm_ctxt
123 atomic_t remote_resources; 123 atomic_t remote_resources;
124 atomic_t unknown_resources; 124 atomic_t unknown_resources;
125 125
126 struct dentry *dlm_debugfs_subroot;
127
126 /* NOTE: Next three are protected by dlm_domain_lock */ 128 /* NOTE: Next three are protected by dlm_domain_lock */
127 struct kref dlm_refs; 129 struct kref dlm_refs;
128 enum dlm_ctxt_state dlm_state; 130 enum dlm_ctxt_state dlm_state;
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
index 64239b37e5d4..62e2a4cbf60d 100644
--- a/fs/ocfs2/dlm/dlmdebug.c
+++ b/fs/ocfs2/dlm/dlmdebug.c
@@ -30,6 +30,7 @@
30#include <linux/utsname.h> 30#include <linux/utsname.h>
31#include <linux/sysctl.h> 31#include <linux/sysctl.h>
32#include <linux/spinlock.h> 32#include <linux/spinlock.h>
33#include <linux/debugfs.h>
33 34
34#include "cluster/heartbeat.h" 35#include "cluster/heartbeat.h"
35#include "cluster/nodemanager.h" 36#include "cluster/nodemanager.h"
@@ -37,8 +38,8 @@
37 38
38#include "dlmapi.h" 39#include "dlmapi.h"
39#include "dlmcommon.h" 40#include "dlmcommon.h"
40
41#include "dlmdomain.h" 41#include "dlmdomain.h"
42#include "dlmdebug.h"
42 43
43#define MLOG_MASK_PREFIX ML_DLM 44#define MLOG_MASK_PREFIX ML_DLM
44#include "cluster/masklog.h" 45#include "cluster/masklog.h"
@@ -266,3 +267,50 @@ const char *dlm_errname(enum dlm_status err)
266 return dlm_errnames[err]; 267 return dlm_errnames[err];
267} 268}
268EXPORT_SYMBOL_GPL(dlm_errname); 269EXPORT_SYMBOL_GPL(dlm_errname);
270
271
272#ifdef CONFIG_DEBUG_FS
273
274static struct dentry *dlm_debugfs_root = NULL;
275
276#define DLM_DEBUGFS_DIR "o2dlm"
277
278/* subroot - domain dir */
279int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm)
280{
281 dlm->dlm_debugfs_subroot = debugfs_create_dir(dlm->name,
282 dlm_debugfs_root);
283 if (!dlm->dlm_debugfs_subroot) {
284 mlog_errno(-ENOMEM);
285 goto bail;
286 }
287
288 return 0;
289bail:
290 dlm_destroy_debugfs_subroot(dlm);
291 return -ENOMEM;
292}
293
294void dlm_destroy_debugfs_subroot(struct dlm_ctxt *dlm)
295{
296 if (dlm->dlm_debugfs_subroot)
297 debugfs_remove(dlm->dlm_debugfs_subroot);
298}
299
300/* debugfs root */
301int dlm_create_debugfs_root(void)
302{
303 dlm_debugfs_root = debugfs_create_dir(DLM_DEBUGFS_DIR, NULL);
304 if (!dlm_debugfs_root) {
305 mlog_errno(-ENOMEM);
306 return -ENOMEM;
307 }
308 return 0;
309}
310
311void dlm_destroy_debugfs_root(void)
312{
313 if (dlm_debugfs_root)
314 debugfs_remove(dlm_debugfs_root);
315}
316#endif /* CONFIG_DEBUG_FS */
diff --git a/fs/ocfs2/dlm/dlmdebug.h b/fs/ocfs2/dlm/dlmdebug.h
new file mode 100644
index 000000000000..b96959512d96
--- /dev/null
+++ b/fs/ocfs2/dlm/dlmdebug.h
@@ -0,0 +1,54 @@
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * dlmdebug.h
5 *
6 * Copyright (C) 2008 Oracle. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 021110-1307, USA.
22 *
23 */
24
25#ifndef DLMDEBUG_H
26#define DLMDEBUG_H
27
28#ifdef CONFIG_DEBUG_FS
29
30int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm);
31void dlm_destroy_debugfs_subroot(struct dlm_ctxt *dlm);
32
33int dlm_create_debugfs_root(void);
34void dlm_destroy_debugfs_root(void);
35
36#else
37
38static int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm)
39{
40 return 0;
41}
42static void dlm_destroy_debugfs_subroot(struct dlm_ctxt *dlm)
43{
44}
45static int dlm_create_debugfs_root(void)
46{
47 return 0;
48}
49static void dlm_destroy_debugfs_root(void)
50{
51}
52
53#endif /* CONFIG_DEBUG_FS */
54#endif /* DLMDEBUG_H */
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index 4f7695c851ed..c137d693cef3 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -33,6 +33,7 @@
33#include <linux/spinlock.h> 33#include <linux/spinlock.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/err.h> 35#include <linux/err.h>
36#include <linux/debugfs.h>
36 37
37#include "cluster/heartbeat.h" 38#include "cluster/heartbeat.h"
38#include "cluster/nodemanager.h" 39#include "cluster/nodemanager.h"
@@ -40,8 +41,8 @@
40 41
41#include "dlmapi.h" 42#include "dlmapi.h"
42#include "dlmcommon.h" 43#include "dlmcommon.h"
43
44#include "dlmdomain.h" 44#include "dlmdomain.h"
45#include "dlmdebug.h"
45 46
46#include "dlmver.h" 47#include "dlmver.h"
47 48
@@ -298,6 +299,8 @@ static int dlm_wait_on_domain_helper(const char *domain)
298 299
299static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm) 300static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm)
300{ 301{
302 dlm_destroy_debugfs_subroot(dlm);
303
301 if (dlm->lockres_hash) 304 if (dlm->lockres_hash)
302 dlm_free_pagevec((void **)dlm->lockres_hash, DLM_HASH_PAGES); 305 dlm_free_pagevec((void **)dlm->lockres_hash, DLM_HASH_PAGES);
303 306
@@ -1494,6 +1497,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
1494 u32 key) 1497 u32 key)
1495{ 1498{
1496 int i; 1499 int i;
1500 int ret;
1497 struct dlm_ctxt *dlm = NULL; 1501 struct dlm_ctxt *dlm = NULL;
1498 1502
1499 dlm = kzalloc(sizeof(*dlm), GFP_KERNEL); 1503 dlm = kzalloc(sizeof(*dlm), GFP_KERNEL);
@@ -1526,6 +1530,15 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
1526 dlm->key = key; 1530 dlm->key = key;
1527 dlm->node_num = o2nm_this_node(); 1531 dlm->node_num = o2nm_this_node();
1528 1532
1533 ret = dlm_create_debugfs_subroot(dlm);
1534 if (ret < 0) {
1535 dlm_free_pagevec((void **)dlm->lockres_hash, DLM_HASH_PAGES);
1536 kfree(dlm->name);
1537 kfree(dlm);
1538 dlm = NULL;
1539 goto leave;
1540 }
1541
1529 spin_lock_init(&dlm->spinlock); 1542 spin_lock_init(&dlm->spinlock);
1530 spin_lock_init(&dlm->master_lock); 1543 spin_lock_init(&dlm->master_lock);
1531 spin_lock_init(&dlm->ast_lock); 1544 spin_lock_init(&dlm->ast_lock);
@@ -1851,8 +1864,13 @@ static int __init dlm_init(void)
1851 goto error; 1864 goto error;
1852 } 1865 }
1853 1866
1867 status = dlm_create_debugfs_root();
1868 if (status)
1869 goto error;
1870
1854 return 0; 1871 return 0;
1855error: 1872error:
1873 dlm_unregister_net_handlers();
1856 dlm_destroy_lock_cache(); 1874 dlm_destroy_lock_cache();
1857 dlm_destroy_master_caches(); 1875 dlm_destroy_master_caches();
1858 dlm_destroy_mle_cache(); 1876 dlm_destroy_mle_cache();
@@ -1861,6 +1879,7 @@ error:
1861 1879
1862static void __exit dlm_exit (void) 1880static void __exit dlm_exit (void)
1863{ 1881{
1882 dlm_destroy_debugfs_root();
1864 dlm_unregister_net_handlers(); 1883 dlm_unregister_net_handlers();
1865 dlm_destroy_lock_cache(); 1884 dlm_destroy_lock_cache();
1866 dlm_destroy_master_caches(); 1885 dlm_destroy_master_caches();