Re: [PATCH 3/3] btrfs: allow BTRFS_IOC_SNAP_DESTROY_V2 to remove ghost subvolume
From: Qu Wenruo <hidden>
Date: 2021-06-30 13:26:35
On 2021/6/30 下午9:16, David Sterba wrote:
On Mon, Jun 28, 2021 at 06:16:37PM +0800, Qu Wenruo wrote:quoted
There is a report from the mail list that some subvolumes don't have any ROOT_REF/BACKREF and has 0 ref. But without an ORPHAN item.Do you have link to the mail report?
Here it is: https://lore.kernel.org/linux-btrfs/CAJ9tZB-G7KZkxGfrADbmHruuEfwyhV1bihUvRZrJ_ypt_iUVKg@mail.gmail.com/T/#t (local)
quoted
Such ghost subvolumes can't be deleted by any ioctl but only rely on btrfs-progs to add ORPHAN item.Is there a way to list such subvolumes from progs?
No, root with 0 ref will not show up in "btrfs subv list". In fact unless we pass @check_ref = false, btrfs_get_fs_root() won't return such ghost root at all.
quoted
Normally kernel only needs to gracefully abort/reject such corrupted structure, but in this case we have all the needed infrastructures and interface to allow BTRFS_IOC_SNAP_DESTROY_V2 to delete it. So add the ability to delete such ghost subvolumes to BTRFS_IOC_SNAP_DESTROY_V2.So this is only extending the functionality and we don't need to handle backward compatibility.
Exactly. In fact, I hope we never need to bother such case in the future... Thanks, Qu