From: Kaiwen Hu <kevinhu@synology.com>
To: dsterba@suse.cz, Qu Wenruo <quwenruo.btrfs@gmx.com>,
linux-btrfs@vger.kernel.org, robbieko@synology.com,
cccheng@synology.com, seanding@synology.com
Subject: Re: [PATCH] btrfs: prevent subvol with swapfile from being deleted
Date: Wed, 23 Mar 2022 11:13:50 +0800 [thread overview]
Message-ID: <71bc3a52-ae07-3030-49f1-6cc176a0f16e@synology.com> (raw)
In-Reply-To: <20220322193932.GI12643@twin.jikos.cz>
On 3/23/2022 3:39 AM, David Sterba wrote:
> On Tue, Mar 22, 2022 at 06:47:59PM +0800, Qu Wenruo wrote:
>> This looks a little weird to me.
>>
>> If the root is already dead, it means we should not be able to access
>> any file inside the subvolume.
>>
>> How could we go into btrfs_swap_activate() while the root is already dead?
>>
>> Or is there some special race I missed?
> The deletion has a few steps, eg. the dentry is removed, root is marked
> as dead and different thing locking protection.
>
> I was wondering about file descriptor access to the subvolume and
> calling swapon on that, but swapon/swapoff is a syscall and work with a
> path argument so that can't happen. I haven't checked in what order are
> the dentry removal and dead flag done, it could be theoretically
> possible that there's a short window where the dentry is accessible and
> subvolume already marked.
Thanks for david's help. Yes, it is possible the subvolume is marked
for deletion, but still not remove yet. So like
|btrfs_ioctl_send()|doing, I check the dead-root mark before activating
swapfile to prevent the race condition.
Thanks,
Kaiwen Hu
next prev parent reply other threads:[~2022-03-23 3:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-22 10:27 [PATCH] btrfs: prevent subvol with swapfile from being deleted Kaiwen Hu
2022-03-22 10:47 ` Qu Wenruo
2022-03-22 19:39 ` David Sterba
2022-03-23 3:13 ` Kaiwen Hu [this message]
2022-03-23 4:40 ` Qu Wenruo
2022-03-23 7:10 ` [PATCH v2] " Kaiwen Hu
2022-03-23 7:59 ` Qu Wenruo
2022-03-23 12:34 ` David Sterba
2022-03-23 13:33 ` Filipe Manana
2022-03-23 13:37 ` Filipe Manana
2022-03-23 21:45 ` David Sterba
2022-03-24 4:59 ` Kaiwen Hu
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=71bc3a52-ae07-3030-49f1-6cc176a0f16e@synology.com \
--to=kevinhu@synology.com \
--cc=cccheng@synology.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo.btrfs@gmx.com \
--cc=robbieko@synology.com \
--cc=seanding@synology.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox