[Cluster-devel] [GFS2 PATCH resend/revised] GFS2: Add new debug trace point and evict code path

Bob Peterson <[email protected]>
Newsgroups com.redhat.cluster-devel
Message-ID <[email protected]>
Hi,

I first sent out this patch on 16 March, but with all the other
activity (e.g. non-recursive delete) it got lost in the shuffle
and got no acks.

Since then I needed to revise it due to changes in the evict code.
This, then, is the revised patch.

Patch description:
------------------
This patch adds a new kernel trace point for general gfs2 debugging.
Its first use is to trace which codepath is taken when an inode is
evicted.

Signed-off-by: Bob Peterson <[email protected]>
---
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 29b0473..1c5c0ea 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -41,6 +41,7 @@
 #include "recovery.h"
 #include "rgrp.h"
 #include "super.h"
+#include "trace_gfs2.h"
 #include "trans.h"
 #include "util.h"
 #include "sys.h"
@@ -815,6 +816,7 @@ static void gfs2_dirty_inode(struct inode *inode, int flags)
 	}
 
 	ret = gfs2_meta_inode_buffer(ip, &bh);
+	trace_gfs2_debug(ip->i_gl, ret, "gfs2_dirty_inode");
 	if (ret == 0) {
 		gfs2_trans_add_meta(ip->i_gl, bh);
 		gfs2_dinode_out(ip, bh->b_data);
@@ -1528,31 +1530,39 @@ static void gfs2_evict_inode(struct inode *inode)
 	int error;
 
 	if (test_bit(GIF_FREE_VFS_INODE, &ip->i_flags)) {
+		trace_gfs2_debug(ip->i_gl, inode->i_nlink, "evict_case_3a");
 		clear_inode(inode);
 		return;
 	}
 
-	if (inode->i_nlink || (sb->s_flags & MS_RDONLY))
+	if (inode->i_nlink || (sb->s_flags & MS_RDONLY)) {
+		trace_gfs2_debug(ip->i_gl, inode->i_state, "evict_case_3");
 		goto out;
+	}
 
 	/* Must not read inode block until block type has been verified */
 	error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_SKIP, &gh);
 	if (unlikely(error)) {
 		ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
 		gfs2_glock_dq_uninit(&ip->i_iopen_gh);
+		trace_gfs2_debug(ip->i_gl, error, "evict_case_glerr");
 		goto out;
 	}
 
 	if (!test_bit(GIF_ALLOC_FAILED, &ip->i_flags)) {
 		error = gfs2_check_blk_type(sdp, ip->i_no_addr, GFS2_BLKST_UNLINKED);
-		if (error)
+		if (error) {
+			trace_gfs2_debug(ip->i_gl, error, "evict_case_2a");
 			goto out_truncate;
+		}
 	}
 
 	if (test_bit(GIF_INVALID, &ip->i_flags)) {
 		error = gfs2_inode_refresh(ip);
-		if (error)
+		if (error) {
+			trace_gfs2_debug(ip->i_gl, error, "evict_case_2b");
 			goto out_truncate;
+		}
 	}
 
 	if (gfs2_holder_initialized(&ip->i_iopen_gh) &&
@@ -1562,8 +1572,10 @@ static void gfs2_evict_inode(struct inode *inode)
 		gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE,
 				   &ip->i_iopen_gh);
 		error = gfs2_glock_nq(&ip->i_iopen_gh);
-		if (error)
+		if (error) {
+			trace_gfs2_debug(ip->i_gl, error, "evict_case_2c");
 			goto out_truncate;
+		}
 	}
 
 	/* Case 1 starts here */
@@ -1571,22 +1583,29 @@ static void gfs2_evict_inode(struct inode *inode)
 	if (S_ISDIR(inode->i_mode) &&
 	    (ip->i_diskflags & GFS2_DIF_EXHASH)) {
 		error = gfs2_dir_exhash_dealloc(ip);
-		if (error)
+		if (error) {
+			trace_gfs2_debug(ip->i_gl, error, "evict_case_1a");
 			goto out_unlock;
+		}
 	}
 
 	if (ip->i_eattr) {
 		error = gfs2_ea_dealloc(ip);
-		if (error)
+		if (error) {
+			trace_gfs2_debug(ip->i_gl, error, "evict_case_1b");
 			goto out_unlock;
+		}
 	}
 
 	if (!gfs2_is_stuffed(ip)) {
 		error = gfs2_file_dealloc(ip);
-		if (error)
+		if (error) {
+			trace_gfs2_debug(ip->i_gl, error, "evict_case_1c");
 			goto out_unlock;
+		}
 	}
 
+	trace_gfs2_debug(ip->i_gl, error, "evict_case_1");
 	error = gfs2_dinode_dealloc(ip);
 	goto out_unlock;
 
diff --git a/fs/gfs2/trace_gfs2.h b/fs/gfs2/trace_gfs2.h
index 49ac55d..3d24bbb 100644
--- a/fs/gfs2/trace_gfs2.h
+++ b/fs/gfs2/trace_gfs2.h
@@ -548,6 +548,38 @@ TRACE_EVENT(gfs2_rs,
 		  rs_func_name(__entry->func), (unsigned long)__entry->free)
 );
 
+/* Generic debug messages */
+TRACE_EVENT(gfs2_debug,
+
+	TP_PROTO(struct gfs2_glock *gl, int ret, const char *msg),
+
+	TP_ARGS(gl, ret, msg),
+
+	TP_STRUCT__entry(
+		__field(        dev_t,  dev                     )
+		__field(	u64,	glnum			)
+		__field(	u32,	gltype			)
+		__field(	int,	ret			)
+		__field(	int,	nrpages			)
+		__string(	msg,	msg			)
+	),
+
+	TP_fast_assign(
+		__entry->dev	= gl->gl_name.ln_sbd->sd_vfs->s_dev;
+		__entry->glnum	= gl->gl_name.ln_number;
+		__entry->gltype	= gl->gl_name.ln_type;
+		__entry->ret = ret;
+		__entry->nrpages = (gfs2_glock2aspace(gl) ?
+				    gfs2_glock2aspace(gl)->nrpages : 0);
+		__assign_str(msg, msg);
+	),
+
+	TP_printk("%u,%u %u:%llu rc:%d pgs: %d %s",
+		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->gltype,
+		  (unsigned long long)__entry->glnum, __entry->ret,
+		  __entry->nrpages, __get_str(msg))
+);
+
 #endif /* _TRACE_GFS2_H */
 
 /* This part must be outside protection */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.