Skip to content

Commit

Permalink
Btrfs: use the transactions block_rsv for the csum root
Browse files Browse the repository at this point in the history
The alloc warnings everybody has been seeing is because we have been reserving
space for csums, but we weren't actually using that space.  So make
get_block_rsv() return the trans->block_rsv if we're modifying the csum root.
Also set the trans->block_rsv to NULL so that if we modify the csum root when
running delayed ref's that comes out of the global reserve like it's supposed
to.  With this patch I'm not seeing those alloc warnings anymore.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
  • Loading branch information
Josef Bacik committed Oct 19, 2011
1 parent c09544e commit 4c13d75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
15 changes: 9 additions & 6 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3565,10 +3565,12 @@ static int reserve_metadata_bytes(struct btrfs_trans_handle *trans,
static struct btrfs_block_rsv *get_block_rsv(struct btrfs_trans_handle *trans,
struct btrfs_root *root)
{
struct btrfs_block_rsv *block_rsv;
if (root->ref_cows)
struct btrfs_block_rsv *block_rsv = NULL;

if (root->ref_cows || root == root->fs_info->csum_root)
block_rsv = trans->block_rsv;
else

if (!block_rsv)
block_rsv = root->block_rsv;

if (!block_rsv)
Expand Down Expand Up @@ -3865,12 +3867,13 @@ static void release_global_block_rsv(struct btrfs_fs_info *fs_info)
void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
struct btrfs_root *root)
{
struct btrfs_block_rsv *block_rsv;

if (!trans->bytes_reserved)
return;

BUG_ON(trans->block_rsv != &root->fs_info->trans_block_rsv);
btrfs_block_rsv_release(root, trans->block_rsv,
trans->bytes_reserved);
block_rsv = &root->fs_info->trans_block_rsv;
btrfs_block_rsv_release(root, block_rsv, trans->bytes_reserved);
trans->bytes_reserved = 0;
}

Expand Down
1 change: 1 addition & 0 deletions fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
return 0;
}

trans->block_rsv = NULL;
while (count < 4) {
unsigned long cur = trans->delayed_ref_updates;
trans->delayed_ref_updates = 0;
Expand Down

0 comments on commit 4c13d75

Please sign in to comment.