Re: [PATCH 2/5] btrfs: fix transaction leak and crash after cleaning up orphans on RO mount
From: Filipe Manana <fdmanana@kernel.org>
Date: 2021-03-16 11:44:30
On Tue, Mar 16, 2021 at 6:49 AM robbieko [off-list ref] wrote:
Hi All, The patch delayed find orphan roots. Move to after orphan cleanup with tree_root. I think this will cause all orphan items to be deleted when orphan cleanup with tree_root. Afterwards, find orphan roots cannot find the subvolume being deleted.
Not entirely able to parse what you are trying to say. I suppose your concern is that the call to: btrfs_orphan_cleanup(fs_info->tree_root) which now happens before calling btrfs_find_orphan_roots(), results in the orphans for roots being accidentally deleted and therefore cause no root deletions to happen later? If that's your concern, than it does not happen because btrfs_orphan_cleanup() skips deletion of orphan items for deleted roots. I've just created a test case to verify it's correct, for RW mounts, RO mounts and remounts from RO to RW: https://pastebin.com/raw/zSZjgn48 I couldn't find any regression. Thanks.
quoted
out: return ret; }@@ -3383,10 +3384,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device } } - ret = btrfs_find_orphan_roots(fs_info); - if (ret) - goto fail_qgroup; - fs_info->fs_root = btrfs_get_fs_root(fs_info, BTRFS_FS_TREE_OBJECTID, true); if (IS_ERR(fs_info->fs_root)) { err = PTR_ERR(fs_info->fs_root);