aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLiu Bo <bo.li.liu@oracle.com>2013-11-04 22:45:53 -0500
committerChris Mason <chris.mason@fusionio.com>2013-11-20 20:42:16 -0500
commitd52c1bcc647ca41ee563bc38d8231e5f3816112c (patch)
tree2698bcd9e7271f268834108e20ecbc985d188805 /fs
parentba69994a40b242bef26ab2683ea84aa29e2e429f (diff)
Btrfs: avoid heavy operations in btrfs_commit_super
The 'git blame' history shows that, the old transaction commit code has to do twice to ensure roots are updated and we have to flush metadata and super block manually, however, right now all of these can be handled well inside the transaction commit code without extra efforts. And the error handling part remains same with the current code, -- 'return to caller once we get error'. This saves us a transaction commit and a flush of super block, which are both heavy operations according to ftrace output analysis. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/disk-io.c21
1 files changed, 1 insertions, 20 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 4c4ed0bb3da1..8072cfa8a3b1 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3517,7 +3517,6 @@ int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info)
3517int btrfs_commit_super(struct btrfs_root *root) 3517int btrfs_commit_super(struct btrfs_root *root)
3518{ 3518{
3519 struct btrfs_trans_handle *trans; 3519 struct btrfs_trans_handle *trans;
3520 int ret;
3521 3520
3522 mutex_lock(&root->fs_info->cleaner_mutex); 3521 mutex_lock(&root->fs_info->cleaner_mutex);
3523 btrfs_run_delayed_iputs(root); 3522 btrfs_run_delayed_iputs(root);
@@ -3531,25 +3530,7 @@ int btrfs_commit_super(struct btrfs_root *root)
3531 trans = btrfs_join_transaction(root); 3530 trans = btrfs_join_transaction(root);
3532 if (IS_ERR(trans)) 3531 if (IS_ERR(trans))
3533 return PTR_ERR(trans); 3532 return PTR_ERR(trans);
3534 ret = btrfs_commit_transaction(trans, root); 3533 return btrfs_commit_transaction(trans, root);
3535 if (ret)
3536 return ret;
3537 /* run commit again to drop the original snapshot */
3538 trans = btrfs_join_transaction(root);
3539 if (IS_ERR(trans))
3540 return PTR_ERR(trans);
3541 ret = btrfs_commit_transaction(trans, root);
3542 if (ret)
3543 return ret;
3544 ret = btrfs_write_and_wait_transaction(NULL, root);
3545 if (ret) {
3546 btrfs_error(root->fs_info, ret,
3547 "Failed to sync btree inode to disk.");
3548 return ret;
3549 }
3550
3551 ret = write_ctree_super(NULL, root, 0);
3552 return ret;
3553} 3534}
3554 3535
3555int close_ctree(struct btrfs_root *root) 3536int close_ctree(struct btrfs_root *root)