aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-06-08 15:33:54 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-06-08 15:33:54 -0400
commit08607c1b182b3b8b54d7141a0c012cda17d201e6 (patch)
treed0cf03f3c03ca513377f85cf58ee0fbafcfd3f00 /fs/btrfs/transaction.c
parentfabb568183de7996257080260d3537fa75b3667e (diff)
Btrfs: add compat ioctl
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index f0f03121b7b..bf7eef67ba0 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -8,6 +8,8 @@ static int total_trans = 0;
extern struct kmem_cache *btrfs_trans_handle_cachep;
extern struct kmem_cache *btrfs_transaction_cachep;
+static struct workqueue_struct *trans_wq;
+
#define BTRFS_ROOT_TRANS_TAG 0
#define TRANS_MAGIC 0xE1E10E
@@ -44,6 +46,7 @@ static int join_transaction(struct btrfs_root *root)
cur_trans->in_commit = 0;
cur_trans->use_count = 1;
cur_trans->commit_done = 0;
+ cur_trans->start_time = get_seconds();
list_add_tail(&cur_trans->list, &root->fs_info->trans_list);
init_bit_radix(&cur_trans->dirty_pages);
}
@@ -350,3 +353,60 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
return ret;
}
+void btrfs_transaction_cleaner(struct work_struct *work)
+{
+ struct btrfs_fs_info *fs_info = container_of(work,
+ struct btrfs_fs_info,
+ trans_work.work);
+
+ struct btrfs_root *root = fs_info->tree_root;
+ struct btrfs_transaction *cur;
+ struct btrfs_trans_handle *trans;
+ unsigned long now;
+ unsigned long delay = HZ * 30;
+ int ret;
+
+printk("btrfs transaction cleaner\n");
+ mutex_lock(&root->fs_info->fs_mutex);
+ mutex_lock(&root->fs_info->trans_mutex);
+ cur = root->fs_info->running_transaction;
+ if (!cur) {
+ mutex_unlock(&root->fs_info->trans_mutex);
+ goto out;
+ }
+ now = get_seconds();
+ if (now < cur->start_time || now - cur->start_time < 30) {
+ mutex_unlock(&root->fs_info->trans_mutex);
+ delay = HZ * 5;
+ goto out;
+ }
+ mutex_unlock(&root->fs_info->trans_mutex);
+printk("forcing commit\n");
+ trans = btrfs_start_transaction(root, 1);
+ ret = btrfs_commit_transaction(trans, root);
+out:
+ mutex_unlock(&root->fs_info->fs_mutex);
+ btrfs_transaction_queue_work(root, delay);
+}
+
+void btrfs_transaction_queue_work(struct btrfs_root *root, int delay)
+{
+ queue_delayed_work(trans_wq, &root->fs_info->trans_work, delay);
+}
+
+void btrfs_transaction_flush_work(struct btrfs_root *root)
+{
+ cancel_rearming_delayed_workqueue(trans_wq, &root->fs_info->trans_work);
+ flush_workqueue(trans_wq);
+}
+
+void __init btrfs_init_transaction_sys(void)
+{
+ trans_wq = create_workqueue("btrfs");
+}
+
+void __exit btrfs_exit_transaction_sys(void)
+{
+ destroy_workqueue(trans_wq);
+}
+