Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 318843
b: refs/heads/master
c: 0e72110
h: refs/heads/master
i:
  318841: f93adb4
  318839: 7467d00
v: v3
  • Loading branch information
Josef Bacik authored and Chris Mason committed Jul 23, 2012
1 parent 03aa88a commit bc97c74
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b9959295151625c17723103afd79077e80b24ddd
refs/heads/master: 0e721106923be82f651dd0ee504742a8a3eb089f
8 changes: 7 additions & 1 deletion trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3961,7 +3961,10 @@ static struct btrfs_block_rsv *get_block_rsv(
{
struct btrfs_block_rsv *block_rsv = NULL;

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

if (root == root->fs_info->csum_root && trans->adding_csums)
block_rsv = trans->block_rsv;

if (!block_rsv)
Expand Down Expand Up @@ -4313,6 +4316,9 @@ 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)
{
if (!trans->block_rsv)
return;

if (!trans->bytes_reserved)
return;

Expand Down
2 changes: 2 additions & 0 deletions trunk/fs/btrfs/file-item.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
return -ENOMEM;

sector_sum = sums->sums;
trans->adding_csums = 1;
again:
next_offset = (u64)-1;
found_next = 0;
Expand Down Expand Up @@ -853,6 +854,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
goto again;
}
out:
trans->adding_csums = 0;
btrfs_free_path(path);
return ret;

Expand Down
22 changes: 8 additions & 14 deletions trunk/fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
h->bytes_reserved = 0;
h->delayed_ref_updates = 0;
h->use_count = 1;
h->adding_csums = 0;
h->block_rsv = NULL;
h->orig_rsv = NULL;
h->aborted = 0;
Expand Down Expand Up @@ -473,20 +474,13 @@ 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;
int err;

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) {
Expand All @@ -495,8 +489,6 @@ int btrfs_should_end_transaction(struct btrfs_trans_handle *trans,
return err;
}

trans->block_rsv = rsv;

return should_end_transaction(trans, root);
}

Expand All @@ -513,8 +505,6 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
return 0;
}

btrfs_trans_release_metadata(trans, root);
trans->block_rsv = NULL;
while (count < 2) {
unsigned long cur = trans->delayed_ref_updates;
trans->delayed_ref_updates = 0;
Expand All @@ -527,6 +517,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
}
count++;
}
btrfs_trans_release_metadata(trans, root);
trans->block_rsv = NULL;

if (lock && !atomic_read(&root->fs_info->open_ioctl_trans) &&
should_end_transaction(trans, root)) {
Expand Down Expand Up @@ -1269,9 +1261,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,

btrfs_run_ordered_operations(root, 0);

btrfs_trans_release_metadata(trans, root);
trans->block_rsv = NULL;

if (cur_trans->aborted)
goto cleanup_transaction;

Expand All @@ -1282,6 +1271,9 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
if (ret)
goto cleanup_transaction;

btrfs_trans_release_metadata(trans, root);
trans->block_rsv = NULL;

cur_trans = trans->transaction;

/*
Expand Down Expand Up @@ -1533,6 +1525,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
return ret;

cleanup_transaction:
btrfs_trans_release_metadata(trans, root);
trans->block_rsv = NULL;
btrfs_printk(root->fs_info, "Skipping commit of aborted transaction.\n");
// WARN_ON(1);
if (current->journal_info == trans)
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/btrfs/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct btrfs_trans_handle {
struct btrfs_block_rsv *block_rsv;
struct btrfs_block_rsv *orig_rsv;
int aborted;
int adding_csums;
};

struct btrfs_pending_snapshot {
Expand Down

0 comments on commit bc97c74

Please sign in to comment.