Use a tracepoint and a counter in gfs2_jdesc to count the number of
outstanding reads (in pages) as we read through a journal to aid
debugging.

Signed-off-by: Abhi Das <[email protected]>
---
 fs/gfs2/incore.h     |  1 +
 fs/gfs2/lops.c       |  3 +++
 fs/gfs2/ops_fstype.c |  1 +
 fs/gfs2/trace_gfs2.h | 25 +++++++++++++++++++++++++
 4 files changed, 30 insertions(+)

diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 31188c0..bb4446d 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -512,6 +512,7 @@ struct gfs2_jdesc {
 
        struct gfs2_log_header_host jd_jhead;
        struct bio *jd_rd_bio; /* bio used for reading this journal */
+       atomic_t jd_rd_pg_ct;
        unsigned int jd_found_blocks;
        unsigned int jd_found_revokes;
        unsigned int jd_replayed_blocks;
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 518b786..a261398 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -250,6 +250,7 @@ static void gfs2_end_log_read(struct bio *bio, int error)
                ptr = page_address(page);
                error = gfs2_log_header_in(&lh, ptr);
                last = page_private(page);
+               atomic_dec(&jd->jd_rd_pg_ct);
 
                if (!test_bit(JDF_JHEAD, &jd->jd_flags)) {
                        mempool_free(page, gfs2_page_pool);
@@ -273,6 +274,7 @@ static void gfs2_end_log_read(struct bio *bio, int error)
        }
 
        bio_put(bio);
+       trace_gfs2_end_log_read(jd);
 }
 
 /**
@@ -454,6 +456,7 @@ void gfs2_log_read_extent(struct gfs2_jdesc *jd, u64 dblock,
                        ret = bio_add_page(bio, page, sb->s_blocksize, 0);
                        WARN_ON(ret == 0);
                }
+               atomic_inc(&jd->jd_rd_pg_ct);
                bio->bi_private = jd;
        }
 }
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 4a17eaf..ac9855a 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -643,6 +643,7 @@ static int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct 
gfs2_holder *ji_gh)
                        break;
                }
                jd->jd_rd_bio = NULL;
+               atomic_set(&jd->jd_rd_pg_ct, 0);
 
                spin_lock(&sdp->sd_jindex_spin);
                jd->jd_jid = sdp->sd_journals++;
diff --git a/fs/gfs2/trace_gfs2.h b/fs/gfs2/trace_gfs2.h
index d1de2ed..9f0cc8d 100644
--- a/fs/gfs2/trace_gfs2.h
+++ b/fs/gfs2/trace_gfs2.h
@@ -613,6 +613,31 @@ TRACE_EVENT(gfs2_rs,
                  rs_func_name(__entry->func), (unsigned long)__entry->free)
 );
 
+TRACE_EVENT(gfs2_end_log_read,
+
+       TP_PROTO(const struct gfs2_jdesc *jd),
+
+
+       TP_ARGS(jd),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,        dev               )
+               __field(        unsigned int, jid               )
+               __field(        unsigned int, pages             )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = jd->jd_inode->i_sb->s_dev;
+               __entry->jid            = jd->jd_jid;
+               __entry->pages          = atomic_read(&jd->jd_rd_pg_ct);
+       ),
+
+       TP_printk("%u,%u end_log_read jid:%u outstanding pages:%u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned int)__entry->jid,
+                 (unsigned int)__entry->pages)
+);
+
 #endif /* _TRACE_GFS2_H */
 
 /* This part must be outside protection */
-- 
2.4.11

Reply via email to