scoutfs: track segment writes and bytes

Add counters for the count of used bytes in segments written.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2017-11-15 15:05:17 -08:00
committed by Mark Fasheh
parent e0f886e892
commit e800cb6785
5 changed files with 21 additions and 4 deletions

View File

@@ -430,7 +430,9 @@ static int compact_segments(struct super_block *sb,
if (ret)
break;
scoutfs_inc_counter(sb, compact_segment_written);
scoutfs_inc_counter(sb, compact_segment_writes);
scoutfs_add_counter(sb, compact_segment_write_bytes,
scoutfs_seg_total_bytes(seg));
}
return ret;

View File

@@ -17,12 +17,14 @@
EXPAND_COUNTER(seg_alloc) \
EXPAND_COUNTER(seg_shrink) \
EXPAND_COUNTER(seg_free) \
EXPAND_COUNTER(trans_level0_seg_write) \
EXPAND_COUNTER(trans_level0_seg_writes) \
EXPAND_COUNTER(trans_level0_seg_write_bytes) \
EXPAND_COUNTER(manifest_compact_migrate) \
EXPAND_COUNTER(compact_operations) \
EXPAND_COUNTER(compact_segment_moved) \
EXPAND_COUNTER(compact_segment_read) \
EXPAND_COUNTER(compact_segment_written) \
EXPAND_COUNTER(compact_segment_writes) \
EXPAND_COUNTER(compact_segment_write_bytes) \
EXPAND_COUNTER(compact_sticky_upper) \
EXPAND_COUNTER(compact_sticky_written) \
EXPAND_COUNTER(data_readpage) \

View File

@@ -557,6 +557,16 @@ int scoutfs_seg_next_off(struct scoutfs_segment *seg, int off)
return off;
}
/*
* Return the count of bytes of the segment actually used.
*/
u32 scoutfs_seg_total_bytes(struct scoutfs_segment *seg)
{
struct scoutfs_segment_block *sblk = off_ptr(seg, 0);
return le32_to_cpu(sblk->total_bytes);
}
/*
* Returns true if the given item population will fit in a single
* segment.

View File

@@ -25,6 +25,7 @@ int scoutfs_seg_wait(struct super_block *sb, struct scoutfs_segment *seg);
int scoutfs_seg_find_off(struct scoutfs_segment *seg,
struct scoutfs_key_buf *key);
int scoutfs_seg_next_off(struct scoutfs_segment *seg, int off);
u32 scoutfs_seg_total_bytes(struct scoutfs_segment *seg);
int scoutfs_seg_item_ptrs(struct scoutfs_segment *seg, int off,
struct scoutfs_key_buf *key, struct kvec *val,
u8 *flags);

View File

@@ -142,7 +142,9 @@ void scoutfs_trans_write_func(struct work_struct *work)
if (ret)
goto out;
scoutfs_inc_counter(sb, trans_level0_seg_write);
scoutfs_inc_counter(sb, trans_level0_seg_writes);
scoutfs_add_counter(sb, trans_level0_seg_write_bytes,
scoutfs_seg_total_bytes(seg));
} else if (sbi->trans_deadline_expired) {
/*