From: Nikolay Borisov <nborisov@suse.com>
To: Josef Bacik <josef@toxicpanda.com>,
linux-btrfs@vger.kernel.org, kernel-team@fb.com
Cc: Josef Bacik <jbacik@fb.com>
Subject: Re: [PATCH 01/22] btrfs: add btrfs_delete_ref_head helper
Date: Fri, 20 Jul 2018 16:11:29 +0300 [thread overview]
Message-ID: <c3e460b9-0939-6fd9-954a-a8aa51a4105c@suse.com> (raw)
In-Reply-To: <20180719145006.17532-1-josef@toxicpanda.com>
On 19.07.2018 17:49, Josef Bacik wrote:
> From: Josef Bacik <jbacik@fb.com>
>
> We do this dance in cleanup_ref_head and check_ref_cleanup, unify it
> into a helper and cleanup the calling functions.
>
> Signed-off-by: Josef Bacik <jbacik@fb.com>
> ---
> fs/btrfs/delayed-ref.c | 14 ++++++++++++++
> fs/btrfs/delayed-ref.h | 3 ++-
> fs/btrfs/extent-tree.c | 24 ++++--------------------
> 3 files changed, 20 insertions(+), 21 deletions(-)
>
> diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
> index 03dec673d12a..e1b322d651dd 100644
> --- a/fs/btrfs/delayed-ref.c
> +++ b/fs/btrfs/delayed-ref.c
> @@ -393,6 +393,20 @@ btrfs_select_ref_head(struct btrfs_trans_handle *trans)
> return head;
> }
>
> +void btrfs_delete_ref_head(struct btrfs_delayed_ref_root *delayed_refs,
> + struct btrfs_delayed_ref_head *head)
> +{
> + lockdep_assert_held(&delayed_refs->lock);
> + lockdep_assert_held(&head->lock);
> +
> + rb_erase(&head->href_node, &delayed_refs->href_root);
> + RB_CLEAR_NODE(&head->href_node);
> + atomic_dec(&delayed_refs->num_entries);
> + delayed_refs->num_heads--;
> + if (head->processing == 0)
> + delayed_refs->num_heads_ready--;
> +}
> +
> /*
> * Helper to insert the ref_node to the tail or merge with tail.
> *
> diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
> index ea1aecb6a50d..36318182e4ec 100644
> --- a/fs/btrfs/delayed-ref.h
> +++ b/fs/btrfs/delayed-ref.h
> @@ -263,7 +263,8 @@ static inline void btrfs_delayed_ref_unlock(struct btrfs_delayed_ref_head *head)
> {
> mutex_unlock(&head->mutex);
> }
> -
> +void btrfs_delete_ref_head(struct btrfs_delayed_ref_root *delayed_refs,
> + struct btrfs_delayed_ref_head *head);
>
> struct btrfs_delayed_ref_head *
> btrfs_select_ref_head(struct btrfs_trans_handle *trans);
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 3d9fe58c0080..ccaccd78534e 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -2577,12 +2577,9 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans,
> spin_unlock(&delayed_refs->lock);
> return 1;
> }
> - delayed_refs->num_heads--;
> - rb_erase(&head->href_node, &delayed_refs->href_root);
> - RB_CLEAR_NODE(&head->href_node);
> - spin_unlock(&head->lock);
> + btrfs_delete_ref_head(delayed_refs, head);
> spin_unlock(&delayed_refs->lock);
> - atomic_dec(&delayed_refs->num_entries);
> + spin_unlock(&head->lock);
>
> trace_run_delayed_ref_head(fs_info, head, 0);
>
> @@ -7122,22 +7119,9 @@ static noinline int check_ref_cleanup(struct btrfs_trans_handle *trans,
> if (!mutex_trylock(&head->mutex))
> goto out;
>
> - /*
> - * at this point we have a head with no other entries. Go
> - * ahead and process it.
> - */
> - rb_erase(&head->href_node, &delayed_refs->href_root);
> - RB_CLEAR_NODE(&head->href_node);
> - atomic_dec(&delayed_refs->num_entries);
> -
> - /*
> - * we don't take a ref on the node because we're removing it from the
> - * tree, so we just steal the ref the tree was holding.
> - */
> - delayed_refs->num_heads--;
> - if (head->processing == 0)
> - delayed_refs->num_heads_ready--;
In cleanup_ref_head we don't have the num_heads_ready-- code so this is
not pure consolidation but changes the behavior to a certain extent. It
seems this patch is also fixing a bug w.r.t num_heads_ready counts if
so, this needs to be documented in the changelog.
> + btrfs_delete_ref_head(delayed_refs, head);
> head->processing = 0;
> +
> spin_unlock(&head->lock);
> spin_unlock(&delayed_refs->lock);
>
>
next prev parent reply other threads:[~2018-07-20 13:59 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-19 14:49 [PATCH 01/22] btrfs: add btrfs_delete_ref_head helper Josef Bacik
2018-07-19 14:49 ` [PATCH 02/22] btrfs: add cleanup_ref_head_accounting helper Josef Bacik
2018-07-19 14:49 ` [PATCH 03/22] btrfs: use cleanup_extent_op in check_ref_cleanup Josef Bacik
2018-07-19 14:49 ` [PATCH 04/22] btrfs: only track ref_heads in delayed_ref_updates Josef Bacik
2018-07-21 8:49 ` Nikolay Borisov
2018-07-19 14:49 ` [PATCH 05/22] btrfs: introduce delayed_refs_rsv Josef Bacik
2018-07-19 14:49 ` [PATCH 06/22] btrfs: check if free bgs for commit Josef Bacik
2018-07-19 14:49 ` [PATCH 07/22] btrfs: don't leak ret from do_chunk_alloc Josef Bacik
2018-07-19 15:43 ` Nikolay Borisov
2018-07-24 11:24 ` David Sterba
2018-07-19 14:49 ` [PATCH 08/22] btrfs: dump block_rsv whe dumping space info Josef Bacik
2018-07-19 15:39 ` Nikolay Borisov
2018-07-20 11:59 ` David Sterba
2018-07-19 14:49 ` [PATCH 09/22] btrfs: release metadata before running delayed refs Josef Bacik
2018-07-19 14:49 ` [PATCH 10/22] btrfs: alloc space cache inode with GFP_NOFS Josef Bacik
2018-07-19 15:35 ` Nikolay Borisov
2018-07-19 15:44 ` David Sterba
2018-07-19 15:56 ` Josef Bacik
2018-07-19 15:55 ` Josef Bacik
2018-07-19 14:49 ` [PATCH 11/22] btrfs: fix truncate throttling Josef Bacik
2018-07-19 14:49 ` [PATCH 12/22] btrfs: don't use global rsv for chunk allocation Josef Bacik
2018-07-19 14:49 ` [PATCH 13/22] btrfs: reset max_extent_size properly Josef Bacik
2018-07-19 14:49 ` [PATCH 14/22] btrfs: don't enospc all tickets on flush failure Josef Bacik
2018-07-19 14:49 ` [PATCH 15/22] btrfs: run delayed iputs before committing Josef Bacik
2018-08-21 13:51 ` David Sterba
2018-07-19 14:50 ` [PATCH 16/22] btrfs: loop in inode_rsv_refill Josef Bacik
2018-07-19 14:50 ` [PATCH 17/22] btrfs: don't take the dio_sem in the fsync path Josef Bacik
2018-07-19 15:12 ` Filipe Manana
2018-07-19 15:21 ` Filipe Manana
2018-07-19 15:54 ` Josef Bacik
2018-07-19 15:57 ` Filipe Manana
2018-07-19 14:50 ` [PATCH 18/22] btrfs: add ALLOC_CHUNK_FORCE to the flushing code Josef Bacik
2018-07-19 14:50 ` [PATCH 19/22] btrfs: set max_extent_size properly Josef Bacik
2018-07-19 14:50 ` [PATCH 20/22] btrfs: don't use ctl->free_space for max_extent_size Josef Bacik
2018-07-19 14:50 ` [PATCH 21/22] btrfs: reset max_extent_size on clear in a bitmap Josef Bacik
2018-07-19 14:50 ` [PATCH 22/22] btrfs: only run delayed refs if we're committing Josef Bacik
2018-07-20 7:37 ` Nikolay Borisov
2018-07-19 16:08 ` [PATCH 01/22] btrfs: add btrfs_delete_ref_head helper David Sterba
2018-07-19 16:12 ` Josef Bacik
2018-07-19 16:36 ` David Sterba
2018-07-20 13:11 ` Nikolay Borisov [this message]
2018-07-20 14:18 ` Josef Bacik
2018-07-20 14:48 ` David Sterba
2018-07-20 16:04 ` 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=c3e460b9-0939-6fd9-954a-a8aa51a4105c@suse.com \
--to=nborisov@suse.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).