Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 128879
b: refs/heads/master
c: 9ca9ee0
h: refs/heads/master
i:
  128877: 8a9dbe9
  128875: 1bba3f4
  128871: f1d875e
  128863: 5551b29
v: v3
  • Loading branch information
Sage Weil authored and Chris Mason committed Sep 25, 2008
1 parent 3052be1 commit 35cecf7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 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: 3117a77370b6cb902191568e4e647cdcba083d0a
refs/heads/master: 9ca9ee09c176a814189063c8b88f75c8f8e4ad19
1 change: 1 addition & 0 deletions trunk/fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ struct btrfs_fs_info {

u64 generation;
u64 last_trans_committed;
u64 open_ioctl_trans;
unsigned long mount_opt;
u64 max_extent;
u64 max_inline;
Expand Down
12 changes: 11 additions & 1 deletion trunk/fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,12 @@ long btrfs_ioctl_trans_start(struct file *file)
ret = -EINPROGRESS;
goto out;
}
trans = btrfs_start_transaction(root, 0);

mutex_lock(&root->fs_info->trans_mutex);
root->fs_info->open_ioctl_trans++;
mutex_unlock(&root->fs_info->trans_mutex);

trans = btrfs_start_ioctl_transaction(root, 0);
if (trans)
file->private_data = trans;
else
Expand Down Expand Up @@ -745,6 +750,11 @@ long btrfs_ioctl_trans_end(struct file *file)
}
btrfs_end_transaction(trans, root);
file->private_data = 0;

mutex_lock(&root->fs_info->trans_mutex);
root->fs_info->open_ioctl_trans--;
mutex_unlock(&root->fs_info->trans_mutex);

out:
return ret;
}
Expand Down
18 changes: 13 additions & 5 deletions trunk/fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ static void wait_current_trans(struct btrfs_root *root)
}

struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
int num_blocks, int join)
int num_blocks, int wait)
{
struct btrfs_trans_handle *h =
kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS);
int ret;

mutex_lock(&root->fs_info->trans_mutex);
if (!join)
if ((wait == 1 && !root->fs_info->open_ioctl_trans) || wait == 2)
wait_current_trans(root);
ret = join_transaction(root);
BUG_ON(ret);
Expand All @@ -180,14 +180,21 @@ struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
int num_blocks)
{
return start_transaction(root, num_blocks, 0);
return start_transaction(root, num_blocks, 1);
}
struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root,
int num_blocks)
{
return start_transaction(root, num_blocks, 1);
return start_transaction(root, num_blocks, 0);
}

struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *r,
int num_blocks)
{
return start_transaction(r, num_blocks, 2);
}


static noinline int wait_for_commit(struct btrfs_root *root,
struct btrfs_transaction *commit)
{
Expand Down Expand Up @@ -247,7 +254,8 @@ static void throttle_on_drops(struct btrfs_root *root)
void btrfs_throttle(struct btrfs_root *root)
{
mutex_lock(&root->fs_info->trans_mutex);
wait_current_trans(root);
if (!root->fs_info->open_ioctl_trans)
wait_current_trans(root);
mutex_unlock(&root->fs_info->trans_mutex);

throttle_on_drops(root);
Expand Down
2 changes: 2 additions & 0 deletions trunk/fs/btrfs/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
int num_blocks);
struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root,
int num_blocks);
struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *r,
int num_blocks);
int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
struct btrfs_root *root);
int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans,
Expand Down

0 comments on commit 35cecf7

Please sign in to comment.