linux/fs/btrfs
Josef Bacik 9ed74f2dba Btrfs: proper -ENOSPC handling
At the start of a transaction we do a btrfs_reserve_metadata_space() and
specify how many items we plan on modifying.  Then once we've done our
modifications and such, just call btrfs_unreserve_metadata_space() for
the same number of items we reserved.

For keeping track of metadata needed for data I've had to add an extent_io op
for when we merge extents.  This lets us track space properly when we are doing
sequential writes, so we don't end up reserving way more metadata space than
what we need.

The only place where the metadata space accounting is not done is in the
relocation code.  This is because Yan is going to be reworking that code in the
near future, so running btrfs-vol -b could still possibly result in a ENOSPC
related panic.  This patch also turns off the metadata_ratio stuff in order to
allow users to more efficiently use their disk space.

This patch makes it so we track how much metadata we need for an inode's
delayed allocation extents by tracking how many extents are currently
waiting for allocation.  It introduces two new callbacks for the
extent_io tree's, merge_extent_hook and split_extent_hook.  These help
us keep track of when we merge delalloc extents together and split them
up.  Reservations are handled prior to any actually dirty'ing occurs,
and then we unreserve after we dirty.

btrfs_unreserve_metadata_for_delalloc() will make the appropriate
unreservations as needed based on the number of reservations we
currently have and the number of extents we currently have.  Doing the
reservation outside of doing any of the actual dirty'ing lets us do
things like filemap_flush() the inode to try and force delalloc to
happen, or as a last resort actually start allocation on all delalloc
inodes in the fs.  This has survived dbench, fs_mark and an fsx torture
test.

Signed-off-by: Josef Bacik <jbacik@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2009-09-28 16:29:42 -04:00
..
acl.c helpers for acl caching + switch to those 2009-06-24 08:17:07 -04:00
async-thread.c Btrfs: Fix async thread shutdown race 2009-09-15 20:20:17 -04:00
async-thread.h Btrfs: keep irqs on more often in the worker threads 2009-09-11 13:31:04 -04:00
btrfs_inode.h Btrfs: proper -ENOSPC handling 2009-09-28 16:29:42 -04:00
compat.h
compression.c Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable 2009-09-11 19:07:25 -04:00
compression.h
ctree.c Btrfs: check size of inode backref before adding hardlink 2009-09-24 09:17:31 -04:00
ctree.h Btrfs: proper -ENOSPC handling 2009-09-28 16:29:42 -04:00
delayed-ref.c
delayed-ref.h
dir-item.c Btrfs: change how subvolumes are organized 2009-09-21 15:56:00 -04:00
disk-io.c Btrfs: proper -ENOSPC handling 2009-09-28 16:29:42 -04:00
disk-io.h
export.c Btrfs: add snapshot/subvolume destroy ioctl 2009-09-21 16:00:26 -04:00
export.h
extent_io.c Btrfs: proper -ENOSPC handling 2009-09-28 16:29:42 -04:00
extent_io.h Btrfs: proper -ENOSPC handling 2009-09-28 16:29:42 -04:00
extent_map.c Btrfs: search for an allocation hint while filling file COW 2009-09-18 16:08:52 -04:00
extent_map.h Btrfs: search for an allocation hint while filling file COW 2009-09-18 16:08:52 -04:00
extent-tree.c Btrfs: proper -ENOSPC handling 2009-09-28 16:29:42 -04:00
file-item.c
file.c Btrfs: proper -ENOSPC handling 2009-09-28 16:29:42 -04:00
free-space-cache.c Btrfs: fix extent entry threshold calculation 2009-09-21 19:23:50 -04:00
free-space-cache.h Btrfs: use hybrid extents+bitmap rb tree for free space 2009-07-24 09:23:30 -04:00
hash.h
inode-item.c Btrfs: check size of inode backref before adding hardlink 2009-09-24 09:17:31 -04:00
inode-map.c Btrfs: do not reuse objectid of deleted snapshot/subvol 2009-09-21 15:56:00 -04:00
inode.c Btrfs: proper -ENOSPC handling 2009-09-28 16:29:42 -04:00
ioctl.c Btrfs: proper -ENOSPC handling 2009-09-28 16:29:42 -04:00
ioctl.h Btrfs: add snapshot/subvolume destroy ioctl 2009-09-21 16:00:26 -04:00
Kconfig
locking.c
locking.h
Makefile
ordered-data.c Btrfs: Use PagePrivate2 to track pages in the data=ordered code. 2009-09-11 13:31:07 -04:00
ordered-data.h Btrfs: Use PagePrivate2 to track pages in the data=ordered code. 2009-09-11 13:31:07 -04:00
orphan.c Btrfs: change how subvolumes are organized 2009-09-21 15:56:00 -04:00
print-tree.c Btrfs: remove of redundant btrfs_header_level 2009-07-22 16:52:13 -04:00
print-tree.h
ref-cache.c
ref-cache.h
relocation.c Btrfs: relocate file extents in clusters 2009-09-24 09:17:31 -04:00
root-tree.c Btrfs: add snapshot/subvolume destroy ioctl 2009-09-21 16:00:26 -04:00
struct-funcs.c
super.c Btrfs: add snapshot/subvolume destroy ioctl 2009-09-21 16:00:26 -04:00
sysfs.c
transaction.c Btrfs: proper -ENOSPC handling 2009-09-28 16:29:42 -04:00
transaction.h Btrfs: be more polite in the async caching threads 2009-07-30 10:14:46 -04:00
tree-defrag.c
tree-log.c Btrfs: add snapshot/subvolume destroy ioctl 2009-09-21 16:00:26 -04:00
tree-log.h
version.h
version.sh
volumes.c Btrfs: make balance code choose more wisely when relocating 2009-09-21 19:23:48 -04:00
volumes.h Btrfs: make balance code choose more wisely when relocating 2009-09-21 19:23:48 -04:00
xattr.c
xattr.h
zlib.c Btrfs: correct error-handling zlib error handling 2009-08-07 13:51:33 -04:00