All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephane Chazelas <stephane_chazelas@yahoo.fr>
To: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: btrfs fi defrag -c
Date: Thu, 27 Oct 2011 20:20:22 +0100	[thread overview]
Message-ID: <20111027192022.GD4389@yahoo.fr> (raw)

I don't quite understand the behavior of "btrfs fi defrag"

~# truncate -s2G ~/a
~# mkfs.btrfs ~/a
        nodesize 4096 leafsize 4096 sectorsize 4096 size 2.00GB
~# mount -o loop ~/a /mnt/1
/mnt/1# cd x
/mnt/1# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop1      2.0G   64K  1.8G   1% /mnt/1
/mnt/1# yes | head -c400M > a
/mnt/1# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop1      2.0G   64K  1.8G   1% /mnt/1
/mnt/1# sync
/mnt/1# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop1      2.0G  402M  1.4G  23% /mnt/1
/mnt/1# btrfs fi defrag -c a

(exit status == 20 BTW).

(20)/mnt/1# sync
/mnt/1# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop1      2.0G  415M  994M  30% /mnt/1

No space gain, even lost 15M or 400M depending on how you look at it.

/mnt/1# btrfs fi defrag  a
(20)/mnt/1# sync
/mnt/1# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop1      2.0G  797M  612M  57% /mnt/1

Lost another 400M.

/mnt/1# ls -l
total 409600
-rw-r--r-- 1 root root 419430400 Oct 27 19:53 a
/mnt/1# btrfs fi balance .
/mnt/1# sync
/mnt/1# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop1      2.0G  798M  845M  49% /mnt/1

Possibly reclaimed some of the space?

At the point where it says 612M free, if I do:
/mnt/1# cat < /dev/zero > b
cat: write error: No space left on device
/mnt/1# ls -lh b
-rw-r--r-- 1 root root 612M Oct 27 20:14 b

There was indeed 612M free.


When the FS is mounted with compress:

~# mkfs.btrfs ./a
        nodesize 4096 leafsize 4096 sectorsize 4096 size 2.00GB
~# mount -o compress ./a /mnt/1
~# cd /mnt/1
/mnt/1# yes | head -c400M > a
/mnt/1# sync
/mnt/1# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop1      2.0G   14M  1.8G   1% /mnt/1
/mnt/1# btrfs fi defrag -c ./a
(20)/mnt/1# sync
/mnt/1# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop1      2.0G   21M  1.4G   2% /mnt/1

Lost 400M?

/mnt/1# btrfs fi defrag ./a
(20)/mnt/1# sync
/mnt/1# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop1      2.0G   21M  1.4G   2% /mnt/1

I take it it doesn't uncompress?

I'm a bit confused here.

(that's with 3.0 amd64)

-- 
Stephane

             reply	other threads:[~2011-10-27 19:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-27 19:20 Stephane Chazelas [this message]
2011-10-28  2:25 ` btrfs fi defrag -c Li Zefan
2011-10-28 10:23   ` Stephane CHAZELAS
2011-10-28  3:02 ` Li Zefan

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=20111027192022.GD4389@yahoo.fr \
    --to=stephane_chazelas@yahoo.fr \
    --cc=linux-btrfs@vger.kernel.org \
    /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.