]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
Merge git://git.kernel.org/pub/scm/linux/kernel/git/josef/btrfs-next.git for-chris...
authorChris Mason <chris.mason@fusionio.com>
Wed, 6 Feb 2013 00:24:44 +0000 (19:24 -0500)
committerChris Mason <chris.mason@fusionio.com>
Wed, 6 Feb 2013 00:24:44 +0000 (19:24 -0500)
1  2 
fs/btrfs/volumes.c

diff --combined fs/btrfs/volumes.c
index 485a5423e3c6152fd752c4f7aab9f5ee9911a3e0,15f6efdf6463589531f8d1507b74c9d8afd35a3d..5cbb7f4b16720fc3c3442ffb09752983195836a5
@@@ -1431,7 -1431,7 +1431,7 @@@ int btrfs_rm_device(struct btrfs_root *
                }
        } else {
                ret = btrfs_get_bdev_and_sb(device_path,
-                                           FMODE_READ | FMODE_EXCL,
+                                           FMODE_WRITE | FMODE_EXCL,
                                            root->fs_info->bdev_holder, 0,
                                            &bdev, &bh);
                if (ret)
        ret = 0;
  
        /* Notify udev that device has changed */
 -      btrfs_kobject_uevent(bdev, KOBJ_CHANGE);
 +      if (bdev)
 +              btrfs_kobject_uevent(bdev, KOBJ_CHANGE);
  
  error_brelse:
        brelse(bh);
@@@ -2615,7 -2614,14 +2615,14 @@@ static int chunk_usage_filter(struct bt
        cache = btrfs_lookup_block_group(fs_info, chunk_offset);
        chunk_used = btrfs_block_group_used(&cache->item);
  
-       user_thresh = div_factor_fine(cache->key.offset, bargs->usage);
+       if (bargs->usage == 0)
+               user_thresh = 0;
+       else if (bargs->usage > 100)
+               user_thresh = cache->key.offset;
+       else
+               user_thresh = div_factor_fine(cache->key.offset,
+                                             bargs->usage);
        if (chunk_used < user_thresh)
                ret = 0;
  
@@@ -2960,6 -2966,8 +2967,8 @@@ static void __cancel_balance(struct btr
        unset_balance_control(fs_info);
        ret = del_balance_item(fs_info->tree_root);
        BUG_ON(ret);
+       atomic_set(&fs_info->mutually_exclusive_operation_running, 0);
  }
  
  void update_ioctl_balance_args(struct btrfs_fs_info *fs_info, int lock,
@@@ -3139,8 -3147,10 +3148,10 @@@ int btrfs_balance(struct btrfs_balance_
  out:
        if (bctl->flags & BTRFS_BALANCE_RESUME)
                __cancel_balance(fs_info);
-       else
+       else {
                kfree(bctl);
+               atomic_set(&fs_info->mutually_exclusive_operation_running, 0);
+       }
        return ret;
  }
  
@@@ -3157,7 -3167,6 +3168,6 @@@ static int balance_kthread(void *data
                ret = btrfs_balance(fs_info->balance_ctl, NULL);
        }
  
-       atomic_set(&fs_info->mutually_exclusive_operation_running, 0);
        mutex_unlock(&fs_info->balance_mutex);
        mutex_unlock(&fs_info->volume_mutex);
  
@@@ -3180,7 -3189,6 +3190,6 @@@ int btrfs_resume_balance_async(struct b
                return 0;
        }
  
-       WARN_ON(atomic_xchg(&fs_info->mutually_exclusive_operation_running, 1));
        tsk = kthread_run(balance_kthread, fs_info, "btrfs-balance");
        if (IS_ERR(tsk))
                return PTR_ERR(tsk);
@@@ -3234,6 -3242,8 +3243,8 @@@ int btrfs_recover_balance(struct btrfs_
        btrfs_balance_sys(leaf, item, &disk_bargs);
        btrfs_disk_balance_args_to_cpu(&bctl->sys, &disk_bargs);
  
+       WARN_ON(atomic_xchg(&fs_info->mutually_exclusive_operation_running, 1));
        mutex_lock(&fs_info->volume_mutex);
        mutex_lock(&fs_info->balance_mutex);
  
@@@ -3497,7 -3507,7 +3508,7 @@@ struct btrfs_raid_attr btrfs_raid_array
        { 1, 1, 2, 2, 2, 2 /* raid1 */ },
        { 1, 2, 1, 1, 1, 2 /* dup */ },
        { 1, 1, 0, 2, 1, 1 /* raid0 */ },
-       { 1, 1, 0, 1, 1, 1 /* single */ },
+       { 1, 1, 1, 1, 1, 1 /* single */ },
  };
  
  static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,