From: Nikolay Borisov <nborisov@suse.com>
To: Josef Bacik <josef@toxicpanda.com>,
kernel-team@fb.com, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/3] btrfs: rename the btrfs_calc_*_metadata_size helpers
Date: Mon, 19 Aug 2019 11:30:16 +0300 [thread overview]
Message-ID: <54a313a2-8355-66cd-74a1-a267bd65cccd@suse.com> (raw)
In-Reply-To: <20190816150600.9188-2-josef@toxicpanda.com>
On 16.08.19 г. 18:05 ч., Josef Bacik wrote:
> btrfs_calc_trunc_metadata_size differs from trans_metadata_size in that
> it doesn't take into account any splitting at the levels, because
> truncate will never split nodes. However truncate _and_ changing will
> never split nodes, so rename btrfs_calc_trunc_metadata_size to
> btrfs_calc_metadata_size. Also btrfs_calc_trans_metadata_size is purely
> for inserting items, so rename this to btrfs_calc_insert_metadata_size.
> Making these clearer will help when I start using them differently in
> upcoming patches.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
> fs/btrfs/block-group.c | 4 ++--
> fs/btrfs/ctree.h | 14 +++++++++-----
> fs/btrfs/delalloc-space.c | 8 ++++----
> fs/btrfs/delayed-inode.c | 4 ++--
> fs/btrfs/delayed-ref.c | 8 ++++----
> fs/btrfs/file.c | 4 ++--
> fs/btrfs/free-space-cache.c | 4 ++--
> fs/btrfs/inode-map.c | 2 +-
> fs/btrfs/inode.c | 6 +++---
> fs/btrfs/props.c | 2 +-
> fs/btrfs/root-tree.c | 2 +-
> fs/btrfs/space-info.c | 2 +-
> fs/btrfs/transaction.c | 4 ++--
> 13 files changed, 34 insertions(+), 30 deletions(-)
Reviewed-by: Nikolay Borisov <nborisov@suse.com> see one discussion
point below.
>
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index afae5c731904..3147e840f839 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -3014,8 +3014,8 @@ void check_system_chunk(struct btrfs_trans_handle *trans, u64 type)
> num_devs = get_profile_num_devs(fs_info, type);
>
> /* num_devs device items to update and 1 chunk item to add or remove */
> - thresh = btrfs_calc_trunc_metadata_size(fs_info, num_devs) +
> - btrfs_calc_trans_metadata_size(fs_info, 1);
> + thresh = btrfs_calc_metadata_size(fs_info, num_devs) +
> + btrfs_calc_insert_metadata_size(fs_info, 1);
>
> if (left < thresh && btrfs_test_opt(fs_info, ENOSPC_DEBUG)) {
> btrfs_info(fs_info, "left=%llu, need=%llu, flags=%llu",
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index 85b808e3ea42..f352aa098015 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -2450,17 +2450,21 @@ int btrfs_get_extent_inline_ref_type(const struct extent_buffer *eb,
>
> u64 btrfs_csum_bytes_to_leaves(struct btrfs_fs_info *fs_info, u64 csum_bytes);
>
> -static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_fs_info *fs_info,
> - unsigned num_items)
> +/*
> + * Use this if we would be adding new items, as we could split nodes as we cow
> + * down the tree.
> + */
> +static inline u64 btrfs_calc_insert_metadata_size(struct btrfs_fs_info *fs_info,
> + unsigned num_items)
> {
> return (u64)fs_info->nodesize * BTRFS_MAX_LEVEL * 2 * num_items;
> }
>
Isn't assuming that we are going to split on every level of the cow
rather pessimistic, bordering on impossible. Isn't it realistically
possible that we will only ever split up until root->level.
<snip>
next prev parent reply other threads:[~2019-08-19 8:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-16 15:05 [PATCH 0/3] Rework the worst case calculations for space reservation Josef Bacik
2019-08-16 15:05 ` [PATCH 1/3] btrfs: rename the btrfs_calc_*_metadata_size helpers Josef Bacik
2019-08-19 8:30 ` Nikolay Borisov [this message]
2019-08-19 12:47 ` Josef Bacik
2019-08-20 17:40 ` David Sterba
2019-08-16 15:05 ` [PATCH 2/3] btrfs: only reserve metadata_size for inodes Josef Bacik
2019-08-19 9:17 ` Nikolay Borisov
2019-08-19 12:49 ` Josef Bacik
2019-08-16 15:06 ` [PATCH 3/3] btrfs: global reserve fallback should use metadata_size Josef Bacik
2019-08-16 15:35 ` Filipe Manana
2019-08-16 16:51 ` Josef Bacik
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=54a313a2-8355-66cd-74a1-a267bd65cccd@suse.com \
--to=nborisov@suse.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