master - tests: make lib/expected-version-dm a dependency of .tests-stamp
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=11fd7b7c645c04...
Commit: 11fd7b7c645c0462cac95687c098019cf779cd58
Parent: d4a5c252c59fb22d705fc0978ccf0d7cf2a69ba7
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Dec 11 13:18:40 2015 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Feb 25 16:40:59 2016 +0000
tests: make lib/expected-version-dm a dependency of .tests-stamp
---
test/Makefile.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index fdae254..77190b3 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -294,7 +294,7 @@ lib/dm-version-expected: $(top_srcdir)/VERSION_DM .lib-dir-stamp
CMDS = lvm $(shell cat $(top_builddir)/tools/.commands 2>/dev/null)
LIB = $(addprefix lib/, $(LIB_SHARED) $(LIB_LOCAL) $(LIB_NOT) $(LIB_LINK_NOT) $(LIB_FLAVOURS))
-.tests-stamp: $(ALL) $(LIB) $(SUBDIRS) lib/version-expected
+.tests-stamp: $(ALL) $(LIB) $(SUBDIRS) lib/version-expected lib/dm-version-expected
@if test "$(srcdir)" != . ; then \
echo "Linking tests to builddir."; \
$(MKDIR_P) shell; \
8 years, 2 months
master - tests: install does not depend on lib/version-expected
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d4a5c252c59fb2...
Commit: d4a5c252c59fb22d705fc0978ccf0d7cf2a69ba7
Parent: 2d630ea78aa430608f914e6da37fb98b051d86fa
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Dec 11 13:17:08 2015 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Feb 25 16:40:59 2016 +0000
tests: install does not depend on lib/version-expected
The install target already depends on .tests-stamp - since this
in turn depends on lib/version-expected there is no need to have
this as a dependency of install.
---
test/Makefile.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index c69b3b6..fdae254 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -199,7 +199,7 @@ LIB_NOT = not
LIB_LINK_NOT = invalid fail should
LIB_SHARED = check aux inittest utils get lvm-wrapper
-install: .tests-stamp lib/paths-installed lib/version-expected
+install: .tests-stamp lib/paths-installed
@echo $(srcdir)
$(INSTALL_DIR) $(DATADIR)/{shell,api,lib} $(EXECDIR)
$(INSTALL_DATA) shell/*.sh $(DATADIR)/shell
8 years, 2 months
master - tests: add template tests/shell/dmstats-create.sh
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2d630ea78aa430...
Commit: 2d630ea78aa430608f914e6da37fb98b051d86fa
Parent: 3dae4162293e385083025c85ec0e6307c48eb48e
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Nov 27 17:57:33 2015 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Feb 25 16:40:58 2016 +0000
tests: add template tests/shell/dmstats-create.sh
Add a template for testing 'dmstats create' operations.
---
test/shell/dmstats-create.sh | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/test/shell/dmstats-create.sh b/test/shell/dmstats-create.sh
new file mode 100644
index 0000000..cb1671a
--- /dev/null
+++ b/test/shell/dmstats-create.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+# Copyright (C) 2009-2011 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+. lib/inittest
+
+# Don't attempt to test stats with driver < 4.33.00
+aux driver_at_least 4 33 || skip
+
+# ensure we can create devices (uses dmsetup, etc)
+#aux prepare_devs 5
+
+# FIXME: some actual tests here.
8 years, 2 months
master - tests: add driver_at_least() to aux.sh
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3dae4162293e38...
Commit: 3dae4162293e385083025c85ec0e6307c48eb48e
Parent: 1f8fd5a1522b607255eb8e45572a22de85d6f2ae
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Nov 27 17:55:08 2015 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Feb 25 16:40:58 2016 +0000
tests: add driver_at_least() to aux.sh
Add a function to test whether the running device-mapper driver
version is at least equal to some given version.
---
test/lib/aux.sh | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index cfd3620..e517bc0 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1232,6 +1232,21 @@ target_at_least() {
}
}
+# Check whether the kernel driver version is greater or equal
+# to the specified version. This can be used to skip tests on
+# kernels where they are known to not be supported.
+#
+# e.g. driver_at_least 4 33
+#
+driver_at_least() {
+ local version=$(dmsetup version | tail -1 2>/dev/null)
+ version=${version##*:}
+ version_at_least "$version" "$@" || {
+ echo "Found driver version $version, but requested $@." >&2
+ return 1
+ }
+}
+
have_thin() {
test "$THIN" = shared -o "$THIN" = internal || {
echo "Thin is not built-in." >&2
8 years, 2 months
master - tests: add basic dmstats tests
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1f8fd5a1522b60...
Commit: 1f8fd5a1522b607255eb8e45572a22de85d6f2ae
Parent: 985ed7822f2ac12724ef3bbd823644b0a74f400c
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Thu Nov 26 17:11:40 2015 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Feb 25 16:40:58 2016 +0000
tests: add basic dmstats tests
Add initial dmstats tests to 000-basic.sh. These tests ensure that
the dmsetup binary is built and linked correctly when called as
'dmstats' and that the version of the binary matches the expected
library version used for the build.
---
test/Makefile.in | 3 +++
test/shell/000-basic.sh | 5 +++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index 915a0b0..c69b3b6 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -288,6 +288,9 @@ lib/paths: lib/paths-common
lib/version-expected: $(top_srcdir)/VERSION .lib-dir-stamp
cut -f 1 -d ' ' <$< >$@
+lib/dm-version-expected: $(top_srcdir)/VERSION_DM .lib-dir-stamp
+ cut -f 1 -d ' ' <$< >$@
+
CMDS = lvm $(shell cat $(top_builddir)/tools/.commands 2>/dev/null)
LIB = $(addprefix lib/, $(LIB_SHARED) $(LIB_LOCAL) $(LIB_NOT) $(LIB_LINK_NOT) $(LIB_FLAVOURS))
diff --git a/test/shell/000-basic.sh b/test/shell/000-basic.sh
index d1c7dc8..da84f3e 100644
--- a/test/shell/000-basic.sh
+++ b/test/shell/000-basic.sh
@@ -21,6 +21,11 @@ lvm pvmove --version|sed -n "1s/.*: *\([0-9][^ ]*\) .*/\1/p" | tee version
# ensure they are the same
diff -u version lib/version-expected
+dmstats version |sed -n "1s/.*: *\([0-9][^ ]*\) .*/\1/p" | tee dmstats-version
+
+# ensure dmstats version matches build
+diff -u dmstats-version lib/dm-version-expected
+
# ensure we can create devices (uses dmsetup, etc)
aux prepare_devs 5
8 years, 2 months
master - dmstats: create dmstats symlink in test/lib
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=985ed7822f2ac1...
Commit: 985ed7822f2ac12724ef3bbd823644b0a74f400c
Parent: 42ae586fa72a30e0f22c0916e0551228d5eed5c3
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Thu Nov 26 12:37:22 2015 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Feb 25 16:40:58 2016 +0000
dmstats: create dmstats symlink in test/lib
Create a symbolic link in test/lib for 'dmstats', pointing to the
dmsetup binary in the tools/ build directory.
---
test/Makefile.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index 98f6cc9..915a0b0 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -309,6 +309,7 @@ LIB = $(addprefix lib/, $(LIB_SHARED) $(LIB_LOCAL) $(LIB_NOT) $(LIB_LINK_NOT) $(
tools/dmsetup daemons/lvmetad/lvmetad \
daemons/lvmpolld/lvmpolld ; do \
$(LN_S) -f $(abs_top_builddir)/$$i lib/; done
+ $(LN_S) -f $(abs_top_builddir)/tools/dmsetup lib/dmstats
$(LN_S) -f $(abs_top_srcdir)/conf/thin-performance.profile lib/
$(LN_S) -f $(abs_top_srcdir)/scripts/fsadm.sh lib/fsadm
$(LN_S) -f $(abs_top_srcdir)/scripts/vgimportclone.sh lib/vgimportclone
8 years, 2 months
master - lvmcache: fix missing free of vginfo->system_id causing mem leak
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=42ae586fa72a30...
Commit: 42ae586fa72a30e0f22c0916e0551228d5eed5c3
Parent: a77ded3001ad584e75bb3b315a8c99c56951e530
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Feb 25 16:24:48 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Feb 25 16:25:27 2016 +0100
lvmcache: fix missing free of vginfo->system_id causing mem leak
---
lib/cache/lvmcache.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 1945a74..c28460e 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -1177,6 +1177,9 @@ static int _free_vginfo(struct lvmcache_vginfo *vginfo)
vginfo2 = vginfo2->next;
}
+ if (vginfo->system_id)
+ dm_free(vginfo->system_id);
+
dm_free(vginfo->vgname);
dm_free(vginfo->creation_host);
8 years, 2 months
master - replace pvcreate_params with pvcreate_each_params
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a77ded3001ad58...
Commit: a77ded3001ad584e75bb3b315a8c99c56951e530
Parent: 4de6caf5b5a1b7eef80fc9ed56ac0cf8b7776ac4
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Feb 18 15:38:23 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Feb 25 09:14:10 2016 -0600
replace pvcreate_params with pvcreate_each_params
"pvcreate_each_params" was a temporary name used
to transition from the old "pvcreate_params".
Remove the old pvcreate_params struct and rename the
new pvcreate_each_params struct to pvcreate_params.
Rename various pvcreate_each_params terms to simply
pvcreate_params.
---
lib/metadata/metadata-exported.h | 14 +--------
lib/metadata/metadata.c | 57 ++++++++++++++++++++++---------------
tools/pvcreate.c | 20 ++++++------
tools/pvremove.c | 4 +-
tools/toollib.c | 45 ++++--------------------------
tools/toollib.h | 5 +--
tools/vgcreate.c | 6 ++--
tools/vgextend.c | 12 ++++----
8 files changed, 64 insertions(+), 99 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index c5dee05..03e8572 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -540,18 +540,6 @@ struct pv_create_args {
};
struct pvcreate_params {
- int zero;
- force_t force;
- unsigned yes;
- const char *restorefile; /* 0 if no --restorefile option */
- struct pv_create_args pva;
-};
-
-/*
- * FIXME: rename this pvcreate_params once the old pvcreate_params is unused.
- * This can probably be put in toollib.h.
- */
-struct pvcreate_each_params {
/*
* From argc and argv.
*/
@@ -747,7 +735,7 @@ int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
const char *new_name);
int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names,
struct pvcreate_params *pp);
-int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_each_params *pp);
+int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_params *pp);
int vg_reduce(struct volume_group *vg, const char *pv_name);
int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index aafc4ce..acdfdec 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -809,7 +809,7 @@ int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names
return 1;
}
-int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_each_params *pp)
+int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_params *pp)
{
struct pv_list *pvl;
unsigned int max_phys_block_size = 0;
@@ -1516,6 +1516,39 @@ int vg_split_mdas(struct cmd_context *cmd __attribute__((unused)),
return 1;
}
+void pvcreate_params_set_defaults(struct pvcreate_params *pp)
+{
+ memset(pp, 0, sizeof(*pp));
+
+ pp->zero = 1;
+ pp->force = PROMPT;
+ pp->yes = 0;
+ pp->restorefile = NULL;
+ pp->uuid_str = NULL;
+
+ pp->pva.size = 0;
+ pp->pva.data_alignment = UINT64_C(0);
+ pp->pva.data_alignment_offset = UINT64_C(0);
+ pp->pva.pvmetadatacopies = DEFAULT_PVMETADATACOPIES;
+ pp->pva.pvmetadatasize = DEFAULT_PVMETADATASIZE;
+ pp->pva.label_sector = DEFAULT_LABELSECTOR;
+ pp->pva.metadataignore = DEFAULT_PVMETADATAIGNORE;
+ pp->pva.ba_start = 0;
+ pp->pva.ba_size = 0;
+ pp->pva.pe_start = PV_PE_START_CALC;
+ pp->pva.extent_count = 0;
+ pp->pva.extent_size = 0;
+
+ dm_list_init(&pp->prompts);
+ dm_list_init(&pp->arg_devices);
+ dm_list_init(&pp->arg_process);
+ dm_list_init(&pp->arg_confirm);
+ dm_list_init(&pp->arg_create);
+ dm_list_init(&pp->arg_remove);
+ dm_list_init(&pp->arg_fail);
+ dm_list_init(&pp->pvs);
+}
+
/*
* See if we may pvcreate on this device.
* 0 indicates we may not.
@@ -1678,28 +1711,6 @@ out:
return r;
}
-void pvcreate_params_set_defaults(struct pvcreate_params *pp)
-{
- memset(pp, 0, sizeof(*pp));
- pp->zero = 1;
- pp->force = PROMPT;
- pp->yes = 0;
- pp->restorefile = 0;
- pp->pva.size = 0;
- pp->pva.data_alignment = UINT64_C(0);
- pp->pva.data_alignment_offset = UINT64_C(0);
- pp->pva.pvmetadatacopies = DEFAULT_PVMETADATACOPIES;
- pp->pva.pvmetadatasize = DEFAULT_PVMETADATASIZE;
- pp->pva.label_sector = DEFAULT_LABELSECTOR;
- pp->pva.metadataignore = DEFAULT_PVMETADATAIGNORE;
- pp->pva.idp = 0;
- pp->pva.ba_start = 0;
- pp->pva.ba_size = 0;
- pp->pva.pe_start = PV_PE_START_CALC;
- pp->pva.extent_count = 0;
- pp->pva.extent_size = 0;
-}
-
static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_write *pvw)
{
struct physical_volume *pv = pvw->pv;
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 92356b3..85fed09 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -22,8 +22,8 @@
* Output arguments:
* pp: structure allocated by caller, fields written / validated here
*/
-static int pvcreate_each_restore_params_from_args(struct cmd_context *cmd, int argc,
- struct pvcreate_each_params *pp)
+static int pvcreate_restore_params_from_args(struct cmd_context *cmd, int argc,
+ struct pvcreate_params *pp)
{
pp->restorefile = arg_str_value(cmd, restorefile_ARG, NULL);
@@ -62,8 +62,8 @@ static int pvcreate_each_restore_params_from_args(struct cmd_context *cmd, int a
return 1;
}
-static int pvcreate_each_restore_params_from_backup(struct cmd_context *cmd,
- struct pvcreate_each_params *pp)
+static int pvcreate_restore_params_from_backup(struct cmd_context *cmd,
+ struct pvcreate_params *pp)
{
struct volume_group *vg;
struct pv_list *existing_pvl;
@@ -99,7 +99,7 @@ static int pvcreate_each_restore_params_from_backup(struct cmd_context *cmd,
int pvcreate(struct cmd_context *cmd, int argc, char **argv)
{
struct processing_handle *handle;
- struct pvcreate_each_params pp;
+ struct pvcreate_params pp;
int ret;
if (!argc) {
@@ -109,7 +109,7 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
/*
* Device info needs to be available for reading the VG backup file in
- * pvcreate_each_restore_params_from_backup.
+ * pvcreate_restore_params_from_backup.
*/
lvmcache_seed_infos_from_lvmetad(cmd);
@@ -123,15 +123,15 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
* 5. argc/argv free args specifying devices
*/
- pvcreate_each_params_set_defaults(&pp);
+ pvcreate_params_set_defaults(&pp);
- if (!pvcreate_each_restore_params_from_args(cmd, argc, &pp))
+ if (!pvcreate_restore_params_from_args(cmd, argc, &pp))
return EINVALID_CMD_LINE;
- if (!pvcreate_each_restore_params_from_backup(cmd, &pp))
+ if (!pvcreate_restore_params_from_backup(cmd, &pp))
return EINVALID_CMD_LINE;
- if (!pvcreate_each_params_from_args(cmd, &pp))
+ if (!pvcreate_params_from_args(cmd, &pp))
return EINVALID_CMD_LINE;
pp.pv_count = argc;
diff --git a/tools/pvremove.c b/tools/pvremove.c
index 1628ecc..dd9a4e8 100644
--- a/tools/pvremove.c
+++ b/tools/pvremove.c
@@ -18,7 +18,7 @@
int pvremove(struct cmd_context *cmd, int argc, char **argv)
{
struct processing_handle *handle;
- struct pvcreate_each_params pp;
+ struct pvcreate_params pp;
int ret;
if (!argc) {
@@ -26,7 +26,7 @@ int pvremove(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- pvcreate_each_params_set_defaults(&pp);
+ pvcreate_params_set_defaults(&pp);
pp.is_remove = 1;
pp.force = arg_count(cmd, force_ARG);
diff --git a/tools/toollib.c b/tools/toollib.c
index b640285..3e48139 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3425,40 +3425,7 @@ int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
return ECMD_PROCESSED;
}
-void pvcreate_each_params_set_defaults(struct pvcreate_each_params *pp)
-{
- memset(pp, 0, sizeof(*pp));
-
- pp->zero = 1;
- pp->force = PROMPT;
- pp->yes = 0;
- pp->restorefile = NULL;
- pp->uuid_str = NULL;
-
- pp->pva.size = 0;
- pp->pva.data_alignment = UINT64_C(0);
- pp->pva.data_alignment_offset = UINT64_C(0);
- pp->pva.pvmetadatacopies = DEFAULT_PVMETADATACOPIES;
- pp->pva.pvmetadatasize = DEFAULT_PVMETADATASIZE;
- pp->pva.label_sector = DEFAULT_LABELSECTOR;
- pp->pva.metadataignore = DEFAULT_PVMETADATAIGNORE;
- pp->pva.ba_start = 0;
- pp->pva.ba_size = 0;
- pp->pva.pe_start = PV_PE_START_CALC;
- pp->pva.extent_count = 0;
- pp->pva.extent_size = 0;
-
- dm_list_init(&pp->prompts);
- dm_list_init(&pp->arg_devices);
- dm_list_init(&pp->arg_process);
- dm_list_init(&pp->arg_confirm);
- dm_list_init(&pp->arg_create);
- dm_list_init(&pp->arg_remove);
- dm_list_init(&pp->arg_fail);
- dm_list_init(&pp->pvs);
-}
-
-int pvcreate_each_params_from_args(struct cmd_context *cmd, struct pvcreate_each_params *pp)
+int pvcreate_params_from_args(struct cmd_context *cmd, struct pvcreate_params *pp)
{
pp->yes = arg_count(cmd, yes_ARG);
pp->force = (force_t) arg_count(cmd, force_ARG);
@@ -3620,7 +3587,7 @@ struct pvcreate_device {
*/
static void _check_pvcreate_prompt(struct cmd_context *cmd,
- struct pvcreate_each_params *pp,
+ struct pvcreate_params *pp,
struct pvcreate_prompt *prompt,
int ask)
{
@@ -3728,7 +3695,7 @@ static int _pvcreate_check_single(struct cmd_context *cmd,
struct physical_volume *pv,
struct processing_handle *handle)
{
- struct pvcreate_each_params *pp = (struct pvcreate_each_params *) handle->custom_handle;
+ struct pvcreate_params *pp = (struct pvcreate_params *) handle->custom_handle;
struct pvcreate_device *pd;
struct pvcreate_prompt *prompt;
struct device *dev;
@@ -3871,7 +3838,7 @@ static int _pv_confirm_single(struct cmd_context *cmd,
struct physical_volume *pv,
struct processing_handle *handle)
{
- struct pvcreate_each_params *pp = (struct pvcreate_each_params *) handle->custom_handle;
+ struct pvcreate_params *pp = (struct pvcreate_params *) handle->custom_handle;
struct pvcreate_device *pd;
int found = 0;
@@ -3958,7 +3925,7 @@ static int _pvremove_check_single(struct cmd_context *cmd,
struct physical_volume *pv,
struct processing_handle *handle)
{
- struct pvcreate_each_params *pp = (struct pvcreate_each_params *) handle->custom_handle;
+ struct pvcreate_params *pp = (struct pvcreate_params *) handle->custom_handle;
struct pvcreate_device *pd;
struct pvcreate_prompt *prompt;
struct label *label;
@@ -4113,7 +4080,7 @@ static int _pvremove_check_single(struct cmd_context *cmd,
int pvcreate_each_device(struct cmd_context *cmd,
struct processing_handle *handle,
- struct pvcreate_each_params *pp)
+ struct pvcreate_params *pp)
{
struct pvcreate_device *pd, *pd2;
struct pvcreate_prompt *prompt, *prompt2;
diff --git a/tools/toollib.h b/tools/toollib.h
index c092c74..a67b3e6 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -152,9 +152,8 @@ const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
unsigned *dev_dir_found);
-void pvcreate_each_params_set_defaults(struct pvcreate_each_params *pp);
-int pvcreate_each_params_from_args(struct cmd_context *cmd, struct pvcreate_each_params *pp);
-int pvcreate_each_device(struct cmd_context *cmd, struct processing_handle *handle, struct pvcreate_each_params *pp);
+int pvcreate_params_from_args(struct cmd_context *cmd, struct pvcreate_params *pp);
+int pvcreate_each_device(struct cmd_context *cmd, struct processing_handle *handle, struct pvcreate_params *pp);
/*
* Builds a list of pv's from the names in argv. Used in
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index 456e207..3811583 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -18,7 +18,7 @@
int vgcreate(struct cmd_context *cmd, int argc, char **argv)
{
struct processing_handle *handle;
- struct pvcreate_each_params pp;
+ struct pvcreate_params pp;
struct vgcreate_params vp_new;
struct vgcreate_params vp_def;
struct volume_group *vg;
@@ -38,9 +38,9 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
argc--;
argv++;
- pvcreate_each_params_set_defaults(&pp);
+ pvcreate_params_set_defaults(&pp);
- if (!pvcreate_each_params_from_args(cmd, &pp))
+ if (!pvcreate_params_from_args(cmd, &pp))
return EINVALID_CMD_LINE;
pp.pv_count = argc;
diff --git a/tools/vgextend.c b/tools/vgextend.c
index 2780755..9cfd3a7 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -16,7 +16,7 @@
#include "tools.h"
struct vgextend_params {
- struct pvcreate_each_params pp;
+ struct pvcreate_params pp;
};
static int _restore_pv(struct volume_group *vg, const char *pv_name)
@@ -47,7 +47,7 @@ static int _vgextend_restoremissing(struct cmd_context *cmd __attribute__((unuse
struct processing_handle *handle)
{
struct vgextend_params *vp = (struct vgextend_params *) handle->custom_handle;
- struct pvcreate_each_params *pp = &vp->pp;
+ struct pvcreate_params *pp = &vp->pp;
int fixed = 0;
int i;
@@ -77,7 +77,7 @@ static int _vgextend_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, struct processing_handle *handle)
{
struct vgextend_params *vp = (struct vgextend_params *) handle->custom_handle;
- struct pvcreate_each_params *pp = &vp->pp;
+ struct pvcreate_params *pp = &vp->pp;
uint32_t mda_copies;
uint32_t mda_used;
int ret = ECMD_FAILED;
@@ -125,7 +125,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
{
struct processing_handle *handle;
struct vgextend_params vp;
- struct pvcreate_each_params *pp = &vp.pp;
+ struct pvcreate_params *pp = &vp.pp;
unsigned restoremissing = arg_is_set(cmd, restoremissing_ARG);
const char *vg_name;
int ret;
@@ -146,9 +146,9 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
argc--;
argv++;
- pvcreate_each_params_set_defaults(pp);
+ pvcreate_params_set_defaults(pp);
- if (!pvcreate_each_params_from_args(cmd, pp))
+ if (!pvcreate_params_from_args(cmd, pp))
return EINVALID_CMD_LINE;
pp->pv_count = argc;
8 years, 2 months
master - redefine pvcreate structs
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4de6caf5b5a1b7...
Commit: 4de6caf5b5a1b7eef80fc9ed56ac0cf8b7776ac4
Parent: c201ee09bdfdfccecd5975ee26537cf790b25e25
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Feb 18 15:31:27 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Feb 25 09:14:10 2016 -0600
redefine pvcreate structs
New pv_create_args struct contains all the specific
parameters for creating a PV, independent of the
command.
---
lib/format1/format1.c | 32 ++++++-------
lib/format_pool/format_pool.c | 5 +--
lib/format_text/archiver.c | 27 +++--------
lib/format_text/archiver.h | 5 +--
lib/format_text/format-text.c | 43 +++++++++---------
lib/metadata/metadata-exported.h | 55 ++++++++--------------
lib/metadata/metadata.c | 86 ++++++++++++++----------------------
lib/metadata/metadata.h | 5 +--
liblvm/lvm_prop.c | 20 ++++----
liblvm/lvm_pv.c | 8 ++--
tools/pvcreate.c | 16 +++---
tools/toollib.c | 92 ++++++++++++++++----------------------
tools/vgconvert.c | 24 ++++------
13 files changed, 168 insertions(+), 250 deletions(-)
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index 30bb696..b3569e0 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -345,10 +345,7 @@ static int _format1_pv_read(const struct format_type *fmt, const char *pv_name,
}
static int _format1_pv_initialise(const struct format_type * fmt,
- int64_t label_sector __attribute__((unused)),
- unsigned long data_alignment __attribute__((unused)),
- unsigned long data_alignment_offset __attribute__((unused)),
- struct pvcreate_restorable_params *rp,
+ struct pv_create_args *pva,
struct physical_volume * pv)
{
if (pv->size > MAX_PV_SIZE)
@@ -360,18 +357,18 @@ static int _format1_pv_initialise(const struct format_type * fmt,
}
/* Nothing more to do if extent size isn't provided */
- if (!rp->extent_size)
+ if (!pva->extent_size)
return 1;
/*
* This works out pe_start and pe_count.
*/
- if (!calculate_extent_count(pv, rp->extent_size, rp->extent_count, rp->pe_start))
+ if (!calculate_extent_count(pv, pva->extent_size, pva->extent_count, pva->pe_start))
return_0;
/* Retain existing extent locations exactly */
- if (((rp->pe_start || rp->extent_count) && (rp->pe_start != pv->pe_start)) ||
- (rp->extent_count && (rp->extent_count != pv->pe_count))) {
+ if (((pva->pe_start || pva->extent_count) && (pva->pe_start != pv->pe_start)) ||
+ (pva->extent_count && (pva->extent_count != pv->pe_count))) {
log_error("Metadata would overwrite physical extents");
return 0;
}
@@ -383,16 +380,15 @@ static int _format1_pv_setup(const struct format_type *fmt,
struct physical_volume *pv,
struct volume_group *vg)
{
- struct pvcreate_restorable_params rp = {.restorefile = NULL,
- .id = {{0}},
- .idp = NULL,
- .ba_start = 0,
- .ba_size = 0,
- .pe_start = 0,
- .extent_count = 0,
- .extent_size = vg->extent_size};
-
- return _format1_pv_initialise(fmt, -1, 0, 0, &rp, pv);
+ struct pv_create_args pva = { .id = {{0}},
+ .idp = NULL,
+ .ba_start = 0,
+ .ba_size = 0,
+ .pe_start = 0,
+ .extent_count = 0,
+ .extent_size = vg->extent_size};
+
+ return _format1_pv_initialise(fmt, &pva, pv);
}
static int _format1_lv_setup(struct format_instance *fid, struct logical_volume *lv)
diff --git a/lib/format_pool/format_pool.c b/lib/format_pool/format_pool.c
index d7792a2..f6e5e01 100644
--- a/lib/format_pool/format_pool.c
+++ b/lib/format_pool/format_pool.c
@@ -166,10 +166,7 @@ bad:
}
static int _pool_pv_initialise(const struct format_type *fmt __attribute__((unused)),
- int64_t label_sector __attribute__((unused)),
- unsigned long data_alignment __attribute__((unused)),
- unsigned long data_alignment_offset __attribute__((unused)),
- struct pvcreate_restorable_params *rp __attribute__((unused)),
+ struct pv_create_args *pva __attribute__((unused)),
struct physical_volume *pv __attribute__((unused)))
{
return 1;
diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c
index 07dece3..b92f4a5 100644
--- a/lib/format_text/archiver.c
+++ b/lib/format_text/archiver.c
@@ -361,13 +361,8 @@ static int _restore_vg_should_write_pv(struct physical_volume *pv, int do_pvcrea
int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg,
int drop_lvmetad,
int do_pvcreate,
- uint64_t bootloaderareasize,
- int pvmetadatacopies,
- uint64_t pvmetadatasize,
- uint64_t label_sector)
-
+ struct pv_create_args *pva)
{
- struct pvcreate_restorable_params rp = { 0 };
struct dm_list new_pvs;
struct pv_list *pvl, *new_pvl;
struct physical_volume *existing_pv, *pv;
@@ -389,20 +384,14 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg,
dm_list_iterate_items(pvl, &vg->pvs) {
existing_pv = pvl->pv;
- rp.id = existing_pv->id;
- rp.idp = &rp.id;
- rp.pe_start = pv_pe_start(existing_pv);
- rp.extent_count = pv_pe_count(existing_pv);
- rp.extent_size = pv_pe_size(existing_pv);
- rp.ba_size = bootloaderareasize;
+ pva->id = existing_pv->id;
+ pva->idp = &pva->id;
+ pva->pe_start = pv_pe_start(existing_pv);
+ pva->extent_count = pv_pe_count(existing_pv);
+ pva->extent_size = pv_pe_size(existing_pv);
/* pe_end = pv_pe_count(existing_pv) * pv_pe_size(existing_pv) + pe_start - 1 */
- if (!(pv = pv_create(cmd, pv_dev(existing_pv),
- 0, 0, 0,
- label_sector,
- pvmetadatacopies,
- pvmetadatasize,
- 0, &rp))) {
+ if (!(pv = pv_create(cmd, pv_dev(existing_pv), pva))) {
log_error("Failed to setup physical volume \"%s\".",
pv_dev_name(existing_pv));
return 0;
@@ -561,7 +550,7 @@ int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name,
missing_pvs = vg_missing_pv_count(vg);
if (missing_pvs == 0)
- r = backup_restore_vg(cmd, vg, 1, 0, 0, 0, 0, 0);
+ r = backup_restore_vg(cmd, vg, 1, 0, NULL);
else
log_error("Cannot restore Volume Group %s with %i PVs "
"marked as missing.", vg->name, missing_pvs);
diff --git a/lib/format_text/archiver.h b/lib/format_text/archiver.h
index b8e53e3..82f7620 100644
--- a/lib/format_text/archiver.h
+++ b/lib/format_text/archiver.h
@@ -55,10 +55,7 @@ struct volume_group *backup_read_vg(struct cmd_context *cmd,
int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg,
int drop_lvmetad,
int do_pvcreate,
- uint64_t bootloaderareasize,
- int pvmetadatacopies,
- uint64_t pvmetadatasize,
- uint64_t label_sector);
+ struct pv_create_args *pva);
int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name,
const char *file, int force);
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 72ca198..408e63c 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -1550,12 +1550,11 @@ static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
}
static int _text_pv_initialise(const struct format_type *fmt,
- const int64_t label_sector,
- unsigned long data_alignment,
- unsigned long data_alignment_offset,
- struct pvcreate_restorable_params *rp,
+ struct pv_create_args *pva,
struct physical_volume *pv)
{
+ unsigned long data_alignment = pva->data_alignment;
+ unsigned long data_alignment_offset = pva->data_alignment_offset;
unsigned long adjustment, final_alignment = 0;
if (!data_alignment)
@@ -1592,13 +1591,13 @@ static int _text_pv_initialise(const struct format_type *fmt,
return 0;
}
- if (pv->size < final_alignment + rp->ba_size) {
+ if (pv->size < final_alignment + pva->ba_size) {
log_error("%s: Bootloader area with data-aligned start must "
"not exceed device size.", pv_dev_name(pv));
return 0;
}
- if (rp->pe_start == PV_PE_START_CALC) {
+ if (pva->pe_start == PV_PE_START_CALC) {
/*
* Calculate new PE start and bootloader area start value.
* Make sure both are properly aligned!
@@ -1608,10 +1607,10 @@ static int _text_pv_initialise(const struct format_type *fmt,
* This needs to be done as we can't have a PV without any DA.
* But we still want to support a PV with BA only!
*/
- if (rp->ba_size) {
+ if (pva->ba_size) {
pv->ba_start = final_alignment;
- pv->ba_size = rp->ba_size;
- if ((adjustment = rp->ba_size % pv->pe_align))
+ pv->ba_size = pva->ba_size;
+ if ((adjustment = pva->ba_size % pv->pe_align))
pv->ba_size += pv->pe_align - adjustment;
if (pv->size < pv->ba_start + pv->ba_size)
pv->ba_size = pv->size - pv->ba_start;
@@ -1626,26 +1625,26 @@ static int _text_pv_initialise(const struct format_type *fmt,
* it in between the final alignment and existing PE start
* if possible.
*/
- pv->pe_start = rp->pe_start;
- if (rp->ba_size) {
- if ((rp->ba_start && rp->ba_start + rp->ba_size > rp->pe_start) ||
- (rp->pe_start <= final_alignment) ||
- (rp->pe_start - final_alignment < rp->ba_size)) {
+ pv->pe_start = pva->pe_start;
+ if (pva->ba_size) {
+ if ((pva->ba_start && pva->ba_start + pva->ba_size > pva->pe_start) ||
+ (pva->pe_start <= final_alignment) ||
+ (pva->pe_start - final_alignment < pva->ba_size)) {
log_error("%s: Bootloader area would overlap "
"data area.", pv_dev_name(pv));
return 0;
} else {
- pv->ba_start = rp->ba_start ? : final_alignment;
- pv->ba_size = rp->ba_size;
+ pv->ba_start = pva->ba_start ? : final_alignment;
+ pv->ba_size = pva->ba_size;
}
}
}
- if (rp->extent_size)
- pv->pe_size = rp->extent_size;
+ if (pva->extent_size)
+ pv->pe_size = pva->extent_size;
- if (rp->extent_count)
- pv->pe_count = rp->extent_count;
+ if (pva->extent_count)
+ pv->pe_count = pva->extent_count;
if ((pv->pe_start + pv->pe_count * (uint64_t)pv->pe_size - 1) > pv->size) {
log_error("Physical extents end beyond end of device %s.",
@@ -1653,8 +1652,8 @@ static int _text_pv_initialise(const struct format_type *fmt,
return 0;
}
- if (label_sector != -1)
- pv->label_sector = label_sector;
+ if (pva->label_sector != -1)
+ pv->label_sector = pva->label_sector;
return 1;
}
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 9c6abd7..c5dee05 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -517,10 +517,21 @@ struct vgnameid_list {
#define PV_PE_START_CALC ((uint64_t) -1) /* Calculate pe_start value */
-struct pvcreate_restorable_params {
- const char *restorefile; /* 0 if no --restorefile option */
- struct id id; /* FIXME: redundant */
- struct id *idp; /* 0 if no --uuid option */
+/*
+ * Values used by pv_create().
+ */
+struct pv_create_args {
+ uint64_t size;
+ unsigned long data_alignment;
+ unsigned long data_alignment_offset;
+ uint64_t label_sector;
+ int pvmetadatacopies;
+ uint64_t pvmetadatasize;
+ unsigned metadataignore;
+
+ /* used when restoring */
+ struct id id;
+ struct id *idp;
uint64_t ba_start;
uint64_t ba_size;
uint64_t pe_start;
@@ -530,16 +541,10 @@ struct pvcreate_restorable_params {
struct pvcreate_params {
int zero;
- uint64_t size;
- uint64_t data_alignment;
- uint64_t data_alignment_offset;
- int pvmetadatacopies;
- uint64_t pvmetadatasize;
- int64_t labelsector;
force_t force;
unsigned yes;
- unsigned metadataignore;
- struct pvcreate_restorable_params rp;
+ const char *restorefile; /* 0 if no --restorefile option */
+ struct pv_create_args pva;
};
/*
@@ -557,31 +562,19 @@ struct pvcreate_each_params {
* From command line args.
*/
int zero;
- uint64_t size;
- uint64_t data_alignment;
- uint64_t data_alignment_offset;
- int pvmetadatacopies;
- uint64_t pvmetadatasize;
- int64_t labelsector;
force_t force;
unsigned yes;
- unsigned metadataignore;
/*
* From recovery-specific command line args.
*/
const char *restorefile; /* NULL if no --restorefile option */
const char *uuid_str; /* id in printable format, NULL if no id */
- struct id id;
/*
- * From reading VG backup file.
+ * Values used by pv_create().
*/
- uint64_t ba_start;
- uint64_t ba_size;
- uint64_t pe_start;
- uint32_t extent_count;
- uint32_t extent_size;
+ struct pv_create_args pva;
/*
* Used for command processing.
@@ -722,15 +715,7 @@ uint32_t vg_read_error(struct volume_group *vg_handle);
/* pe_start and pe_end relate to any existing data so that new metadata
* areas can avoid overlap */
struct physical_volume *pv_create(const struct cmd_context *cmd,
- struct device *dev,
- uint64_t size,
- unsigned long data_alignment,
- unsigned long data_alignment_offset,
- uint64_t label_sector,
- unsigned pvmetadatacopies,
- uint64_t pvmetadatasize,
- unsigned metadataignore,
- struct pvcreate_restorable_params *rp);
+ struct device *dev, struct pv_create_args *pva);
int pvremove_single(struct cmd_context *cmd, const char *pv_name,
void *handle __attribute__((unused)), unsigned force_count,
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 5a51782..aafc4ce 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1682,25 +1682,24 @@ void pvcreate_params_set_defaults(struct pvcreate_params *pp)
{
memset(pp, 0, sizeof(*pp));
pp->zero = 1;
- pp->size = 0;
- pp->data_alignment = UINT64_C(0);
- pp->data_alignment_offset = UINT64_C(0);
- pp->pvmetadatacopies = DEFAULT_PVMETADATACOPIES;
- pp->pvmetadatasize = DEFAULT_PVMETADATASIZE;
- pp->labelsector = DEFAULT_LABELSECTOR;
pp->force = PROMPT;
pp->yes = 0;
- pp->metadataignore = DEFAULT_PVMETADATAIGNORE;
- pp->rp.restorefile = 0;
- pp->rp.idp = 0;
- pp->rp.ba_start = 0;
- pp->rp.ba_size = 0;
- pp->rp.pe_start = PV_PE_START_CALC;
- pp->rp.extent_count = 0;
- pp->rp.extent_size = 0;
+ pp->restorefile = 0;
+ pp->pva.size = 0;
+ pp->pva.data_alignment = UINT64_C(0);
+ pp->pva.data_alignment_offset = UINT64_C(0);
+ pp->pva.pvmetadatacopies = DEFAULT_PVMETADATACOPIES;
+ pp->pva.pvmetadatasize = DEFAULT_PVMETADATASIZE;
+ pp->pva.label_sector = DEFAULT_LABELSECTOR;
+ pp->pva.metadataignore = DEFAULT_PVMETADATAIGNORE;
+ pp->pva.idp = 0;
+ pp->pva.ba_start = 0;
+ pp->pva.ba_size = 0;
+ pp->pva.pe_start = PV_PE_START_CALC;
+ pp->pva.extent_count = 0;
+ pp->pva.extent_size = 0;
}
-
static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_write *pvw)
{
struct physical_volume *pv = pvw->pv;
@@ -1753,17 +1752,17 @@ static int _verify_pv_create_params(struct pvcreate_params *pp)
/*
* FIXME: Some of these checks are duplicates in pvcreate_params_validate.
*/
- if (pp->pvmetadatacopies > 2) {
+ if (pp->pva.pvmetadatacopies > 2) {
log_error("Metadatacopies may only be 0, 1 or 2");
return 0;
}
- if (pp->data_alignment > UINT32_MAX) {
+ if (pp->pva.data_alignment > UINT32_MAX) {
log_error("Physical volume data alignment is too big.");
return 0;
}
- if (pp->data_alignment_offset > UINT32_MAX) {
+ if (pp->pva.data_alignment_offset > UINT32_MAX) {
log_error("Physical volume data alignment offset is too big.");
return 0;
}
@@ -1802,10 +1801,10 @@ struct physical_volume *pvcreate_vol(struct cmd_context *cmd, const char *pv_nam
goto bad;
}
- if (pp->rp.idp) {
- if ((dev = lvmcache_device_from_pvid(cmd, pp->rp.idp, NULL, NULL)) &&
+ if (pp->pva.idp) {
+ if ((dev = lvmcache_device_from_pvid(cmd, pp->pva.idp, NULL, NULL)) &&
(dev != dev_cache_get(pv_name, cmd->full_filter))) {
- if (!id_write_format((const struct id*)&pp->rp.idp->uuid,
+ if (!id_write_format((const struct id*)&pp->pva.idp->uuid,
buffer, sizeof(buffer)))
goto_bad;
log_error("uuid %s already in use on \"%s\"", buffer,
@@ -1847,10 +1846,7 @@ struct physical_volume *pvcreate_vol(struct cmd_context *cmd, const char *pv_nam
dm_list_init(&mdas);
- if (!(pv = pv_create(cmd, dev, pp->size, pp->data_alignment,
- pp->data_alignment_offset, pp->labelsector,
- pp->pvmetadatacopies, pp->pvmetadatasize,
- pp->metadataignore, &pp->rp))) {
+ if (!(pv = pv_create(cmd, dev, &pp->pva))) {
log_error("Failed to setup physical volume \"%s\"", pv_name);
goto bad;
}
@@ -1895,47 +1891,32 @@ static struct physical_volume *_alloc_pv(struct dm_pool *mem, struct device *dev
* pv_create - initialize a physical volume for use with a volume group
* created PV belongs to Orphan VG.
*
- * @fmt: format type
- * @dev: PV device to initialize
- * @size: size of the PV in sectors
- * @data_alignment: requested alignment of data
- * @data_alignment_offset: requested offset to aligned data
- * @pe_start: physical extent start
- * @existing_extent_count
- * @existing_extent_size
- * @pvmetadatacopies
- * @pvmetadatasize
- * @mdas
- *
* Returns:
* PV handle - physical volume initialized successfully
* NULL - invalid parameter or problem initializing the physical volume
- *
- * Note:
- * FIXME: shorten argument list and replace with explict 'set' functions
*/
+
struct physical_volume *pv_create(const struct cmd_context *cmd,
struct device *dev,
- uint64_t size,
- unsigned long data_alignment,
- unsigned long data_alignment_offset,
- uint64_t label_sector,
- unsigned pvmetadatacopies,
- uint64_t pvmetadatasize,
- unsigned metadataignore,
- struct pvcreate_restorable_params *rp)
+ struct pv_create_args *pva)
{
const struct format_type *fmt = cmd->fmt;
struct dm_pool *mem = fmt->orphan_vg->vgmem;
struct physical_volume *pv = _alloc_pv(mem, dev);
unsigned mda_index;
struct pv_list *pvl;
+ uint64_t size = pva->size;
+ unsigned long data_alignment = pva->data_alignment;
+ unsigned long data_alignment_offset = pva->data_alignment_offset;
+ unsigned pvmetadatacopies = pva->pvmetadatacopies;
+ uint64_t pvmetadatasize = pva->pvmetadatasize;
+ unsigned metadataignore = pva->metadataignore;
if (!pv)
return_NULL;
- if (rp->idp)
- memcpy(&pv->id, rp->idp, sizeof(*rp->idp));
+ if (pva->idp)
+ memcpy(&pv->id, pva->idp, sizeof(*pva->idp));
else if (!id_create(&pv->id)) {
log_error("Failed to create random uuid for %s.",
dev_name(dev));
@@ -1981,8 +1962,7 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
pv->fmt = fmt;
pv->vg_name = fmt->orphan_vg_name;
- if (!fmt->ops->pv_initialise(fmt, label_sector, data_alignment,
- data_alignment_offset, rp, pv)) {
+ if (!fmt->ops->pv_initialise(fmt, pva, pv)) {
log_error("Format-specific initialisation of physical "
"volume %s failed.", pv_dev_name(pv));
goto bad;
@@ -1991,7 +1971,7 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
for (mda_index = 0; mda_index < pvmetadatacopies; mda_index++) {
if (pv->fmt->ops->pv_add_metadata_area &&
!pv->fmt->ops->pv_add_metadata_area(pv->fmt, pv,
- rp->pe_start != PV_PE_START_CALC,
+ pva->pe_start != PV_PE_START_CALC,
mda_index, pvmetadatasize,
metadataignore)) {
log_error("Failed to add metadata area for "
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 192f88e..91e5961 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -256,10 +256,7 @@ struct format_handler {
* Initialise a new PV.
*/
int (*pv_initialise) (const struct format_type * fmt,
- int64_t label_sector,
- unsigned long data_alignment,
- unsigned long data_alignment_offset,
- struct pvcreate_restorable_params *rp,
+ struct pv_create_args *pva,
struct physical_volume * pv);
/*
diff --git a/liblvm/lvm_prop.c b/liblvm/lvm_prop.c
index f269a7f..d5b1493 100644
--- a/liblvm/lvm_prop.c
+++ b/liblvm/lvm_prop.c
@@ -21,20 +21,20 @@ GET_LVCREATEPARAMS_NUM_PROPERTY_FN(skip_zero, lvcp->zero)
SET_LVCREATEPARAMS_NUM_PROPERTY_FN(skip_zero, lvcp->zero)
/* PV create parameters */
-GET_PVCREATEPARAMS_NUM_PROPERTY_FN(size, pvcp->size)
-SET_PVCREATEPARAMS_NUM_PROPERTY_FN(size, pvcp->size)
+GET_PVCREATEPARAMS_NUM_PROPERTY_FN(size, pvcp->pva.size)
+SET_PVCREATEPARAMS_NUM_PROPERTY_FN(size, pvcp->pva.size)
-GET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatacopies, pvcp->pvmetadatacopies)
-SET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatacopies, pvcp->pvmetadatacopies)
+GET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatacopies, pvcp->pva.pvmetadatacopies)
+SET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatacopies, pvcp->pva.pvmetadatacopies)
-GET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatasize, pvcp->pvmetadatasize)
-SET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatasize, pvcp->pvmetadatasize)
+GET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatasize, pvcp->pva.pvmetadatasize)
+SET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatasize, pvcp->pva.pvmetadatasize)
-GET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment, pvcp->data_alignment)
-SET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment, pvcp->data_alignment)
+GET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment, pvcp->pva.data_alignment)
+SET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment, pvcp->pva.data_alignment)
-GET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment_offset, pvcp->data_alignment_offset)
-SET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment_offset, pvcp->data_alignment_offset)
+GET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment_offset, pvcp->pva.data_alignment_offset)
+SET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment_offset, pvcp->pva.data_alignment_offset)
GET_PVCREATEPARAMS_NUM_PROPERTY_FN(zero, pvcp->zero)
SET_PVCREATEPARAMS_NUM_PROPERTY_FN(zero, pvcp->zero)
diff --git a/liblvm/lvm_pv.c b/liblvm/lvm_pv.c
index 9bc7153..4c40b8b 100644
--- a/liblvm/lvm_pv.c
+++ b/liblvm/lvm_pv.c
@@ -421,12 +421,12 @@ static int _pv_create(pv_create_params_t params)
struct cmd_context *cmd = (struct cmd_context *)params->libh;
int rc = 0;
- if (params->pv_p.size) {
- if (params->pv_p.size % SECTOR_SIZE) {
+ if (params->pv_p.pva.size) {
+ if (params->pv_p.pva.size % SECTOR_SIZE) {
log_errno(EINVAL, "Size not a multiple of 512");
return -1;
}
- params->pv_p.size = params->pv_p.size >> SECTOR_SHIFT;
+ params->pv_p.pva.size = params->pv_p.pva.size >> SECTOR_SHIFT;
}
if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
@@ -448,7 +448,7 @@ int lvm_pv_create(lvm_t libh, const char *pv_name, uint64_t size)
struct saved_env e = store_user_env((struct cmd_context *)libh);
if (_lvm_pv_params_create(libh, pv_name, &pp)) {
- pp.pv_p.size = size;
+ pp.pv_p.pva.size = size;
rc = _pv_create(&pp);
}
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 47eb85c..92356b3 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -47,7 +47,7 @@ static int pvcreate_each_restore_params_from_args(struct cmd_context *cmd, int a
if (arg_count(cmd, uuidstr_ARG)) {
pp->uuid_str = arg_str_value(cmd, uuidstr_ARG, "");
- if (!id_read_format(&pp->id, pp->uuid_str))
+ if (!id_read_format(&pp->pva.id, pp->uuid_str))
return 0;
}
@@ -55,7 +55,7 @@ static int pvcreate_each_restore_params_from_args(struct cmd_context *cmd, int a
log_error("Physical volume size may not be negative");
return 0;
}
- pp->size = arg_uint64_value(cmd, physicalvolumesize_ARG, UINT64_C(0));
+ pp->pva.size = arg_uint64_value(cmd, physicalvolumesize_ARG, UINT64_C(0));
if (arg_count(cmd, restorefile_ARG) || arg_count(cmd, uuidstr_ARG))
pp->zero = 0;
@@ -79,18 +79,18 @@ static int pvcreate_each_restore_params_from_backup(struct cmd_context *cmd,
return 0;
}
- if (!(existing_pvl = find_pv_in_vg_by_uuid(vg, &pp->id))) {
+ if (!(existing_pvl = find_pv_in_vg_by_uuid(vg, &pp->pva.id))) {
release_vg(vg);
log_error("Can't find uuid %s in backup file %s",
pp->uuid_str, pp->restorefile);
return 0;
}
- pp->ba_start = pv_ba_start(existing_pvl->pv);
- pp->ba_size = pv_ba_size(existing_pvl->pv);
- pp->pe_start = pv_pe_start(existing_pvl->pv);
- pp->extent_size = pv_pe_size(existing_pvl->pv);
- pp->extent_count = pv_pe_count(existing_pvl->pv);
+ pp->pva.ba_start = pv_ba_start(existing_pvl->pv);
+ pp->pva.ba_size = pv_ba_size(existing_pvl->pv);
+ pp->pva.pe_start = pv_pe_start(existing_pvl->pv);
+ pp->pva.extent_size = pv_pe_size(existing_pvl->pv);
+ pp->pva.extent_count = pv_pe_count(existing_pvl->pv);
release_vg(vg);
return 1;
diff --git a/tools/toollib.c b/tools/toollib.c
index dc025e4..b640285 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3430,22 +3430,23 @@ void pvcreate_each_params_set_defaults(struct pvcreate_each_params *pp)
memset(pp, 0, sizeof(*pp));
pp->zero = 1;
- pp->size = 0;
- pp->data_alignment = UINT64_C(0);
- pp->data_alignment_offset = UINT64_C(0);
- pp->pvmetadatacopies = DEFAULT_PVMETADATACOPIES;
- pp->pvmetadatasize = DEFAULT_PVMETADATASIZE;
- pp->labelsector = DEFAULT_LABELSECTOR;
pp->force = PROMPT;
pp->yes = 0;
- pp->metadataignore = DEFAULT_PVMETADATAIGNORE;
pp->restorefile = NULL;
pp->uuid_str = NULL;
- pp->ba_start = 0;
- pp->ba_size = 0;
- pp->pe_start = PV_PE_START_CALC;
- pp->extent_count = 0;
- pp->extent_size = 0;
+
+ pp->pva.size = 0;
+ pp->pva.data_alignment = UINT64_C(0);
+ pp->pva.data_alignment_offset = UINT64_C(0);
+ pp->pva.pvmetadatacopies = DEFAULT_PVMETADATACOPIES;
+ pp->pva.pvmetadatasize = DEFAULT_PVMETADATASIZE;
+ pp->pva.label_sector = DEFAULT_LABELSECTOR;
+ pp->pva.metadataignore = DEFAULT_PVMETADATAIGNORE;
+ pp->pva.ba_start = 0;
+ pp->pva.ba_size = 0;
+ pp->pva.pe_start = PV_PE_START_CALC;
+ pp->pva.extent_count = 0;
+ pp->pva.extent_size = 0;
dm_list_init(&pp->prompts);
dm_list_init(&pp->arg_devices);
@@ -3467,7 +3468,7 @@ int pvcreate_each_params_from_args(struct cmd_context *cmd, struct pvcreate_each
LABEL_SCAN_SECTORS);
return 0;
} else {
- pp->labelsector = arg_int64_value(cmd, labelsector_ARG,
+ pp->pva.label_sector = arg_int64_value(cmd, labelsector_ARG,
DEFAULT_LABELSECTOR);
}
@@ -3489,14 +3490,14 @@ int pvcreate_each_params_from_args(struct cmd_context *cmd, struct pvcreate_each
}
if (arg_count(cmd, metadataignore_ARG))
- pp->metadataignore = arg_int_value(cmd, metadataignore_ARG,
+ pp->pva.metadataignore = arg_int_value(cmd, metadataignore_ARG,
DEFAULT_PVMETADATAIGNORE);
else
- pp->metadataignore = find_config_tree_bool(cmd, metadata_pvmetadataignore_CFG, NULL);
+ pp->pva.metadataignore = find_config_tree_bool(cmd, metadata_pvmetadataignore_CFG, NULL);
if (arg_count(cmd, pvmetadatacopies_ARG) &&
!arg_int_value(cmd, pvmetadatacopies_ARG, -1) &&
- pp->metadataignore) {
+ pp->pva.metadataignore) {
log_error("metadataignore only applies to metadatacopies > 0");
return 0;
}
@@ -3507,9 +3508,9 @@ int pvcreate_each_params_from_args(struct cmd_context *cmd, struct pvcreate_each
log_error("Physical volume data alignment may not be negative.");
return 0;
}
- pp->data_alignment = arg_uint64_value(cmd, dataalignment_ARG, UINT64_C(0));
+ pp->pva.data_alignment = arg_uint64_value(cmd, dataalignment_ARG, UINT64_C(0));
- if (pp->data_alignment > UINT32_MAX) {
+ if (pp->pva.data_alignment > UINT32_MAX) {
log_error("Physical volume data alignment is too big.");
return 0;
}
@@ -3518,22 +3519,22 @@ int pvcreate_each_params_from_args(struct cmd_context *cmd, struct pvcreate_each
log_error("Physical volume data alignment offset may not be negative");
return 0;
}
- pp->data_alignment_offset = arg_uint64_value(cmd, dataalignmentoffset_ARG, UINT64_C(0));
+ pp->pva.data_alignment_offset = arg_uint64_value(cmd, dataalignmentoffset_ARG, UINT64_C(0));
- if (pp->data_alignment_offset > UINT32_MAX) {
+ if (pp->pva.data_alignment_offset > UINT32_MAX) {
log_error("Physical volume data alignment offset is too big.");
return 0;
}
- if ((pp->data_alignment + pp->data_alignment_offset) &&
- (pp->pe_start != PV_PE_START_CALC)) {
- if ((pp->data_alignment ? pp->pe_start % pp->data_alignment : pp->pe_start) != pp->data_alignment_offset) {
+ if ((pp->pva.data_alignment + pp->pva.data_alignment_offset) &&
+ (pp->pva.pe_start != PV_PE_START_CALC)) {
+ if ((pp->pva.data_alignment ? pp->pva.pe_start % pp->pva.data_alignment : pp->pva.pe_start) != pp->pva.data_alignment_offset) {
log_warn("WARNING: Ignoring data alignment %s"
" incompatible with restored pe_start value %s)",
- display_size(cmd, pp->data_alignment + pp->data_alignment_offset),
- display_size(cmd, pp->pe_start));
- pp->data_alignment = 0;
- pp->data_alignment_offset = 0;
+ display_size(cmd, pp->pva.data_alignment + pp->pva.data_alignment_offset),
+ display_size(cmd, pp->pva.pe_start));
+ pp->pva.data_alignment = 0;
+ pp->pva.data_alignment_offset = 0;
}
}
@@ -3547,20 +3548,20 @@ int pvcreate_each_params_from_args(struct cmd_context *cmd, struct pvcreate_each
return 0;
}
- pp->pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0));
- if (!pp->pvmetadatasize)
- pp->pvmetadatasize = find_config_tree_int(cmd, metadata_pvmetadatasize_CFG, NULL);
+ pp->pva.pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0));
+ if (!pp->pva.pvmetadatasize)
+ pp->pva.pvmetadatasize = find_config_tree_int(cmd, metadata_pvmetadatasize_CFG, NULL);
- pp->pvmetadatacopies = arg_int_value(cmd, pvmetadatacopies_ARG, -1);
- if (pp->pvmetadatacopies < 0)
- pp->pvmetadatacopies = find_config_tree_int(cmd, metadata_pvmetadatacopies_CFG, NULL);
+ pp->pva.pvmetadatacopies = arg_int_value(cmd, pvmetadatacopies_ARG, -1);
+ if (pp->pva.pvmetadatacopies < 0)
+ pp->pva.pvmetadatacopies = find_config_tree_int(cmd, metadata_pvmetadatacopies_CFG, NULL);
- if (pp->pvmetadatacopies > 2) {
+ if (pp->pva.pvmetadatacopies > 2) {
log_error("Metadatacopies may only be 0, 1 or 2");
return 0;
}
- pp->ba_size = arg_uint64_value(cmd, bootloaderareasize_ARG, pp->ba_size);
+ pp->pva.ba_size = arg_uint64_value(cmd, bootloaderareasize_ARG, pp->pva.ba_size);
return 1;
}
@@ -3763,7 +3764,7 @@ static int _pvcreate_check_single(struct cmd_context *cmd,
/*
* Check if the uuid specified for the new PV is used by another PV.
*/
- if (!found && pv->dev && pp->uuid_str && id_equal(&pv->id, &pp->id)) {
+ if (!found && pv->dev && pp->uuid_str && id_equal(&pv->id, &pp->pva.id)) {
log_error("uuid %s already in use on \"%s\"", pp->uuid_str, pv_dev_name(pv));
pp->check_failed = 1;
return 0;
@@ -4114,7 +4115,6 @@ int pvcreate_each_device(struct cmd_context *cmd,
struct processing_handle *handle,
struct pvcreate_each_params *pp)
{
- struct pvcreate_restorable_params rp;
struct pvcreate_device *pd, *pd2;
struct pvcreate_prompt *prompt, *prompt2;
struct physical_volume *pv;
@@ -4445,23 +4445,7 @@ do_command:
log_debug("Creating a new PV on %s", pv_name);
- /* FIXME: get rid of rp usage in pv_create to avoid this. */
- memset(&rp, 0, sizeof(rp));
- rp.restorefile = pp->restorefile;
- if (pp->uuid_str) {
- rp.id = pp->id;
- rp.idp = &pp->id;
- }
- rp.ba_start = pp->ba_start;
- rp.ba_size = pp->ba_size;
- rp.pe_start = pp->pe_start;
- rp.extent_count = pp->extent_count;
- rp.extent_size = pp->extent_size;
-
- if (!(pv = pv_create(cmd, pd->dev, pp->size, pp->data_alignment,
- pp->data_alignment_offset, pp->labelsector,
- pp->pvmetadatacopies, pp->pvmetadatasize,
- pp->metadataignore, &rp))) {
+ if (!(pv = pv_create(cmd, pd->dev, &pp->pva))) {
log_error("Failed to setup physical volume \"%s\"", pv_name);
dm_list_move(&pp->arg_fail, &pd->list);
continue;
diff --git a/tools/vgconvert.c b/tools/vgconvert.c
index 1462d77..666b484 100644
--- a/tools/vgconvert.c
+++ b/tools/vgconvert.c
@@ -19,13 +19,11 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
struct processing_handle *handle __attribute__((unused)))
{
+ struct pv_create_args pva = { 0 };
struct logical_volume *lv;
struct lv_list *lvl;
struct lvinfo info;
int active = 0;
- int pvmetadatacopies = 0;
- uint64_t pvmetadatasize = 0;
- uint64_t bootloaderareasize = 0;
if (!vg_check_status(vg, LVM_WRITE | EXPORTED_VG))
return_ECMD_FAILED;
@@ -42,13 +40,13 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
return EINVALID_CMD_LINE;
}
- pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0));
- if (!pvmetadatasize)
- pvmetadatasize = find_config_tree_int(cmd, metadata_pvmetadatasize_CFG, NULL);
+ pva.pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0));
+ if (!pva.pvmetadatasize)
+ pva.pvmetadatasize = find_config_tree_int(cmd, metadata_pvmetadatasize_CFG, NULL);
- pvmetadatacopies = arg_int_value(cmd, pvmetadatacopies_ARG, -1);
- if (pvmetadatacopies < 0)
- pvmetadatacopies = find_config_tree_int(cmd, metadata_pvmetadatacopies_CFG, NULL);
+ pva.pvmetadatacopies = arg_int_value(cmd, pvmetadatacopies_ARG, -1);
+ if (pva.pvmetadatacopies < 0)
+ pva.pvmetadatacopies = find_config_tree_int(cmd, metadata_pvmetadatacopies_CFG, NULL);
}
if (cmd->fmt->features & FMT_BAS) {
@@ -57,7 +55,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
return EINVALID_CMD_LINE;
}
- bootloaderareasize = arg_uint64_value(cmd, bootloaderareasize_ARG, UINT64_C(0));
+ pva.ba_size = arg_uint64_value(cmd, bootloaderareasize_ARG, UINT64_C(0));
}
if (!vg_check_new_extent_size(cmd->fmt, vg->extent_size))
@@ -128,11 +126,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
log_verbose("Writing metadata for VG %s using format %s", vg_name,
cmd->fmt->name);
- if (!backup_restore_vg(cmd, vg, 0, 1,
- bootloaderareasize,
- pvmetadatacopies,
- pvmetadatasize,
- arg_int64_value(cmd, labelsector_ARG, DEFAULT_LABELSECTOR))) {
+ if (!backup_restore_vg(cmd, vg, 0, 1, &pva)) {
log_error("Conversion failed for volume group %s.", vg_name);
log_error("Use pvcreate and vgcfgrestore to repair from "
"archived metadata.");
8 years, 2 months
master - metadata: add fixme about code used only by liblvm
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c201ee09bdfdfc...
Commit: c201ee09bdfdfccecd5975ee26537cf790b25e25
Parent: 04d34da706a596b7c1d7c5376fb42aa99374fc51
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 16 15:33:40 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Feb 25 09:14:10 2016 -0600
metadata: add fixme about code used only by liblvm
---
lib/metadata/metadata.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 20caab9..5a51782 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -749,6 +749,24 @@ bad:
}
/*
+ * FIXME: commands shifting to common code in toollib have left a large
+ * amount of code only used by liblvm. Either remove this by shifting
+ * liblvm to use toollib, or isolate all this code into a liblvm-specific
+ * source file. All the following and more are only used by liblvm:
+ *
+ * . vg_extend()
+ * . vg_extend_single_pv()
+ * . pvcreate_vol()
+ * . _pvcreate_check()
+ * . _pvcreate_write()
+ * . pvremove_many()
+ * . pvremove_single()
+ * . find_pv_by_name()
+ * . get_pvs()
+ * . the vg->pvs_to_write list and pv_to_write struct
+ */
+
+/*
* Extend a VG by a single PV / device path
*
* Parameters:
8 years, 2 months