Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: David Sterba <dsterba@suse.com>,
	linux-btrfs@vger.kernel.org, Nikolay Borisov <nborisov@suse.com>,
	Naohiro Aota <Naohiro.Aota@wdc.com>
Subject: Re: [PATCH 06/21] btrfs: zoned: move mark_block_group_to_copy to zoned code
Date: Wed, 24 Nov 2021 18:48:38 +0100	[thread overview]
Message-ID: <20211124174838.GX28560@twin.jikos.cz> (raw)
In-Reply-To: <7515f0e28e89b7c2266bfcc021f9639dd45ae898.1637745470.git.johannes.thumshirn@wdc.com>

On Wed, Nov 24, 2021 at 01:30:32AM -0800, Johannes Thumshirn wrote:
> mark_block_group_to_copy() is only used in zoned filesystems, so move the
> code to zoned code.

Should it rather be moved to block-group.c, as it logically belongs to
the bg API? That it is used by zoned mode is ok, it's the zoned mode
using that particular helper from the API, but otherwise I don't see
anything specific in that helper.

> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  fs/btrfs/dev-replace.c | 126 +----------------------------------------
>  fs/btrfs/zoned.c       | 124 ++++++++++++++++++++++++++++++++++++++++
>  fs/btrfs/zoned.h       |   8 +++
>  3 files changed, 133 insertions(+), 125 deletions(-)
> 
> diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
> index 66fa61cb3f235..7572d80bff2ac 100644
> --- a/fs/btrfs/dev-replace.c
> +++ b/fs/btrfs/dev-replace.c
> @@ -460,130 +460,6 @@ static char* btrfs_dev_name(struct btrfs_device *device)
>  		return rcu_str_deref(device->name);
>  }
>  
> -static int mark_block_group_to_copy(struct btrfs_fs_info *fs_info,
> -				    struct btrfs_device *src_dev)
> -{
> -	struct btrfs_path *path;
> -	struct btrfs_key key;
> -	struct btrfs_key found_key;
> -	struct btrfs_root *root = fs_info->dev_root;
> -	struct btrfs_dev_extent *dev_extent = NULL;
> -	struct btrfs_block_group *cache;
> -	struct btrfs_trans_handle *trans;
> -	int ret = 0;
> -	u64 chunk_offset;
> -
> -	/* Do not use "to_copy" on non zoned filesystem for now */
> -	if (!btrfs_is_zoned(fs_info))
> -		return 0;

Let's take this as an example. My idea of removing the btrfs_is_zoned
calls is something like:

Caller:

	if (need_to_copy_bg(fs_info)) {
		ret = btrfs_mark_block_group_to_copy();
		if (ret)
			...;
	}

Where the need_to_copy_bg obviously wraps the is-zoned check. This
allows to separate the layers a and keep btrfs_mark_block_group_to_copy
in block-group.c where it belongs, while not opencoding the zoned inside
random functions.

This adds the indirection and perhaps too trivial wrappers, but reading
the code is not hurt and layers are more separated.

In summary:
- move the is-zoned checks to callers
- add wrappers that follow the semantics of the check (ie. is-zoned is
  an implementation detail)
- move functions to their respective API file if it exists

  reply	other threads:[~2021-11-24 17:48 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-24  9:30 [PATCH 00/21] btrfs: first batch of zoned cleanups Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 01/21] btrfs: zoned: encapsulate inode locking for zoned relocation Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 02/21] btrfs: zoned: simplify btrfs_check_meta_write_pointer Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 03/21] btrfs: zoned: sink zone check into btrfs_repair_one_zone Johannes Thumshirn
2021-11-24 16:28   ` Josef Bacik
2021-11-24 17:29   ` David Sterba
2021-11-25  7:13     ` Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 04/21] btrfs: zoned: it's pointless to check for REQ_OP_ZONE_APPEND and btrfs_is_zoned Johannes Thumshirn
2021-11-24 17:33   ` David Sterba
2021-11-24  9:30 ` [PATCH 05/21] btrfs: zoned: move compatible fs flags check to zoned code Johannes Thumshirn
2021-11-24 17:36   ` David Sterba
2021-11-25 10:00     ` Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 06/21] btrfs: zoned: move mark_block_group_to_copy " Johannes Thumshirn
2021-11-24 17:48   ` David Sterba [this message]
2021-11-24  9:30 ` [PATCH 07/21] btrfs: zoned: move btrfs_finish_block_group_to_copy " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 08/21] btrfs: zoned: move is_block_group_to_copy " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 09/21] btrfs: zoned: skip zoned check if block_group is marked as copy Johannes Thumshirn
2021-11-29  8:18   ` [btrfs] a323b5f59e: xfstests.btrfs.167.fail kernel test robot
2021-11-24  9:30 ` [PATCH 10/21] btrfs: move struct scrub_ctx to scrub.h Johannes Thumshirn
2021-11-26 16:48   ` David Sterba
2021-11-24  9:30 ` [PATCH 11/21] btrfs: zoned: move fill_writer_pointer_gap to zoned code Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 12/21] btrfs: zoned: sync_write_pointer_for_zoned " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 13/21] btrfs: make scrub_submit and scrub_wr_submit non-static Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 14/21] btrfs: zoned: move sync_replace_for_zoned to zoned code Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 15/21] btrfs: zoned: move finish_extent_writes_for_zoned " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 16/21] btrfs: move btrfs_scrub_dev() definition to scrub.h Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 17/21] btrfs: move btrfs_scrub_pause() " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 18/21] btrfs: move btrfs_scrub_continue() " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 19/21] btrfs: move btrfs_scrub_cancel() " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 20/21] btrfs: move btrfs_scrub_cancel_dev() " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 21/21] btrfs: move btrfs_scrub_progress() " Johannes Thumshirn
2021-11-24 16:34 ` [PATCH 00/21] btrfs: first batch of zoned cleanups Josef Bacik
2021-11-25  9:58   ` Johannes Thumshirn

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=20211124174838.GX28560@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=Naohiro.Aota@wdc.com \
    --cc=dsterba@suse.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@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