Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332571
b: refs/heads/master
c: 60376ce
h: refs/heads/master
i:
  332569: 14450dc
  332567: b7bb3e1
v: v3
  • Loading branch information
Josef Bacik authored and Chris Mason committed Oct 4, 2012
1 parent f02d442 commit 9c61d8b
Show file tree
Hide file tree
Showing 4 changed files with 19 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: b3ae244e7174d981c09ad7a6a68e7909d600aaca
refs/heads/master: 60376ce4a8396bc5cd777be05b6a9bf044520f42
15 changes: 6 additions & 9 deletions trunk/fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,16 +854,13 @@ int btrfs_sync_fs(struct super_block *sb, int wait)

btrfs_wait_ordered_extents(root, 0, 0);

spin_lock(&fs_info->trans_lock);
if (!fs_info->running_transaction) {
spin_unlock(&fs_info->trans_lock);
return 0;
}
spin_unlock(&fs_info->trans_lock);

trans = btrfs_join_transaction(root);
if (IS_ERR(trans))
trans = btrfs_join_transaction_freeze(root);
if (IS_ERR(trans)) {
/* Frozen, don't bother */
if (PTR_ERR(trans) == -EPERM)
return 0;
return PTR_ERR(trans);
}
return btrfs_commit_transaction(trans, root);
}

Expand Down
12 changes: 11 additions & 1 deletion trunk/fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ enum btrfs_trans_type {
TRANS_JOIN,
TRANS_USERSPACE,
TRANS_JOIN_NOLOCK,
TRANS_JOIN_FREEZE,
};

static int may_wait_transaction(struct btrfs_root *root, int type)
Expand Down Expand Up @@ -341,7 +342,11 @@ static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
if (!h)
return ERR_PTR(-ENOMEM);

sb_start_intwrite(root->fs_info->sb);
if (!__sb_start_write(root->fs_info->sb, SB_FREEZE_FS, false)) {
if (type == TRANS_JOIN_FREEZE)
return ERR_PTR(-EPERM);
sb_start_intwrite(root->fs_info->sb);
}

if (may_wait_transaction(root, type))
wait_current_trans(root);
Expand Down Expand Up @@ -424,6 +429,11 @@ struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root
return start_transaction(root, 0, TRANS_USERSPACE, 0);
}

struct btrfs_trans_handle *btrfs_join_transaction_freeze(struct btrfs_root *root)
{
return start_transaction(root, 0, TRANS_JOIN_FREEZE, 0);
}

/* wait for a transaction commit to be fully complete */
static noinline void wait_for_commit(struct btrfs_root *root,
struct btrfs_transaction *commit)
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 @@ -102,6 +102,7 @@ struct btrfs_trans_handle *btrfs_start_transaction_noflush(
struct btrfs_root *root, int num_items);
struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root);
struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root);
struct btrfs_trans_handle *btrfs_join_transaction_freeze(struct btrfs_root *root);
struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root);
int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid);
int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
Expand Down

0 comments on commit 9c61d8b

Please sign in to comment.