* Deleting mounted subvolumes
@ 2017-07-02 21:33 Pete
2017-07-02 23:30 ` Hans van Kranenburg
0 siblings, 1 reply; 7+ messages in thread
From: Pete @ 2017-07-02 21:33 UTC (permalink / raw)
To: linux-btrfs
I found that I can delete a mounted subvolume using:
btrfs subvolume delete <mounted sub volume>
This works. Is this the intended action? To me it would seem like a
warning and the command exiting would make sense?
Pete
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Deleting mounted subvolumes
2017-07-02 21:33 Deleting mounted subvolumes Pete
@ 2017-07-02 23:30 ` Hans van Kranenburg
2017-07-03 20:48 ` Pete
0 siblings, 1 reply; 7+ messages in thread
From: Hans van Kranenburg @ 2017-07-02 23:30 UTC (permalink / raw)
To: Pete, linux-btrfs
On 07/02/2017 11:33 PM, Pete wrote:
> I found that I can delete a mounted subvolume using:
> btrfs subvolume delete <mounted sub volume>
>
> This works. Is this the intended action? To me it would seem like a
> warning and the command exiting would make sense?
Yes, you can do that. It's a bit similar to the fact that you can also
delete a regular file when it's still open by another program.
But, still having a file open (inode, filedescriptor, what's it
called...) does actually block the cleaner process from progressing
beyond that point.
You can also delete a subvolume which is not separately mounted, while a
process still has open files in it.
In case of deleting a mounted subvolume... it's a bit different. As long
as it's mounted, even if nothing else is using a file within, it won't
be actually completely deleted in the background, unless the final
umount is done. What can happen (I just tried it) is that the mount
point ends up looking completely empty already in the meantime, as soon
as no files are open and after I cd .. out of it. If I cd back into the
mount point, there's nothing any more and any action to create something
new within will end up with a "No such file or directory".
Only when doing the umount, the subvolume completely disappears.
--
Hans van Kranenburg
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Deleting mounted subvolumes
2017-07-02 23:30 ` Hans van Kranenburg
@ 2017-07-03 20:48 ` Pete
2017-07-03 21:38 ` Hans van Kranenburg
0 siblings, 1 reply; 7+ messages in thread
From: Pete @ 2017-07-03 20:48 UTC (permalink / raw)
To: linux-btrfs
On 07/03/2017 12:30 AM, Hans van Kranenburg wrote:
> On 07/02/2017 11:33 PM, Pete wrote:
>> I found that I can delete a mounted subvolume using:
>> btrfs subvolume delete <mounted sub volume>
>>
>> This works. Is this the intended action? To me it would seem like a
>> warning and the command exiting would make sense?
>
> Yes, you can do that. It's a bit similar to the fact that you can also
> delete a regular file when it's still open by another program.
I was expecting it to behave somewhat like trying to unmount an active
filesystem, where you are prevented from doing so.
Aside: the way I found out was that the backup script I was writing,
rather than deleting the read only snapshots deleted the source
subvolumes, nearly everything on the system apart from the snapshots...
> But, still having a file open (inode, filedescriptor, what's it
> called...) does actually block the cleaner process from progressing
> beyond that point.
>
> You can also delete a subvolume which is not separately mounted, while a
> process still has open files in it.
>
You'd have to do that from within the mounted parent subvolume, I think,
so that looks more normal?
> In case of deleting a mounted subvolume... it's a bit different. As long
> as it's mounted, even if nothing else is using a file within, it won't
> be actually completely deleted in the background, unless the final
> umount is done. What can happen (I just tried it) is that the mount
> point ends up looking completely empty already in the meantime, as soon
> as no files are open and after I cd .. out of it. If I cd back into the
> mount point, there's nothing any more and any action to create something
> new within will end up with a "No such file or directory".
>
> Only when doing the umount, the subvolume completely disappears.
>
So provided I did not unmount the deleted subvols then I could actually
have undeleted them? Of does that require developer level skills? Too
late now, and I recovered from snapshots and a little data from the
backup drive. Also I'd think dangerous to offer this option as people
might assume they could rely on it which might be a dangerous assumption.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Deleting mounted subvolumes
2017-07-03 20:48 ` Pete
@ 2017-07-03 21:38 ` Hans van Kranenburg
2017-07-03 23:21 ` Chris Murphy
0 siblings, 1 reply; 7+ messages in thread
From: Hans van Kranenburg @ 2017-07-03 21:38 UTC (permalink / raw)
To: Pete, linux-btrfs
On 07/03/2017 10:48 PM, Pete wrote:
> On 07/03/2017 12:30 AM, Hans van Kranenburg wrote:
>> On 07/02/2017 11:33 PM, Pete wrote:
>>> I found that I can delete a mounted subvolume using:
>>> btrfs subvolume delete <mounted sub volume>
>>>
>>> This works. Is this the intended action? To me it would seem like a
>>> warning and the command exiting would make sense?
>>
>> Yes, you can do that. It's a bit similar to the fact that you can also
>> delete a regular file when it's still open by another program.
>
> I was expecting it to behave somewhat like trying to unmount an active
> filesystem, where you are prevented from doing so.
>
> Aside: the way I found out was that the backup script I was writing,
> rather than deleting the read only snapshots deleted the source
> subvolumes, nearly everything on the system apart from the snapshots...
Heh.. :)
>> But, still having a file open (inode, filedescriptor, what's it
>> called...) does actually block the cleaner process from progressing
>> beyond that point.
>>
>> You can also delete a subvolume which is not separately mounted, while a
>> process still has open files in it.
>>
>
> You'd have to do that from within the mounted parent subvolume, I think,
> so that looks more normal?
>
>> In case of deleting a mounted subvolume... it's a bit different. As long
>> as it's mounted, even if nothing else is using a file within, it won't
>> be actually completely deleted in the background, unless the final
>> umount is done. What can happen (I just tried it) is that the mount
>> point ends up looking completely empty already in the meantime, as soon
>> as no files are open and after I cd .. out of it. If I cd back into the
>> mount point, there's nothing any more and any action to create something
>> new within will end up with a "No such file or directory".
>>
>> Only when doing the umount, the subvolume completely disappears.
>>
>
> So provided I did not unmount the deleted subvols then I could actually
> have undeleted them? Of does that require developer level skills? Too
> late now, and I recovered from snapshots and a little data from the
> backup drive. Also I'd think dangerous to offer this option as people
> might assume they could rely on it which might be a dangerous assumption.
Not really, it's halfway gone through the grinder already. Deleting a
subvolume means looking at all the files that are in the filetree of
that subvolume, looking at all extents they reference, and then for all
of those extents lower reference counts, and free all space for extents
that are not used by anyone else any more.
If that's done, then removing the actual filesystem root object if it's
held by some mount reference (as I imagine it would be) in the kernel is
just the last straw.
--
Hans van Kranenburg
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Deleting mounted subvolumes
2017-07-03 21:38 ` Hans van Kranenburg
@ 2017-07-03 23:21 ` Chris Murphy
2017-07-04 0:32 ` Duncan
2017-07-04 3:42 ` Andrei Borzenkov
0 siblings, 2 replies; 7+ messages in thread
From: Chris Murphy @ 2017-07-03 23:21 UTC (permalink / raw)
To: Hans van Kranenburg; +Cc: Pete, Btrfs BTRFS
It's more like a bind mount of a directory, as far as what's going on
under the hood. I take it it's possible to delete a directory that is
bind mounted elsewhere? I'm not sure what happens though.
Chris Murphy
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Deleting mounted subvolumes
2017-07-03 23:21 ` Chris Murphy
@ 2017-07-04 0:32 ` Duncan
2017-07-04 3:42 ` Andrei Borzenkov
1 sibling, 0 replies; 7+ messages in thread
From: Duncan @ 2017-07-04 0:32 UTC (permalink / raw)
To: linux-btrfs
Chris Murphy posted on Mon, 03 Jul 2017 17:21:18 -0600 as excerpted:
> It's more like a bind mount of a directory, as far as what's going on
> under the hood. I take it it's possible to delete a directory that is
> bind mounted elsewhere? I'm not sure what happens though.
Yes, deleting a directory in a rw-mounted bind-mount is possible, as is
simply modifying an existing file.
What makes this "interesting" is the possibility that either the original
mount or (at least) one of the bind-mounts is mounted ro, while the one
you'd delete the directory in would obviously be rw in ordered for it to
work, making it very possible for the contents of an ro mount to change!
IOW, if there ever was a day when read-only meant unchangeable, that day
is long gone. Just because it's read-only does NOT mean it's
unchangeable!
--
Duncan - List replies preferred. No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master." Richard Stallman
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Deleting mounted subvolumes
2017-07-03 23:21 ` Chris Murphy
2017-07-04 0:32 ` Duncan
@ 2017-07-04 3:42 ` Andrei Borzenkov
1 sibling, 0 replies; 7+ messages in thread
From: Andrei Borzenkov @ 2017-07-04 3:42 UTC (permalink / raw)
To: Chris Murphy, Hans van Kranenburg; +Cc: Pete, Btrfs BTRFS
04.07.2017 02:21, Chris Murphy пишет:
> It's more like a bind mount of a directory, as far as what's going on
> under the hood. I take it it's possible to delete a directory that is
> bind mounted elsewhere?
Yes, it is. Usual rules apply - it must be empty, but "rm -r" works as
well (and is more or less what happens when you delete subvolume is I
get it right).
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-07-04 3:42 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-02 21:33 Deleting mounted subvolumes Pete
2017-07-02 23:30 ` Hans van Kranenburg
2017-07-03 20:48 ` Pete
2017-07-03 21:38 ` Hans van Kranenburg
2017-07-03 23:21 ` Chris Murphy
2017-07-04 0:32 ` Duncan
2017-07-04 3:42 ` Andrei Borzenkov
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).