Btrfs: extent_map and data=ordered fixes for space balancing
* Add an EXTENT_BOUNDARY state bit to keep the writepage code from merging data extents that are in the process of being relocated. This allows us to do accounting for them properly. * The balancing code relocates data extents indepdent of the underlying inode. The extent_map code was modified to properly account for things moving around (invalidating extent_map caches in the inode). * Don't take the drop_mutex in the create_subvol ioctl. It isn't required. * Fix walking of the ordered extent list to avoid races with sys_unlink * Change the lock ordering rules. Transaction start goes outside the drop_mutex. This allows btrfs_commit_transaction to directly drop the relocation trees. Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
@@ -290,7 +290,6 @@ int noinline btrfs_cow_block(struct btrfs_trans_handle *trans,
|
||||
struct extent_buffer **cow_ret, u64 prealloc_dest)
|
||||
{
|
||||
u64 search_start;
|
||||
u64 header_trans;
|
||||
int ret;
|
||||
|
||||
if (trans->transaction != root->fs_info->running_transaction) {
|
||||
@@ -304,9 +303,9 @@ int noinline btrfs_cow_block(struct btrfs_trans_handle *trans,
|
||||
WARN_ON(1);
|
||||
}
|
||||
|
||||
header_trans = btrfs_header_generation(buf);
|
||||
spin_lock(&root->fs_info->hash_lock);
|
||||
if (header_trans == trans->transid &&
|
||||
if (btrfs_header_generation(buf) == trans->transid &&
|
||||
btrfs_header_owner(buf) == root->root_key.objectid &&
|
||||
!btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN)) {
|
||||
*cow_ret = buf;
|
||||
spin_unlock(&root->fs_info->hash_lock);
|
||||
@@ -1300,6 +1299,7 @@ again:
|
||||
/* is a cow on this block not required */
|
||||
spin_lock(&root->fs_info->hash_lock);
|
||||
if (btrfs_header_generation(b) == trans->transid &&
|
||||
btrfs_header_owner(b) == root->root_key.objectid &&
|
||||
!btrfs_header_flag(b, BTRFS_HEADER_FLAG_WRITTEN)) {
|
||||
spin_unlock(&root->fs_info->hash_lock);
|
||||
goto cow_done;
|
||||
@@ -1396,7 +1396,8 @@ cow_done:
|
||||
|
||||
/* this is only true while dropping a snapshot */
|
||||
if (level == lowest_level) {
|
||||
break;
|
||||
ret = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
blocknr = btrfs_node_blockptr(b, slot);
|
||||
|
Reference in New Issue
Block a user