Skip to content

Commit 1d2e244

Browse files
riteshharjanitytso
authored andcommitted
ext4: add transaction tid info in fc_track events
This patch adds the transaction & inode tid info in trace events for callers of ext4_fc_track_template(). This is helpful in debugging race conditions where an inode could belong to two different transaction tids. It also fixes the checkpatch warnings which says use tabs instead of spaces. Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com> Link: https://lore.kernel.org/r/c203c09dc11bb372803c430f621f25a4b8c2c8b4.1647057583.git.riteshh@linux.ibm.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 08f4c42 commit 1d2e244

2 files changed

Lines changed: 73 additions & 50 deletions

File tree

fs/ext4/fast_commit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ void __ext4_fc_track_unlink(handle_t *handle,
487487

488488
ret = ext4_fc_track_template(handle, inode, __track_dentry_update,
489489
(void *)&args, 0);
490-
trace_ext4_fc_track_unlink(inode, dentry, ret);
490+
trace_ext4_fc_track_unlink(handle, inode, dentry, ret);
491491
}
492492

493493
void ext4_fc_track_unlink(handle_t *handle, struct dentry *dentry)
@@ -516,7 +516,7 @@ void __ext4_fc_track_link(handle_t *handle,
516516

517517
ret = ext4_fc_track_template(handle, inode, __track_dentry_update,
518518
(void *)&args, 0);
519-
trace_ext4_fc_track_link(inode, dentry, ret);
519+
trace_ext4_fc_track_link(handle, inode, dentry, ret);
520520
}
521521

522522
void ext4_fc_track_link(handle_t *handle, struct dentry *dentry)
@@ -545,7 +545,7 @@ void __ext4_fc_track_create(handle_t *handle, struct inode *inode,
545545

546546
ret = ext4_fc_track_template(handle, inode, __track_dentry_update,
547547
(void *)&args, 0);
548-
trace_ext4_fc_track_create(inode, dentry, ret);
548+
trace_ext4_fc_track_create(handle, inode, dentry, ret);
549549
}
550550

551551
void ext4_fc_track_create(handle_t *handle, struct dentry *dentry)
@@ -596,7 +596,7 @@ void ext4_fc_track_inode(handle_t *handle, struct inode *inode)
596596
return;
597597

598598
ret = ext4_fc_track_template(handle, inode, __track_inode, NULL, 1);
599-
trace_ext4_fc_track_inode(inode, ret);
599+
trace_ext4_fc_track_inode(handle, inode, ret);
600600
}
601601

