[Ocfs2-tools-devel] [PATCH] debugfs.ocfs2: Add a fragmentation score to the 'frag' command.
Sunil Mushran
sunil.mushran at oracle.com
Thu Aug 6 18:57:37 PDT 2009
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
Though it may be more accurate if we replace OCFS2_MAX_CLUSTERSIZE
with 1048576.
Joel Becker wrote:
> Fragmentation is often looked at to see the effect on I/O. But a 100%
> fragmented file of 1MB clusters will perform a lot better than a 10%
> fragmented file of 4K clusters.
>
> This adds a 'fragmentation score' to the 'frag' command of
> debugfs.ocfs2. The score is simply calculated as the fragmentation
> percentage times the number of clusters per megabyte. Why a megabyte?
> Partly because it's our largest cluster size, but also because we know
> 1MB I/Os are a nice sweet spot.
>
> This gives us an easy way to compare the I/O of files across cluster
> sizes. The higher the score, the worse the I/O.
>
> A file with one extent has a score of 0. Our theoretical 100%
> fragmented file of 1MB clusters has a score of 100. The 10% fragmented
> file of 4K clusters has a score of 2560. Ouch! That 10% fragmented
> file has an average extent size of 40K.
>
> Signed-off-by: Joel Becker <joel.becker at oracle.com>
> ---
> debugfs.ocfs2/dump.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/debugfs.ocfs2/dump.c b/debugfs.ocfs2/dump.c
> index f69f8bd..4c6891a 100644
> --- a/debugfs.ocfs2/dump.c
> +++ b/debugfs.ocfs2/dump.c
> @@ -1016,6 +1016,8 @@ void dump_frag(FILE *out, uint64_t ino, uint32_t clusters,
> uint32_t extents)
> {
> float frag_level = 0;
> + int clusters_per_mb =
> + ocfs2_clusters_in_bytes(gbls.fs, OCFS2_MAX_CLUSTERSIZE);
>
> if (clusters > 1 && extents) {
> float e = extents, c = clusters;
> @@ -1023,5 +1025,6 @@ void dump_frag(FILE *out, uint64_t ino, uint32_t clusters,
> }
>
> fprintf(out, "Inode: %"PRIu64"\t%% fragmented: %.2f\tclusters:"
> - " %u\textents: %u\n", ino, frag_level, clusters, extents);
> + " %u\textents: %u\tscore: %.0f\n", ino,
> + frag_level, clusters, extents, frag_level * clusters_per_mb);
> }
>
More information about the Ocfs2-tools-devel
mailing list