Skip to content

Commit f1b8a1e

Browse files
committed
btrfs: simplify btrfs_dev_replace_kthread
This function prints an informative message and then continues dev-replace. The message contains a progress percentage which is read from the status. The status is allocated dynamically, about 2600 bytes, just to read the single value. That's an overkill. We'll use the new helper and drop the allocation. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 74b595f commit f1b8a1e

1 file changed

Lines changed: 11 additions & 17 deletions

File tree

‎fs/btrfs/dev-replace.c‎

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -809,25 +809,19 @@ static int btrfs_dev_replace_kthread(void *data)
809809
{
810810
struct btrfs_fs_info *fs_info = data;
811811
struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
812-
struct btrfs_ioctl_dev_replace_args *status_args;
813812
u64 progress;
814813

815-
status_args = kzalloc(sizeof(*status_args), GFP_KERNEL);
816-
if (status_args) {
817-
btrfs_dev_replace_status(fs_info, status_args);
818-
progress = status_args->status.progress_1000;
819-
kfree(status_args);
820-
progress = div_u64(progress, 10);
821-
btrfs_info_in_rcu(fs_info,
822-
"continuing dev_replace from %s (devid %llu) to %s @%u%%",
823-
dev_replace->srcdev->missing ? "<missing disk>" :
824-
rcu_str_deref(dev_replace->srcdev->name),
825-
dev_replace->srcdev->devid,
826-
dev_replace->tgtdev ?
827-
rcu_str_deref(dev_replace->tgtdev->name) :
828-
"<missing target disk>",
829-
(unsigned int)progress);
830-
}
814+
progress = btrfs_dev_replace_progress(fs_info);
815+
progress = div_u64(progress, 10);
816+
btrfs_info_in_rcu(fs_info,
817+
"continuing dev_replace from %s (devid %llu) to %s @%u%%",
818+
dev_replace->srcdev->missing ? "<missing disk>"
819+
: rcu_str_deref(dev_replace->srcdev->name),
820+
dev_replace->srcdev->devid,
821+
dev_replace->tgtdev ? rcu_str_deref(dev_replace->tgtdev->name)
822+
: "<missing target disk>",
823+
(unsigned int)progress);
824+
831825
btrfs_dev_replace_continue_on_mount(fs_info);
832826
clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);
833827

0 commit comments

Comments
 (0)