linux/fs/btrfs
Josef Bacik 0f9dd46cda Btrfs: free space accounting redo
1) replace the per fs_info extent_io_tree that tracked free space with two
rb-trees per block group to track free space areas via offset and size.  The
reason to do this is because most allocations come with a hint byte where to
start, so we can usually find a chunk of free space at that hint byte to satisfy
the allocation and get good space packing.  If we cannot find free space at or
after the given offset we fall back on looking for a chunk of the given size as
close to that given offset as possible.  When we fall back on the size search we
also try to find a slot as close to the size we want as possible, to avoid
breaking small chunks off of huge areas if possible.

2) remove the extent_io_tree that tracked the block group cache from fs_info and
replaced it with an rb-tree thats tracks block group cache via offset.  also
added a per space_info list that tracks the block group cache for the particular
space so we can lookup related block groups easily.

3) cleaned up the allocation code to make it a little easier to read and a
little less complicated.  Basically there are 3 steps, first look from our
provided hint.  If we couldn't find from that given hint, start back at our
original search start and look for space from there.  If that fails try to
allocate space if we can and start looking again.  If not we're screwed and need
to start over again.

4) small fixes.  there were some issues in volumes.c where we wouldn't allocate
the rest of the disk.  fixed cow_file_range to actually pass the alloc_hint,
which has helped a good bit in making the fs_mark test I run have semi-normal
results as we run out of space.  Generally with data allocations we don't track
where we last allocated from, so everytime we did a data allocation we'd search
through every block group that we have looking for free space.  Now searching a
block group with no free space isn't terribly time consuming, it was causing a
slight degradation as we got more data block groups.  The alloc_hint has fixed
this slight degredation and made things semi-normal.

