diff options
| author | Anand Jain <anand.jain@oracle.com> | 2017-11-27 21:43:10 -0500 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2018-01-22 10:08:15 -0500 |
| commit | 3c958bd23b60c22947b857d2cb13196e2cc58c58 (patch) | |
| tree | 2d1043ef3f6f633e71ded47ff86eb1de1de6340a /fs/btrfs/dev-replace.c | |
| parent | 38b5f68e98117daa221c7df813608f48c374aef4 (diff) | |
btrfs: add helper for device path or missing
This patch creates a helper function to get either the rcu device path
or missing.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
[ rename to btrfs_dev_name, switch to if/else ]
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/dev-replace.c')
| -rw-r--r-- | fs/btrfs/dev-replace.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 7c655f9a7a50..483eb62b9b27 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
| @@ -304,6 +304,14 @@ void btrfs_after_dev_replace_commit(struct btrfs_fs_info *fs_info) | |||
| 304 | dev_replace->cursor_left_last_write_of_item; | 304 | dev_replace->cursor_left_last_write_of_item; |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | static char* btrfs_dev_name(struct btrfs_device *device) | ||
| 308 | { | ||
| 309 | if (device->missing) | ||
| 310 | return "<missing disk>"; | ||
| 311 | else | ||
| 312 | return rcu_str_deref(device->name); | ||
| 313 | } | ||
| 314 | |||
| 307 | int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, | 315 | int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, |
| 308 | const char *tgtdev_name, u64 srcdevid, const char *srcdev_name, | 316 | const char *tgtdev_name, u64 srcdevid, const char *srcdev_name, |
| 309 | int read_src) | 317 | int read_src) |
| @@ -363,8 +371,7 @@ int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, | |||
| 363 | 371 | ||
| 364 | btrfs_info_in_rcu(fs_info, | 372 | btrfs_info_in_rcu(fs_info, |
| 365 | "dev_replace from %s (devid %llu) to %s started", | 373 | "dev_replace from %s (devid %llu) to %s started", |
| 366 | src_device->missing ? "<missing disk>" : | 374 | btrfs_dev_name(src_device), |
| 367 | rcu_str_deref(src_device->name), | ||
| 368 | src_device->devid, | 375 | src_device->devid, |
| 369 | rcu_str_deref(tgt_device->name)); | 376 | rcu_str_deref(tgt_device->name)); |
| 370 | 377 | ||
| @@ -538,8 +545,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, | |||
| 538 | } else { | 545 | } else { |
| 539 | btrfs_err_in_rcu(fs_info, | 546 | btrfs_err_in_rcu(fs_info, |
| 540 | "btrfs_scrub_dev(%s, %llu, %s) failed %d", | 547 | "btrfs_scrub_dev(%s, %llu, %s) failed %d", |
| 541 | src_device->missing ? "<missing disk>" : | 548 | btrfs_dev_name(src_device), |
| 542 | rcu_str_deref(src_device->name), | ||
| 543 | src_device->devid, | 549 | src_device->devid, |
| 544 | rcu_str_deref(tgt_device->name), scrub_ret); | 550 | rcu_str_deref(tgt_device->name), scrub_ret); |
| 545 | btrfs_dev_replace_unlock(dev_replace, 1); | 551 | btrfs_dev_replace_unlock(dev_replace, 1); |
| @@ -557,8 +563,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, | |||
| 557 | 563 | ||
| 558 | btrfs_info_in_rcu(fs_info, | 564 | btrfs_info_in_rcu(fs_info, |
| 559 | "dev_replace from %s (devid %llu) to %s finished", | 565 | "dev_replace from %s (devid %llu) to %s finished", |
| 560 | src_device->missing ? "<missing disk>" : | 566 | btrfs_dev_name(src_device), |
| 561 | rcu_str_deref(src_device->name), | ||
| 562 | src_device->devid, | 567 | src_device->devid, |
| 563 | rcu_str_deref(tgt_device->name)); | 568 | rcu_str_deref(tgt_device->name)); |
| 564 | tgt_device->is_tgtdev_for_dev_replace = 0; | 569 | tgt_device->is_tgtdev_for_dev_replace = 0; |
| @@ -814,12 +819,10 @@ static int btrfs_dev_replace_kthread(void *data) | |||
| 814 | progress = btrfs_dev_replace_progress(fs_info); | 819 | progress = btrfs_dev_replace_progress(fs_info); |
| 815 | progress = div_u64(progress, 10); | 820 | progress = div_u64(progress, 10); |
| 816 | btrfs_info_in_rcu(fs_info, | 821 | btrfs_info_in_rcu(fs_info, |
| 817 | "continuing dev_replace from %s (devid %llu) to %s @%u%%", | 822 | "continuing dev_replace from %s (devid %llu) to target %s @%u%%", |
| 818 | dev_replace->srcdev->missing ? "<missing disk>" | 823 | btrfs_dev_name(dev_replace->srcdev), |
| 819 | : rcu_str_deref(dev_replace->srcdev->name), | ||
| 820 | dev_replace->srcdev->devid, | 824 | dev_replace->srcdev->devid, |
| 821 | dev_replace->tgtdev ? rcu_str_deref(dev_replace->tgtdev->name) | 825 | btrfs_dev_name(dev_replace->tgtdev), |
| 822 | : "<missing target disk>", | ||
| 823 | (unsigned int)progress); | 826 | (unsigned int)progress); |
| 824 | 827 | ||
| 825 | btrfs_dev_replace_continue_on_mount(fs_info); | 828 | btrfs_dev_replace_continue_on_mount(fs_info); |
