btrfs-progs: tune: convert printf to message helpers
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
7f0035c9d1
commit
85f49ce2cd
|
@ -102,7 +102,6 @@ static int change_extents_csum(struct btrfs_fs_info *fs_info, int csum_type)
|
|||
goto out;
|
||||
}
|
||||
/* Only rewrite block */
|
||||
/* printf("CSUM: start %llu\n", eb->start); */
|
||||
ret = write_tree_block(NULL, fs_info, eb);
|
||||
free_extent_buffer(eb);
|
||||
if (ret < 0) {
|
||||
|
@ -196,8 +195,9 @@ static int fill_csum_tree_from_extent(struct btrfs_fs_info *fs_info)
|
|||
|
||||
trans = btrfs_start_transaction(extent_root, 1);
|
||||
if (trans == NULL) {
|
||||
/* fixme */
|
||||
printf("cannot start transaction\n");
|
||||
ret = PTR_ERR(trans);
|
||||
errno = -ret;
|
||||
error_msg(ERROR_MSG_START_TRANS, "%m");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ int rewrite_checksums(struct btrfs_root *root, int csum_type)
|
|||
fs_info->force_csum_type = csum_type;
|
||||
|
||||
/* Step 1 sets the in progress flag, no other change to the sb */
|
||||
printf("Set superblock flag CHANGING_CSUM\n");
|
||||
pr_verbose(LOG_DEFAULT, "Set superblock flag CHANGING_CSUM\n");
|
||||
trans = btrfs_start_transaction(root, 1);
|
||||
super_flags |= BTRFS_SUPER_FLAG_CHANGING_CSUM;
|
||||
btrfs_set_super_flags(disk_super, super_flags);
|
||||
|
@ -291,7 +291,7 @@ int rewrite_checksums(struct btrfs_root *root, int csum_type)
|
|||
return ret;
|
||||
|
||||
/* Change extents first */
|
||||
printf("Change fsid in extents\n");
|
||||
pr_verbose(LOG_DEFAULT, "Change fsid in extents\n");
|
||||
ret = change_extents_csum(fs_info, csum_type);
|
||||
if (ret < 0) {
|
||||
error("failed to change csum of metadata: %d", ret);
|
||||
|
@ -299,7 +299,7 @@ int rewrite_checksums(struct btrfs_root *root, int csum_type)
|
|||
}
|
||||
|
||||
/* Then devices */
|
||||
printf("Change csum in chunk tree\n");
|
||||
pr_verbose(LOG_DEFAULT, "Change csum in chunk tree\n");
|
||||
ret = change_devices_csum(fs_info->chunk_root, csum_type);
|
||||
if (ret < 0) {
|
||||
error("failed to change UUID of devices: %d", ret);
|
||||
|
@ -307,7 +307,7 @@ int rewrite_checksums(struct btrfs_root *root, int csum_type)
|
|||
}
|
||||
|
||||
/* DATA */
|
||||
printf("Change csum of data blocks\n");
|
||||
pr_verbose(LOG_DEFAULT, "Change csum of data blocks\n");
|
||||
ret = fill_csum_tree_from_extent(fs_info);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
@ -318,13 +318,13 @@ int rewrite_checksums(struct btrfs_root *root, int csum_type)
|
|||
goto out;
|
||||
|
||||
/* All checksums done, drop the flag, super block csum will get updated */
|
||||
printf("Clear superblock flag CHANGING_CSUM\n");
|
||||
pr_verbose(LOG_DEFAULT, "Clear superblock flag CHANGING_CSUM\n");
|
||||
super_flags = btrfs_super_flags(fs_info->super_copy);
|
||||
super_flags &= ~BTRFS_SUPER_FLAG_CHANGING_CSUM;
|
||||
btrfs_set_super_flags(fs_info->super_copy, super_flags);
|
||||
btrfs_set_super_csum_type(disk_super, csum_type);
|
||||
ret = write_all_supers(fs_info);
|
||||
printf("Checksum change finished\n");
|
||||
pr_verbose(LOG_DEFAULT, "Checksum change finished\n");
|
||||
out:
|
||||
/* check errors */
|
||||
|
||||
|
|
|
@ -264,18 +264,18 @@ int change_uuid(struct btrfs_fs_info *fs_info, const char *new_fsid_str)
|
|||
|
||||
memcpy(old_fsid, (const char*)fs_info->fs_devices->fsid, BTRFS_UUID_SIZE);
|
||||
uuid_unparse(old_fsid, uuid_buf);
|
||||
printf("Current fsid: %s\n", uuid_buf);
|
||||
pr_verbose(LOG_DEFAULT, "Current fsid: %s\n", uuid_buf);
|
||||
|
||||
uuid_unparse(new_fsid, uuid_buf);
|
||||
printf("New fsid: %s\n", uuid_buf);
|
||||
pr_verbose(LOG_DEFAULT, "New fsid: %s\n", uuid_buf);
|
||||
/* Now we can begin fsid change */
|
||||
printf("Set superblock flag CHANGING_FSID\n");
|
||||
pr_verbose(LOG_DEFAULT, "Set superblock flag CHANGING_FSID\n");
|
||||
ret = change_fsid_prepare(fs_info, new_fsid);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
/* Change extents first */
|
||||
printf("Change fsid in extents\n");
|
||||
pr_verbose(LOG_DEFAULT, "Change fsid in extents\n");
|
||||
ret = change_extents_uuid(fs_info, new_fsid);
|
||||
if (ret < 0) {
|
||||
error("failed to change UUID of metadata: %d", ret);
|
||||
|
@ -283,7 +283,7 @@ int change_uuid(struct btrfs_fs_info *fs_info, const char *new_fsid_str)
|
|||
}
|
||||
|
||||
/* Then devices */
|
||||
printf("Change fsid on devices\n");
|
||||
pr_verbose(LOG_DEFAULT, "Change fsid on devices\n");
|
||||
ret = change_devices_uuid(fs_info->chunk_root, new_fsid);
|
||||
if (ret < 0) {
|
||||
error("failed to change UUID of devices: %d", ret);
|
||||
|
@ -298,10 +298,10 @@ int change_uuid(struct btrfs_fs_info *fs_info, const char *new_fsid_str)
|
|||
goto out;
|
||||
|
||||
/* Now fsid change is done */
|
||||
printf("Clear superblock flag CHANGING_FSID\n");
|
||||
pr_verbose(LOG_DEFAULT, "Clear superblock flag CHANGING_FSID\n");
|
||||
ret = change_fsid_done(fs_info);
|
||||
fs_info->new_chunk_tree_uuid = NULL;
|
||||
printf("Fsid change finished\n");
|
||||
pr_verbose(LOG_DEFAULT, "Fsid change finished\n");
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ iterate_bgs:
|
|||
error_msg(ERROR_MSG_COMMIT_TRANS, "final transaction: %m");
|
||||
return ret;
|
||||
}
|
||||
printf("Converted the filesystem to block group tree feature\n");
|
||||
pr_verbose(LOG_DEFAULT, "Converted the filesystem to block group tree feature\n");
|
||||
return 0;
|
||||
error:
|
||||
btrfs_abort_transaction(trans, ret);
|
||||
|
|
|
@ -116,6 +116,8 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[])
|
|||
u64 super_flags = 0;
|
||||
int fd = -1;
|
||||
|
||||
btrfs_config_init();
|
||||
|
||||
while(1) {
|
||||
enum { GETOPT_VAL_CSUM = GETOPT_VAL_FIRST };
|
||||
static const struct option long_options[] = {
|
||||
|
@ -177,7 +179,7 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[])
|
|||
"Switching checksums is experimental, do not use for valuable data!");
|
||||
ctree_flags |= OPEN_CTREE_SKIP_CSUM_CHECK;
|
||||
csum_type = parse_csum_type(optarg);
|
||||
printf("Switch csum to %s\n",
|
||||
pr_verbose(LOG_DEFAULT, "Switch csum to %s\n",
|
||||
btrfs_super_csum_name(csum_type));
|
||||
break;
|
||||
#endif
|
||||
|
@ -294,7 +296,7 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[])
|
|||
|
||||
if (csum_type != -1) {
|
||||
/* TODO: check conflicting flags */
|
||||
printf("Proceed to switch checksums\n");
|
||||
pr_verbose(LOG_DEFAULT, "Proceed to switch checksums\n");
|
||||
ret = rewrite_checksums(root, csum_type);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue