public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Boris Burkov <boris@bur.io>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/4] btrfs: forget stray device on failed open
Date: Sat, 16 Mar 2024 18:58:15 +0530	[thread overview]
Message-ID: <25212038-240e-4a4b-b086-ef99fa88fe91@oracle.com> (raw)
In-Reply-To: <20240314170516.GC3483638@zen.localdomain>

On 3/14/24 22:35, Boris Burkov wrote:
> On Sat, Mar 09, 2024 at 07:14:29PM +0530, Anand Jain wrote:
>> If the physical device of a flakey dm device is tried mounting it fails
>> to open the device with handle, and leaves behind a stray single device
>> in the device list.
>>
>> Remove it if the open fails and if it is a single device. As we don't
>> register a single device in the device list unless it is mounted.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   fs/btrfs/super.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
>> index 29fab56c8152..4b73c3a2d7ab 100644
>> --- a/fs/btrfs/super.c
>> +++ b/fs/btrfs/super.c
>> @@ -1820,6 +1820,9 @@ static int btrfs_get_tree_super(struct fs_context *fc)
>>   	fs_info->fs_devices = fs_devices;
>>   
>>   	ret = btrfs_open_devices(fs_devices, mode, &btrfs_fs_type);
>> +	if (ret && fs_devices->total_devices == 1)
>> +		btrfs_free_stale_devices(device->devt, NULL);
>> +
> 
> It feels like we need to do this free no matter what the mount error is
> after this point, not just in this one place.
> 

Indeed. At goto error, btrfs_close_devices() is called, in turn
calls free_fs_devices() for single-device filesystems.

Thanks, Anand


>>   	mutex_unlock(&uuid_mutex);
>>   	if (ret)
>>   		return ret;
>> -- 
>> 2.38.1
>>


  reply	other threads:[~2024-03-16 13:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-09 13:44 [PATCH 0/4] btrfs: enhanced logic for stray single device Anand Jain
2024-03-09 13:44 ` [PATCH 1/4] btrfs: declare btrfs_free_stale_devices non-static Anand Jain
2024-03-09 13:44 ` [PATCH 2/4] btrfs: forget stray device on failed open Anand Jain
2024-03-14 17:05   ` Boris Burkov
2024-03-16 13:28     ` Anand Jain [this message]
2024-03-09 13:44 ` [PATCH 3/4] btrfs: refactor btrfs_free_stale_devices to free single stray device Anand Jain
2024-03-09 13:44 ` [PATCH 4/4] btrfs: validate device_list at scan for stray free Anand Jain
2024-03-14 17:11   ` Boris Burkov
2024-03-16 14:13     ` Anand Jain
2024-03-21 11:19       ` Anand Jain
2024-03-14 13:37 ` [PATCH 0/4] btrfs: enhanced logic for stray single device 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=25212038-240e-4a4b-b086-ef99fa88fe91@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=boris@bur.io \
    --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