public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: damenly.su@gmail.com, linux-btrfs@vger.kernel.org
Cc: Su Yue <Damenly_Su@gmx.com>
Subject: Re: [PATCH 1/6] btrfs: metadata_uuid: fix failed assertion due to unsuccessful device scan
Date: Thu, 12 Dec 2019 16:15:36 +0200	[thread overview]
Message-ID: <78eab88a-a6be-f87b-34d7-13a1cffbf36b@suse.com> (raw)
In-Reply-To: <20191212110132.11063-2-Damenly_Su@gmx.com>



On 12.12.19 г. 13:01 ч., damenly.su@gmail.com wrote:

<snip>

> Acutally, there are two devices in the fs. Device 2 with
> FSID_CHANGING_V2 allocated a fs_devices. But, device 1 found the
> fs_devices but failed to be added into since fs_devices->opened (

It's not clear why device 1 wasn't able to be added to the fs_devices
allocated by dev 2. Please elaborate?


> the thread is doing mount device 1). But device 1's fsid was copied
> to fs_devices->fsid then the assertion failed.


dev 1 fsid should be copied iff its transid is newer.

> 
> The solution is that only if a new device was added into a existing
> fs_device, then the fs_devices->fsid is allowed to be rewritten.

fs_devices->fsid must be re-written by any device which is _newer_ w.r.t
to the transid.

> 
> Fixes: 7a62d0f07377 ("btrfs: Handle one more split-brain scenario during fsid change")
> Signed-off-by: Su Yue <Damenly_Su@gmx.com>
> ---
>  fs/btrfs/volumes.c | 36 +++++++++++++++++++++---------------
>  1 file changed, 21 insertions(+), 15 deletions(-)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index d8e5560db285..9efa4123c335 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -732,6 +732,9 @@ static noinline struct btrfs_device *device_list_add(const char *path,
>  		BTRFS_FEATURE_INCOMPAT_METADATA_UUID);
>  	bool fsid_change_in_progress = (btrfs_super_flags(disk_super) &
>  					BTRFS_SUPER_FLAG_CHANGING_FSID_V2);
> +	bool fs_devices_found = false;
> +
> +	*new_device_added = false;
>  
>  	if (fsid_change_in_progress) {
>  		if (!has_metadata_uuid) {
> @@ -772,24 +775,11 @@ static noinline struct btrfs_device *device_list_add(const char *path,
>  
>  		device = NULL;
>  	} else {
> +		fs_devices_found = true;
> +
>  		mutex_lock(&fs_devices->device_list_mutex);
>  		device = btrfs_find_device(fs_devices, devid,
>  				disk_super->dev_item.uuid, NULL, false);
> -
> -		/*
> -		 * If this disk has been pulled into an fs devices created by
> -		 * a device which had the CHANGING_FSID_V2 flag then replace the
> -		 * metadata_uuid/fsid values of the fs_devices.
> -		 */
> -		if (has_metadata_uuid && fs_devices->fsid_change &&
> -		    found_transid > fs_devices->latest_generation) {
> -			memcpy(fs_devices->fsid, disk_super->fsid,
> -					BTRFS_FSID_SIZE);
> -			memcpy(fs_devices->metadata_uuid,
> -					disk_super->metadata_uuid, BTRFS_FSID_SIZE);
> -
> -			fs_devices->fsid_change = false;
> -		}
>  	}
>  
>  	if (!device) {
> @@ -912,6 +902,22 @@ static noinline struct btrfs_device *device_list_add(const char *path,
>  		}
>  	}
>  
> +	/*
> +	 * If the new added disk has been pulled into an fs devices created by
> +	 * a device which had the CHANGING_FSID_V2 flag then replace the
> +	 * metadata_uuid/fsid values of the fs_devices.
> +	 */
> +	if (*new_device_added && fs_devices_found &&
> +	    has_metadata_uuid && fs_devices->fsid_change &&
> +	    found_transid > fs_devices->latest_generation) {
> +		memcpy(fs_devices->fsid, disk_super->fsid,
> +		       BTRFS_FSID_SIZE);
> +		memcpy(fs_devices->metadata_uuid,
> +		       disk_super->metadata_uuid, BTRFS_FSID_SIZE);
> +
> +		fs_devices->fsid_change = false;
> +	}
> +
>  	/*
>  	 * Unmount does not free the btrfs_device struct but would zero
>  	 * generation along with most of the other members. So just update
> 

  reply	other threads:[~2019-12-12 14:15 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-12 11:01 [PATCH 0/6] btrfs: metadata uuid fixes and enhancements damenly.su
2019-12-12 11:01 ` [PATCH 1/6] btrfs: metadata_uuid: fix failed assertion due to unsuccessful device scan damenly.su
2019-12-12 14:15   ` Nikolay Borisov [this message]
2019-12-13  2:30     ` Su Yue
2019-12-13  2:46     ` [PATCH 1/6] btrfs: metadata_uuid: fix failed assertion due to unsuccessful device scan (reformatted) Su Yue
2019-12-13  5:36       ` Anand Jain
2019-12-13  7:15         ` Su Yue
2019-12-13  8:51           ` Anand Jain
2019-12-13 10:10             ` Su Yue
2019-12-12 11:01 ` [PATCH 2/6] btrfs: metadata_uuid: move split-brain handling from fs_id() to new function damenly.su
2019-12-12 13:05   ` Nikolay Borisov
2019-12-12 13:32     ` Su Yue
2019-12-12 11:01 ` [PATCH 3/6] btrfs: split-brain case for scanned changing device with INCOMPAT_METADATA_UUID damenly.su
2019-12-12 13:24   ` Su Yue
2019-12-12 13:34   ` Nikolay Borisov
2019-12-12 14:19     ` Su Yue
2019-12-12 11:01 ` [PATCH 4/6] btrfs: split-brain case for scanned changed device without INCOMPAT_METADATA_UUID damenly.su
2019-12-12 11:01 ` [PATCH 5/6] btrfs: copy fsid and metadata_uuid for pulled disk " damenly.su
2020-01-06 15:12   ` Nikolay Borisov
2020-01-07  1:31     ` Su Yue
2020-01-07  7:18       ` Nikolay Borisov
2020-01-07  7:34         ` Su Yue
2019-12-12 11:01 ` [PATCH 6/6] btrfs: metadata_uuid: move partly logic into find_fsid_inprogress() damenly.su
2019-12-12 13:37   ` Nikolay Borisov
2019-12-13  8:03 ` [PATCH 0/6] btrfs: metadata uuid fixes and enhancements Nikolay Borisov
2019-12-16  0:49   ` Su Yue

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=78eab88a-a6be-f87b-34d7-13a1cffbf36b@suse.com \
    --to=nborisov@suse.com \
    --cc=Damenly_Su@gmx.com \
    --cc=damenly.su@gmail.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