master - vgchange: Prevent lvm1 system ID changes.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dcba4781eaa554...
Commit: dcba4781eaa5545981a831c3c27374d3fce085fe
Parent: 340369ab2526bc3cf5c52c2738998e589865f4a2
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Mar 4 00:50:54 2015 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Mar 4 00:50:54 2015 +0000
vgchange: Prevent lvm1 system ID changes.
(This system_id setting code shouldn't be in two places.)
---
tools/vgchange.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 8371310..3f97722 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -523,6 +523,13 @@ static int _vgchange_system_id(struct cmd_context *cmd, struct volume_group *vg)
const char *system_id;
const char *system_id_arg_str = arg_str_value(cmd, systemid_ARG, NULL);
+ /* FIXME Merge with vg_set_system_id() */
+ if (systemid_on_pvs(vg)) {
+ log_error("Metadata format %s does not support this type of system ID.",
+ vg->fid->fmt->name);
+ return 0;
+ }
+
if (!(system_id = system_id_from_string(cmd, system_id_arg_str))) {
log_error("Unable to set system ID.");
return 0;
9 years, 1 month
master - format1: Export generate_lvm1_system_id.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=340369ab2526bc...
Commit: 340369ab2526bc3cf5c52c2738998e589865f4a2
Parent: 4e6f3e5162e06de09c38e360cbd1d348939ad7f0
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Mar 4 00:44:15 2015 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Mar 4 00:44:15 2015 +0000
format1: Export generate_lvm1_system_id.
Export _lvm1_system_id as generate_lvm1_system_id and call it in
vg_setup() so it is set before writing the metadata to disk
and not missing from the initial metadata backup file.
---
lib/format1/disk-rep.h | 2 ++
lib/format1/format1.c | 5 +++++
lib/format1/import-export.c | 8 ++++----
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/lib/format1/disk-rep.h b/lib/format1/disk-rep.h
index 729601e..9d1c8a5 100644
--- a/lib/format1/disk-rep.h
+++ b/lib/format1/disk-rep.h
@@ -245,4 +245,6 @@ int get_free_vg_number(struct format_instance *fid, struct dev_filter *filter,
int export_vg_number(struct format_instance *fid, struct dm_list *pvds,
const char *vg_name, struct dev_filter *filter);
+int generate_lvm1_system_id(struct cmd_context *cmd, char *s, const char *prefix);
+
#endif
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index f7df7c3..19df8aa 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -496,6 +496,11 @@ static int _format1_vg_setup(struct format_instance *fid, struct volume_group *v
if (!vg_check_new_extent_size(vg->fid->fmt, vg->extent_size))
return_0;
+ /* Generate lvm1_system_id if not yet set */
+ if (!*vg->lvm1_system_id &&
+ !generate_lvm1_system_id(vg->cmd, vg->lvm1_system_id, ""))
+ return_0;
+
return 1;
}
diff --git a/lib/format1/import-export.c b/lib/format1/import-export.c
index a3c060f..8155b04 100644
--- a/lib/format1/import-export.c
+++ b/lib/format1/import-export.c
@@ -125,7 +125,7 @@ int import_pv(const struct format_type *fmt, struct dm_pool *mem,
return 1;
}
-static int _lvm1_system_id(struct cmd_context *cmd, char *s, const char *prefix)
+int generate_lvm1_system_id(struct cmd_context *cmd, char *s, const char *prefix)
{
if (dm_snprintf(s, NAME_LEN, "%s%s%lu",
@@ -165,7 +165,7 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute__((unused
if (!*vg->lvm1_system_id ||
strncmp(vg->lvm1_system_id, EXPORTED_TAG,
sizeof(EXPORTED_TAG) - 1)) {
- if (!_lvm1_system_id(cmd, (char *)pvd->system_id, EXPORTED_TAG))
+ if (!generate_lvm1_system_id(cmd, (char *)pvd->system_id, EXPORTED_TAG))
return_0;
}
if (strlen((char *)pvd->vg_name) + sizeof(EXPORTED_TAG) >
@@ -180,13 +180,13 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute__((unused
/* Is VG being imported? */
if (vg && !vg_is_exported(vg) && *vg->lvm1_system_id &&
!strncmp(vg->lvm1_system_id, EXPORTED_TAG, sizeof(EXPORTED_TAG) - 1)) {
- if (!_lvm1_system_id(cmd, (char *)pvd->system_id, IMPORTED_TAG))
+ if (!generate_lvm1_system_id(cmd, (char *)pvd->system_id, IMPORTED_TAG))
return_0;
}
/* Generate system_id if PV is in VG */
if (!pvd->system_id[0])
- if (!_lvm1_system_id(cmd, (char *)pvd->system_id, ""))
+ if (!generate_lvm1_system_id(cmd, (char *)pvd->system_id, ""))
return_0;
/* Update internal system_id if we changed it */
9 years, 1 month
master - archives: Preserve format type in file.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4e6f3e5162e06d...
Commit: 4e6f3e5162e06de09c38e360cbd1d348939ad7f0
Parent: 24774959221ab75038c336074470108a0727e672
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Mar 4 00:30:26 2015 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Mar 4 00:30:26 2015 +0000
archives: Preserve format type in file.
format_text processes both lvm2 on-disk metadata and metadata read
from other sources such as backup files. Add original_fmt field
to retain the format type of the original metadata.
Before this patch, /etc/lvm/archives would contain backups of
lvm1 metadata with format = "lvm2" unless the source was lvm1 on-disk
metadata.
---
WHATS_NEW | 1 +
lib/format_text/export.c | 9 +++++++--
lib/format_text/import_vsn1.c | 9 ++++++++-
lib/metadata/vg.h | 1 +
4 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 87ea7b6..ae8bc70 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.117 -
====================================
+ Preserve original format type field when processing backup files.
Implement status action for lvm2-monitor initscript to display monitored LVs.
Allow lvchange -p to change kernel state only if metadata state differs.
Fix incorrect persistent .cache after report with label fields only (2.02.106).
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index d6a92c4..ddaaebb 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -393,6 +393,7 @@ static int _out_tags(struct formatter *f, struct dm_list *tagsl)
static int _print_vg(struct formatter *f, struct volume_group *vg)
{
char buffer[4096];
+ const struct format_type *fmt = NULL;
if (!id_write_format(&vg->id, buffer, sizeof(buffer)))
return_0;
@@ -401,8 +402,12 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
outf(f, "seqno = %u", vg->seqno);
- if (vg->fid && vg->fid->fmt)
- outfc(f, "# informational", "format = \"%s\"", vg->fid->fmt->name);
+ if (vg->original_fmt)
+ fmt = vg->original_fmt;
+ else if (vg->fid)
+ fmt = vg->fid->fmt;
+ if (fmt)
+ outfc(f, "# informational", "format = \"%s\"", fmt->name);
if (!_print_flag_config(f, vg->status, VG_FLAGS))
return_0;
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 42ff451..366e61c 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -733,7 +733,7 @@ static struct volume_group *_read_vg(struct format_instance *fid,
{
const struct dm_config_node *vgn;
const struct dm_config_value *cv;
- const char *str;
+ const char *str, *format_str;
struct volume_group *vg;
struct dm_hash_table *pv_hash = NULL, *lv_hash = NULL;
unsigned scan_done_once = use_cached_pvs;
@@ -775,6 +775,13 @@ static struct volume_group *_read_vg(struct format_instance *fid,
vgn = vgn->child;
+ /* A backup file might be a backup of a different format */
+ if (dm_config_get_str(vgn, "format", &format_str) &&
+ !(vg->original_fmt = get_format_by_name(fid->fmt->cmd, format_str))) {
+ log_error("Unrecognised format %s for volume group %s.", format_str, vg->name);
+ goto bad;
+ }
+
if (dm_config_get_str(vgn, "system_id", &str))
strncpy(system_id, str, NAME_LEN);
diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h
index 2964b82..2467721 100644
--- a/lib/metadata/vg.h
+++ b/lib/metadata/vg.h
@@ -44,6 +44,7 @@ struct volume_group {
struct cmd_context *cmd;
struct dm_pool *vgmem;
struct format_instance *fid;
+ const struct format_type *original_fmt; /* Set when processing backup files */
struct lvmcache_vginfo *vginfo;
struct dm_list *cmd_vgs;/* List of wanted/locked and opened VGs */
uint32_t cmd_missing_vgs;/* Flag marks missing VG */
9 years, 1 month
master - lvchange, vgchange: fix the system_id check
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=24774959221ab7...
Commit: 24774959221ab75038c336074470108a0727e672
Parent: cccc2b2980f8321e5f8c8b553f50966f7e1b5abc
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Mar 3 16:45:16 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Mar 3 16:45:16 2015 -0600
lvchange, vgchange: fix the system_id check
The check for matching system_id needs to check
that the system_id is not blank.
---
tools/lvchange.c | 3 ++-
tools/vgchange.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index bf7e356..0351e4e 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -191,7 +191,8 @@ static int _lvchange_activate(struct cmd_context *cmd, struct logical_volume *lv
* a foreign VG, which allows the VG to be accessed by lvchange -a
* so the LV can be deactivated.
*/
- if (lv->vg->system_id && cmd->system_id &&
+ if (lv->vg->system_id && lv->vg->system_id[0] &&
+ cmd->system_id && cmd->system_id[0] &&
strcmp(lv->vg->system_id, cmd->system_id) &&
is_change_activating(activate)) {
log_error("Cannot activate LVs in a foreign VG.");
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 38a129f..8371310 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -201,7 +201,8 @@ int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
* a foreign VG, which allows the VG to be accessed by vgchange -a
* so the LV can be deactivated.
*/
- if (vg->system_id && cmd->system_id &&
+ if (vg->system_id && vg->system_id[0] &&
+ cmd->system_id && cmd->system_id[0] &&
strcmp(vg->system_id, cmd->system_id) &&
is_change_activating(activate)) {
log_error("Cannot activate LVs in a foreign VG.");
9 years, 1 month
master - vgchange: deactivate LVs in foreign VG
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cccc2b2980f832...
Commit: cccc2b2980f8321e5f8c8b553f50966f7e1b5abc
Parent: 926b38c0d73d958e5774082ff17fb2a48e20d32e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Mar 3 13:23:13 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Mar 3 13:23:13 2015 -0600
vgchange: deactivate LVs in foreign VG
Apply the same logic as lvchange, which allows
deactivating LVs in a foreign VG.
---
tools/vgchange.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 199ee82..38a129f 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -197,6 +197,18 @@ int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
int do_activate = is_change_activating(activate);
/*
+ * We can get here in the odd case where an LV is already active in
+ * a foreign VG, which allows the VG to be accessed by vgchange -a
+ * so the LV can be deactivated.
+ */
+ if (vg->system_id && cmd->system_id &&
+ strcmp(vg->system_id, cmd->system_id) &&
+ is_change_activating(activate)) {
+ log_error("Cannot activate LVs in a foreign VG.");
+ return ECMD_FAILED;
+ }
+
+ /*
* Safe, since we never write out new metadata here. Required for
* partial activation to work.
*/
@@ -795,6 +807,9 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
if (!update || !update_partial_unsafe)
cmd->handles_missing_pvs = 1;
+ if (arg_is_set(cmd, activate_ARG))
+ cmd->include_active_foreign_vgs = 1;
+
return process_each_vg(cmd, argc, argv, update ? READ_FOR_UPDATE : 0,
NULL, &vgchange_single);
}
9 years, 1 month
master - spec: Add lvmlocal.conf to RPMs.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=926b38c0d73d95...
Commit: 926b38c0d73d958e5774082ff17fb2a48e20d32e
Parent: 1a41e649a68b03fd6ea4769ed06e83f9d9785c45
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Tue Mar 3 15:45:47 2015 +0100
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Tue Mar 3 15:47:13 2015 +0100
spec: Add lvmlocal.conf to RPMs.
---
spec/packages.inc | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/spec/packages.inc b/spec/packages.inc
index 9fb3060..6d6f92e 100644
--- a/spec/packages.inc
+++ b/spec/packages.inc
@@ -149,6 +149,7 @@ fi
%dir %{_sysconfdir}/lvm
%ghost %{_sysconfdir}/lvm/cache/.cache
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lvm/lvm.conf
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lvm/lvmlocal.conf
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lvm/profile/command_profile_template.profile
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lvm/profile/metadata_profile_template.profile
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lvm/profile/thin-generic.profile
9 years, 1 month
master - metadata: vg: alloc lvm1_system_id in alloc_vg sooner
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1a41e649a68b03...
Commit: 1a41e649a68b03fd6ea4769ed06e83f9d9785c45
Parent: eeaf3f2e88ef2c664b5cbefb9c9a9e7ada0c752b
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Mar 2 13:00:37 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Mar 2 13:00:45 2015 +0100
metadata: vg: alloc lvm1_system_id in alloc_vg sooner
---
lib/metadata/vg.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 2993655..2bed1ad 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -41,6 +41,12 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
return NULL;
}
+ if (!(vg->lvm1_system_id = dm_pool_zalloc(vgmem, NAME_LEN + 1))) {
+ log_error("Failed to allocate VG systemd id.");
+ dm_pool_destroy(vgmem);
+ return NULL;
+ }
+
vg->cmd = cmd;
vg->vgmem = vgmem;
vg->alloc = ALLOC_NORMAL;
@@ -57,12 +63,6 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
dm_list_init(&vg->tags);
dm_list_init(&vg->removed_pvs);
- if (!(vg->lvm1_system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN + 1))) {
- log_error("Failed to allocate VG systemd id.");
- dm_pool_destroy(vgmem);
- return NULL;
- }
-
log_debug_mem("Allocated VG %s at %p.", vg->name, vg);
return vg;
9 years, 1 month
master - metadata: vg: add missing vg->lvm1_system_id initialization
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=eeaf3f2e88ef2c...
Commit: eeaf3f2e88ef2c664b5cbefb9c9a9e7ada0c752b
Parent: 047fe6c59fe2cf3a52208b219caebed469ed6bdc
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Mar 2 12:16:55 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Mar 2 12:17:27 2015 +0100
metadata: vg: add missing vg->lvm1_system_id initialization
The vg->lvm1_systemd_id needs to be initialized as all the code around
counts with that. Just like we initialize lvm1_system_id in vg_create
(no matter if it's actually LVM1 or LVM2 format), this patch adds this
init in alloc_vg as well so the rest of the code does not segfaul
when trying to access vg->lvm1_system_id.
---
lib/metadata/vg.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 446aa7c..2993655 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -57,6 +57,12 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
dm_list_init(&vg->tags);
dm_list_init(&vg->removed_pvs);
+ if (!(vg->lvm1_system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN + 1))) {
+ log_error("Failed to allocate VG systemd id.");
+ dm_pool_destroy(vgmem);
+ return NULL;
+ }
+
log_debug_mem("Allocated VG %s at %p.", vg->name, vg);
return vg;
9 years, 1 month
master - report: check value of args_are_pvs, not the pointer (fix for commit 9ea77b7)
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=047fe6c59fe2cf...
Commit: 047fe6c59fe2cf3a52208b219caebed469ed6bdc
Parent: c32efc7f7ed9fa3257e667cd8b70d8a5c8379b4b
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Mar 2 10:36:32 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Mar 2 10:36:32 2015 +0100
report: check value of args_are_pvs, not the pointer (fix for commit 9ea77b7)
---
tools/reporter.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/reporter.c b/tools/reporter.c
index 9bf366e..eb6a4ed 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -576,7 +576,7 @@ static void _check_pv_list(struct cmd_context *cmd, int argc, char **argv,
*report_type == LABEL ||
*report_type == PVSEGS) ? 1 : 0;
- if (args_are_pvs && argc) {
+ if (*args_are_pvs && argc) {
for (i = 0; i < argc; i++) {
if (!rescan_done && !dev_cache_get(argv[i], cmd->full_filter)) {
cmd->filter->wipe(cmd->filter);
9 years, 1 month