aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/dev-replace.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/dev-replace.c')
-rw-r--r--fs/btrfs/dev-replace.c56
1 files changed, 32 insertions, 24 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 2cfc3dfff64f..564c92638b20 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -102,7 +102,8 @@ no_valid_dev_replace_entry_found:
102 ptr = btrfs_item_ptr(eb, slot, struct btrfs_dev_replace_item); 102 ptr = btrfs_item_ptr(eb, slot, struct btrfs_dev_replace_item);
103 103
104 if (item_size != sizeof(struct btrfs_dev_replace_item)) { 104 if (item_size != sizeof(struct btrfs_dev_replace_item)) {
105 pr_warn("btrfs: dev_replace entry found has unexpected size, ignore entry\n"); 105 btrfs_warn(fs_info,
106 "dev_replace entry found has unexpected size, ignore entry");
106 goto no_valid_dev_replace_entry_found; 107 goto no_valid_dev_replace_entry_found;
107 } 108 }
108 109
@@ -145,13 +146,19 @@ no_valid_dev_replace_entry_found:
145 if (!dev_replace->srcdev && 146 if (!dev_replace->srcdev &&
146 !btrfs_test_opt(dev_root, DEGRADED)) { 147 !btrfs_test_opt(dev_root, DEGRADED)) {
147 ret = -EIO; 148 ret = -EIO;
148 pr_warn("btrfs: cannot mount because device replace operation is ongoing and\n" "srcdev (devid %llu) is missing, need to run 'btrfs dev scan'?\n", 149 btrfs_warn(fs_info,
149 src_devid); 150 "cannot mount because device replace operation is ongoing and");
151 btrfs_warn(fs_info,
152 "srcdev (devid %llu) is missing, need to run 'btrfs dev scan'?",
153 src_devid);
150 } 154 }
151 if (!dev_replace->tgtdev && 155 if (!dev_replace->tgtdev &&
152 !btrfs_test_opt(dev_root, DEGRADED)) { 156 !btrfs_test_opt(dev_root, DEGRADED)) {
153 ret = -EIO; 157 ret = -EIO;
154 pr_warn("btrfs: cannot mount because device replace operation is ongoing and\n" "tgtdev (devid %llu) is missing, need to run btrfs dev scan?\n", 158 btrfs_warn(fs_info,
159 "cannot mount because device replace operation is ongoing and");
160 btrfs_warn(fs_info,
161 "tgtdev (devid %llu) is missing, need to run 'btrfs dev scan'?",
155 BTRFS_DEV_REPLACE_DEVID); 162 BTRFS_DEV_REPLACE_DEVID);
156 } 163 }
157 if (dev_replace->tgtdev) { 164 if (dev_replace->tgtdev) {
@@ -210,7 +217,7 @@ int btrfs_run_dev_replace(struct btrfs_trans_handle *trans,
210 } 217 }
211 ret = btrfs_search_slot(trans, dev_root, &key, path, -1, 1); 218 ret = btrfs_search_slot(trans, dev_root, &key, path, -1, 1);
212 if (ret < 0) { 219 if (ret < 0) {
213 pr_warn("btrfs: error %d while searching for dev_replace item!\n", 220 btrfs_warn(fs_info, "error %d while searching for dev_replace item!",
214 ret); 221 ret);
215 goto out; 222 goto out;
216 } 223 }
@@ -230,7 +237,7 @@ int btrfs_run_dev_replace(struct btrfs_trans_handle *trans,
230 */ 237 */
231 ret = btrfs_del_item(trans, dev_root, path); 238 ret = btrfs_del_item(trans, dev_root, path);
232 if (ret != 0) { 239 if (ret != 0) {
233 pr_warn("btrfs: delete too small dev_replace item failed %d!\n", 240 btrfs_warn(fs_info, "delete too small dev_replace item failed %d!",
234 ret); 241 ret);
235 goto out; 242 goto out;
236 } 243 }
@@ -243,7 +250,7 @@ int btrfs_run_dev_replace(struct btrfs_trans_handle *trans,
243 ret = btrfs_insert_empty_item(trans, dev_root, path, 250 ret = btrfs_insert_empty_item(trans, dev_root, path,
244 &key, sizeof(*ptr)); 251 &key, sizeof(*ptr));
245 if (ret < 0) { 252 if (ret < 0) {
246 pr_warn("btrfs: insert dev_replace item failed %d!\n", 253 btrfs_warn(fs_info, "insert dev_replace item failed %d!",
247 ret); 254 ret);
248 goto out; 255 goto out;
249 } 256 }
@@ -305,7 +312,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
305 struct btrfs_device *src_device = NULL; 312 struct btrfs_device *src_device = NULL;
306 313
307 if (btrfs_fs_incompat(fs_info, RAID56)) { 314 if (btrfs_fs_incompat(fs_info, RAID56)) {
308 pr_warn("btrfs: dev_replace cannot yet handle RAID5/RAID6\n"); 315 btrfs_warn(fs_info, "dev_replace cannot yet handle RAID5/RAID6");
309 return -EINVAL; 316 return -EINVAL;
310 } 317 }
311 318
@@ -325,7 +332,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
325 ret = btrfs_init_dev_replace_tgtdev(root, args->start.tgtdev_name, 332 ret = btrfs_init_dev_replace_tgtdev(root, args->start.tgtdev_name,
326 &tgt_device); 333 &tgt_device);
327 if (ret) { 334 if (ret) {
328 pr_err("btrfs: target device %s is invalid!\n", 335 btrfs_err(fs_info, "target device %s is invalid!",
329 args->start.tgtdev_name); 336 args->start.tgtdev_name);
330 mutex_unlock(&fs_info->volume_mutex); 337 mutex_unlock(&fs_info->volume_mutex);
331 return -EINVAL; 338 return -EINVAL;
@@ -341,7 +348,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
341 } 348 }
342 349
343 if (tgt_device->total_bytes < src_device->total_bytes) { 350 if (tgt_device->total_bytes < src_device->total_bytes) {
344 pr_err("btrfs: target device is smaller than source device!\n"); 351 btrfs_err(fs_info, "target device is smaller than source device!");
345 ret = -EINVAL; 352 ret = -EINVAL;
346 goto leave_no_lock; 353 goto leave_no_lock;
347 } 354 }
@@ -366,7 +373,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
366 dev_replace->tgtdev = tgt_device; 373 dev_replace->tgtdev = tgt_device;
367 374
368 printk_in_rcu(KERN_INFO 375 printk_in_rcu(KERN_INFO
369 "btrfs: dev_replace from %s (devid %llu) to %s started\n", 376 "BTRFS: dev_replace from %s (devid %llu) to %s started\n",
370 src_device->missing ? "<missing disk>" : 377 src_device->missing ? "<missing disk>" :
371 rcu_str_deref(src_device->name), 378 rcu_str_deref(src_device->name),
372 src_device->devid, 379 src_device->devid,
@@ -489,7 +496,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
489 496
490 if (scrub_ret) { 497 if (scrub_ret) {
491 printk_in_rcu(KERN_ERR 498 printk_in_rcu(KERN_ERR
492 "btrfs: btrfs_scrub_dev(%s, %llu, %s) failed %d\n", 499 "BTRFS: btrfs_scrub_dev(%s, %llu, %s) failed %d\n",
493 src_device->missing ? "<missing disk>" : 500 src_device->missing ? "<missing disk>" :
494 rcu_str_deref(src_device->name), 501 rcu_str_deref(src_device->name),
495 src_device->devid, 502 src_device->devid,
@@ -504,7 +511,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
504 } 511 }
505 512
506 printk_in_rcu(KERN_INFO 513 printk_in_rcu(KERN_INFO
507 "btrfs: dev_replace from %s (devid %llu) to %s) finished\n", 514 "BTRFS: dev_replace from %s (devid %llu) to %s) finished\n",
508 src_device->missing ? "<missing disk>" : 515 src_device->missing ? "<missing disk>" :
509 rcu_str_deref(src_device->name), 516 rcu_str_deref(src_device->name),
510 src_device->devid, 517 src_device->devid,
@@ -699,7 +706,7 @@ void btrfs_dev_replace_suspend_for_unmount(struct btrfs_fs_info *fs_info)
699 BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED; 706 BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED;
700 dev_replace->time_stopped = get_seconds(); 707 dev_replace->time_stopped = get_seconds();
701 dev_replace->item_needs_writeback = 1; 708 dev_replace->item_needs_writeback = 1;
702 pr_info("btrfs: suspending dev_replace for unmount\n"); 709 btrfs_info(fs_info, "suspending dev_replace for unmount");
703 break; 710 break;
704 } 711 }
705 712
@@ -728,8 +735,9 @@ int btrfs_resume_dev_replace_async(struct btrfs_fs_info *fs_info)
728 break; 735 break;
729 } 736 }
730 if (!dev_replace->tgtdev || !dev_replace->tgtdev->bdev) { 737 if (!dev_replace->tgtdev || !dev_replace->tgtdev->bdev) {
731 pr_info("btrfs: cannot continue dev_replace, tgtdev is missing\n" 738 btrfs_info(fs_info, "cannot continue dev_replace, tgtdev is missing");
732 "btrfs: you may cancel the operation after 'mount -o degraded'\n"); 739 btrfs_info(fs_info,
740 "you may cancel the operation after 'mount -o degraded'");
733 btrfs_dev_replace_unlock(dev_replace); 741 btrfs_dev_replace_unlock(dev_replace);
734 return 0; 742 return 0;
735 } 743 }
@@ -755,14 +763,14 @@ static int btrfs_dev_replace_kthread(void *data)
755 kfree(status_args); 763 kfree(status_args);
756 do_div(progress, 10); 764 do_div(progress, 10);
757 printk_in_rcu(KERN_INFO 765 printk_in_rcu(KERN_INFO
758 "btrfs: continuing dev_replace from %s (devid %llu) to %s @%u%%\n", 766 "BTRFS: continuing dev_replace from %s (devid %llu) to %s @%u%%\n",
759 dev_replace->srcdev->missing ? "<missing disk>" : 767 dev_replace->srcdev->missing ? "<missing disk>" :
760 rcu_str_deref(dev_replace->srcdev->name), 768 rcu_str_deref(dev_replace->srcdev->name),
761 dev_replace->srcdev->devid, 769 dev_replace->srcdev->devid,
762 dev_replace->tgtdev ? 770 dev_replace->tgtdev ?
763 rcu_str_deref(dev_replace->tgtdev->name) : 771 rcu_str_deref(dev_replace->tgtdev->name) :
764 "<missing target disk>", 772 "<missing target disk>",
765 (unsigned int)progress); 773 (unsigned int)progress);
766 } 774 }
767 btrfs_dev_replace_continue_on_mount(fs_info); 775 btrfs_dev_replace_continue_on_mount(fs_info);
768 atomic_set(&fs_info->mutually_exclusive_operation_running, 0); 776 atomic_set(&fs_info->mutually_exclusive_operation_running, 0);