[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [GFS2 patch] Make dump_glock a bit more friendly



Hi,

This patch makes the glock dump a little more user-friendly.
My primary goal was to get rid of the very-misleading report
of the glock being "(unlocked)" based on gl_flag, but it goes
a step further.  If it's too verbose, feel free to say no.

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, " \n");
 	print_dbg(gi, "  gl_ref = %d\n", atomic_read(&gl->gl_ref));
-	print_dbg(gi, "  gl_state = %u\n", gl->gl_state);
+	print_dbg(gi, "  gl_state = %u (%s)\n", 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)
@@ -1932,6 +1958,8 @@ static int dump_glock(struct glock_iter *gi, struct gfs2_glock *gl)
 	print_dbg(gi, "  req_gh = %s\n", (gl->gl_req_gh) ? "yes" : "no");
 	print_dbg(gi, "  lvb_count = %d\n", atomic_read(&gl->gl_lvb_count));
 	print_dbg(gi, "  object = %s\n", (gl->gl_object) ? "yes" : "no");
+	print_dbg(gi, "  le = %s\n",
+		   (list_empty(&gl->gl_le.le_list)) ? "no" : "yes");
 	print_dbg(gi, "  reclaim = %s\n",
 		   (list_empty(&gl->gl_reclaim)) ? "no" : "yes");
 	if (gl->gl_aspace)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]