602602
struct __track_range_args {
@@ -653,7 +653,7 @@ void ext4_fc_track_range(handle_t *handle, struct inode *inode, ext4_lblk_t star
653653

654654
ret = ext4_fc_track_template(handle, inode, __track_range, &args, 1);
655655

656-
trace_ext4_fc_track_range(inode, start, end, ret);
656+
trace_ext4_fc_track_range(handle, inode, start, end, ret);
657657
}
658658

659659
static void ext4_fc_submit_bh(struct super_block *sb, bool is_tail)

include/trace/events/ext4.h

Lines changed: 68 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,85 +2782,108 @@ TRACE_EVENT(ext4_fc_stats,
27822782

27832783
DECLARE_EVENT_CLASS(ext4_fc_track_dentry,
27842784

2785-
TP_PROTO(struct inode *inode, struct dentry *dentry, int ret),
2785+
TP_PROTO(handle_t *handle, struct inode *inode,
2786+
struct dentry *dentry, int ret),
27862787

2787-
TP_ARGS(inode, dentry, ret),
2788+
TP_ARGS(handle, inode, dentry, ret),
27882789

27892790
TP_STRUCT__entry(
27902791
__field(dev_t, dev)
2792+
__field(tid_t, t_tid)
27912793
__field(ino_t, i_ino)
2794+
__field(tid_t, i_sync_tid)
27922795
__field(int, error)
27932796
),
27942797

27952798
TP_fast_assign(
2799+
struct ext4_inode_info *ei = EXT4_I(inode);
2800+
27962801
__entry->dev = inode->i_sb->s_dev;
2802+
__entry->t_tid = handle->h_transaction->t_tid;
27972803
__entry->i_ino = inode->i_ino;
2804+
__entry->i_sync_tid = ei->i_sync_tid;
27982805
__entry->error = ret;
27992806
),
28002807

2801-
TP_printk("dev %d,%d, ino %lu, error %d",
2808+
TP_printk("dev %d,%d, t_tid %u, ino %lu, i_sync_tid %u, error %d",
28022809
MAJOR(__entry->dev), MINOR(__entry->dev),
2803-
__entry->i_ino, __entry->error
2810+
__entry->t_tid, __entry->i_ino, __entry->i_sync_tid,
2811+
__entry->error
28042812
)
28052813
);
28062814

28072815
#define DEFINE_EVENT_CLASS_DENTRY(__type) \
28082816
DEFINE_EVENT(ext4_fc_track_dentry, ext4_fc_track_##__type, \
2809-
TP_PROTO(struct inode *inode, struct dentry *dentry, int ret), \
2810-
TP_ARGS(inode, dentry, ret) \
2817+
TP_PROTO(handle_t *handle, struct inode *inode, \
2818+
struct dentry *dentry, int ret), \
2819+
TP_ARGS(handle, inode, dentry, ret) \
28112820
)
28122821

28132822
DEFINE_EVENT_CLASS_DENTRY(create);
28142823
DEFINE_EVENT_CLASS_DENTRY(link);
28152824
DEFINE_EVENT_CLASS_DENTRY(unlink);
28162825

28172826
TRACE_EVENT(ext4_fc_track_inode,
2818-
TP_PROTO(struct inode *inode, int ret),
2827+
TP_PROTO(handle_t *handle, struct inode *inode, int ret),
28192828

2820-
TP_ARGS(inode, ret),
2829+
TP_ARGS(handle, inode, ret),
28212830

2822-
TP_STRUCT__entry(
2823-
__field(dev_t, dev)
2824-
__field(int, ino)
2825-
__field(int, error)
2826-
),
2831+
TP_STRUCT__entry(
2832+
__field(dev_t, dev)
2833+
__field(tid_t, t_tid)
2834+
__field(ino_t, i_ino)
2835+
__field(tid_t, i_sync_tid)
2836+
__field(int, error)
2837+
),
28272838

2828-
TP_fast_assign(
2829-
__entry->dev = inode->i_sb->s_dev;
2830-
__entry->ino = inode->i_ino;
2831-
__entry->error = ret;
2832-
),
2839+
TP_fast_assign(
2840+
struct ext4_inode_info *ei = EXT4_I(inode);
28332841

2834-
TP_printk("dev %d:%d, inode %d, error %d",
2835-
MAJOR(__entry->dev), MINOR(__entry->dev),
2836-
__entry->ino, __entry->error)
2842+
__entry->dev = inode->i_sb->s_dev;
2843+
__entry->t_tid = handle->h_transaction->t_tid;
2844+
__entry->i_ino = inode->i_ino;
2845+
__entry->i_sync_tid = ei->i_sync_tid;
2846+
__entry->error = ret;
2847+
),
2848+
2849+
TP_printk("dev %d:%d, t_tid %u, inode %lu, i_sync_tid %u, error %d",
2850+
MAJOR(__entry->dev), MINOR(__entry->dev),
2851+
__entry->t_tid, __entry->i_ino, __entry->i_sync_tid,
2852+
__entry->error)
28372853
);
28382854

28392855
TRACE_EVENT(ext4_fc_track_range,
2840-
TP_PROTO(struct inode *inode, long start, long end, int ret),
2841-
2842-
TP_ARGS(inode, start, end, ret),
2843-
2844-
TP_STRUCT__entry(
2845-
__field(dev_t, dev)
2846-
__field(int, ino)
2847-
__field(long, start)
2848-
__field(long, end)
2849-
__field(int, error)
2850-
),
2851-
2852-
TP_fast_assign(
2853-
__entry->dev = inode->i_sb->s_dev;
2854-
__entry->ino = inode->i_ino;
2855-
__entry->start = start;
2856-
__entry->end = end;
2857-
__entry->error = ret;
2858-
),
2859-
2860-
TP_printk("dev %d:%d, inode %d, error %d, start %ld, end %ld",
2861-
MAJOR(__entry->dev), MINOR(__entry->dev),
2862-
__entry->ino, __entry->error, __entry->start,
2863-
__entry->end)
2856+
TP_PROTO(handle_t *handle, struct inode *inode,
2857+
long start, long end, int ret),
2858+
2859+
TP_ARGS(handle, inode, start, end, ret),
2860+
2861+
TP_STRUCT__entry(
2862+
__field(dev_t, dev)
2863+
__field(tid_t, t_tid)
2864+
__field(ino_t, i_ino)
2865+
__field(tid_t, i_sync_tid)
2866+
__field(long, start)
2867+
__field(long, end)
2868+
__field(int, error)
2869+
),
2870+
2871+
TP_fast_assign(
2872+
struct ext4_inode_info *ei = EXT4_I(inode);
2873+
2874+
__entry->dev = inode->i_sb->s_dev;
2875+
__entry->t_tid = handle->h_transaction->t_tid;
2876+
__entry->i_ino = inode->i_ino;
2877+
__entry->i_sync_tid = ei->i_sync_tid;
2878+
__entry->start = start;
2879+
__entry->end = end;
2880+
__entry->error = ret;
2881+
),
2882+
2883+
TP_printk("dev %d:%d, t_tid %u, inode %lu, i_sync_tid %u, error %d, start %ld, end %ld",
2884+
MAJOR(__entry->dev), MINOR(__entry->dev),
2885+
__entry->t_tid, __entry->i_ino, __entry->i_sync_tid,
2886+
__entry->error, __entry->start, __entry->end)
28642887
);
28652888

28662889
TRACE_EVENT(ext4_fc_cleanup,

0 commit comments

Comments
 (0)