Btrfs: avoid heavy operations in btrfs_commit_super

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Nov 22 17:59:04 EST 2013


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=d52c1bcc647ca41ee563bc38d8231e5f3816112c
Commit:     d52c1bcc647ca41ee563bc38d8231e5f3816112c
Parent:     ba69994a40b242bef26ab2683ea84aa29e2e429f
Author:     Liu Bo <bo.li.liu at oracle.com>
AuthorDate: Tue Nov 5 11:45:53 2013 +0800
Committer:  Chris Mason <chris.mason at fusionio.com>
CommitDate: Wed Nov 20 20:42:16 2013 -0500

    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 at oracle.com>
    Signed-off-by: Josef Bacik <jbacik at fusionio.com>
    Signed-off-by: Chris Mason <chris.mason at fusionio.com>
---
 fs/btrfs/disk-io.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 4c4ed0b..8072cfa 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)
 int btrfs_commit_super(struct btrfs_root *root)
 {
 	struct btrfs_trans_handle *trans;
-	int ret;
 
 	mutex_lock(&root->fs_info->cleaner_mutex);
 	btrfs_run_delayed_iputs(root);
@@ -3531,25 +3530,7 @@ int btrfs_commit_super(struct btrfs_root *root)
 	trans = btrfs_join_transaction(root);
 	if (IS_ERR(trans))
 		return PTR_ERR(trans);
-	ret = btrfs_commit_transaction(trans, root);
-	if (ret)
-		return ret;
-	/* run commit again to drop the original snapshot */
-	trans = btrfs_join_transaction(root);
-	if (IS_ERR(trans))
-		return PTR_ERR(trans);
-	ret = btrfs_commit_transaction(trans, root);
-	if (ret)
-		return ret;
-	ret = btrfs_write_and_wait_transaction(NULL, root);
-	if (ret) {
-		btrfs_error(root->fs_info, ret,
-			    "Failed to sync btree inode to disk.");
-		return ret;
-	}
-
-	ret = write_ctree_super(NULL, root, 0);
-	return ret;
+	return btrfs_commit_transaction(trans, root);
 }
 
 int close_ctree(struct btrfs_root *root)



More information about the linux-mtd-cvs mailing list