aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ctree.h1
-rw-r--r--fs/btrfs/ioctl.c12
-rw-r--r--fs/btrfs/transaction.c18
-rw-r--r--fs/btrfs/transaction.h2
4 files changed, 27 insertions, 6 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 9b02596..62499dd 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -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;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 224da28..0b63c3c 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -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
@@ -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;
}
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index cf73342..a2c821e 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -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);
@@ -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)
{
@@ -247,7 +254,8 @@ harder:
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);
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index f5adb23..2c73cae 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -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,