Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Cluster Development (http://www.linux-archive.org/cluster-development/)
-   -   Make dump_glock a bit more friendly - CORRECTION (http://www.linux-archive.org/cluster-development/70871-make-dump_glock-bit-more-friendly-correction.html)

Bob Peterson 04-16-2008 05:33 PM

Make dump_glock a bit more friendly - CORRECTION
 
Hi,

My previous post contained some RHEL-specific code that doesn't belong
in the upstream kernel. This re-post fixes that.

Regards,

Bob Peterson
--
fs/gfs2/glock.c | 34 +++++++++++++++++++++++++++++++---
1 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index d636b3e..53396e7 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -122,6 +122,20 @@ static inline rwlock_t *gl_lock_addr(unsigned int x)
}
#endif

+const char *gl_flags[] = {"",
+ "GLF_LOCK",
+ "GLF_STICKY",
+ "GLF_DEMOTE",
+ "GLF_PENDING_DEMOTE",
+ "GLF_DIRTY"
+};
+
+const char *gl_states[] = {"LM_ST_UNLOCKED",
+ "LM_ST_EXCLUSIVE",
+ "LM_ST_DEFERRED",
+ "LM_ST_SHARED"
+};
+
/**
* relaxed_state_ok - is a requested lock compatible with the current lock mode?
* @actual: the current state of the lock
@@ -1903,6 +1917,7 @@ static int dump_glock(struct glock_iter *gi, struct gfs2_glock *gl)
unsigned int x;
int error = -ENOBUFS;
struct task_struct *gl_owner;
+ int first, count;

spin_lock(&gl->gl_spin);

@@ -1913,11 +1928,22 @@ static int dump_glock(struct glock_iter *gi, struct gfs2_glock *gl)
if (test_bit(x, &gl->gl_flags))
print_dbg(gi, " %u", x);
}
- if (!test_bit(GLF_LOCK, &gl->gl_flags))
- print_dbg(gi, " (unlocked)");
+ first = 1;
+ count = 0;
+ for (x = GLF_LOCK; x <= GLF_DIRTY; x++) {
+ if (test_bit(x, &gl->gl_flags)) {
+ print_dbg(gi, "%c", first ? '(' : '|');
+ print_dbg(gi, "%s", gl_flags[x]);
+ first = 0;
+ count++;
+ }
+ }
+ if (count)
+ print_dbg(gi, ")");
print_dbg(gi, "
");
print_dbg(gi, " gl_ref = %d
", atomic_read(&gl->gl_ref));
- print_dbg(gi, " gl_state = %u
", gl->gl_state);
+ print_dbg(gi, " gl_state = %u (%s)
", gl->gl_state,
+ gl_states[gl->gl_state & 0x3]);
if (gl->gl_owner_pid) {
gl_owner = pid_task(gl->gl_owner_pid, PIDTYPE_PID);
if (gl_owner)


All times are GMT. The time now is 10:03 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.