Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Nikolay Borisov <nborisov@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 7/8] btrfs-progs: check: Implement removing received data for RW subvols
Date: Tue, 14 Sep 2021 17:25:43 +0800	[thread overview]
Message-ID: <15295190-51cb-7fff-c9dd-1f604a177064@gmx.com> (raw)
In-Reply-To: <20210914090558.79411-8-nborisov@suse.com>



On 2021/9/14 下午5:05, Nikolay Borisov wrote:
> Making a received subvolume RO should preclude doing an incremental send
> of said subvolume since it can't be guaranteed that nothing changed in
> the structure and this in turn has correctness implications for send.
>
> There is a pending kernel change that implements this behavior and
> ensures that in the future RO volumes which are switched to RW can't be
> used for incremental send. However, old kernels won't have that patch
> backported. To ensure there is a supported way for users to put their
> subvolumes in sane state let's implement the same functionality in
> progs.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>   check/main.c        | 16 +++++++++++++++-
>   check/mode-lowmem.c | 11 ++++++++++-
>   2 files changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/check/main.c b/check/main.c
> index 6369bdd90656..9d3822a2ebae 100644
> --- a/check/main.c
> +++ b/check/main.c
> @@ -3544,6 +3544,7 @@ static int check_fs_root(struct btrfs_root *root,
>   	int ret = 0;
>   	int err = 0;
>   	bool generation_err = false;
> +	bool rw_received_err = false;
>   	int wret;
>   	int level;
>   	u64 super_generation;
> @@ -3658,6 +3659,19 @@ static int check_fs_root(struct btrfs_root *root,
>   					sizeof(found_key)));
>   	}
>
> +	if (!((btrfs_root_flags(root_item) & BTRFS_ROOT_SUBVOL_RDONLY) ||
> +			btrfs_is_empty_uuid(root_item->received_uuid))) {
> +		error("Subvolume id: %llu is RW and has a received uuid",
> +				root->root_key.objectid);
> +		rw_received_err = true;
> +		if (repair) {
> +			ret = repair_received_subvol(root);
> +			if (ret)
> +				return ret;
> +			rw_received_err = false;
> +		}
> +	}
> +
>   	while (1) {
>   		ctx.item_count++;
>   		wret = walk_down_tree(root, &path, wc, &level, &nrefs);
> @@ -3722,7 +3736,7 @@ static int check_fs_root(struct btrfs_root *root,
>
>   	free_corrupt_blocks_tree(&corrupt_blocks);
>   	gfs_info->corrupt_blocks = NULL;
> -	if (!ret && generation_err)
> +	if (!ret && (generation_err ||  rw_received_err))
>   		ret = -1;
>   	return ret;
>   }
> diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
> index 323e66bc4cb1..d8f783bea424 100644
> --- a/check/mode-lowmem.c
> +++ b/check/mode-lowmem.c
> @@ -5197,8 +5197,17 @@ static int check_btrfs_root(struct btrfs_root *root, int check_all)
>   		ret = check_fs_first_inode(root);
>   		if (ret < 0)
>   			return FATAL_ERROR;
> -	}
>
> +		if (!((btrfs_root_flags(root_item) & BTRFS_ROOT_SUBVOL_RDONLY) ||
> +					btrfs_is_empty_uuid(root_item->received_uuid))) {
> +			error("Subvolume id: %llu is RW and has a received uuid",
> +				  root->root_key.objectid);
> +			if (repair)
> +				ret = repair_received_subvol(root);
> +			if (ret < 0)
> +				return FATAL_ERROR;
> +		}

Not sure if we need to error out completely.

I guess continue the check would be better?

Despite that, everything looks good to me.

Thanks,
Qu
> +	}
>
>   	level = btrfs_header_level(root->node);
>   	btrfs_init_path(&path);
>

  reply	other threads:[~2021-09-14  9:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14  9:05 [PATCH v2 0/8] Implement progs support for removing received uuid on RW vols Nikolay Borisov
2021-09-14  9:05 ` [PATCH v2 1/8] btrfs-progs: Add btrfs_is_empty_uuid Nikolay Borisov
2021-09-16  7:26   ` Anand Jain
2021-09-20 11:41     ` David Sterba
2021-09-14  9:05 ` [PATCH v2 2/8] btrfs-progs: Remove root argument from btrfs_fixup_low_keys Nikolay Borisov
2021-09-14  9:05 ` [PATCH v2 3/8] btrfs-progs: Remove fs_info argument from leaf_data_end Nikolay Borisov
2021-09-14  9:05 ` [PATCH v2 4/8] btrfs-progs: Remove root argument from btrfs_truncate_item Nikolay Borisov
2021-09-14  9:05 ` [PATCH v2 5/8] btrfs-progs: Add btrfs_uuid_tree_remove Nikolay Borisov
2021-09-14  9:22   ` Qu Wenruo
2021-09-14  9:05 ` [PATCH v2 6/8] btrfs-progs: Implement helper to remove received information of RW subvol Nikolay Borisov
2021-09-14  9:23   ` Qu Wenruo
2021-09-14  9:05 ` [PATCH v2 7/8] btrfs-progs: check: Implement removing received data for RW subvols Nikolay Borisov
2021-09-14  9:25   ` Qu Wenruo [this message]
2021-09-14  9:55     ` Nikolay Borisov
2021-09-14  9:05 ` [PATCH v2 8/8] btrfs-progs: tests: Add test for received information removal Nikolay Borisov
2021-09-14  9:30 ` [PATCH v2 0/8] Implement progs support for removing received uuid on RW vols Qu Wenruo
2021-09-14  9:30 ` Qu Wenruo
2021-09-14  9:31   ` Nikolay Borisov
2021-09-21 18:51 ` David Sterba
2021-09-21 22:08   ` Graham Cobb

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=15295190-51cb-7fff-c9dd-1f604a177064@gmx.com \
    --to=quwenruo.btrfs@gmx.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