* [PATCH] Btrfs: avoid heavy operations in btrfs_commit_super
@ 2013-11-03 15:24 Liu Bo
2013-11-04 8:49 ` Stefan Behrens
0 siblings, 1 reply; 3+ messages in thread
From: Liu Bo @ 2013-11-03 15:24 UTC (permalink / raw)
To: linux-btrfs
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>
---
fs/btrfs/disk-io.c | 20 +-------------------
1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 62176ad..d6728c3 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3542,25 +3542,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)
--
1.8.2.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Btrfs: avoid heavy operations in btrfs_commit_super
2013-11-03 15:24 [PATCH] Btrfs: avoid heavy operations in btrfs_commit_super Liu Bo
@ 2013-11-04 8:49 ` Stefan Behrens
2013-11-04 9:58 ` Liu Bo
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Behrens @ 2013-11-04 8:49 UTC (permalink / raw)
To: Liu Bo, linux-btrfs
On Sun, 3 Nov 2013 23:24:34 +0800, Liu Bo wrote:
> 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>
> ---
> fs/btrfs/disk-io.c | 20 +-------------------
> 1 file changed, 1 insertion(+), 19 deletions(-)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 62176ad..d6728c3 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -3542,25 +3542,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)
>
fs/btrfs/disk-io.c: In function 'btrfs_commit_super':
fs/btrfs/disk-io.c:3520: warning: unused variable 'ret'
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Btrfs: avoid heavy operations in btrfs_commit_super
2013-11-04 8:49 ` Stefan Behrens
@ 2013-11-04 9:58 ` Liu Bo
0 siblings, 0 replies; 3+ messages in thread
From: Liu Bo @ 2013-11-04 9:58 UTC (permalink / raw)
To: Stefan Behrens; +Cc: linux-btrfs
On Mon, Nov 04, 2013 at 09:49:59AM +0100, Stefan Behrens wrote:
> On Sun, 3 Nov 2013 23:24:34 +0800, Liu Bo wrote:
> > 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>
> > ---
> > fs/btrfs/disk-io.c | 20 +-------------------
> > 1 file changed, 1 insertion(+), 19 deletions(-)
> >
> > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> > index 62176ad..d6728c3 100644
> > --- a/fs/btrfs/disk-io.c
> > +++ b/fs/btrfs/disk-io.c
> > @@ -3542,25 +3542,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)
> >
>
> fs/btrfs/disk-io.c: In function 'btrfs_commit_super':
> fs/btrfs/disk-io.c:3520: warning: unused variable 'ret'
>
Oops, sorry for that, will fix it soon.
thanks,
-liubo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-11-04 9:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-03 15:24 [PATCH] Btrfs: avoid heavy operations in btrfs_commit_super Liu Bo
2013-11-04 8:49 ` Stefan Behrens
2013-11-04 9:58 ` Liu Bo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).