]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/btrfs/dev-replace.c
Merge branch 'ttm-fixes-3.13' of git://people.freedesktop.org/~thomash/linux into...
[karo-tx-linux.git] / fs / btrfs / dev-replace.c
index 9efb94e95858e8c53cb84f587b74a064e8701dc4..342f9fd411e3f5d79c15f675300ebcabad95738b 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/kthread.h>
 #include <linux/math64.h>
 #include <asm/div64.h>
-#include "compat.h"
 #include "ctree.h"
 #include "extent_map.h"
 #include "disk-io.h"
@@ -38,7 +37,6 @@
 #include "rcu-string.h"
 #include "dev-replace.h"
 
-static u64 btrfs_get_seconds_since_1970(void);
 static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
                                       int scrub_ret);
 static 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)
                dev_replace->cursor_left_last_write_of_item;
 }
 
-static u64 btrfs_get_seconds_since_1970(void)
-{
-       struct timespec t = CURRENT_TIME_SEC;
-
-       return t.tv_sec;
-}
-
 int btrfs_dev_replace_start(struct btrfs_root *root,
                            struct btrfs_ioctl_dev_replace_args *args)
 {
@@ -390,7 +381,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
         * go to the tgtdev as well (refer to btrfs_map_block()).
         */
        dev_replace->replace_state = BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED;
-       dev_replace->time_started = btrfs_get_seconds_since_1970();
+       dev_replace->time_started = get_seconds();
        dev_replace->cursor_left = 0;
        dev_replace->committed_cursor_left = 0;
        dev_replace->cursor_left_last_write_of_item = 0;
@@ -400,7 +391,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
        args->result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
        btrfs_dev_replace_unlock(dev_replace);
 
-       btrfs_wait_all_ordered_extents(root->fs_info);
+       btrfs_wait_ordered_roots(root->fs_info, -1);
 
        /* force writing the updated state information to disk */
        trans = btrfs_start_transaction(root, 0);
@@ -470,12 +461,12 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
         * flush all outstanding I/O and inode extent mappings before the
         * copy operation is declared as being finished
         */
-       ret = btrfs_start_all_delalloc_inodes(root->fs_info, 0);
+       ret = btrfs_start_delalloc_roots(root->fs_info, 0);
        if (ret) {
                mutex_unlock(&dev_replace->lock_finishing_cancel_unmount);
                return ret;
        }
-       btrfs_wait_all_ordered_extents(root->fs_info);
+       btrfs_wait_ordered_roots(root->fs_info, -1);
 
        trans = btrfs_start_transaction(root, 0);
        if (IS_ERR(trans)) {
@@ -493,7 +484,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
                          : BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED;
        dev_replace->tgtdev = NULL;
        dev_replace->srcdev = NULL;
-       dev_replace->time_stopped = btrfs_get_seconds_since_1970();
+       dev_replace->time_stopped = get_seconds();
        dev_replace->item_needs_writeback = 1;
 
        if (scrub_ret) {
@@ -650,6 +641,9 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
        u64 result;
        int ret;
 
+       if (fs_info->sb->s_flags & MS_RDONLY)
+               return -EROFS;
+
        mutex_lock(&dev_replace->lock_finishing_cancel_unmount);
        btrfs_dev_replace_lock(dev_replace);
        switch (dev_replace->replace_state) {
@@ -668,7 +662,7 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
                break;
        }
        dev_replace->replace_state = BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED;
-       dev_replace->time_stopped = btrfs_get_seconds_since_1970();
+       dev_replace->time_stopped = get_seconds();
        dev_replace->item_needs_writeback = 1;
        btrfs_dev_replace_unlock(dev_replace);
        btrfs_scrub_cancel(fs_info);
@@ -703,7 +697,7 @@ void btrfs_dev_replace_suspend_for_unmount(struct btrfs_fs_info *fs_info)
        case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED:
                dev_replace->replace_state =
                        BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED;
-               dev_replace->time_stopped = btrfs_get_seconds_since_1970();
+               dev_replace->time_stopped = get_seconds();
                dev_replace->item_needs_writeback = 1;
                pr_info("btrfs: suspending dev_replace for unmount\n");
                break;