There is still one nagging problem I'm working on where we will get ENOSPC when
there is definitely plenty of space.  This only happens with metadata
allocations, and only when we are almost full.  So you generally hit the 85%
mark first, but sometimes you'll hit the BUG before you hit the 85% wall.  I'm
still tracking it down, but until then this seems to be pretty stable and make a
significant performance gain.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25 11:04:07 -04:00
..
acl.c Btrfs: optimize btrget/set/removexattr 2008-09-25 11:04:07 -04:00
async-thread.c Btrfs: Lower contention on the csum mutex 2008-09-25 11:04:06 -04:00
async-thread.h Btrfs: Give all the worker threads descriptive names 2008-09-25 11:04:06 -04:00
bit-radix.c Btrfs: trivial include fixups 2007-07-11 10:00:37 -04:00
bit-radix.h Btrfs: add GPLv2 2007-06-12 09:07:21 -04:00
btrfs_inode.h Btrfs: Dir fsync optimizations 2008-09-25 11:04:07 -04:00
compat.h Btrfs: Add a write ahead tree log to optimize synchronous operations 2008-09-25 11:04:07 -04:00
COPYING Btrfs: add GPLv2 2007-06-12 09:07:21 -04:00
crc32c.h Btrfs: Add support for HW assisted crc32c 2008-09-25 11:04:06 -04:00
ctree.c Btrfs: free space accounting redo 2008-09-25 11:04:07 -04:00
ctree.h Btrfs: free space accounting redo 2008-09-25 11:04:07 -04:00
dir-item.c Btrfs: Add a write ahead tree log to optimize synchronous operations 2008-09-25 11:04:07 -04:00
disk-io.c Btrfs: free space accounting redo 2008-09-25 11:04:07 -04:00
disk-io.h Btrfs: Tree logging fixes 2008-09-25 11:04:07 -04:00
export.c Btrfs: cleanup d_obtain_alias useage 2008-09-25 11:04:07 -04:00
export.h NFS support for btrfs - v3 2008-09-25 11:04:06 -04:00
extent_io.c Btrfs: free space accounting redo 2008-09-25 11:04:07 -04:00
extent_io.h Btrfs: Tree logging fixes 2008-09-25 11:04:07 -04:00
extent_map.c Btrfs: Fix add_extent_mapping to check for duplicates across the whole range 2008-09-25 11:04:06 -04:00
extent_map.h Btrfs: Fix some data=ordered related data corruptions 2008-09-25 11:04:05 -04:00
extent-tree.c Btrfs: free space accounting redo 2008-09-25 11:04:07 -04:00
file-item.c Btrfs: Fix variable init during csum creation 2008-09-25 11:04:07 -04:00
file.c Btrfs: Dir fsync optimizations 2008-09-25 11:04:07 -04:00
free-space-cache.c Btrfs: free space accounting redo 2008-09-25 11:04:07 -04:00
hash.h Switch btrfs_name_hash() to crc32c 2008-09-25 11:04:06 -04:00
inode-item.c Btrfs: Implement new dir index format 2008-09-25 11:04:05 -04:00
inode-map.c Btrfs: Update find free objectid function for orphan cleanup code 2008-09-25 11:04:07 -04:00
inode.c Btrfs: free space accounting redo 2008-09-25 11:04:07 -04:00
INSTALL Btrfs: Documentation update 2007-06-22 14:49:31 -04:00
ioctl.c Btrfs: trivial sparse fixes 2008-09-25 11:04:07 -04:00
ioctl.h Btrfs: transaction ioctls 2008-09-25 11:04:03 -04:00
locking.c btrfs_search_slot: reduce lock contention by cowing in two stages 2008-09-25 11:04:06 -04:00
locking.h btrfs_search_slot: reduce lock contention by cowing in two stages 2008-09-25 11:04:06 -04:00
Makefile Btrfs: free space accounting redo 2008-09-25 11:04:07 -04:00
ordered-data.c Btrfs: Fix nodatacow for the new data=ordered mode 2008-09-25 11:04:06 -04:00
ordered-data.h Btrfs: Fix nodatacow for the new data=ordered mode 2008-09-25 11:04:06 -04:00
orphan.c Btrfs: Create orphan inode records to prevent lost files after a crash 2008-09-25 11:04:05 -04:00
print-tree.c Btrfs: implement memory reclaim for leaf reference cache 2008-09-25 11:04:05 -04:00
print-tree.h Btrfs: Create extent_buffer interface for large blocksizes 2008-09-25 11:03:56 -04:00
ref-cache.c Btrfs: implement memory reclaim for leaf reference cache 2008-09-25 11:04:05 -04:00
ref-cache.h Btrfs: implement memory reclaim for leaf reference cache 2008-09-25 11:04:05 -04:00
root-tree.c Btrfs: Add a write ahead tree log to optimize synchronous operations 2008-09-25 11:04:07 -04:00
struct-funcs.c Btrfs: unaligned access fixes 2008-09-25 11:04:00 -04:00
super.c Btrfs: Reinstate '-osubvol=.' option to mount entire tree 2008-09-25 11:04:06 -04:00
sysfs.c Btrfs: trivial sparse fixes 2008-09-25 11:04:07 -04:00
TODO Btrfs: add GPLv2 2007-06-12 09:07:21 -04:00
transaction.c Btrfs: Record dirty pages tree-log pages in an extent_io tree 2008-09-25 11:04:07 -04:00
transaction.h Btrfs: Record dirty pages tree-log pages in an extent_io tree 2008-09-25 11:04:07 -04:00
tree-defrag.c Btrfs: Add a write ahead tree log to optimize synchronous operations 2008-09-25 11:04:07 -04:00
tree-log.c Btrfs: Disable the dir fsync optimization to skip logging the dir sometimes 2008-09-25 11:04:07 -04:00
tree-log.h Btrfs: Add a write ahead tree log to optimize synchronous operations 2008-09-25 11:04:07 -04:00
version.sh Btrfs: Update version.sh to v0.16 2008-09-25 11:04:06 -04:00
volumes.c Btrfs: free space accounting redo 2008-09-25 11:04:07 -04:00
volumes.h Btrfs: Fix the multi-bio code to save the original bio for completion 2008-09-25 11:04:06 -04:00
xattr.c Btrfs: optimize btrget/set/removexattr 2008-09-25 11:04:07 -04:00
xattr.h Btrfs: optimize btrget/set/removexattr 2008-09-25 11:04:07 -04:00