Chen Hanxiao
2015-Feb-21 12:23 UTC
[Libguestfs] [PATCH 0/4] btrfs: add support to btrfstune
This series adds new APIs to support btrfstune. Chen Hanxiao (4): New API: btrfstune_S_enable New API: btrfstune_S_disable New API: btrfstune_r New API: btrfstune_x daemon/btrfs.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++ generator/actions.ml | 64 +++++++++++++++++++++++++++++++++ src/MAX_PROC_NR | 2 +- 3 files changed, 164 insertions(+), 1 deletion(-) -- 2.1.0
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
---
daemon/btrfs.c | 25 +++++++++++++++++++++++++
generator/actions.ml | 16 ++++++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index d84c28e..c94c11a 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -2090,3 +2090,28 @@ do_btrfs_inspect_internal_logical_resolve (int64_t
logical, const char *fs)
return out;
}
+
+int
+do_btrfstune_S_enable (const char *device)
+{
+ const size_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ CLEANUP_FREE char *err = NULL;
+ CLEANUP_FREE char *out = NULL;
+ int r;
+
+ ADD_ARG (argv, i, str_btrfstune);
+ ADD_ARG (argv, i, "-S");
+ ADD_ARG (argv, i, "1");
+ ADD_ARG (argv, i, device);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (&out, &err, argv);
+ if (r == -1) {
+ reply_with_error ("%s: %s", device, err);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index 7b7655d..6dccb5c 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12531,6 +12531,22 @@ Get path on a btrfs filesystem for the given
inode." };
longdesc = "\
Get path on a btrfs filesystem for the logical address." };
+ { defaults with
+ name = "btrfstune_S_enable";
+ style = RErr, [Device "device"], [];
+ proc_nr = Some 454;
+ optional = Some "btrfs"; camel_name =
"BTRFSTuneSEnable";
+ tests = [
+ InitPartition, Always, TestRun (
+ [["mkfs_btrfs"; "/dev/sda1"; "";
""; "NOARG"; ""; "NOARG";
"NOARG"; ""; ""];
+ ["btrfstune_S_enable"; "/dev/sda1"]]), []
+ ];
+
+ shortdesc = "enable seeding of a btrfs device";
+ longdesc = "\
+Enable seeding of a btrfs device, this will force a fs readonly
+so that you can use it tto build other filesystems." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 534b992..515f19a 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-453
+454
--
2.1.0
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
---
daemon/btrfs.c | 26 ++++++++++++++++++++++++++
generator/actions.ml | 18 ++++++++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index c94c11a..a129e2e 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -2115,3 +2115,29 @@ do_btrfstune_S_enable (const char *device)
return 0;
}
+
+int
+do_btrfstune_S_disable (const char *device)
+{
+ const size_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ CLEANUP_FREE char *err = NULL;
+ CLEANUP_FREE char *out = NULL;
+ int r;
+
+ ADD_ARG (argv, i, str_btrfstune);
+ ADD_ARG (argv, i, "-S");
+ ADD_ARG (argv, i, "0");
+ ADD_ARG (argv, i, "-f");
+ ADD_ARG (argv, i, device);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (&out, &err, argv);
+ if (r == -1) {
+ reply_with_error ("%s: %s", device, err);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index 6dccb5c..3c906a4 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12547,6 +12547,24 @@ Get path on a btrfs filesystem for the logical
address." };
Enable seeding of a btrfs device, this will force a fs readonly
so that you can use it tto build other filesystems." };
+ { defaults with
+ name = "btrfstune_S_disable";
+ style = RErr, [Device "device"], [];
+ proc_nr = Some 455;
+ optional = Some "btrfs"; camel_name =
"BTRFSTuneSDisable";
+ tests = [
+ InitPartition, Always, TestRun (
+ [["mkfs_btrfs"; "/dev/sda1"; "";
""; "NOARG"; ""; "NOARG";
"NOARG"; ""; ""];
+ ["btrfstune_S_enable"; "/dev/sda1"];
+ ["btrfstune_S_disable"; "/dev/sda1"]]), []
+ ];
+
+ shortdesc = "disable seeding of a btrfs device";
+ longdesc = "\
+ This will disable seeding of a btrfs device.
+ Warning: This is dangerous, clearing the seeding flag
+ may cause the derived device not to be mountable!" };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 515f19a..4930863 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-454
+455
--
2.1.0
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
---
daemon/btrfs.c | 24 ++++++++++++++++++++++++
generator/actions.ml | 15 +++++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index a129e2e..ea2f1f1 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -2141,3 +2141,27 @@ do_btrfstune_S_disable (const char *device)
return 0;
}
+
+int
+do_btrfstune_r (const char *device)
+{
+ const size_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ CLEANUP_FREE char *err = NULL;
+ CLEANUP_FREE char *out = NULL;
+ int r;
+
+ ADD_ARG (argv, i, str_btrfstune);
+ ADD_ARG (argv, i, "-r");
+ ADD_ARG (argv, i, device);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (&out, &err, argv);
+ if (r == -1) {
+ reply_with_error ("%s: %s", device, err);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index 3c906a4..661ba9a 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12565,6 +12565,21 @@ so that you can use it tto build other
filesystems." };
Warning: This is dangerous, clearing the seeding flag
may cause the derived device not to be mountable!" };
+ { defaults with
+ name = "btrfstune_r";
+ style = RErr, [Device "device"], [];
+ proc_nr = Some 456;
+ optional = Some "btrfs"; camel_name = "BTRFSTuneR";
+ tests = [
+ InitPartition, Always, TestRun (
+ [["mkfs_btrfs"; "/dev/sda1"; "";
""; "NOARG"; ""; "NOARG";
"NOARG"; ""; ""];
+ ["btrfstune_r"; "/dev/sda1"]]), []
+ ];
+
+ shortdesc = "enable extended inode refs";
+ longdesc = "\
+ This will Enable extended inode refs." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 4930863..8d38505 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-455
+456
--
2.1.0
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
---
daemon/btrfs.c | 24 ++++++++++++++++++++++++
generator/actions.ml | 15 +++++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index ea2f1f1..cccac9a 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -2165,3 +2165,27 @@ do_btrfstune_r (const char *device)
return 0;
}
+
+int
+do_btrfstune_x (const char *device)
+{
+ const size_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ CLEANUP_FREE char *err = NULL;
+ CLEANUP_FREE char *out = NULL;
+ int r;
+
+ ADD_ARG (argv, i, str_btrfstune);
+ ADD_ARG (argv, i, "-x");
+ ADD_ARG (argv, i, device);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (&out, &err, argv);
+ if (r == -1) {
+ reply_with_error ("%s: %s", device, err);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index 661ba9a..9888f94 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12580,6 +12580,21 @@ so that you can use it tto build other
filesystems." };
longdesc = "\
This will Enable extended inode refs." };
+ { defaults with
+ name = "btrfstune_x";
+ style = RErr, [Device "device"], [];
+ proc_nr = Some 457;
+ optional = Some "btrfs"; camel_name = "BTRFSTuneX";
+ tests = [
+ InitPartition, Always, TestRun (
+ [["mkfs_btrfs"; "/dev/sda1"; "";
""; "NOARG"; ""; "NOARG";
"NOARG"; ""; ""];
+ ["btrfstune_x"; "/dev/sda1"]]), []
+ ];
+
+ shortdesc = "enable skinny metadata extent refs";
+ longdesc = "\
+ This enable skinny metadata extent refs." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 8d38505..de2a00c 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-456
+457
--
2.1.0
Richard W.M. Jones
2015-Feb-27 13:40 UTC
Re: [Libguestfs] [PATCH 2/4] New API: btrfstune_S_disable
On Sat, Feb 21, 2015 at 08:23:19PM +0800, Chen Hanxiao wrote:> Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> > --- > daemon/btrfs.c | 26 ++++++++++++++++++++++++++ > generator/actions.ml | 18 ++++++++++++++++++ > src/MAX_PROC_NR | 2 +- > 3 files changed, 45 insertions(+), 1 deletion(-) > > diff --git a/daemon/btrfs.c b/daemon/btrfs.c > index c94c11a..a129e2e 100644 > --- a/daemon/btrfs.c > +++ b/daemon/btrfs.c > @@ -2115,3 +2115,29 @@ do_btrfstune_S_enable (const char *device) > > return 0; > } > + > +int > +do_btrfstune_S_disable (const char *device) > +{ > + const size_t MAX_ARGS = 64; > + const char *argv[MAX_ARGS]; > + size_t i = 0; > + CLEANUP_FREE char *err = NULL; > + CLEANUP_FREE char *out = NULL; > + int r; > + > + ADD_ARG (argv, i, str_btrfstune); > + ADD_ARG (argv, i, "-S"); > + ADD_ARG (argv, i, "0"); > + ADD_ARG (argv, i, "-f"); > + ADD_ARG (argv, i, device); > + ADD_ARG (argv, i, NULL); > + > + r = commandv (&out, &err, argv); > + if (r == -1) { > + reply_with_error ("%s: %s", device, err); > + return -1; > + } > + > + return 0; > +} > diff --git a/generator/actions.ml b/generator/actions.ml > index 6dccb5c..3c906a4 100644 > --- a/generator/actions.ml > +++ b/generator/actions.ml > @@ -12547,6 +12547,24 @@ Get path on a btrfs filesystem for the logical address." }; > Enable seeding of a btrfs device, this will force a fs readonly > so that you can use it tto build other filesystems." }; > > + { defaults with > + name = "btrfstune_S_disable"; > + style = RErr, [Device "device"], []; > + proc_nr = Some 455; > + optional = Some "btrfs"; camel_name = "BTRFSTuneSDisable"; > + tests = [ > + InitPartition, Always, TestRun ( > + [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""]; > + ["btrfstune_S_enable"; "/dev/sda1"]; > + ["btrfstune_S_disable"; "/dev/sda1"]]), [] > + ]; > + > + shortdesc = "disable seeding of a btrfs device"; > + longdesc = "\ > + This will disable seeding of a btrfs device. > + Warning: This is dangerous, clearing the seeding flag > + may cause the derived device not to be mountable!" }; > +Sorry for the delayed reply. How do you feel about combining btrfstune_S_enable & btrfstune_S_disable into a single call: name = "btrfstune_seeding"; style = RErr, [Device "device", Bool "enable"], []; where you can enable or disable by setting the boolean? The two patches look otherwise fine to me. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Richard W.M. Jones
2015-Feb-27 13:41 UTC
Re: [Libguestfs] [PATCH 3/4] New API: btrfstune_r
On Sat, Feb 21, 2015 at 08:23:20PM +0800, Chen Hanxiao wrote:> Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> > --- > daemon/btrfs.c | 24 ++++++++++++++++++++++++ > generator/actions.ml | 15 +++++++++++++++ > src/MAX_PROC_NR | 2 +- > 3 files changed, 40 insertions(+), 1 deletion(-) > > diff --git a/daemon/btrfs.c b/daemon/btrfs.c > index a129e2e..ea2f1f1 100644 > --- a/daemon/btrfs.c > +++ b/daemon/btrfs.c > @@ -2141,3 +2141,27 @@ do_btrfstune_S_disable (const char *device) > > return 0; > } > + > +int > +do_btrfstune_r (const char *device) > +{ > + const size_t MAX_ARGS = 64; > + const char *argv[MAX_ARGS]; > + size_t i = 0; > + CLEANUP_FREE char *err = NULL; > + CLEANUP_FREE char *out = NULL; > + int r; > + > + ADD_ARG (argv, i, str_btrfstune); > + ADD_ARG (argv, i, "-r"); > + ADD_ARG (argv, i, device); > + ADD_ARG (argv, i, NULL); > + > + r = commandv (&out, &err, argv); > + if (r == -1) { > + reply_with_error ("%s: %s", device, err); > + return -1; > + } > + > + return 0; > +} > diff --git a/generator/actions.ml b/generator/actions.ml > index 3c906a4..661ba9a 100644 > --- a/generator/actions.ml > +++ b/generator/actions.ml > @@ -12565,6 +12565,21 @@ so that you can use it tto build other filesystems." }; > Warning: This is dangerous, clearing the seeding flag > may cause the derived device not to be mountable!" }; > > + { defaults with > + name = "btrfstune_r"; > + style = RErr, [Device "device"], []; > + proc_nr = Some 456; > + optional = Some "btrfs"; camel_name = "BTRFSTuneR"; > + tests = [ > + InitPartition, Always, TestRun ( > + [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""]; > + ["btrfstune_r"; "/dev/sda1"]]), [] > + ]; > + > + shortdesc = "enable extended inode refs"; > + longdesc = "\ > + This will Enable extended inode refs." };^^^^ Some extra spaces here. Is it better to call this something like btrfstune_enable_extended_inode_refs? (Wow, too long :-!) Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Richard W.M. Jones
2015-Feb-27 13:42 UTC
Re: [Libguestfs] [PATCH 4/4] New API: btrfstune_x
On Sat, Feb 21, 2015 at 08:23:21PM +0800, Chen Hanxiao wrote:> Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> > --- > daemon/btrfs.c | 24 ++++++++++++++++++++++++ > generator/actions.ml | 15 +++++++++++++++ > src/MAX_PROC_NR | 2 +- > 3 files changed, 40 insertions(+), 1 deletion(-) > > diff --git a/daemon/btrfs.c b/daemon/btrfs.c > index ea2f1f1..cccac9a 100644 > --- a/daemon/btrfs.c > +++ b/daemon/btrfs.c > @@ -2165,3 +2165,27 @@ do_btrfstune_r (const char *device) > > return 0; > } > + > +int > +do_btrfstune_x (const char *device) > +{ > + const size_t MAX_ARGS = 64; > + const char *argv[MAX_ARGS]; > + size_t i = 0; > + CLEANUP_FREE char *err = NULL; > + CLEANUP_FREE char *out = NULL; > + int r; > + > + ADD_ARG (argv, i, str_btrfstune); > + ADD_ARG (argv, i, "-x"); > + ADD_ARG (argv, i, device); > + ADD_ARG (argv, i, NULL); > + > + r = commandv (&out, &err, argv); > + if (r == -1) { > + reply_with_error ("%s: %s", device, err); > + return -1; > + } > + > + return 0; > +} > diff --git a/generator/actions.ml b/generator/actions.ml > index 661ba9a..9888f94 100644 > --- a/generator/actions.ml > +++ b/generator/actions.ml > @@ -12580,6 +12580,21 @@ so that you can use it tto build other filesystems." }; > longdesc = "\ > This will Enable extended inode refs." }; > > + { defaults with > + name = "btrfstune_x"; > + style = RErr, [Device "device"], []; > + proc_nr = Some 457; > + optional = Some "btrfs"; camel_name = "BTRFSTuneX"; > + tests = [ > + InitPartition, Always, TestRun ( > + [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""]; > + ["btrfstune_x"; "/dev/sda1"]]), [] > + ]; > + > + shortdesc = "enable skinny metadata extent refs"; > + longdesc = "\ > + This enable skinny metadata extent refs." };^^^^ Extra spaces again. Maybe call this "btrfstune_enable_skinny_metadata_extent_refs"? Patches 3/4 look fine apart from the extra spaces and possible naming issue. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW