@@ -808,6 +808,33 @@ static ssize_t btrfs_checksum_show(struct kobject *kobj,
BTRFS_ATTR(, checksum, btrfs_checksum_show);
+static ssize_t btrfs_balance_show(struct btrfs_fs_info *fs_info, char *buf)
+{
+ ssize_t ret = 0;
+ struct btrfs_balance_control *bctl;
+
+ ret += scnprintf(buf, PAGE_SIZE, "balance\n");
+ spin_lock(&fs_info->balance_lock);
+ bctl = fs_info->balance_ctl;
+ if (!bctl) {
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+ "State: stopping\n");
+ goto out;
+ }
+ if (test_bit(BTRFS_FS_BALANCE_RUNNING, &fs_info->flags))
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+ "State: running\n");
+ else
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+ "State: paused\n");
+ ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%llu %llu %llu\n",
+ bctl->stat.expected, bctl->stat.considered,
+ bctl->stat.completed);
+out:
+ spin_unlock(&fs_info->balance_lock);
+ return ret;
+}
+
static ssize_t btrfs_exclusive_operation_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{
@@ -816,7 +843,7 @@ static ssize_t btrfs_exclusive_operation_show(struct kobject *kobj,
case BTRFS_EXCLOP_NONE:
return scnprintf(buf, PAGE_SIZE, "none\n");
case BTRFS_EXCLOP_BALANCE:
- return scnprintf(buf, PAGE_SIZE, "balance\n");
+ return btrfs_balance_show(fs_info, buf);
case BTRFS_EXCLOP_DEV_ADD:
return scnprintf(buf, PAGE_SIZE, "device add\n");
case BTRFS_EXCLOP_DEV_REPLACE: