linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 2/3] btrfs_progs: _PROGRESS ioctl for error output in do_balance()
@ 2020-04-08 13:15 Petr Janecek
  0 siblings, 0 replies; only message in thread
From: Petr Janecek @ 2020-04-08 13:15 UTC (permalink / raw)
  To: linux-btrfs

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-08 13:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-08 13:15 [RFC PATCH 2/3] btrfs_progs: _PROGRESS ioctl for error output in do_balance() Petr Janecek

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).