[Ocfs2-tools-devel] [PATCH 2/3] debugfs: Add option to limit
fs_locks to dump only busy locks
Sunil Mushran
sunil.mushran at oracle.com
Mon Feb 25 12:27:04 PST 2008
This patch enhances the fs_locks command in debugfs.ocfs2 to limit
the output to only the busy locks. This is useful in debugging hangs
in a cluster operation as it allows the user to limit the dump to
only the locks that could be relevant to the issue.
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
debugfs.ocfs2/commands.c | 14 ++++++++++----
debugfs.ocfs2/dump_fs_locks.c | 22 ++++++++++++++--------
debugfs.ocfs2/include/dump_fs_locks.h | 4 ++--
3 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
index cdab387..c06442c 100644
--- a/debugfs.ocfs2/commands.c
+++ b/debugfs.ocfs2/commands.c
@@ -801,7 +801,7 @@ static void do_help (char **args)
printf ("encode <filespec>\t\t\tShow lock name\n");
printf ("extent <block#>\t\t\t\tShow extent block\n");
printf ("findpath <block#>\t\t\tList one pathname of the inode/lockname\n");
- printf ("fs_locks [-l]\t\t\t\tShow live fs locking state\n");
+ printf ("fs_locks [-l] [-B]\t\t\tShow live fs locking state\n");
printf ("group <block#>\t\t\t\tShow chain group\n");
printf ("hb\t\t\t\t\tShows the used heartbeat blocks\n");
printf ("help, ?\t\t\t\t\tThis information\n");
@@ -1469,15 +1469,21 @@ static void do_fs_locks(char **args)
{
FILE *out;
int dump_lvbs = 0;
+ int only_busy = 0;
+ int i = 0;
if (check_device_open())
return;
- if (args[1] && !strcmp("-l", args[1]))
- dump_lvbs = 1;
+ while (args[++i]) {
+ if (!strcmp("-l", args[i]))
+ dump_lvbs = 1;
+ else if (!strcmp("-B", args[i]))
+ only_busy = 1;
+ }
out = open_pager(gbls.interactive);
- dump_fs_locks(gbls.fs->uuid_str, out, dump_lvbs);
+ dump_fs_locks(gbls.fs->uuid_str, out, dump_lvbs, only_busy);
close_pager(out);
}
diff --git a/debugfs.ocfs2/dump_fs_locks.c b/debugfs.ocfs2/dump_fs_locks.c
index 74423eb..28059d0 100644
--- a/debugfs.ocfs2/dump_fs_locks.c
+++ b/debugfs.ocfs2/dump_fs_locks.c
@@ -5,7 +5,7 @@
*
* Interface with the kernel and dump current fs locking state
*
- * Copyright (C) 2005 Oracle. All rights reserved.
+ * Copyright (C) 2005, 2008 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -21,9 +21,8 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
- * This code is a port of e2fsprogs/lib/ext2fs/dir_iterate.c
- * Copyright (C) 1993, 1994, 1994, 1995, 1996, 1997 Theodore Ts'o.
*/
+
#define _XOPEN_SOURCE 600 /* Triggers XOPEN2K in features.h */
#define _LARGEFILE64_SOURCE
@@ -226,7 +225,7 @@ static void dump_meta_lvb(const char *raw_lvb, FILE *out)
}
/* 0 = eof, > 0 = success, < 0 = error */
-static int dump_version_one(FILE *file, FILE *out, int lvbs)
+static int dump_version_one(FILE *file, FILE *out, int lvbs, int only_busy)
{
char id[OCFS2_LOCK_ID_MAX_LEN + 1];
char lvb[DLM_LVB_LEN];
@@ -276,6 +275,13 @@ static int dump_version_one(FILE *file, FILE *out, int lvbs)
lvb[i] = (char) dummy;
}
+ if (only_busy) {
+ if (!(flags & OCFS2_LOCK_BUSY)) {
+ ret = 1;
+ goto out;
+ }
+ }
+
fprintf(out, "Lockres: %s Mode: %s\nFlags:", id, level_str(level));
print_flags(flags, out);
fprintf(out, "\nRO Holders: %u EX Holders: %u\n", ro, ex);
@@ -311,7 +317,7 @@ static int end_line(FILE *f)
#define CURRENT_PROTO 1
/* returns 0 on error or end of file */
-static int dump_one_lockres(FILE *file, FILE *out, int lvbs)
+static int dump_one_lockres(FILE *file, FILE *out, int lvbs, int only_busy)
{
unsigned int version;
int ret;
@@ -326,7 +332,7 @@ static int dump_one_lockres(FILE *file, FILE *out, int lvbs)
return 0;
}
- ret = dump_version_one(file, out, lvbs);
+ ret = dump_version_one(file, out, lvbs, only_busy);
if (ret <= 0)
return 0;
@@ -398,7 +404,7 @@ out:
#define DEBUGFS_PATH SYSFS_BASE "debug"
#define DEBUGFS_ALTERNATE_PATH "/debug"
-void dump_fs_locks(char *uuid_str, FILE *out, int dump_lvbs)
+void dump_fs_locks(char *uuid_str, FILE *out, int dump_lvbs, int only_busy)
{
errcode_t ret;
int err;
@@ -425,7 +431,7 @@ void dump_fs_locks(char *uuid_str, FILE *out, int dump_lvbs)
return;
}
- while (dump_one_lockres(file, out, dump_lvbs))
+ while (dump_one_lockres(file, out, dump_lvbs, only_busy))
;
fclose(file);
diff --git a/debugfs.ocfs2/include/dump_fs_locks.h b/debugfs.ocfs2/include/dump_fs_locks.h
index 420a6d1..f218458 100644
--- a/debugfs.ocfs2/include/dump_fs_locks.h
+++ b/debugfs.ocfs2/include/dump_fs_locks.h
@@ -3,7 +3,7 @@
*
* Function prototypes, macros, etc. for related 'C' files
*
- * Copyright (C) 2005 Oracle. All rights reserved.
+ * Copyright (C) 2005, 2008 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -25,6 +25,6 @@
#ifndef _DUMP_FS_LOCKS_H_
#define _DUMP_FS_LOCKS_H_
-void dump_fs_locks(char *uuid, FILE *out, int dump_lvbs);
+void dump_fs_locks(char *uuid, FILE *out, int dump_lvbs, int only_busy);
#endif /* _DUMP_FS_LOCKS_H_ */
--
1.5.2.5
More information about the Ocfs2-tools-devel
mailing list