All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kazuya Mio <k-mio@sx.jp.nec.com>
To: Greg Freemyer <greg.freemyer@gmail.com>,
	Andreas Dilger <aedilger@gmail.com>,
	Eric Sandeen <sandeen@redhat.com>, "Ted Ts'o" <tytso@mit.edu>
Cc: ext4 <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH 01/11 RESEND] libe2p: Add new function get_fragment_score()
Date: Thu, 07 Jul 2011 19:40:02 +0900	[thread overview]
Message-ID: <4E158D02.10802@sx.jp.nec.com> (raw)
In-Reply-To: <BANLkTikZwscrs4F1NeVRKBTPSouthhMgSg@mail.gmail.com>

Hi all,

I come up with the new fragmentation score based on your comments.
The interface of new libe2p function will be as follows:

int e2p_get_fragscore(int fd, __u32 threshold, __u32 max_chunk_blks)

This function returns the fragmentation score that shows how badly fragmented
the file might be. The score is extents per @threshold, so the higher score
means the worse fragmentation.

Fragmentation score treats extents, whose file offset continues and
whose status is the same, as one chunk. If the number of extents
in chunk is equal to the ideal number of extents, the chunk is not used for
the fragmentation score because there is no fragment in the chunk.
The ideal number of extents is calculated based on @max_chunk_blks.

In case of ext4, @max_chunk_blks is 32768 blocks. If you have 128MB file
with two extents, these two extents are used for the calculation of
the fragmentation score because the ideal number of extents in this file is one.

e4defrag will judge the necessity of calling EXT4_IOC_MOVE_EXT ioctl by
fragmentation score. If the fragmentation score of defrag target file is
more than one, and the score of the file created by fallocate is zero,
e4defrag will call the ioctl. I'll decide the better value of threshold during
some tests. If you must do e4defrag to the specified file, you will be able to
force defrag by using new option of e4defrag.


Two examples (@threshold=256, @max_chunk_blks=32768):

# filefrag -v fragment
Filesystem type is: ef53
File size of fragment is 409600 (100 blocks, blocksize 4096)
  ext logical physical expected length flags
    0       0    33807              16
    1      16    32848    33822     84 eof
fragment: 2 extents found

This small file has two extents, so it is fragmented. The calculation is
as follows:

fragmentation score = 2 / (100 / 256)
                     = 5 extents / MB.

# filefrag -v not_fragment
Filesystem type is: ef53
File size of not_fragment is 125829120 (30720 blocks, blocksize 4096)
  ext logical physical expected length flags
    0       0    33823              16
    1      16    32944    33838     48
    2      64    33152    32991     64
    3     128    34304    33215  30592 eof
not_fragment: 4 extents found

This file has four extents included one large extent. So the score is zero
in this case.

fragmentation score = 4 / (30720 / 256)
                     = 0 extents / MB.

Regards,
Kazuya Mio

  parent reply	other threads:[~2011-07-07 10:40 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-15  6:33 [PATCH 01/11 RESEND] libe2p: Add new function get_fragment_score() Kazuya Mio
2011-06-16  3:06 ` Andreas Dilger
2011-06-17  3:01   ` Kazuya Mio
2011-06-17  3:18 ` Ted Ts'o
2011-06-17 14:20   ` Eric Sandeen
2011-06-18  7:19     ` Andreas Dilger
2011-06-18 17:00       ` Greg Freemyer
2011-06-18 17:15         ` Andreas Dilger
2011-06-21 11:28       ` Kazuya Mio
2011-06-23 11:16         ` Greg Freemyer
2011-06-23 11:27           ` Greg Freemyer
2011-06-24  8:28           ` Kazuya Mio
2011-06-26  2:16             ` Greg Freemyer
2011-06-28 10:21               ` Kazuya Mio
2011-06-28 13:53                 ` Greg Freemyer
2011-07-01  8:34                   ` Kazuya Mio
2011-07-07 10:40                   ` Kazuya Mio [this message]
2011-06-21 11:26   ` Kazuya Mio
2011-06-21 13:56     ` Ted Ts'o
2011-06-23  8:00       ` Kazuya Mio
2011-06-19 19:55 ` Greg Freemyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E158D02.10802@sx.jp.nec.com \
    --to=k-mio@sx.jp.nec.com \
    --cc=aedilger@gmail.com \
    --cc=greg.freemyer@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.