Skip to content

Commit 6399777

Browse files
committed
GFS2: Add tracepoints
This patch adds the ability to trace various aspects of the GFS2 filesystem. The trace points are divided into three groups, glocks, logging and bmap. These points have been chosen because they allow inspection of the major internal functions of GFS2 and they are also generic enough that they are unlikely to need any major changes as the filesystem evolves. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent 8ebf975 commit 6399777

8 files changed

Lines changed: 442 additions & 6 deletions

File tree

‎fs/gfs2/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
EXTRA_CFLAGS := -I$(src)
12
obj-$(CONFIG_GFS2_FS) += gfs2.o
23
gfs2-y := acl.o bmap.o dir.o eaops.o eattr.o glock.o \
34
glops.o inode.o log.o lops.o main.o meta_io.o \

‎fs/gfs2/bmap.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "trans.h"
2626
#include "dir.h"
2727
#include "util.h"
28+
#include "trace_gfs2.h"
2829

2930
/* This doesn't need to be that large as max 64 bit pointers in a 4k
3031
* block is 512, so __u16 is fine for that. It saves stack space to
@@ -589,6 +590,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
589590
clear_buffer_mapped(bh_map);
590591
clear_buffer_new(bh_map);
591592
clear_buffer_boundary(bh_map);
593+
trace_gfs2_bmap(ip, bh_map, lblock, create, 1);
592594
if (gfs2_is_dir(ip)) {
593595
bsize = sdp->sd_jbsize;
594596
arr = sdp->sd_jheightsize;
@@ -623,6 +625,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
623625
ret = 0;
624626
out:
625627
release_metapath(&mp);
628+
trace_gfs2_bmap(ip, bh_map, lblock, create, ret);
626629
bmap_unlock(ip, create);
627630
return ret;
628631

‎fs/gfs2/glock.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#include "super.h"
4040
#include "util.h"
4141
#include "bmap.h"
42+
#define CREATE_TRACE_POINTS
43+
#include "trace_gfs2.h"
4244

4345
struct gfs2_gl_hash_bucket {
4446
struct hlist_head hb_list;
@@ -155,7 +157,7 @@ static void glock_free(struct gfs2_glock *gl)
155157

156158
if (aspace)
157159
gfs2_aspace_put(aspace);
158-
160+
trace_gfs2_glock_put(gl);
159161
sdp->sd_lockstruct.ls_ops->lm_put_lock(gfs2_glock_cachep, gl);
160162
}
161163

@@ -317,14 +319,17 @@ __acquires(&gl->gl_spin)
317319
return 2;
318320
gh->gh_error = ret;
319321
list_del_init(&gh->gh_list);
322+
trace_gfs2_glock_queue(gh, 0);
320323
gfs2_holder_wake(gh);
321324
goto restart;
322325
}
323326
set_bit(HIF_HOLDER, &gh->gh_iflags);
327+
trace_gfs2_promote(gh, 1);
324328
gfs2_holder_wake(gh);
325329
goto restart;
326330
}
327331
set_bit(HIF_HOLDER, &gh->gh_iflags);
332+
trace_gfs2_promote(gh, 0);
328333
gfs2_holder_wake(gh);
329334
continue;
330335
}
@@ -354,6 +359,7 @@ static inline void do_error(struct gfs2_glock *gl, const int ret)
354359
else
355360
continue;
356361
list_del_init(&gh->gh_list);
362+
trace_gfs2_glock_queue(gh, 0);
357363
gfs2_holder_wake(gh);
358364
}
359365
}
@@ -422,6 +428,7 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret)
422428
int rv;
423429

424430
spin_lock(&gl->gl_spin);
431+
trace_gfs2_glock_state_change(gl, state);
425432
state_change(gl, state);
426433
gh = find_first_waiter(gl);
427434

@@ -851,6 +858,7 @@ static void handle_callback(struct gfs2_glock *gl, unsigned int state,
851858
gl->gl_demote_state != state) {
852859
gl->gl_demote_state = LM_ST_UNLOCKED;
853860
}
861+
trace_gfs2_demote_rq(gl);
854862
}
855863

856864
/**
@@ -936,6 +944,7 @@ __acquires(&gl->gl_spin)
936944
goto do_cancel;
937945
return;
938946
}
947+
trace_gfs2_glock_queue(gh, 1);
939948
list_add_tail(&gh->gh_list, insert_pt);
940949
do_cancel:
941950
gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list);
@@ -1032,6 +1041,7 @@ void gfs2_glock_dq(struct gfs2_holder *gh)
10321041
!test_bit(GLF_DEMOTE, &gl->gl_flags))
10331042
fast_path = 1;
10341043
}
1044+
trace_gfs2_glock_queue(gh, 0);
10351045
spin_unlock(&gl->gl_spin);
10361046
if (likely(fast_path))
10371047
return;

‎fs/gfs2/log.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "meta_io.h"
2929
#include "util.h"
3030
#include "dir.h"
31+
#include "trace_gfs2.h"
3132

3233
#define PULL 1
3334

@@ -313,6 +314,7 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks)
313314
gfs2_log_lock(sdp);
314315
}
315316
atomic_sub(blks, &sdp->sd_log_blks_free);
317+
trace_gfs2_log_blocks(sdp, -blks);
316318
gfs2_log_unlock(sdp);
317319
mutex_unlock(&sdp->sd_log_reserve_mutex);
318320

@@ -333,6 +335,7 @@ void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks)
333335

334336
gfs2_log_lock(sdp);
335337
atomic_add(blks, &sdp->sd_log_blks_free);
338+
trace_gfs2_log_blocks(sdp, blks);
336339
gfs2_assert_withdraw(sdp,
337340
atomic_read(&sdp->sd_log_blks_free) <= sdp->sd_jdesc->jd_blocks);
338341
gfs2_log_unlock(sdp);
@@ -558,6 +561,7 @@ static void log_pull_tail(struct gfs2_sbd *sdp, unsigned int new_tail)
558561

559562
gfs2_log_lock(sdp);
560563
atomic_add(dist, &sdp->sd_log_blks_free);
564+
trace_gfs2_log_blocks(sdp, dist);
561565
gfs2_assert_withdraw(sdp, atomic_read(&sdp->sd_log_blks_free) <= sdp->sd_jdesc->jd_blocks);
562566
gfs2_log_unlock(sdp);
563567

@@ -715,6 +719,7 @@ void __gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
715719
up_write(&sdp->sd_log_flush_lock);
716720
return;
717721
}
722+
trace_gfs2_log_flush(sdp, 1);
718723

719724
ai = kzalloc(sizeof(struct gfs2_ail), GFP_NOFS | __GFP_NOFAIL);
720725
INIT_LIST_HEAD(&ai->ai_ail1_list);
@@ -746,6 +751,7 @@ void __gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
746751
else if (sdp->sd_log_tail != current_tail(sdp) && !sdp->sd_log_idle){
747752
gfs2_log_lock(sdp);
748753
atomic_dec(&sdp->sd_log_blks_free); /* Adjust for unreserved buffer */
754+
trace_gfs2_log_blocks(sdp, -1);
749755
gfs2_log_unlock(sdp);
750756
log_write_header(sdp, 0, PULL);
751757
}
@@ -763,7 +769,7 @@ void __gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
763769
ai = NULL;
764770
}
765771
gfs2_log_unlock(sdp);
766-
772+
trace_gfs2_log_flush(sdp, 0);
767773
up_write(&sdp->sd_log_flush_lock);
768774

