From: Goldwyn Rodrigues <rgoldwyn@suse.de>
To: linux-btrfs@vger.kernel.org
Cc: Goldwyn Rodrigues <rgoldwyn@suse.com>
Subject: [PATCH 3/3] btrfs: add more information for balance
Date: Mon, 27 Jul 2020 17:04:51 -0500 [thread overview]
Message-ID: <20200727220451.30680-4-rgoldwyn@suse.de> (raw)
In-Reply-To: <20200727220451.30680-1-rgoldwyn@suse.de>
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
Include information about the state of the balance and expected,
considered and completed statistics.
Q: I am not sure of the cancelled state, and stopping seemed more
appropriate since it was a transient state to cancelling the operation.
Would you prefer to call it cancelled?
This information is not used by user space as of now. We could use it
for "btrfs balance status" or ignore this patch for inclusion at all.
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
fs/btrfs/sysfs.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 71950c121588..001a7ae375d0 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -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:
--
2.26.2
next prev parent reply other threads:[~2020-07-27 22:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-27 22:04 [PATCH 0/3] btrfs: Enumerate and export exclusive operations Goldwyn Rodrigues
2020-07-27 22:04 ` [PATCH 1/3] btrfs: enumerate the type of exclusive operation in progress Goldwyn Rodrigues
2020-07-28 8:45 ` Johannes Thumshirn
2020-07-27 22:04 ` [PATCH 2/3] btrfs: export currently executing exclusive operation via sysfs Goldwyn Rodrigues
2020-07-27 22:04 ` Goldwyn Rodrigues [this message]
2020-07-27 22:08 ` [PATCH 1/4] btrfs-progs: get_fsid_fd() for getting fsid using fd Goldwyn Rodrigues
2020-07-27 22:08 ` [PATCH 2/4] btrfs-progs: add sysfs file reading functions Goldwyn Rodrigues
2020-07-27 22:08 ` [PATCH 3/4] btrfs-progs: Check for exclusive operation before issuing ioctl Goldwyn Rodrigues
2020-07-27 22:08 ` [PATCH 4/4] btrfs-progs: Enqueue command if it can't be performed immediately Goldwyn Rodrigues
2020-07-28 8:38 ` [PATCH 1/4] btrfs-progs: get_fsid_fd() for getting fsid using fd Johannes Thumshirn
-- strict thread matches above, loose matches on Subject: below --
2020-08-03 20:29 [PATCH v2 0/3] btrfs: Enumerate and export exclusive operations Goldwyn Rodrigues
2020-08-03 20:29 ` [PATCH 3/3] btrfs: add more information for balance Goldwyn Rodrigues
2020-08-05 12:17 ` Nikolay Borisov
2020-08-05 16:29 ` Goldwyn Rodrigues
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200727220451.30680-4-rgoldwyn@suse.de \
--to=rgoldwyn@suse.de \
--cc=linux-btrfs@vger.kernel.org \
--cc=rgoldwyn@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox