From: Nikolay Borisov <nborisov@suse.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/3] btrfs-progs: Refactor btrfs_finish_extent_commit()
Date: Tue, 16 Apr 2019 10:39:02 +0300 [thread overview]
Message-ID: <c5e92734-0c9a-aab2-2c6f-e849418bbdde@suse.com> (raw)
In-Reply-To: <20190416071526.3576-3-wqu@suse.com>
On 16.04.19 г. 10:15 ч., Qu Wenruo wrote:
> This patch will refactor btrfs_finish_extent_commit() by:
> - Make it return void
> There is no failure pattern for btrfs_finish_extent_commit(), thus it
> always return 0. And the caller doesn't care about the return value.
> So no need to return int.
>
> - Remove @root and @unpin parameters
> @root is only used to extract fs_info, which can be extracted from
> transaction handler already.
> @unpin is always fs_info->pinned_extents.
> All these parameters can be extracted from @trans, no need to pass
> them.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
This also makes the function's signature identical to its kernel
counterpart.
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> ctree.h | 4 +---
> extent-tree.c | 14 ++++++--------
> transaction.c | 3 +--
> 3 files changed, 8 insertions(+), 13 deletions(-)
>
> diff --git a/ctree.h b/ctree.h
> index 3357290d7045..76f52b1c9b08 100644
> --- a/ctree.h
> +++ b/ctree.h
> @@ -2516,9 +2516,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans,
> struct btrfs_root *root,
> u64 bytenr, u64 num_bytes, u64 parent,
> u64 root_objectid, u64 owner, u64 offset);
> -int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
> - struct btrfs_root *root,
> - struct extent_io_tree *unpin);
> +void btrfs_finish_extent_commit(struct btrfs_trans_handle *trans);
> int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
> struct btrfs_root *root,
> u64 bytenr, u64 num_bytes, u64 parent,
> diff --git a/extent-tree.c b/extent-tree.c
> index b7ece0ccc237..1140ebfc61ff 100644
> --- a/extent-tree.c
> +++ b/extent-tree.c
> @@ -1977,27 +1977,25 @@ next:
> return 0;
> }
>
> -int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
> - struct btrfs_root *root,
> - struct extent_io_tree *unpin)
> +void btrfs_finish_extent_commit(struct btrfs_trans_handle *trans)
> {
> u64 start;
> u64 end;
> int ret;
> - struct extent_io_tree *free_space_cache;
> - free_space_cache = &root->fs_info->free_space_cache;
> + struct btrfs_fs_info *fs_info = trans->fs_info;
> + struct extent_io_tree *free_space_cache = &fs_info->free_space_cache;
> + struct extent_io_tree *pinned_extents = &fs_info->pinned_extents;
>
> while(1) {
> - ret = find_first_extent_bit(unpin, 0, &start, &end,
> + ret = find_first_extent_bit(pinned_extents, 0, &start, &end,
> EXTENT_DIRTY);
> if (ret)
> break;
> update_pinned_extents(trans->fs_info, start, end + 1 - start,
> 0);
> - clear_extent_dirty(unpin, start, end);
> + clear_extent_dirty(pinned_extents, start, end);
> set_extent_dirty(free_space_cache, start, end);
> }
> - return 0;
> }
>
> static int pin_down_bytes(struct btrfs_trans_handle *trans, u64 bytenr,
> diff --git a/transaction.c b/transaction.c
> index 3a63988b0969..8d15eb11c7b5 100644
> --- a/transaction.c
> +++ b/transaction.c
> @@ -198,8 +198,7 @@ commit_tree:
> if (ret < 0)
> goto out;
> ret = write_ctree_super(trans);
> - btrfs_finish_extent_commit(trans, fs_info->extent_root,
> - &fs_info->pinned_extents);
> + btrfs_finish_extent_commit(trans);
> kfree(trans);
> free_extent_buffer(root->commit_root);
> root->commit_root = NULL;
>
next prev parent reply other threads:[~2019-04-16 7:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-16 7:15 [PATCH 0/3] btrfs-progs: Handle error properly in btrfs_commit_transaction() Qu Wenruo
2019-04-16 7:15 ` [PATCH 1/3] btrfs-progs: Remove the dead branch in btrfs_run_delayed_refs() Qu Wenruo
2019-04-16 7:36 ` Nikolay Borisov
2019-04-16 7:15 ` [PATCH 2/3] btrfs-progs: Refactor btrfs_finish_extent_commit() Qu Wenruo
2019-04-16 7:39 ` Nikolay Borisov [this message]
2019-04-16 7:15 ` [PATCH 3/3] btrfs-progs: Handle error properly in btrfs_commit_transaction() Qu Wenruo
2019-04-16 7:48 ` Nikolay Borisov
2019-05-13 13:55 ` [PATCH 0/3] " David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c5e92734-0c9a-aab2-2c6f-e849418bbdde@suse.com \
--to=nborisov@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).