linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: Anand Jain <anand.jain@oracle.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 4/5] btrfs: remove identified alien device in open_fs_devices
Date: Mon, 7 Oct 2019 16:30:02 +0300	[thread overview]
Message-ID: <b370fdd7-2d97-877f-88e6-3624205c8617@suse.com> (raw)
In-Reply-To: <20191007094515.925-5-anand.jain@oracle.com>



On 7.10.19 г. 12:45 ч., Anand Jain wrote:
> Following test case explains it all, even though the degraded mount is
> successful the btrfs-progs fails to report the missing device.
> 
>  mkfs.btrfs -fq -draid1 -mraid1 /dev/sdc /dev/sdd && \
>  wipefs -a /dev/sdd && mount -o degraded /dev/sdc /btrfs && \
>  btrfs fi show -m /btrfs
> 
>  Label: none  uuid: 2b3b8d92-572b-4d37-b4ee-046d3a538495
> 	Total devices 2 FS bytes used 128.00KiB
> 	devid    1 size 1.09TiB used 2.01GiB path /dev/sdc
> 	devid    2 size 1.09TiB used 2.01GiB path /dev/sdd
> 
> This is because btrfs-progs does it fundamentally wrong way that
> it deduces the missing device status in the user land instead of
> refuting from the kernel.
> 
> At the same time in the kernel when we know that there is device
> with non-btrfs magic, then remove that device from the list so
> that btrfs-progs or someother userland utility won't be confused.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  fs/btrfs/disk-io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 326d5281ad93..e05856432456 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -3417,7 +3417,7 @@ int btrfs_read_dev_one_super(struct block_device *bdev, int copy_num,
>  	if (btrfs_super_bytenr(super) != bytenr ||
>  		    btrfs_super_magic(super) != BTRFS_MAGIC) {
>  		brelse(bh);
> -		return -EINVAL;
> +		return -EUCLEAN;

This is really non-obvious and you are propagating the special-meaning
of EUCLEAN waaaaaaaay beyond btrfs_open_one_device. In fact what this
patch does is make the following call chain return EUCLAN:

btrfs_open_one_device <-- finally removing the device in this function
 btrfs_get_bdev_and_sb <-- propagating it to here
  btrfs_read_dev_super
    btrfs_read_dev_one_super <-- you return the EUCLEAN


And your commit log doesn't mention anything about that. EUCLEAN
warrants a comment in this case since it changes behavior in
higher-level layers.

>  	}
>  
>  	*bh_ret = bh;
> 

  reply	other threads:[~2019-10-07 13:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-07  9:45 [PATCH v3 0/5] btrfs: fix issues due to alien device Anand Jain
2019-10-07  9:45 ` [PATCH 1/5] btrfs: drop useless goto in open_fs_devices Anand Jain
2020-01-16 15:52   ` Josef Bacik
2019-10-07  9:45 ` [PATCH 2/5] btrfs: include non-missing as a qualifier for the latest_bdev Anand Jain
2020-01-16 15:52   ` Josef Bacik
2020-01-17  3:01     ` Anand Jain
2019-10-07  9:45 ` [PATCH v3 3/5] btrfs: remove identified alien btrfs device in open_fs_devices Anand Jain
2020-01-16 15:56   ` Josef Bacik
2020-01-17  9:10     ` Anand Jain
2020-01-17 14:23       ` Josef Bacik
2019-10-07  9:45 ` [PATCH 4/5] btrfs: remove identified alien " Anand Jain
2019-10-07 13:30   ` Nikolay Borisov [this message]
2019-10-07 13:37     ` Qu Wenruo
2019-10-07 17:03       ` David Sterba
2019-10-08  3:26         ` Anand Jain
2020-01-15  8:56           ` Anand Jain
2019-10-07  9:45 ` [PATCH 5/5] btrfs: free alien device due to device add Anand Jain
2020-01-16 16:00   ` Josef Bacik
2019-10-07 17:36 ` [PATCH v3 0/5] btrfs: fix issues due to alien device David Sterba
2019-10-08  6:11   ` Anand Jain

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=b370fdd7-2d97-877f-88e6-3624205c8617@suse.com \
    --to=nborisov@suse.com \
    --cc=anand.jain@oracle.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).