769775
kfree(ai);
@@ -787,6 +793,7 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
787793
gfs2_assert_withdraw(sdp, sdp->sd_log_blks_reserved + tr->tr_reserved >= reserved);
788794
unused = sdp->sd_log_blks_reserved - reserved + tr->tr_reserved;
789795
atomic_add(unused, &sdp->sd_log_blks_free);
796+
trace_gfs2_log_blocks(sdp, unused);
790797
gfs2_assert_withdraw(sdp, atomic_read(&sdp->sd_log_blks_free) <=
791798
sdp->sd_jdesc->jd_blocks);
792799
sdp->sd_log_blks_reserved = reserved;

‎fs/gfs2/lops.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "rgrp.h"
2828
#include "trans.h"
2929
#include "util.h"
30+
#include "trace_gfs2.h"
3031

3132
/**
3233
* gfs2_pin - Pin a buffer in memory
@@ -53,6 +54,7 @@ static void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh)
5354
if (bd->bd_ail)
5455
list_move(&bd->bd_ail_st_list, &bd->bd_ail->ai_ail2_list);
5556
get_bh(bh);
57+
trace_gfs2_pin(bd, 1);
5658
}
5759

5860
/**
@@ -89,6 +91,7 @@ static void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh,
8991
bd->bd_ail = ai;
9092
list_add(&bd->bd_ail_st_list, &ai->ai_ail1_list);
9193
clear_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
94+
trace_gfs2_pin(bd, 0);
9295
gfs2_log_unlock(sdp);
9396
unlock_buffer(bh);
9497
}

‎fs/gfs2/ops_fstype.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "log.h"
3434
#include "quota.h"
3535
#include "dir.h"
36+
#include "trace_gfs2.h"
3637

3738
#define DO 0
3839
#define UNDO 1
@@ -775,6 +776,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
775776
/* Map the extents for this journal's blocks */
776777
map_journal_extents(sdp);
777778
}
779+
trace_gfs2_log_blocks(sdp, atomic_read(&sdp->sd_log_blks_free));
778780

