Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Stefan Behrens <sbehrens@giantdisaster.de>
To: Josef Bacik <jbacik@fusionio.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs-progs: add a free space cache checker to fsck V2
Date: Mon, 15 Apr 2013 14:32:33 +0200	[thread overview]
Message-ID: <516BF361.3090300@giantdisaster.de> (raw)
In-Reply-To: <1365083870-3241-1-git-send-email-jbacik@fusionio.com>

On Thu, 4 Apr 2013 09:57:50 -0400, Josef Bacik wrote:
> In trying to track down a weird tree log problem I wanted to make sure that the
> free space cache was actually valid, which we currently have no way of doing.
> So this patch adds a bunch of support for the free space cache code and then a
> checker to fsck.  Basically we go through and if we can actually load the free
> space cache then we will walk the extent tree and verify that the free space
> cache exactly matches what is in the extent tree.  Hopefully this will always be
> correct, the only time it wouldn't is if the extent tree is corrupt or we have
> some sort of awful bug in the free space cache.  Thanks,
> 
> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
> ---
> V1->V2:
> - fix ret == 1 from btrfs_search_slot leaking out of verify_space_cache
> - check the last bit of free space from the last extent to the end of the block
>   group
> - unlink any entries we find so we can check and make sure the free space cache
>   tree is empty once we're done.
> 

Josef, xfstests 013, 068 and 113 fail with your new fsck free space cache checker, see below.
$TEST_DEV /dev/sdc is a 50GB SSD, $SCRATCH_DEV /dev/sds is a 100GB SSD. Default mount options.
 

# mkfs.btrfs -f -n 16384 $SCRATCH_DEV
# mkfs.btrfs -f -n 16384 $TEST_DEV
# ./check 013
# btrfsck $TEST_DEV
Checking filesystem on /dev/sdc
UUID: 1c91dbb9-2495-4324-bb53-f96e15cff0dc
checking extents
checking free space cache
Wanted bytes 606208, found 16384 for off 191184896
Wanted bytes 911917056, found 16384 for off 191184896
cache appears valid but isnt 29360128
btrfs: unable to add free space :-17
btrfsck: free-space-cache.c:815: btrfs_add_free_space: Assertion `!(ret == -17)' failed.
Aborted

# mkfs.btrfs -f -n 16384 $SCRATCH_DEV
# mkfs.btrfs -f -n 16384 $TEST_DEV
# ./check 013
# btrfsck $TEST_DEV
Checking filesystem on /dev/sdc
UUID: 18046b2a-9c98-4b34-9294-954d094049c2
checking extents
checking free space cache
Wanted bytes 16203776, found 9355264 for off 168624128
Wanted bytes 934477824, found 9355264 for off 168624128
cache appears valid but isnt 29360128
There is no free space entry for 1115480064-1115504640
There is no free space entry for 1115480064-2176843776
cache appears valid but isnt 1103101952
found 380784640 bytes used err is -22
total csum bytes: 87084
total tree bytes: 4833280
total fs tree bytes: 4390912
total extent tree bytes: 245760
btree space waste bytes: 952741
file data blocks allocated: 500023296
 referenced 363667456
Btrfs v0.20-rc1-298-gf65141e

# mkfs.btrfs -f -n 16384 $SCRATCH_DEV
# mkfs.btrfs -f -n 16384 $TEST_DEV
# ./check 068
_check_btrfs_filesystem: filesystem on /dev/sds is inconsistent
*** fsck.btrfs output ***
checking extents
checking free space cache
Wanted bytes 490909696, found 536870912 for off 1103101952
Wanted bytes 1073741824, found 536870912 for off 1103101952
cache appears valid but isnt 1103101952
Checking filesystem on /dev/sds
UUID: d5340e2c-d1e5-4155-afc2-70afb6bbbe85
found 638976 bytes used err is -22
total csum bytes: 0
total tree bytes: 114688
total fs tree bytes: 32768
total extent tree bytes: 16384
btree space waste bytes: 107558
file data blocks allocated: 524288
 referenced 524288
Btrfs v0.20-rc1-298-gf65141e
*** end fsck.btrfs output

# mkfs.btrfs -f -n 16384 $SCRATCH_DEV
# mkfs.btrfs -f -n 16384 $TEST_DEV
# ./check 113
_check_btrfs_filesystem: filesystem on /dev/sdc is inconsistent
*** fsck.btrfs output ***
checking extents
checking free space cache
btrfs: unable to add free space :-17
btrfsck: free-space-cache.c:815: btrfs_add_free_space: Assertion `!(ret == -17)' failed.
Checking filesystem on /dev/sdc
UUID: 9fef532c-2cf2-4bad-8b00-aa997403b415
*** end fsck.btrfs output



      reply	other threads:[~2013-04-15 12:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-04 13:57 [PATCH] Btrfs-progs: add a free space cache checker to fsck V2 Josef Bacik
2013-04-15 12:32 ` Stefan Behrens [this message]

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=516BF361.3090300@giantdisaster.de \
    --to=sbehrens@giantdisaster.de \
    --cc=jbacik@fusionio.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox