Re: Defragmentation Not Working with Directory as Argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday, January 24, 2011 19:11:07 Mitch Harder wrote:
> Defragmentation is not working when a directory is supplied as the
> argument.  When a file name is supplied as the argument,
> defragmentation works well.
> 
> This can be demonstrated as follows:
> 
> # mount /dev/sdb2 /mnt/btrfs
> # cd /mnt/btrfs/
> # cp /usr/src/linux/fs/btrfs/zlib.c  .    (any suitable file will do,
> small text files seemed appropriate)
> # cp zlib.c fragmented-zlib.c
> # btrfs fi sync /mnt/btrfs
> # cat zlib.c >> fragmented-zlib.c
> # btrfs fi sync /mnt/btrfs
> # filefrag zlib.c fragmented-zlib.c
> zlib.c: 1 extent found
> fragmented-zlib.c: 2 extents found
> # btrfs filesystem defragment /mnt/btrfs/
> # btrfs fi sync /mnt/btrfs
> # filefrag zlib.c fragmented-zlib.c
> zlib.c: 1 extent found
> fragmented-zlib.c: 2 extents found
> 
> Now, supply a filename as the argument
> 
> # btrfs filesystem defragment /mnt/btrfs/fragmented-zlib.c
> # btrfs fi sync /mnt/btrfs
> # filefrag zlib.c fragmented-zlib.c
> zlib.c: 1 extent found
> fragmented-zlib.c: 1 extent found
> 
> I've also tested defragmentation on my normal btrfs filesystems, and
> have seen the same results.  I've never seen a file defragmented when
> using a directory as the argument.

That's because this defragments only directory metadata.

> Also, I was wondering if one of the Btrfs developers could clarify the
> intended scope of defragmentation when a directory is supplied as the
> argument.

I submited apropriate patches few days back to update man and help messages

> I have seen comments on the mailing list indicating that only the
> directory supplied is intended to be defragmented, and defragmentation
> will not recurse to subdirectories below.

that's true

> However, if I look at the code, and read the documentation for the
> older btrfsctl command (which seems to be the basis for the current
> btrfs command), it seems like the intention is to recursively
> defragment the entire tree below the directory supplied in the
> argument.

Then it looks like the userspace part of implementation changed, don't know 
why though.

Regards,
-- 
Hubert Kario
QBS - Quality Business Software
02-656 Warszawa, ul. Ksawerów 30/85
tel. +48 (22) 646-61-51, 646-74-24
www.qbs.com.pl
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux