Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 253819
b: refs/heads/master
c: e999376
h: refs/heads/master
i:
  253817: 2a8bf28
  253815: bc411f3
v: v3
  • Loading branch information
Chris Mason committed Jun 17, 2011
1 parent c411657 commit 9ed7372
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 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: 35a30d7ce54e087d8025a725d4e5a2fdee723a9f
refs/heads/master: e999376f094162aa425ae749aa1df95ab928d010
7 changes: 7 additions & 0 deletions trunk/fs/btrfs/delayed-inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,13 @@ static int btrfs_wq_run_delayed_node(struct btrfs_delayed_root *delayed_root,
return 0;
}

void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
{
struct btrfs_delayed_root *delayed_root;
delayed_root = btrfs_get_delayed_root(root);
WARN_ON(btrfs_first_delayed_node(delayed_root));
}

void btrfs_balance_delayed_items(struct btrfs_root *root)
{
struct btrfs_delayed_root *delayed_root;
Expand Down
4 changes: 4 additions & 0 deletions trunk/fs/btrfs/delayed-inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,8 @@ int btrfs_readdir_delayed_dir_index(struct file *filp, void *dirent,
/* for init */
int __init btrfs_delayed_inode_init(void);
void btrfs_delayed_inode_exit(void);

/* for debugging */
void btrfs_assert_delayed_root_empty(struct btrfs_root *root);

#endif
27 changes: 17 additions & 10 deletions trunk/fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,15 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
ret = btrfs_update_inode(trans, parent_root, parent_inode);
BUG_ON(ret);

/*
* pull in the delayed directory update
* and the delayed inode item
* otherwise we corrupt the FS during
* snapshot
*/
ret = btrfs_run_delayed_items(trans, root);
BUG_ON(ret);

record_root_in_trans(trans, root);
btrfs_set_root_last_snapshot(&root->root_item, trans->transid);
memcpy(new_root_item, &root->root_item, sizeof(*new_root_item));
Expand Down Expand Up @@ -1018,14 +1027,6 @@ static noinline int create_pending_snapshots(struct btrfs_trans_handle *trans,
int ret;

list_for_each_entry(pending, head, list) {
/*
* We must deal with the delayed items before creating
* snapshots, or we will create a snapthot with inconsistent
* information.
*/
ret = btrfs_run_delayed_items(trans, fs_info->fs_root);
BUG_ON(ret);

ret = create_pending_snapshot(trans, fs_info, pending);
BUG_ON(ret);
}
Expand Down Expand Up @@ -1319,15 +1320,21 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
*/
mutex_lock(&root->fs_info->reloc_mutex);

ret = create_pending_snapshots(trans, root->fs_info);
ret = btrfs_run_delayed_items(trans, root);
BUG_ON(ret);

ret = btrfs_run_delayed_items(trans, root);
ret = create_pending_snapshots(trans, root->fs_info);
BUG_ON(ret);

ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1);
BUG_ON(ret);

/*
* make sure none of the code above managed to slip in a
* delayed item
*/
btrfs_assert_delayed_root_empty(root);

WARN_ON(cur_trans != trans->transaction);

btrfs_scrub_pause(root);
Expand Down

0 comments on commit 9ed7372

Please sign in to comment.