From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [GFS2 PATCH] GFS2: Add new debug trace point and evict code path
Date: Thu, 16 Mar 2017 16:15:23 -0400 (EDT) [thread overview]
Message-ID: <1241019872.3178045.1489695323434.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1230083468.3177884.1489695219753.JavaMail.zimbra@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 */
parent reply other threads:[~2017-03-16 20:15 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <1230083468.3177884.1489695219753.JavaMail.zimbra@redhat.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1241019872.3178045.1489695323434.JavaMail.zimbra@redhat.com \
--to=rpeterso@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).