mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-25 22:40:38 +00:00
btrfs-progs: convert: allow to set a duplicate uuid
Relax the condition about a unique uuid for convert, only print a warning. In case we copy the uuid, it's expected that at the time the conversion starts the uuid is not unique as it sill exists on the source filesystem. In case user sets the uuid manually but it's still the same one as on the source filesystem we should also allow that, so it warns in this case as well. Update the test so it creates a block device where the uuid would be also cached by blkid and lets the non-unique check succeed. Issue: #404 Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
3c7e75eefb
commit
88de623dd2
@ -104,11 +104,10 @@ static int setup_temp_super(int fd, struct btrfs_mkfs_config *cfg,
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (!test_uuid_unique(cfg->fs_uuid)) {
|
||||
error("non-unique UUID: %s", cfg->fs_uuid);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* Caller should make sure the uuid is either unique or OK to
|
||||
* be duplicate in case it's copied from the source filesystem.
|
||||
*/
|
||||
uuid_copy(super->metadata_uuid, super->fsid);
|
||||
} else {
|
||||
uuid_generate(super->fsid);
|
||||
|
@ -1189,6 +1189,8 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize,
|
||||
|
||||
if (convert_flags & CONVERT_FLAG_COPY_FSID) {
|
||||
uuid_unparse(cctx.fs_uuid, mkfs_cfg.fs_uuid);
|
||||
if (!test_uuid_unique(mkfs_cfg.fs_uuid))
|
||||
warning("non-unique UUID (copy): %s", mkfs_cfg.fs_uuid);
|
||||
} else if (fsid[0] == 0) {
|
||||
uuid_t uuid;
|
||||
|
||||
@ -1196,6 +1198,8 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize,
|
||||
uuid_unparse(uuid, mkfs_cfg.fs_uuid);
|
||||
} else {
|
||||
memcpy(mkfs_cfg.fs_uuid, fsid, BTRFS_UUID_UNPARSED_SIZE);
|
||||
if (!test_uuid_unique(mkfs_cfg.fs_uuid))
|
||||
warning("non-unique UUID (user set): %s", mkfs_cfg.fs_uuid);
|
||||
}
|
||||
|
||||
printf("Source filesystem:\n");
|
||||
|
@ -5,9 +5,12 @@ source "$TEST_TOP/common"
|
||||
source "$TEST_TOP/common.convert"
|
||||
|
||||
setup_root_helper
|
||||
prepare_test_dev
|
||||
check_prereq btrfs-convert
|
||||
check_global_prereq mke2fs
|
||||
setup_loopdevs 1
|
||||
prepare_loopdevs
|
||||
# Convert helpers need the backing file, can't pass ${loopdevs[1]}
|
||||
TEST_DEV=${loopdev_prefix}1
|
||||
|
||||
convert_test_prep_fs ext4 mke2fs -t ext4 -b 4096
|
||||
run_check_umount_test_dev
|
||||
@ -55,3 +58,5 @@ run_check "$TOP/btrfs-convert" --rollback "$TEST_DEV"
|
||||
|
||||
run_mustfail "invalid UUID passed" \
|
||||
"$TOP/btrfs-convert" --uuid invalid "$TEST_DEV"
|
||||
|
||||
cleanup_loopdevs
|
||||
|
Loading…
Reference in New Issue
Block a user