linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Boris Burkov <boris@bur.io>, Dave Sterba <dsterba@suse.com>,
	Chris Mason <clm@fb.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 2/2] btrfs: remove free space items when creating free space tree
Date: Thu, 3 Sep 2020 17:43:25 -0400	[thread overview]
Message-ID: <a4e6d3da-50ee-28e4-d7c4-661396a0f53a@toxicpanda.com> (raw)
In-Reply-To: <c52c3edb5927356a33a3aa7af2adea69f7361576.1599164377.git.boris@bur.io>

On 9/3/20 4:33 PM, Boris Burkov wrote:
> When the file system transitions from space cache v1 to v2 it removes
> the old cached data, but does not remove the FREE_SPACE items nor the
> free space inodes they point to. This doesn't cause any issues besides
> being a bit inefficient, since these items no longer do anything useful.
> 
> To fix it, as part of populating the free space tree, destroy each block
> group's free space item and free space inode. This code is lifted from
> the existing code for removing them when removing the block group.
> 
> Furthermore, cache_save_setup is called unconditionally from transaction
> commit on dirty block groups, so we must also stop creating these items
> when we are not using SPACE_CACHE.
> 
> References: https://github.com/btrfs/btrfs-todo/issues/5
> Signed-off-by: Boris Burkov <boris@bur.io>
> ---
>   fs/btrfs/block-group.c      | 42 ++++---------------------------
>   fs/btrfs/free-space-cache.c | 49 ++++++++++++++++++++++++++++++++++++-
>   fs/btrfs/free-space-cache.h |  2 ++
>   fs/btrfs/free-space-tree.c  |  3 +++
>   4 files changed, 58 insertions(+), 38 deletions(-)
> 
<snip>

>   
> +	if (!btrfs_test_opt(fs_info, SPACE_CACHE))
> +		return 0;
> +

This is functionally unrelated, so it needs to be it's own patch.

>   	/*
>   	 * If this block group is smaller than 100 megs don't bother caching the
>   	 * block group.
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index 8759f5a1d6a0..52612d99a842 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -207,6 +207,54 @@ int create_free_space_inode(struct btrfs_trans_handle *trans,
>   					 ino, block_group->start);
>   }
>   
> +int remove_free_space_inode(struct btrfs_trans_handle *trans,
> +			    struct btrfs_block_group *block_group)
> +{

It's public, lets call this btrfs_remove_free_space_inode().

<snip>

> @@ -2806,7 +2854,6 @@ void btrfs_remove_free_space_cache(struct btrfs_block_group *block_group)
>   	__btrfs_remove_free_space_cache_locked(ctl);
>   	btrfs_discard_update_discardable(block_group, ctl);
>   	spin_unlock(&ctl->tree_lock);
> -
>   }

Thou shall not change random whitespace that's not anywhere near the code you're 
modifying.  Thanks,

Josef

      reply	other threads:[~2020-09-03 21:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03 20:33 [PATCH 0/2] btrfs: free space tree mounting fixes Boris Burkov
2020-09-03 20:33 ` [PATCH 1/2] btrfs: support remount of ro fs with free space tree Boris Burkov
2020-09-03 21:40   ` Josef Bacik
2020-09-03 23:34     ` Boris Burkov
2020-09-03 20:33 ` [PATCH 2/2] btrfs: remove free space items when creating " Boris Burkov
2020-09-03 21:43   ` Josef Bacik [this message]

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=a4e6d3da-50ee-28e4-d7c4-661396a0f53a@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=boris@bur.io \
    --cc=clm@fb.com \
    --cc=dsterba@suse.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).