Chen Hanxiao
2015-Mar-01 07:20 UTC
[Libguestfs] [PATCH v2 0/3] btrfs: add support to btrfstune
This series adds new APIs to support btrfstune. v2: - merge btrfstune_S_[enable|disable] together - fix naming issue Chen Hanxiao (3): New API: btrfstune_seeding New API: btrfstune_enable_extended_inode_refs New API: btrfstune_enable_skinny_metadata_extent_refs daemon/btrfs.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ generator/actions.ml | 47 ++++++++++++++++++++++++++++++++ src/MAX_PROC_NR | 2 +- 3 files changed, 124 insertions(+), 1 deletion(-) -- 2.1.0
Use btrfstune_seeding to enable or disable seeding. Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com> --- daemon/btrfs.c | 28 ++++++++++++++++++++++++++++ generator/actions.ml | 17 +++++++++++++++++ src/MAX_PROC_NR | 2 +- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/daemon/btrfs.c b/daemon/btrfs.c index 6b93973..d2d4492 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -1929,3 +1929,31 @@ error: free (ret); return NULL; } + +int +do_btrfstune_seeding (const char *device, int svalue) +{ + 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; + const char *s_value = svalue ? "1" : "0"; + + ADD_ARG (argv, i, str_btrfstune); + ADD_ARG (argv, i, "-S"); + ADD_ARG (argv, i, s_value); + if (svalue == 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 c995787..cb67fc5 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -12475,6 +12475,23 @@ Show the status of a running or paused balance on a btrfs filesystem." }; longdesc = "\ Show status of running or finished scrub on a btrfs filesystem." }; + { defaults with + name = "btrfstune_seeding"; + style = RErr, [Device "device"; Bool "seeding"], []; + proc_nr = Some 450; + optional = Some "btrfs"; camel_name = "BTRFSTuneSeeding"; + tests = [ + InitPartition, Always, TestRun ( + [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""]; + ["btrfstune_seeding"; "/dev/sda1"; "true"]; + ["btrfstune_seeding"; "/dev/sda1"; "false"]]), [] + ]; + + shortdesc = "enable or disable 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 2b20fd0..29ba0df 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -449 +450 -- 2.1.0
Chen Hanxiao
2015-Mar-01 07:20 UTC
[Libguestfs] [PATCH v2 2/3] New API: btrfstune_enable_extended_inode_refs
Signed-off-by: Chen Hanxiao <chenhanxiao at 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 d2d4492..48693ce 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -1957,3 +1957,27 @@ do_btrfstune_seeding (const char *device, int svalue) return 0; } + +int +do_btrfstune_enable_extended_inode_refs (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 cb67fc5..bf02bdc 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -12492,6 +12492,21 @@ Show status of running or finished scrub on a btrfs filesystem." }; 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_enable_extended_inode_refs"; + style = RErr, [Device "device"], []; + proc_nr = Some 451; + optional = Some "btrfs"; camel_name = "BTRFSTuneEnableExtendedInodeRefs"; + tests = [ + InitPartition, Always, TestRun ( + [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""]; + ["btrfstune_enable_extended_inode_refs"; "/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 29ba0df..4619a8a 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -450 +451 -- 2.1.0
Chen Hanxiao
2015-Mar-01 07:20 UTC
[Libguestfs] [PATCH v2 3/3] New API: btrfstune_enable_skinny_metadata_extent_refs
Signed-off-by: Chen Hanxiao <chenhanxiao at 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 48693ce..d4b3207 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -1981,3 +1981,27 @@ do_btrfstune_enable_extended_inode_refs (const char *device) return 0; } + +int +do_btrfstune_enable_skinny_metadata_extent_refs (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 bf02bdc..448dc4f 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -12507,6 +12507,21 @@ so that you can use it tto build other filesystems." }; longdesc = "\ This will Enable extended inode refs." }; + { defaults with + name = "btrfstune_enable_skinny_metadata_extent_refs"; + style = RErr, [Device "device"], []; + proc_nr = Some 452; + optional = Some "btrfs"; camel_name = "BTRFSTuneEnableSkinnyMetadataExtentRefs"; + tests = [ + InitPartition, Always, TestRun ( + [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""]; + ["btrfstune_enable_skinny_metadata_extent_refs"; "/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 4619a8a..8670c73 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -451 +452 -- 2.1.0
Richard W.M. Jones
2015-Mar-01 20:22 UTC
[Libguestfs] [PATCH v2 0/3] btrfs: add support to btrfstune
On Sun, Mar 01, 2015 at 02:20:46AM -0500, Chen Hanxiao wrote:> This series adds new APIs to support btrfstune. > > v2: > - merge btrfstune_S_[enable|disable] together > - fix naming issue > > Chen Hanxiao (3): > New API: btrfstune_seeding > New API: btrfstune_enable_extended_inode_refs > New API: btrfstune_enable_skinny_metadata_extent_refs > > daemon/btrfs.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > generator/actions.ml | 47 ++++++++++++++++++++++++++++++++ > src/MAX_PROC_NR | 2 +- > 3 files changed, 124 insertions(+), 1 deletion(-)At a quick glance, this looks good to me. Let me play with it a bit more when I get to work tomorrow. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Richard W.M. Jones
2015-Mar-02 12:11 UTC
Re: [Libguestfs] [PATCH v2 0/3] btrfs: add support to btrfstune
On Sun, Mar 01, 2015 at 08:22:03PM +0000, Richard W.M. Jones wrote:> On Sun, Mar 01, 2015 at 02:20:46AM -0500, Chen Hanxiao wrote: > > This series adds new APIs to support btrfstune. > > > > v2: > > - merge btrfstune_S_[enable|disable] together > > - fix naming issue > > > > Chen Hanxiao (3): > > New API: btrfstune_seeding > > New API: btrfstune_enable_extended_inode_refs > > New API: btrfstune_enable_skinny_metadata_extent_refs > > > > daemon/btrfs.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > > generator/actions.ml | 47 ++++++++++++++++++++++++++++++++ > > src/MAX_PROC_NR | 2 +- > > 3 files changed, 124 insertions(+), 1 deletion(-) > > At a quick glance, this looks good to me. Let me play with it a bit > more when I get to work tomorrow.That series has been pushed now, thanks. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org