btrfs-progs: prepare the latest device's superblock for commit

Add a flag to copy the superblock of the latest device to the
fs_info::super_copy for the commit process, rather than using the
superblock from the device specified in the argument.

This serves as groundwork to enable recovery from an incomplete
btrfstune -M|m|u|U operation.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Anand Jain 2023-08-14 23:28:06 +08:00 committed by David Sterba
parent 9f6e0ab2a4
commit 66c4c9632f
2 changed files with 8 additions and 0 deletions

View File

@ -1513,6 +1513,9 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, struct open_ctree_args *oca
if (flags & OPEN_CTREE_RECOVER_SUPER)
ret = btrfs_read_dev_super(fs_devices->latest_bdev, disk_super,
sb_bytenr, SBREAD_RECOVER);
else if (flags & OPEN_CTREE_USE_LATEST_BDEV)
ret = btrfs_read_dev_super(fs_devices->latest_bdev, disk_super,
sb_bytenr, sbflags);
else
ret = btrfs_read_dev_super(fp, disk_super, sb_bytenr,
sbflags);

View File

@ -104,6 +104,11 @@ enum btrfs_open_ctree_flags {
* specific checks and only do the superficial checks.
*/
OPEN_CTREE_SKIP_LEAF_ITEM_CHECKS = (1U << 17),
/*
* Use the superblock of the latest device for the transaction commit.
*/
OPEN_CTREE_USE_LATEST_BDEV = (1U << 18),
};
/*