Message ID | 20230911-raid-stripe-tree-v8-10-647676fa852c@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: introduce RAID stripe tree | expand |
On Mon, Sep 11, 2023 at 05:52:11AM -0700, Johannes Thumshirn wrote: > Add trace events for raid-stripe-tree operations. > > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> > --- > fs/btrfs/raid-stripe-tree.c | 8 +++++ > include/trace/events/btrfs.h | 75 ++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 83 insertions(+) > > diff --git a/fs/btrfs/raid-stripe-tree.c b/fs/btrfs/raid-stripe-tree.c > index 7ed02e4b79ec..5a9952cf557c 100644 > --- a/fs/btrfs/raid-stripe-tree.c > +++ b/fs/btrfs/raid-stripe-tree.c > @@ -62,6 +62,9 @@ int btrfs_delete_raid_extent(struct btrfs_trans_handle *trans, u64 start, > if (found_end <= start) > break; > > + trace_btrfs_raid_extent_delete(fs_info, start, end, > + found_start, found_end); > + > ASSERT(found_start >= start && found_end <= end); > ret = btrfs_del_item(trans, stripe_root, path); > if (ret) > @@ -120,6 +123,8 @@ static int btrfs_insert_one_raid_extent(struct btrfs_trans_handle *trans, > return -ENOMEM; > } > > + trace_btrfs_insert_one_raid_extent(fs_info, bioc->logical, bioc->size, > + num_stripes); > btrfs_set_stack_stripe_extent_encoding(stripe_extent, encoding); > for (int i = 0; i < num_stripes; i++) { > u64 devid = bioc->stripes[i].dev->devid; > @@ -445,6 +450,9 @@ int btrfs_get_raid_extent_offset(struct btrfs_fs_info *fs_info, > > stripe->physical = physical + offset; > > + trace_btrfs_get_raid_extent_offset(fs_info, logical, *length, > + stripe->physical, devid); > + > ret = 0; > goto free_path; > } > diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h > index b2db2c2f1c57..e2c6f1199212 100644 > --- a/include/trace/events/btrfs.h > +++ b/include/trace/events/btrfs.h > @@ -2497,6 +2497,81 @@ DEFINE_EVENT(btrfs_raid56_bio, raid56_write, > TP_ARGS(rbio, bio, trace_info) > ); > > +TRACE_EVENT(btrfs_insert_one_raid_extent, > + > + TP_PROTO(struct btrfs_fs_info *fs_info, u64 logical, u64 length, const struct fs_info > + int num_stripes), > + > + TP_ARGS(fs_info, logical, length, num_stripes), > + > + TP_STRUCT__entry_btrfs( > + __field( u64, logical ) > + __field( u64, length ) > + __field( int, num_stripes ) > + ), > + > + TP_fast_assign_btrfs(fs_info, > + __entry->logical = logical; > + __entry->length = length; > + __entry->num_stripes = num_stripes; > + ), > + > + TP_printk_btrfs("logical=%llu, length=%llu, num_stripes=%d", > + __entry->logical, __entry->length, > + __entry->num_stripes) Tracepoint messages should follow the formatting guidelines https://btrfs.readthedocs.io/en/latest/dev/Development-notes.html#tracepoints > +); > + > +TRACE_EVENT(btrfs_raid_extent_delete, > + > + TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 end, > + u64 found_start, u64 found_end), > + > + TP_ARGS(fs_info, start, end, found_start, found_end), > + > + TP_STRUCT__entry_btrfs( > + __field( u64, start ) > + __field( u64, end ) > + __field( u64, found_start ) > + __field( u64, found_end ) > + ), > + > + TP_fast_assign_btrfs(fs_info, > + __entry->start = start; > + __entry->end = end; > + __entry->found_start = found_start; > + __entry->found_end = found_end; Tracepoints follow the fancy spacing and alignment in the assign blocks. > + ), > + > + TP_printk_btrfs("start=%llu, end=%llu, found_start=%llu, found_end=%llu", > + __entry->start, __entry->end, __entry->found_start, > + __entry->found_end) > +);
diff --git a/fs/btrfs/raid-stripe-tree.c b/fs/btrfs/raid-stripe-tree.c index 7ed02e4b79ec..5a9952cf557c 100644 --- a/fs/btrfs/raid-stripe-tree.c +++ b/fs/btrfs/raid-stripe-tree.c @@ -62,6 +62,9 @@ int btrfs_delete_raid_extent(struct btrfs_trans_handle *trans, u64 start, if (found_end <= start) break; + trace_btrfs_raid_extent_delete(fs_info, start, end, + found_start, found_end); + ASSERT(found_start >= start && found_end <= end); ret = btrfs_del_item(trans, stripe_root, path); if (ret) @@ -120,6 +123,8 @@ static int btrfs_insert_one_raid_extent(struct btrfs_trans_handle *trans, return -ENOMEM; } + trace_btrfs_insert_one_raid_extent(fs_info, bioc->logical, bioc->size, + num_stripes); btrfs_set_stack_stripe_extent_encoding(stripe_extent, encoding); for (int i = 0; i < num_stripes; i++) { u64 devid = bioc->stripes[i].dev->devid; @@ -445,6 +450,9 @@ int btrfs_get_raid_extent_offset(struct btrfs_fs_info *fs_info, stripe->physical = physical + offset; + trace_btrfs_get_raid_extent_offset(fs_info, logical, *length, + stripe->physical, devid); + ret = 0; goto free_path; } diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h index b2db2c2f1c57..e2c6f1199212 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -2497,6 +2497,81 @@ DEFINE_EVENT(btrfs_raid56_bio, raid56_write, TP_ARGS(rbio, bio, trace_info) ); +TRACE_EVENT(btrfs_insert_one_raid_extent, + + TP_PROTO(struct btrfs_fs_info *fs_info, u64 logical, u64 length, + int num_stripes), + + TP_ARGS(fs_info, logical, length, num_stripes), + + TP_STRUCT__entry_btrfs( + __field( u64, logical ) + __field( u64, length ) + __field( int, num_stripes ) + ), + + TP_fast_assign_btrfs(fs_info, + __entry->logical = logical; + __entry->length = length; + __entry->num_stripes = num_stripes; + ), + + TP_printk_btrfs("logical=%llu, length=%llu, num_stripes=%d", + __entry->logical, __entry->length, + __entry->num_stripes) +); + +TRACE_EVENT(btrfs_raid_extent_delete, + + TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 end, + u64 found_start, u64 found_end), + + TP_ARGS(fs_info, start, end, found_start, found_end), + + TP_STRUCT__entry_btrfs( + __field( u64, start ) + __field( u64, end ) + __field( u64, found_start ) + __field( u64, found_end ) + ), + + TP_fast_assign_btrfs(fs_info, + __entry->start = start; + __entry->end = end; + __entry->found_start = found_start; + __entry->found_end = found_end; + ), + + TP_printk_btrfs("start=%llu, end=%llu, found_start=%llu, found_end=%llu", + __entry->start, __entry->end, __entry->found_start, + __entry->found_end) +); + +TRACE_EVENT(btrfs_get_raid_extent_offset, + + TP_PROTO(struct btrfs_fs_info *fs_info, u64 logical, u64 length, + u64 physical, u64 devid), + + TP_ARGS(fs_info, logical, length, physical, devid), + + TP_STRUCT__entry_btrfs( + __field( u64, logical ) + __field( u64, length ) + __field( u64, physical ) + __field( u64, devid ) + ), + + TP_fast_assign_btrfs(fs_info, + __entry->logical = logical; + __entry->length = length; + __entry->physical = physical; + __entry->devid = devid; + ), + + TP_printk_btrfs("logical=%llu, length=%llu, physical=%llu, devid=%llu", + __entry->logical, __entry->length, __entry->physical, + __entry->devid) +); #endif /* _TRACE_BTRFS_H */ /* This part must be outside protection */
Add trace events for raid-stripe-tree operations. Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> --- fs/btrfs/raid-stripe-tree.c | 8 +++++ include/trace/events/btrfs.h | 75 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+)