Btrfs: fix free space cache when there are pinned extents and clusters V2
authorJosef Bacik <josef@redhat.com>
Fri, 1 Apr 2011 14:55:00 +0000 (14:55 +0000)
committerChris Mason <chris.mason@oracle.com>
Tue, 5 Apr 2011 05:20:24 +0000 (01:20 -0400)
commit43be21462d8c263e2449b52b23326232fd710bee
tree096a8cf240ffa7aa83625245ccdba08970e46612
parent08fe4db170b4193603d9d31f40ebaf652d07ac9c
Btrfs: fix free space cache when there are pinned extents and clusters V2

I noticed a huge problem with the free space cache that was presenting
as an early ENOSPC.  Turns out when writing the free space cache out I
forgot to take into account pinned extents and more importantly
clusters.  This would result in us leaking free space everytime we
unmounted the filesystem and remounted it.

I fix this by making sure to check and see if the current block group
has a cluster and writing out any entries that are in the cluster to the
cache, as well as writing any pinned extents we currently have to the
cache since those will be available for us to use the next time the fs
mounts.

This patch also adds a check to the end of load_free_space_cache to make
sure we got the right amount of free space cache, and if not make sure
to clear the cache and re-cache the old fashioned way.

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/free-space-cache.c