From: Petr Janecek <janecek@ucw.cz>
To: linux-btrfs@vger.kernel.org
Subject: [RFC PATCH 2/3] btrfs_progs: _PROGRESS ioctl for error output in do_balance()
Date: Wed, 8 Apr 2020 15:15:19 +0200 [thread overview]
Message-ID: <20200408131517.GC19101@jkm> (raw)
With 'btrfs balance start --background ...', all the potential error
messages are lost. Add ioctl() to check for basic permission denied
and balance in progress conditions.
---
cmds/balance.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/cmds/balance.c b/cmds/balance.c
index fada2ab3..3d4deb27 100644
--- a/cmds/balance.c
+++ b/cmds/balance.c
@@ -444,6 +444,24 @@ static int do_balance(const char *path, struct btrfs_ioctl_balance_args *args,
return 1;
if (flags & BALANCE_START_BACKGROUND) {
+ /*
+ * We are not going to see any error output from the
+ * forked process. So do a sanity check that the
+ * balance is likely to start.
+ */
+ struct btrfs_ioctl_balance_args stat_args;
+ ret = ioctl(fd, BTRFS_IOC_BALANCE_PROGRESS, &stat_args);
+ if (ret == 0) {
+ error("error during balancing '%s': "
+ "Operation now in progress", path);
+ ret = 1;
+ goto out;
+ } else if (errno != ENOTCONN) {
+ error("error during balancing '%s': %m", path);
+ ret = 1;
+ goto out;
+ }
+
switch (fork()) {
case (-1):
error("unable to fork to run balance in background");
--
2.26.0
reply other threads:[~2020-04-08 13:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200408131517.GC19101@jkm \
--to=janecek@ucw.cz \
--cc=linux-btrfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).