Btrfs: add flushoncommit mount option
[linux-2.6-block.git] / fs / btrfs / transaction.c
index 3e8225de4e9d59776e1284d558ed3438832fd1cb..2869b3361eb6be3cf82e60ba58ce1d9191360c46 100644 (file)
@@ -972,6 +972,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
        int ret;
        int should_grow = 0;
        unsigned long now = get_seconds();
+       int flush_on_commit = btrfs_test_opt(root, FLUSHONCOMMIT);
 
        btrfs_run_ordered_operations(root, 0);
 
@@ -1051,7 +1052,9 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
 
                mutex_unlock(&root->fs_info->trans_mutex);
 
-               if (snap_pending) {
+               if (flush_on_commit || snap_pending) {
+                       if (flush_on_commit)
+                               btrfs_start_delalloc_inodes(root);
                        ret = btrfs_wait_ordered_extents(root, 1);
                        BUG_ON(ret);
                }