These two patches complement the previous two kernel-side
patches. The first implements a way of displaying the current progress
of any running balance process. The second patch allows a running
balance to be cancelled.
I''m a bit uncertain about the best name for these commands. Several
options:
1)
# btrfs filesystem progress <path>
# btrfs filesystem cancel <path>
Way too vague (cancel *what*?)
2)
# btrfs filesystem balance-progress <path>
# btrfs filesystem balance-cancel <path>
Clashes horribly with "filesystem balance" -- no abbreviations
possible.
3)
btrfs filesystem balance -p <path>
btrfs filesystem balance -c <path>
Changes behaviour significantly on a switch, in contrast to the
behaviour of the rest of the btrfs tool.
4)
btrfs balance progress <path>
btrfs balance cancel <path>
My current favourite, although we introduce a new namespace
("balance") for commands. We could add "btrfs balance start
<path>" as
a synonym for "btrfs filesystem balance <path>", for some degree
of
consistency.
At some point, I''ll add a "monitor" function, which will
poll at 1s
intervals for progress updates, and print out progress when it changes.
Hugo.
--
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk == PGP
key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
--- "No! My collection of rare, incurable diseases! Violated!" ---
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs"
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Add support to the btrfs tool for monitoring a balance operation on a
filesystem.
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
---
btrfs.c | 4 ++++
btrfs_cmds.c | 40 ++++++++++++++++++++++++++++++++++++++++
btrfs_cmds.h | 1 +
ioctl.h | 7 +++++++
4 files changed, 52 insertions(+)
Index: btrfs-progs-unstable/btrfs.c
==================================================================---
btrfs-progs-unstable.orig/btrfs.c 2010-10-28 22:58:54.805035975 +0100
+++ btrfs-progs-unstable/btrfs.c 2010-10-30 00:19:59.968416575 +0100
@@ -95,6 +95,10 @@
"filesystem balance", "<path>\n"
"Balance the chunks across the device."
},
+ { do_balance_progress, 1,
+ "balance progress", "<path>\n"
+ "Show progress of the balance operation running on <path>."
+ },
{ do_scan,
999, "device scan", "[<device>
[<device>..]\n"
"Scan all device for or the passed device for a btrfs\n"
Index: btrfs-progs-unstable/btrfs_cmds.c
==================================================================---
btrfs-progs-unstable.orig/btrfs_cmds.c 2010-10-28 22:58:54.855033936 +0100
+++ btrfs-progs-unstable/btrfs_cmds.c 2010-10-30 00:04:48.335524683 +0100
@@ -808,6 +808,46 @@
}
return 0;
}
+
+int do_balance_progress(int argc, char **argv)
+{
+ char *path = argv[1];
+ int fdmnt;
+ int ret = 0;
+ int err = 0;
+ struct btrfs_ioctl_balance_progress bal;
+
+ fdmnt = open_file_or_dir(path);
+ if(fdmnt < 0) {
+ fprintf(stderr, "ERROR: can''t access
''%s''\n", path);
+ return 12;
+ }
+
+ ret = ioctl(fdmnt, BTRFS_IOC_BALANCE_PROGRESS, &bal);
+ if(!ret)
+ err = errno;
+ close(fdmnt);
+
+ switch(err) {
+ case 0:
+ break;
+ case -EINVAL:
+ fprintf(stderr, "No balance operation running on
''%s''.\n",
+ path);
+ return 20;
+ default:
+ fprintf(stderr, "ERROR: ioctl returned error %d.", err);
+ return 21;
+ }
+
+ printf("%llu/%llu block groups moved, %0.2f%% complete.\n",
+ bal.completed,
+ bal.expected,
+ (float)bal.completed/bal.expected*100.0);
+
+ return 0;
+}
+
int do_remove_volume(int nargs, char **args)
{
Index: btrfs-progs-unstable/btrfs_cmds.h
==================================================================---
btrfs-progs-unstable.orig/btrfs_cmds.h 2010-10-28 22:58:54.895032304 +0100
+++ btrfs-progs-unstable/btrfs_cmds.h 2010-10-30 00:04:48.335524683 +0100
@@ -23,6 +23,7 @@
int do_show_filesystem(int nargs, char **argv);
int do_add_volume(int nargs, char **args);
int do_balance(int nargs, char **argv);
+int do_balance_progress(int nargs, char **argv);
int do_remove_volume(int nargs, char **args);
int do_scan(int nargs, char **argv);
int do_resize(int nargs, char **argv);
Index: btrfs-progs-unstable/ioctl.h
==================================================================---
btrfs-progs-unstable.orig/ioctl.h 2010-10-28 23:14:16.937413446 +0100
+++ btrfs-progs-unstable/ioctl.h 2010-10-30 00:04:48.325525089 +0100
@@ -132,6 +132,11 @@
struct btrfs_ioctl_space_info spaces[0];
};
+struct btrfs_ioctl_balance_progress {
+ __u64 expected;
+ __u64 completed;
+};
+
#define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
struct btrfs_ioctl_vol_args)
#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
@@ -169,4 +174,6 @@
#define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, u64)
#define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
struct btrfs_ioctl_space_args)
+#define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 21, \
+ struct btrfs_ioctl_balance_progress)
#endif
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs"
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hugo Mills
2010-Oct-30 00:10 UTC
[patch 2/2] User-space tool for cancelling balance operations.
Add an option to the btrfs tool to use the ioctl for cancelling
balance operations.
SIgned-off-by: Hugo Mills <hugo@carfax.org.uk>
---
btrfs.c | 4 ++++
btrfs_cmds.c | 41 +++++++++++++++++++++++++++++++++++++++++
btrfs_cmds.h | 1 +
ioctl.h | 1 +
4 files changed, 47 insertions(+)
Index: btrfs-progs-unstable/btrfs.c
==================================================================---
btrfs-progs-unstable.orig/btrfs.c 2010-10-30 00:19:59.968416575 +0100
+++ btrfs-progs-unstable/btrfs.c 2010-10-30 00:20:38.446849736 +0100
@@ -99,6 +99,10 @@
"balance progress", "<path>\n"
"Show progress of the balance operation running on <path>."
},
+ { do_balance_cancel, 1,
+ "balance cancel", "<path>\n"
+ "Cancel the balance operation running on <path>."
+ },
{ do_scan,
999, "device scan", "[<device>
[<device>..]\n"
"Scan all device for or the passed device for a btrfs\n"
Index: btrfs-progs-unstable/btrfs_cmds.c
==================================================================---
btrfs-progs-unstable.orig/btrfs_cmds.c 2010-10-30 00:04:48.335524683 +0100
+++ btrfs-progs-unstable/btrfs_cmds.c 2010-10-30 00:20:22.267508562 +0100
@@ -848,6 +848,47 @@
return 0;
}
+int do_balance_cancel(int nargs, char **argv)
+{
+ char *path = argv[1];
+ int fdmnt;
+ int ret = 0;
+ int err = 0;
+
+ fdmnt = open_file_or_dir(path);
+ if(fdmnt < 0) {
+ fprintf(stderr, "ERROR: can''t access
''%s''\n", path);
+ return 12;
+ }
+
+ ret = ioctl(fdmnt, BTRFS_IOC_BALANCE_CANCEL, NULL);
+ err = errno;
+
+ if(ret) {
+ switch(err) {
+ case 0:
+ break;
+ case EINVAL:
+ fprintf(stderr, "ERROR: no balance in progress.\n");
+ err = 20;
+ break;
+ case ECANCELED:
+ fprintf(stderr, "ERROR: operation already cancelled.\n");
+ err = 21;
+ break;
+ default:
+ fprintf(stderr, "ERROR: ioctl returned error
''%d''.\n",
+ err);
+ err = 22;
+ break;
+ }
+ }
+
+ close(fdmnt);
+
+ return err;
+}
+
int do_remove_volume(int nargs, char **args)
{
Index: btrfs-progs-unstable/btrfs_cmds.h
==================================================================---
btrfs-progs-unstable.orig/btrfs_cmds.h 2010-10-30 00:04:48.335524683 +0100
+++ btrfs-progs-unstable/btrfs_cmds.h 2010-10-30 00:20:22.307506934 +0100
@@ -24,6 +24,7 @@
int do_add_volume(int nargs, char **args);
int do_balance(int nargs, char **argv);
int do_balance_progress(int nargs, char **argv);
+int do_balance_cancel(int nargs, char **argv);
int do_remove_volume(int nargs, char **args);
int do_scan(int nargs, char **argv);
int do_resize(int nargs, char **argv);
Index: btrfs-progs-unstable/ioctl.h
==================================================================---
btrfs-progs-unstable.orig/ioctl.h 2010-10-30 00:04:48.325525089 +0100
+++ btrfs-progs-unstable/ioctl.h 2010-10-30 00:20:22.357504895 +0100
@@ -176,4 +176,5 @@
struct btrfs_ioctl_space_args)
#define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 21, \
struct btrfs_ioctl_balance_progress)
+#define BTRFS_IOC_BALANCE_CANCEL _IO(BTRFS_IOCTL_MAGIC, 22)
#endif
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs"
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jérôme Poulin
2010-Oct-30 00:30 UTC
Re: [patch 0/2] Control filesystem balances (userspace)
You could always use btrfs filesystem balance progress which would not introduce a new root level option and still be short to type. That would mean balance should have a "start" option or default to start when no sub options are used. Sent from my mobile device. On 2010-10-29, at 20:11, Hugo Mills <hugo@carfax.org.uk> wrote:> These two patches complement the previous two kernel-side > patches. The first implements a way of displaying the current progress > of any running balance process. The second patch allows a running > balance to be cancelled. > > I''m a bit uncertain about the best name for these commands. Several > options: > > 1) > # btrfs filesystem progress <path> > # btrfs filesystem cancel <path> > > Way too vague (cancel *what*?) > > > 2) > # btrfs filesystem balance-progress <path> > # btrfs filesystem balance-cancel <path> > > Clashes horribly with "filesystem balance" -- no abbreviations > possible. > > > 3) > btrfs filesystem balance -p <path> > btrfs filesystem balance -c <path> > > Changes behaviour significantly on a switch, in contrast to the > behaviour of the rest of the btrfs tool. > > > 4) > btrfs balance progress <path> > btrfs balance cancel <path> > > My current favourite, although we introduce a new namespace > ("balance") for commands. We could add "btrfs balance start <path>" as > a synonym for "btrfs filesystem balance <path>", for some degree of > consistency. > > At some point, I''ll add a "monitor" function, which will poll at 1s > intervals for progress updates, and print out progress when it changes. > > Hugo. > > -- > === Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ==> PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk > --- "No! My collection of rare, incurable diseases! Violated!" --- > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Goffredo Baroncelli
2010-Oct-30 17:49 UTC
Re: [patch 0/2] Control filesystem balances (userspace)
On Saturday, 30 October, 2010, Hugo Mills wrote:> These two patches complement the previous two kernel-side > patches. The first implements a way of displaying the current progress > of any running balance process. The second patch allows a running > balance to be cancelled. > > I''m a bit uncertain about the best name for these commands. Several > options: >[...]> > 4) > btrfs balance progress <path> > btrfs balance cancel <path> > > My current favourite, although we introduce a new namespace > ("balance") for commands. We could add "btrfs balance start <path>" as > a synonym for "btrfs filesystem balance <path>", for some degree of > consistency.I like this. Regards G.Baroncelli> > At some point, I''ll add a "monitor" function, which will poll at 1s > intervals for progress updates, and print out progress when it changes. > > Hugo. > > -- > === Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ==> PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk > --- "No! My collection of rare, incurable diseases! Violated!" --- > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >-- gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijack@inwind.it> Key fingerprint = 4769 7E51 5293 D36C 814E C054 BF04 F161 3DC5 0512 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html