linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Finding Fragmentation on a Btrfs Volume
@ 2010-11-05  4:34 Mitch Harder
  0 siblings, 0 replies; only message in thread
From: Mitch Harder @ 2010-11-05  4:34 UTC (permalink / raw)
  To: linux-btrfs

I was Googling around for ways to check fragmentation on Btrfs, and I
came across the 'filefrag' command.

Even though it is a ext2/3 command, it seems to work on Btrfs files
since it uses the FIEMAP ioctl to determine the number of extents.

>From a bash prompt, I found I could examine large sections with something like:

# for file in $(find <PATH/TO/BTRFS/VOL/> -type f); do filefrag
${file}; done | sort -n -k 2 | less

You may want to start with smaller, more discrete portions of a Btrfs
volume, since I ran into stalls running on more populated Btrfs
volumes.

Also, I haven't tested this on any RAID devices.

I was wondering if the people on the M/L could tell if the approach
was garbage, or should it work?

You can use the results to defrag targeted files.  However, I
discovered that defraging files on a Volume that has snapshots may be
counter-productive.  You end up duplicating the files you are
defragging, since Btrfs now needs to create different copies for the
snapshot and the original (or at least portions of the file).

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-11-05  4:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-05  4:34 Finding Fragmentation on a Btrfs Volume Mitch Harder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).