Btrfs: add extra flushing for renames and truncates
[linux-2.6-block.git] / fs / btrfs / transaction.c
index 9c8f158dd2dbb95dd04a2690efdfa6c946380da3..664782c6a2dfbf6e65628f09fe2ff8552335f016 100644 (file)
@@ -975,6 +975,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
        int should_grow = 0;
        unsigned long now = get_seconds();
 
+       btrfs_run_ordered_operations(root, 0);
+
        /* make a pass through all the delayed refs we have so far
         * any runnings procs may add more while we are here
         */
@@ -1056,6 +1058,15 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
                        BUG_ON(ret);
                }
 
+               /*
+                * rename don't use btrfs_join_transaction, so, once we
+                * set the transaction to blocked above, we aren't going
+                * to get any new ordered operations.  We can safely run
+                * it here and no for sure that nothing new will be added
+                * to the list
+                */
+               btrfs_run_ordered_operations(root, 1);
+
                smp_mb();
                if (cur_trans->num_writers > 1 || should_grow)
                        schedule_timeout(timeout);