[RFC PATCH 2/3] btrfs_progs: _PROGRESS ioctl for error output in do_balance()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux