All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: dsterba@suse.cz, linux-btrfs@vger.kernel.org, dsterba@suse.com,
	nborisov@suse.com, josef@toxicpanda.com
Subject: Re: [PATCH 3/3] btrfs: free alien device due to device add
Date: Tue, 5 May 2020 19:02:50 +0200	[thread overview]
Message-ID: <20200505170250.GU18421@twin.jikos.cz> (raw)
In-Reply-To: <af735fb7-e03d-b143-5eef-5b1b32c283bd@oracle.com>

On Sat, May 02, 2020 at 04:01:28AM +0800, Anand Jain wrote:
>   Ah. I didn't notice that. Will fix.
> 
> > As there's NULL passed, 
> 
>   NULL is passed to the 2nd argument skip_device
> 
> > all stale devices will be removed from the list,
> 
>   No, It means it does not have any particular device to skip.
>   Added device is already part of mounted fs_device list,
>   the loop skips its check. So no need to skip_device.
> 
> > but we can remove just the device being added, no?
> 
>   It does exactly that.
>   btrfs_free_stale_devices(device_path, NULL);
> 
>   It removes the device from all other fs_devices which are _unmounted_.

Right, I got it wrong.

> > And before the whole
> > operation starts, not after. 
> 
>   What if the add fails? Then we have to add scanned device back to avoid
>   that mess. why not remove after we have successfully add the device
>   to the mounted fsid.

As there's no synchronization, there will be either need for a rollback
action or stale information after the change is permanent (device added
to new filesystem) but no fs_devices update happens.

The difference is that when the device is removed first, the rollback
happens only in exceptional cases, when the commit fails.

OTOH the time window between commit and removal happens each time. The
ohly hope here is that the window is really short so there's practically
zero chance of another process to jump in trying to use the device.

  reply	other threads:[~2020-05-05 17:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 15:22 [PATCH v3 REBASED 0/3] btrfs: fix issues due to alien device Anand Jain
2020-04-28 15:22 ` [PATCH 1/3] btrfs: drop useless goto in open_fs_devices Anand Jain
2020-04-30 14:09   ` David Sterba
2020-04-28 15:22 ` [PATCH 2/3] btrfs: include non-missing as a qualifier for the latest_bdev Anand Jain
2020-04-30 13:46   ` David Sterba
2020-05-01 22:54     ` Anand Jain
2020-04-28 15:22 ` [PATCH 3/3] btrfs: free alien device due to device add Anand Jain
2020-04-30 13:31   ` David Sterba
2020-05-01 20:01     ` Anand Jain
2020-05-05 17:02       ` David Sterba [this message]
2020-05-04 18:58   ` [PATCH v4 2/3] btrfs: include non-missing as a qualifier for the latest_bdev Anand Jain
2020-05-04 18:58   ` [PATCH v4 3/3] btrfs: free alien device due to device add Anand Jain
2020-05-05 19:34     ` David Sterba
2020-05-05 23:40       ` Anand Jain
2020-04-30  6:05 ` [PATCH v3 REBASED 0/3] btrfs: fix issues due to alien device Nikolay Borisov
2020-04-30 17:54   ` Anand Jain
2020-04-30 10:28     ` Nikolay Borisov
2020-05-01 19:45       ` 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=20200505170250.GU18421@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.