From: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
To: Josef Bacik <josef@toxicpanda.com>
Cc: <linux-btrfs@vger.kernel.org>, <kernel-team@fb.com>,
Josef Bacik <jbacik@fb.com>
Subject: Re: [PATCH 3/6] btrfs: cleanup extent_op handling
Date: Thu, 22 Nov 2018 16:56:38 +0800 [thread overview]
Message-ID: <20181122085638.GA3002@fnst.localdomain> (raw)
In-Reply-To: <20181121185912.24288-4-josef@toxicpanda.com>
On Wed, Nov 21, 2018 at 01:59:09PM -0500, Josef Bacik wrote:
>From: Josef Bacik <jbacik@fb.com>
>
>The cleanup_extent_op function actually would run the extent_op if it
>needed running, which made the name sort of a misnomer. Change it to
>run_and_cleanup_extent_op, and move the actual cleanup work to
>cleanup_extent_op so it can be used by check_ref_cleanup() in order to
>unify the extent op handling.
>
>Signed-off-by: Josef Bacik <jbacik@fb.com>
One nitpick below.
Reviewed-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
>---
> fs/btrfs/extent-tree.c | 36 +++++++++++++++++++++++-------------
> 1 file changed, 23 insertions(+), 13 deletions(-)
>
>diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
>index e3ed3507018d..8a776dc9cb38 100644
>--- a/fs/btrfs/extent-tree.c
>+++ b/fs/btrfs/extent-tree.c
>@@ -2424,19 +2424,33 @@ static void unselect_delayed_ref_head(struct btrfs_delayed_ref_root *delayed_ref
> btrfs_delayed_ref_unlock(head);
> }
>
>-static int cleanup_extent_op(struct btrfs_trans_handle *trans,
>- struct btrfs_delayed_ref_head *head)
>+static struct btrfs_delayed_extent_op *
>+cleanup_extent_op(struct btrfs_trans_handle *trans,
The trans parameter seems useless.
--
Thanks,
Lu
>+ struct btrfs_delayed_ref_head *head)
> {
> struct btrfs_delayed_extent_op *extent_op = head->extent_op;
>- int ret;
>
> if (!extent_op)
>- return 0;
>- head->extent_op = NULL;
>+ return NULL;
>+
> if (head->must_insert_reserved) {
>+ head->extent_op = NULL;
> btrfs_free_delayed_extent_op(extent_op);
>- return 0;
>+ return NULL;
> }
>+ return extent_op;
>+}
>+
>+static int run_and_cleanup_extent_op(struct btrfs_trans_handle *trans,
>+ struct btrfs_delayed_ref_head *head)
>+{
>+ struct btrfs_delayed_extent_op *extent_op =
>+ cleanup_extent_op(trans, head);
>+ int ret;
>+
>+ if (!extent_op)
>+ return 0;
>+ head->extent_op = NULL;
> spin_unlock(&head->lock);
> ret = run_delayed_extent_op(trans, head, extent_op);
> btrfs_free_delayed_extent_op(extent_op);
>@@ -2488,7 +2502,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans,
>
> delayed_refs = &trans->transaction->delayed_refs;
>
>- ret = cleanup_extent_op(trans, head);
>+ ret = run_and_cleanup_extent_op(trans, head);
> if (ret < 0) {
> unselect_delayed_ref_head(delayed_refs, head);
> btrfs_debug(fs_info, "run_delayed_extent_op returned %d", ret);
>@@ -6977,12 +6991,8 @@ static noinline int check_ref_cleanup(struct btrfs_trans_handle *trans,
> if (!RB_EMPTY_ROOT(&head->ref_tree.rb_root))
> goto out;
>
>- if (head->extent_op) {
>- if (!head->must_insert_reserved)
>- goto out;
>- btrfs_free_delayed_extent_op(head->extent_op);
>- head->extent_op = NULL;
>- }
>+ if (cleanup_extent_op(trans, head) != NULL)
>+ goto out;
>
> /*
> * waiting for the lock here would deadlock. If someone else has it
>--
>2.14.3
>
>
>
next prev parent reply other threads:[~2018-11-22 8:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-21 18:59 [PATCH 0/6] Delayed refs rsv Josef Bacik
2018-11-21 18:59 ` [PATCH 1/6] btrfs: add btrfs_delete_ref_head helper Josef Bacik
2018-11-22 9:12 ` Nikolay Borisov
2018-11-22 9:42 ` Nikolay Borisov
2018-11-23 13:45 ` David Sterba
2018-11-23 13:50 ` Nikolay Borisov
2018-11-21 18:59 ` [PATCH 2/6] btrfs: add cleanup_ref_head_accounting helper Josef Bacik
2018-11-22 1:06 ` Qu Wenruo
2018-11-23 13:51 ` David Sterba
2018-11-21 18:59 ` [PATCH 3/6] btrfs: cleanup extent_op handling Josef Bacik
2018-11-22 8:56 ` Lu Fengqi [this message]
2018-11-22 10:09 ` Nikolay Borisov
2018-11-27 15:39 ` Josef Bacik
2018-11-23 15:05 ` David Sterba
2018-11-21 18:59 ` [PATCH 4/6] btrfs: only track ref_heads in delayed_ref_updates Josef Bacik
2018-11-22 10:19 ` Nikolay Borisov
2018-11-21 18:59 ` [PATCH 5/6] btrfs: introduce delayed_refs_rsv Josef Bacik
2018-11-26 9:14 ` Nikolay Borisov
2018-11-27 15:38 ` David Sterba
2018-11-27 19:11 ` Josef Bacik
2018-11-21 18:59 ` [PATCH 6/6] btrfs: fix truncate throttling Josef Bacik
2018-11-26 9:44 ` Nikolay Borisov
2018-11-23 15:55 ` [PATCH 0/6] Delayed refs rsv 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=20181122085638.GA3002@fnst.localdomain \
--to=lufq.fnst@cn.fujitsu.com \
--cc=jbacik@fb.com \
--cc=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/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).