Btrfs: reap dead roots right after commit
authorChris Mason <chris.mason@oracle.com>
Sat, 9 Jun 2007 12:19:57 +0000 (08:19 -0400)
committerDavid Woodhouse <dwmw2@hera.kernel.org>
Sat, 9 Jun 2007 12:19:57 +0000 (08:19 -0400)
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/transaction.c

index b859db395fd56d941a9a982890c24642fad6d022..a2c5820f1d3d4213b27bb95e00a0b75b4b63aed3 100644 (file)
@@ -371,13 +371,6 @@ void btrfs_transaction_cleaner(struct work_struct *work)
        int ret;
 
        INIT_LIST_HEAD(&dirty_roots);
-       mutex_lock(&root->fs_info->trans_mutex);
-       list_splice_init(&root->fs_info->dead_roots, &dirty_roots);
-       mutex_unlock(&root->fs_info->trans_mutex);
-
-       if (!list_empty(&dirty_roots)) {
-               drop_dirty_roots(root, &dirty_roots);
-       }
        mutex_lock(&root->fs_info->fs_mutex);
        mutex_lock(&root->fs_info->trans_mutex);
        cur = root->fs_info->running_transaction;
@@ -396,6 +389,14 @@ void btrfs_transaction_cleaner(struct work_struct *work)
        ret = btrfs_commit_transaction(trans, root);
 out:
        mutex_unlock(&root->fs_info->fs_mutex);
+
+       mutex_lock(&root->fs_info->trans_mutex);
+       list_splice_init(&root->fs_info->dead_roots, &dirty_roots);
+       mutex_unlock(&root->fs_info->trans_mutex);
+
+       if (!list_empty(&dirty_roots)) {
+               drop_dirty_roots(root, &dirty_roots);
+       }
        btrfs_transaction_queue_work(root, delay);
 }