aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/dev-replace.c
diff options
context:
space:
mode:
authorPaul Moore <pmoore@redhat.com>2014-01-28 14:44:16 -0500
committerPaul Moore <pmoore@redhat.com>2014-02-05 10:39:48 -0500
commit825e587af2e90e9b953849f3347a01d8f383d577 (patch)
treee48942a05882da47544e179c6a0c920e00137a6a /fs/btrfs/dev-replace.c
parent8ed814602876bec9bad2649ca17f34b499357a1c (diff)
parentd8ec26d7f8287f5788a494f56e8814210f0e64be (diff)
Merge tag 'v3.13' into stable-3.14
Linux 3.13 Conflicts: security/selinux/hooks.c Trivial merge issue in selinux_inet_conn_request() likely due to me including patches that I sent to the stable folks in my next tree resulting in the patch hitting twice (I think). Thankfully it was an easy fix this time, but regardless, lesson learned, I will not do that again.
Diffstat (limited to 'fs/btrfs/dev-replace.c')
-rw-r--r--fs/btrfs/dev-replace.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 9efb94e95858..2cfc3dfff64f 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -26,7 +26,6 @@
26#include <linux/kthread.h> 26#include <linux/kthread.h>
27#include <linux/math64.h> 27#include <linux/math64.h>
28#include <asm/div64.h> 28#include <asm/div64.h>
29#include "compat.h"
30#include "ctree.h" 29#include "ctree.h"
31#include "extent_map.h" 30#include "extent_map.h"
32#include "disk-io.h" 31#include "disk-io.h"
@@ -38,7 +37,6 @@
38#include "rcu-string.h" 37#include "rcu-string.h"
39#include "dev-replace.h" 38#include "dev-replace.h"
40 39
41static u64 btrfs_get_seconds_since_1970(void);
42static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, 40static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
43 int scrub_ret); 41 int scrub_ret);
44static void btrfs_dev_replace_update_device_in_mapping_tree( 42static void btrfs_dev_replace_update_device_in_mapping_tree(
@@ -296,13 +294,6 @@ void btrfs_after_dev_replace_commit(struct btrfs_fs_info *fs_info)
296 dev_replace->cursor_left_last_write_of_item; 294 dev_replace->cursor_left_last_write_of_item;
297} 295}
298 296
299static u64 btrfs_get_seconds_since_1970(void)
300{
301 struct timespec t = CURRENT_TIME_SEC;
302
303 return t.tv_sec;
304}
305
306int btrfs_dev_replace_start(struct btrfs_root *root, 297int btrfs_dev_replace_start(struct btrfs_root *root,
307 struct btrfs_ioctl_dev_replace_args *args) 298 struct btrfs_ioctl_dev_replace_args *args)
308{ 299{
@@ -375,7 +366,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
375 dev_replace->tgtdev = tgt_device; 366 dev_replace->tgtdev = tgt_device;
376 367
377 printk_in_rcu(KERN_INFO 368 printk_in_rcu(KERN_INFO
378 "btrfs: dev_replace from %s (devid %llu) to %s) started\n", 369 "btrfs: dev_replace from %s (devid %llu) to %s started\n",
379 src_device->missing ? "<missing disk>" : 370 src_device->missing ? "<missing disk>" :
380 rcu_str_deref(src_device->name), 371 rcu_str_deref(src_device->name),
381 src_device->devid, 372 src_device->devid,
@@ -390,7 +381,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
390 * go to the tgtdev as well (refer to btrfs_map_block()). 381 * go to the tgtdev as well (refer to btrfs_map_block()).
391 */ 382 */
392 dev_replace->replace_state = BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED; 383 dev_replace->replace_state = BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED;
393 dev_replace->time_started = btrfs_get_seconds_since_1970(); 384 dev_replace->time_started = get_seconds();
394 dev_replace->cursor_left = 0; 385 dev_replace->cursor_left = 0;
395 dev_replace->committed_cursor_left = 0; 386 dev_replace->committed_cursor_left = 0;
396 dev_replace->cursor_left_last_write_of_item = 0; 387 dev_replace->cursor_left_last_write_of_item = 0;
@@ -400,7 +391,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
400 args->result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR; 391 args->result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
401 btrfs_dev_replace_unlock(dev_replace); 392 btrfs_dev_replace_unlock(dev_replace);
402 393
403 btrfs_wait_all_ordered_extents(root->fs_info); 394 btrfs_wait_ordered_roots(root->fs_info, -1);
404 395
405 /* force writing the updated state information to disk */ 396 /* force writing the updated state information to disk */
406 trans = btrfs_start_transaction(root, 0); 397 trans = btrfs_start_transaction(root, 0);
@@ -470,12 +461,12 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
470 * flush all outstanding I/O and inode extent mappings before the 461 * flush all outstanding I/O and inode extent mappings before the
471 * copy operation is declared as being finished 462 * copy operation is declared as being finished
472 */ 463 */
473 ret = btrfs_start_all_delalloc_inodes(root->fs_info, 0); 464 ret = btrfs_start_delalloc_roots(root->fs_info, 0);
474 if (ret) { 465 if (ret) {
475 mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); 466 mutex_unlock(&dev_replace->lock_finishing_cancel_unmount);
476 return ret; 467 return ret;
477 } 468 }
478 btrfs_wait_all_ordered_extents(root->fs_info); 469 btrfs_wait_ordered_roots(root->fs_info, -1);
479 470
480 trans = btrfs_start_transaction(root, 0); 471 trans = btrfs_start_transaction(root, 0);
481 if (IS_ERR(trans)) { 472 if (IS_ERR(trans)) {
@@ -493,7 +484,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
493 : BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED; 484 : BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED;
494 dev_replace->tgtdev = NULL; 485 dev_replace->tgtdev = NULL;
495 dev_replace->srcdev = NULL; 486 dev_replace->srcdev = NULL;
496 dev_replace->time_stopped = btrfs_get_seconds_since_1970(); 487 dev_replace->time_stopped = get_seconds();
497 dev_replace->item_needs_writeback = 1; 488 dev_replace->item_needs_writeback = 1;
498 489
499 if (scrub_ret) { 490 if (scrub_ret) {
@@ -650,6 +641,9 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
650 u64 result; 641 u64 result;
651 int ret; 642 int ret;
652 643
644 if (fs_info->sb->s_flags & MS_RDONLY)
645 return -EROFS;
646
653 mutex_lock(&dev_replace->lock_finishing_cancel_unmount); 647 mutex_lock(&dev_replace->lock_finishing_cancel_unmount);
654 btrfs_dev_replace_lock(dev_replace); 648 btrfs_dev_replace_lock(dev_replace);
655 switch (dev_replace->replace_state) { 649 switch (dev_replace->replace_state) {
@@ -668,7 +662,7 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
668 break; 662 break;
669 } 663 }
670 dev_replace->replace_state = BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED; 664 dev_replace->replace_state = BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED;
671 dev_replace->time_stopped = btrfs_get_seconds_since_1970(); 665 dev_replace->time_stopped = get_seconds();
672 dev_replace->item_needs_writeback = 1; 666 dev_replace->item_needs_writeback = 1;
673 btrfs_dev_replace_unlock(dev_replace); 667 btrfs_dev_replace_unlock(dev_replace);
674 btrfs_scrub_cancel(fs_info); 668 btrfs_scrub_cancel(fs_info);
@@ -703,7 +697,7 @@ void btrfs_dev_replace_suspend_for_unmount(struct btrfs_fs_info *fs_info)
703 case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED: 697 case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED:
704 dev_replace->replace_state = 698 dev_replace->replace_state =
705 BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED; 699 BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED;
706 dev_replace->time_stopped = btrfs_get_seconds_since_1970(); 700 dev_replace->time_stopped = get_seconds();
707 dev_replace->item_needs_writeback = 1; 701 dev_replace->item_needs_writeback = 1;
708 pr_info("btrfs: suspending dev_replace for unmount\n"); 702 pr_info("btrfs: suspending dev_replace for unmount\n");
709 break; 703 break;