Linux-BTRFS Archive on lore.kernel.org
 help / color / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Anand Jain <anand.jain@oracle.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 5/5] btrfs: free alien device due to device add
Date: Thu, 16 Jan 2020 11:00:32 -0500
Message-ID: <c78edb05-c277-6345-d7b5-7d05d6a4559c@toxicpanda.com> (raw)
In-Reply-To: <20191007094515.925-6-anand.jain@oracle.com>

On 10/7/19 5:45 AM, Anand Jain wrote:
> When the old device has new fsid through btrfs device add -f <dev> our
> fs_devices list has an alien device in one of the fs_devices.
> 
> By having an alien device in fs_devices, we have two issues so far
> 
> 1. missing device is not shows as missing in the userland
> 
> Which is due to cracks in the function btrfs_open_one_device() and
> hardened by patch
>   btrfs: delete identified alien device in open_fs_devices
> 
> 2. mount of a degraded fs_devices fails
> 
> Which is due to cracks in the function btrfs_free_extra_devids() and
> hardened by patch
>   btrfs: include non-missing as a qualifier for the latest_bdev
> 
> Now the reason for both of this issue is that there is an alien (does not
> contain the intended fsid) device in the fs_devices.
> 
> We know a device can be scanned/added through
> btrfs-control::BTRFS_IOC_SCAN_DEV|BTRFS_IOC_DEVICES_READY
> or by
> ioctl::BTRFS_IOC_ADD_DEV
> 
> And device coming through btrfs-control is checked against the all other
> devices in btrfs kernel but not coming through BTRFS_IOC_ADD_DEV.
> 
> This patch checks if the device add is alienating any other scanned
> device and deletes it.
> 
> In fact, this patch fixes both the issues 1 and 2 (above) by eliminating
> the source of the issue, but still they have their own patch as well
> because its the right way to harden the functions and fill the cracks.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

I agree, but mostly because btrfs_scan_one_device(), which is what gets called 
by the control thingy, does this in the case that it adds a device.  This patch 
makes add dev consistent with the normal scanning stuff, so I'm ok with it.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

  reply index

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
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 [this message]
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 publically 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=c78edb05-c277-6345-d7b5-7d05d6a4559c@toxicpanda.com \
    --to=josef@toxicpanda.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

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org
	public-inbox-index linux-btrfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git