Merge branch 'samsung/fixes' of git+ssh://master.kernel.org/pub/scm/linux/kernel...
[firefly-linux-kernel-4.4.55.git] / fs / btrfs / extent-tree.c
index a3e71b59f66e3deb34ec617b682ba2372b520131..f5be06a2462f4b01b5bba3834c1527a3a0c5bf18 100644 (file)
@@ -6277,8 +6277,8 @@ static noinline int walk_up_tree(struct btrfs_trans_handle *trans,
  * also make sure backrefs for the shared block and all lower level
  * blocks are properly updated.
  */
-int btrfs_drop_snapshot(struct btrfs_root *root,
-                       struct btrfs_block_rsv *block_rsv, int update_ref)
+void btrfs_drop_snapshot(struct btrfs_root *root,
+                        struct btrfs_block_rsv *block_rsv, int update_ref)
 {
        struct btrfs_path *path;
        struct btrfs_trans_handle *trans;
@@ -6291,13 +6291,16 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
        int level;
 
        path = btrfs_alloc_path();
-       if (!path)
-               return -ENOMEM;
+       if (!path) {
+               err = -ENOMEM;
+               goto out;
+       }
 
        wc = kzalloc(sizeof(*wc), GFP_NOFS);
        if (!wc) {
                btrfs_free_path(path);
-               return -ENOMEM;
+               err = -ENOMEM;
+               goto out;
        }
 
        trans = btrfs_start_transaction(tree_root, 0);
@@ -6326,7 +6329,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
                path->lowest_level = 0;
                if (ret < 0) {
                        err = ret;
-                       goto out;
+                       goto out_free;
                }
                WARN_ON(ret > 0);
 
@@ -6433,11 +6436,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
                free_extent_buffer(root->commit_root);
                kfree(root);
        }
-out:
+out_free:
        btrfs_end_transaction_throttle(trans, tree_root);
        kfree(wc);
        btrfs_free_path(path);
-       return err;
+out:
+       if (err)
+               btrfs_std_error(root->fs_info, err);
+       return;
 }
 
 /*
@@ -6729,9 +6735,9 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
        struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices;
        struct btrfs_device *device;
        u64 min_free;
+       u64 dev_min = 1;
+       u64 dev_nr = 0;
        int index;
-       int dev_nr = 0;
-       int dev_min = 1;
        int full = 0;
        int ret = 0;
 
@@ -6790,14 +6796,16 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
        index = get_block_group_index(block_group);
        if (index == 0) {
                dev_min = 4;
-               min_free /= 2;
+               /* Divide by 2 */
+               min_free >>= 1;
        } else if (index == 1) {
                dev_min = 2;
        } else if (index == 2) {
-               min_free *= 2;
+               /* Multiply by 2 */
+               min_free <<= 1;
        } else if (index == 3) {
                dev_min = fs_devices->rw_devices;
-               min_free /= dev_min;
+               do_div(min_free, dev_min);
        }
 
        mutex_lock(&root->fs_info->chunk_mutex);