779781
if (sdp->sd_lockstruct.ls_first) {
780782
unsigned int x;

‎fs/gfs2/rgrp.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "util.h"
3030
#include "log.h"
3131
#include "inode.h"
32+
#include "trace_gfs2.h"
3233

3334
#define BFITNOENT ((u32)~0)
3435
#define NO_BLOCK ((u64)~0)
@@ -1519,7 +1520,7 @@ int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n)
15191520
spin_lock(&sdp->sd_rindex_spin);
15201521
rgd->rd_free_clone -= *n;
15211522
spin_unlock(&sdp->sd_rindex_spin);
1522-
1523+
trace_gfs2_block_alloc(ip, block, *n, GFS2_BLKST_USED);
15231524
*bn = block;
15241525
return 0;
15251526

@@ -1571,7 +1572,7 @@ u64 gfs2_alloc_di(struct gfs2_inode *dip, u64 *generation)
15711572
spin_lock(&sdp->sd_rindex_spin);
15721573
rgd->rd_free_clone--;
15731574
spin_unlock(&sdp->sd_rindex_spin);
1574-
1575+
trace_gfs2_block_alloc(dip, block, 1, GFS2_BLKST_DINODE);
15751576
return block;
15761577
}
15771578

@@ -1591,7 +1592,7 @@ void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen)
15911592
rgd = rgblk_free(sdp, bstart, blen, GFS2_BLKST_FREE);
15921593
if (!rgd)
15931594
return;
1594-
1595+
trace_gfs2_block_alloc(ip, bstart, blen, GFS2_BLKST_FREE);
15951596
rgd->rd_free += blen;
15961597

15971598
gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1);
@@ -1619,7 +1620,7 @@ void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen)
16191620
rgd = rgblk_free(sdp, bstart, blen, GFS2_BLKST_FREE);
16201621
if (!rgd)
16211622
return;
1622-
1623+
trace_gfs2_block_alloc(ip, bstart, blen, GFS2_BLKST_FREE);
16231624
rgd->rd_free += blen;
16241625

16251626
gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1);
@@ -1642,6 +1643,7 @@ void gfs2_unlink_di(struct inode *inode)
16421643
rgd = rgblk_free(sdp, blkno, 1, GFS2_BLKST_UNLINKED);
16431644
if (!rgd)
16441645
return;
1646+
trace_gfs2_block_alloc(ip, blkno, 1, GFS2_BLKST_UNLINKED);
16451647
gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1);
16461648
gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data);
16471649
gfs2_trans_add_rg(rgd);
@@ -1673,6 +1675,7 @@ static void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, u64 blkno)
16731675
void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip)
16741676
{
16751677
gfs2_free_uninit_di(rgd, ip->i_no_addr);
1678+
trace_gfs2_block_alloc(ip, ip->i_no_addr, 1, GFS2_BLKST_FREE);
16761679
gfs2_quota_change(ip, -1, ip->i_inode.i_uid, ip->i_inode.i_gid);
16771680
gfs2_meta_wipe(ip, ip->i_no_addr, 1);
16781681
}

0 commit comments

Comments
 (0)