diff options
author | Josef Bacik <josef@redhat.com> | 2011-09-19 17:58:54 +0200 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2011-10-19 21:12:44 +0200 |
commit | 9c8d86db9aee6f85866d480e0f9b37817264814c (patch) | |
tree | 0f191662ee322e52ed7946390b6fc4bb7c0eb130 | |
parent | Btrfs: stop passing a trans handle all around the reservation code (diff) | |
download | linux-9c8d86db9aee6f85866d480e0f9b37817264814c.tar.xz linux-9c8d86db9aee6f85866d480e0f9b37817264814c.zip |
Btrfs: make sure to unset trans->block_rsv before running delayed refs
Checksums are charged in 2 different ways. The first case is when we're writing
to the disk, we account for the new checksums with the delalloc block rsv. In
order for this to work we check if we're allocating a block for the csum root
and if trans->block_rsv == the delalloc block rsv. But when we're deleting the
csums because of cow, this is charged to the global block rsv, and is done when
we run the delayed refs. So we need to make sure that trans->block_rsv == NULL
when running the delayed refs. So set it to NULL and reset it in
should_end_transaction, and set it to NULL in commit_transaction. This got rid
of the ridiculous amount of warnings I was seeing when trying to do a balance.
Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
-rw-r--r-- | fs/btrfs/transaction.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 8d6f4c78f73f..7debbf396ef3 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -427,17 +427,26 @@ int btrfs_should_end_transaction(struct btrfs_trans_handle *trans, struct btrfs_root *root) { struct btrfs_transaction *cur_trans = trans->transaction; + struct btrfs_block_rsv *rsv = trans->block_rsv; int updates; smp_mb(); if (cur_trans->blocked || cur_trans->delayed_refs.flushing) return 1; + /* + * We need to do this in case we're deleting csums so the global block + * rsv get's used instead of the csum block rsv. + */ + trans->block_rsv = NULL; + updates = trans->delayed_ref_updates; trans->delayed_ref_updates = 0; if (updates) btrfs_run_delayed_refs(trans, root, updates); + trans->block_rsv = rsv; + return should_end_transaction(trans, root); } @@ -1167,6 +1176,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, btrfs_run_ordered_operations(root, 0); + trans->block_rsv = NULL; + /* make a pass through all the delayed refs we have so far * any runnings procs may add more while we are here */ |