* [Cluster-devel] [GFS2 PATCH] GFS2: Add new debug trace point and evict code path
[not found] <1230083468.3177884.1489695219753.JavaMail.zimbra@redhat.com>
@ 2017-03-16 20:15 ` Bob Peterson
0 siblings, 0 replies; only message in thread
From: Bob Peterson @ 2017-03-16 20:15 UTC (permalink / raw)
To: cluster-devel.redhat.com
Hi,
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. This helped me debugging some nasty problems.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 2a9a830..ae70bcf 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,12 +1530,15 @@ 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);
@@ -1541,19 +1546,24 @@ static void gfs2_evict_inode(struct inode *inode)
ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
gfs2_glock_dq_wait(&ip->i_iopen_gh);
gfs2_holder_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) &&
@@ -1563,8 +1573,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 */
@@ -1572,22 +1584,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 */
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-03-16 20:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1230083468.3177884.1489695219753.JavaMail.zimbra@redhat.com>
2017-03-16 20:15 ` [Cluster-devel] [GFS2 PATCH] GFS2: Add new debug trace point and evict code path Bob Peterson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).