diff mbox series

[2/5] btrfs-progs: tune use the latest bdev in fs_devices for super_copy

Message ID c76f142e562f0c337cbd657b07fd9105e5ff34c4.1692963810.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: recover from failed metadata_uuid port kernel | expand

Commit Message

Anand Jain Aug. 25, 2023, 2:47 p.m. UTC
btrfstune relies on the superblock of the device specified in the
btrfstune argument for fs_info::super_copy. Instead, should use
fs_devices::latest_bdev.

To support for reuniting devices following past failures of
btrfstune -m|M|u|U as in the following patch, use
fs_devices::latest_bdev.

 btrfs-progs: add support to fix superblock with CHANGING_FSID_V2 flag
 btrfs-progs: recover from the failed btrfstune -m|M

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tune/main.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

David Sterba Aug. 28, 2023, 3:27 p.m. UTC | #1
On Fri, Aug 25, 2023 at 10:47:48PM +0800, Anand Jain wrote:
> btrfstune relies on the superblock of the device specified in the
> btrfstune argument for fs_info::super_copy. Instead, should use
> fs_devices::latest_bdev.

This lacks explanatni why it should use it, it's not obvious.

> To support for reuniting devices following past failures of
> btrfstune -m|M|u|U as in the following patch, use
> fs_devices::latest_bdev.
> 
>  btrfs-progs: add support to fix superblock with CHANGING_FSID_V2 flag
>  btrfs-progs: recover from the failed btrfstune -m|M
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
Anand Jain Aug. 28, 2023, 10:43 p.m. UTC | #2
Currently, btrfstune relies on the superblock of the device specified
in the btrfstune argument for fs_info::super_copy. However, it should
use fs_devices::latest_bdev, as it points to the device with the highest
fs_devices::generation number. This will contain the superblock updates
that other devices may have missed and we can now support reuniting
devices following failures of btrfstune -m|M|u|U as in the patches:

    btrfs-progs: add support to fix superblock with CHANGING_FSID_V2 flag
    btrfs-progs: recover from the failed btrfstune -m|M


> This lacks explanatni why it should use it, it's not obvious.

Could you please use the commit log above, or let me know
if a reroll is preferred?

Thanks, Anand
diff mbox series

Patch

diff --git a/tune/main.c b/tune/main.c
index d344cdad06e1..7d2e2fb3b97d 100644
--- a/tune/main.c
+++ b/tune/main.c
@@ -290,6 +290,9 @@  int BOX_MAIN(btrfstune)(int argc, char *argv[])
 		goto free_out;
 	}
 
+	if (change_metadata_uuid || random_fsid || new_fsid_str)
+		ctree_flags |= OPEN_CTREE_USE_LATEST_BDEV;
+
 	root = open_ctree_fd(fd, device, 0, ctree_flags);
 
 	if (!root) {