master - lib: return value
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=60427d5d429b88...
Commit: 60427d5d429b88d1c6cd13f90794f9b50dc366e6
Parent: 4d16bfaabb5d72009e80cb6f5bc0d650101ebb33
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 6 09:04:31 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 6 13:51:43 2015 +0100
lib: return value
Drop label out: with goto and return NULL directly.
Add log_debug() for zero metadata offset.
---
lib/format_text/format-text.c | 30 ++++++++++++++----------------
1 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index c142e1b..375a793 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -1142,7 +1142,7 @@ const char *vgname_from_mda(const struct format_type *fmt,
if (!mdah) {
log_error(INTERNAL_ERROR "vgname_from_mda called with NULL pointer for mda_header");
- goto_out;
+ return NULL;
}
/* FIXME Cope with returning a list */
@@ -1151,13 +1151,16 @@ const char *vgname_from_mda(const struct format_type *fmt,
/*
* If no valid offset, do not try to search for vgname
*/
- if (!rlocn->offset)
- goto out;
+ if (!rlocn->offset) {
+ log_debug("%s: found metadata with offset 0.",
+ dev_name(dev_area->dev));
+ return NULL;
+ }
/* Do quick check for a vgname */
if (!dev_read(dev_area->dev, dev_area->start + rlocn->offset,
NAME_LEN, buf))
- goto_out;
+ return_NULL;
while (buf[len] && !isspace(buf[len]) && buf[len] != '{' &&
len < (NAME_LEN - 1))
@@ -1167,7 +1170,7 @@ const char *vgname_from_mda(const struct format_type *fmt,
/* Ignore this entry if the characters aren't permissible */
if (!validate_name(buf))
- goto_out;
+ return_NULL;
/* We found a VG - now check the metadata */
if (rlocn->offset + rlocn->size > mdah->size)
@@ -1176,7 +1179,7 @@ const char *vgname_from_mda(const struct format_type *fmt,
if (wrap > rlocn->offset) {
log_error("%s: metadata too large for circular buffer",
dev_name(dev_area->dev));
- goto out;
+ return NULL;
}
/* FIXME 64-bit */
@@ -1188,18 +1191,14 @@ const char *vgname_from_mda(const struct format_type *fmt,
MDA_HEADER_SIZE),
wrap, calc_crc, rlocn->checksum,
vgid, vgstatus, creation_host)))
- goto_out;
+ return_NULL;
/* Ignore this entry if the characters aren't permissible */
- if (!validate_name(vgname)) {
- vgname = NULL;
- goto_out;
- }
+ if (!validate_name(vgname))
+ return_NULL;
- if (!id_write_format(vgid, uuid, sizeof(uuid))) {
- vgname = NULL;
- goto_out;
- }
+ if (!id_write_format(vgid, uuid, sizeof(uuid)))
+ return_NULL;
log_debug_metadata("%s: Found metadata at %" PRIu64 " size %" PRIu64
" (in area at %" PRIu64 " size %" PRIu64
@@ -1218,7 +1217,6 @@ const char *vgname_from_mda(const struct format_type *fmt,
*mda_free_sectors = ((buffer_size - 2 * current_usage) / 2) >> SECTOR_SHIFT;
}
- out:
return vgname;
}
8 years, 6 months
master - lib: zero returned labeller struct
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4d16bfaabb5d72...
Commit: 4d16bfaabb5d72009e80cb6f5bc0d650101ebb33
Parent: 6f68f4364b537cf52a27b5e53bb7f10de5a938fe
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 6 08:42:20 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 6 13:17:39 2015 +0100
lib: zero returned labeller struct
Return zeroed struct.
(Structure will be extended, so ensure all members are initilized.)
---
lib/format_text/text_label.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/format_text/text_label.c b/lib/format_text/text_label.c
index 516d694..e451be4 100644
--- a/lib/format_text/text_label.c
+++ b/lib/format_text/text_label.c
@@ -465,7 +465,7 @@ struct labeller *text_labeller_create(const struct format_type *fmt)
{
struct labeller *l;
- if (!(l = dm_malloc(sizeof(*l)))) {
+ if (!(l = dm_zalloc(sizeof(*l)))) {
log_error("Couldn't allocate labeller object.");
return NULL;
}
8 years, 6 months
master - devices: avoid extra open() syscall
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6f68f4364b537c...
Commit: 6f68f4364b537cf52a27b5e53bb7f10de5a938fe
Parent: b48ff3b94e7cd771bbaf42f38b546054d02bc0f2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Mar 3 15:37:17 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 6 13:17:39 2015 +0100
devices: avoid extra open() syscall
If the device is already opened by lvm's device cache,
avoid extra syscall opening devices for obtaining its size.
---
WHATS_NEW | 1 +
lib/device/dev-io.c | 17 +++++++----------
lib/device/device.h | 2 +-
lib/report/report.c | 2 +-
4 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 46783e1..b62a632 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.118 -
=================================
+ Save extra device open/close when scanning device for size.
Fix seg_monitor field to report status also for mirrors and thick snapshots.
Version 2.02.117 - 4th March 2015
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index 122b616..d712f31 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -289,25 +289,22 @@ static int _dev_get_size_file(const struct device *dev, uint64_t *size)
return 1;
}
-static int _dev_get_size_dev(const struct device *dev, uint64_t *size)
+static int _dev_get_size_dev(struct device *dev, uint64_t *size)
{
- int fd;
const char *name = dev_name(dev);
- if ((fd = open(name, O_RDONLY)) < 0) {
- log_sys_error("open", name);
- return 0;
- }
+ if (!dev_open_readonly(dev))
+ return_0;
- if (ioctl(fd, BLKGETSIZE64, size) < 0) {
+ if (ioctl(dev_fd(dev), BLKGETSIZE64, size) < 0) {
log_sys_error("ioctl BLKGETSIZE64", name);
- if (close(fd))
+ if (!dev_close(dev))
log_sys_error("close", name);
return 0;
}
*size >>= BLKSIZE_SHIFT; /* Convert to sectors */
- if (close(fd))
+ if (!dev_close(dev))
log_sys_error("close", name);
log_very_verbose("%s: size is %" PRIu64 " sectors", name, *size);
@@ -377,7 +374,7 @@ static int _dev_discard_blocks(struct device *dev, uint64_t offset_bytes, uint64
* Public functions
*---------------------------------------------------------------*/
-int dev_get_size(const struct device *dev, uint64_t *size)
+int dev_get_size(struct device *dev, uint64_t *size)
{
if (!dev)
return 0;
diff --git a/lib/device/device.h b/lib/device/device.h
index 0d38f96..dcc3713 100644
--- a/lib/device/device.h
+++ b/lib/device/device.h
@@ -94,7 +94,7 @@ int dev_ext_release(struct device *dev);
* All io should use these routines.
*/
int dev_get_block_size(struct device *dev, unsigned int *phys_block_size, unsigned int *block_size);
-int dev_get_size(const struct device *dev, uint64_t *size);
+int dev_get_size(struct device *dev, uint64_t *size);
int dev_get_read_ahead(struct device *dev, uint32_t *read_ahead);
int dev_discard_blocks(struct device *dev, uint64_t offset_bytes, uint64_t size_bytes);
diff --git a/lib/report/report.c b/lib/report/report.c
index 4ef2b04..86b0a54 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -965,7 +965,7 @@ static int _devsize_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
{
- const struct device *dev = *(const struct device * const *) data;
+ struct device *dev = *(struct device * const *) data;
uint64_t size;
if (!dev || !dev->dev || !dev_get_size(dev, &size))
8 years, 6 months
master - man: add info to lvmsystemid
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b48ff3b94e7cd7...
Commit: b48ff3b94e7cd771bbaf42f38b546054d02bc0f2
Parent: 5e25bca1a98f2376b94904a2e220a3e2f68923ad
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Mar 5 12:12:42 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Mar 5 12:12:42 2015 -0600
man: add info to lvmsystemid
about losing access to a VG if lvm is downgraded
to an earlier version.
---
man/lvmsystemid.7.in | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/man/lvmsystemid.7.in b/man/lvmsystemid.7.in
index 0881b1e..76b0e83 100644
--- a/man/lvmsystemid.7.in
+++ b/man/lvmsystemid.7.in
@@ -42,13 +42,7 @@ maximum length of a system_id is 128 characters.
To benefit fully from system_id, all hosts must have system_id set, and
VGs must have system_id set. A VG on shared storage can be damaged or
-destroyed in the following cases which the user must be careful to avoid:
-
-.IP \[bu] 2
-A host using an old version of lvm without the system_id feature will not
-recognize the system_id of other hosts' VGs. VGs with a new system_id
-are nominally protected from old versions of lvm by appearing to be
-read-only to the old versions.
+destroyed in some cases which the user must be careful to avoid.
.IP \[bu] 2
A VG without a system_id can be used without restriction from any host,
@@ -73,6 +67,19 @@ operations and corrupting the PVs. See the
.B orphans
section for more information.
+.IP \[bu] 2
+A host using an old version of lvm without the system_id feature will not
+recognize a new system_id in VGs from other hosts. Even though the old
+version of lvm is not blocked from reading a VG with a system_id, it is
+blocked from writing to the VG (or its LVs). The new system_id changes
+the write mode of a VG, making it appear read-only to previous lvm
+versions.
+
+This also means that if a host downgrades its version of lvm, it would
+lose access to any VGs it had created with a system_id. To avoid this,
+the system_id should be removed from VGs before downgrading to an lvm
+version without the system_id feature.
+
.P
.SS Types of VG access
8 years, 6 months
master - system_id: avoid munging vg and lv fields
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5e25bca1a98f23...
Commit: 5e25bca1a98f2376b94904a2e220a3e2f68923ad
Parent: 8bb76aea81574042c6010291a8c799a90570b0d3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Mar 5 10:23:16 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Mar 5 10:23:16 2015 -0600
system_id: avoid munging vg and lv fields
Munge the WRITE/WRITE_LOCKED flags in a temp variable
instead of in the vg/lv fields.
---
lib/format_text/export.c | 28 ++++++++++------------------
1 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index ec01fcc..2d985b4 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -394,6 +394,7 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
{
char buffer[4096];
const struct format_type *fmt = NULL;
+ uint64_t status = vg->status;
if (!id_write_format(&vg->id, buffer, sizeof(buffer)))
return_0;
@@ -413,19 +414,14 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
* Removing WRITE and adding WRITE_LOCKED makes it read-only
* to old versions of lvm that only look for WRITE.
*/
- if ((vg->status & LVM_WRITE) && vg_flag_write_locked(vg)) {
- vg->status &= ~LVM_WRITE;
- vg->status |= LVM_WRITE_LOCKED;
+ if ((status & LVM_WRITE) && vg_flag_write_locked(vg)) {
+ status &= ~LVM_WRITE;
+ status |= LVM_WRITE_LOCKED;
}
- if (!_print_flag_config(f, vg->status, VG_FLAGS))
+ if (!_print_flag_config(f, status, VG_FLAGS))
return_0;
- if (vg->status & LVM_WRITE_LOCKED) {
- vg->status |= LVM_WRITE;
- vg->status &= ~LVM_WRITE_LOCKED;
- }
-
if (!_out_tags(f, &vg->tags))
return_0;
@@ -621,6 +617,7 @@ static int _print_lv(struct formatter *f, struct logical_volume *lv)
int seg_count;
struct tm *local_tm;
time_t ts;
+ uint64_t status = lv->status;
outnl(f);
outf(f, "%s {", lv->name);
@@ -636,19 +633,14 @@ static int _print_lv(struct formatter *f, struct logical_volume *lv)
* Removing WRITE and adding WRITE_LOCKED makes it read-only
* to old versions of lvm that only look for WRITE.
*/
- if ((lv->status & LVM_WRITE) && vg_flag_write_locked(lv->vg)) {
- lv->status &= ~LVM_WRITE;
- lv->status |= LVM_WRITE_LOCKED;
+ if ((status & LVM_WRITE) && vg_flag_write_locked(lv->vg)) {
+ status &= ~LVM_WRITE;
+ status |= LVM_WRITE_LOCKED;
}
- if (!_print_flag_config(f, lv->status, LV_FLAGS))
+ if (!_print_flag_config(f, status, LV_FLAGS))
return_0;
- if (lv->status & LVM_WRITE_LOCKED) {
- lv->status |= LVM_WRITE;
- lv->status &= ~LVM_WRITE_LOCKED;
- }
-
if (!_out_tags(f, &lv->tags))
return_0;
8 years, 6 months
master - system_id: undo the previous changes to the lvm1 code
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8bb76aea815740...
Commit: 8bb76aea81574042c6010291a8c799a90570b0d3
Parent: 1e65fdd9ba00ab249ab07d8b5815c398ded556e3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Mar 5 10:13:05 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Mar 5 10:13:05 2015 -0600
system_id: undo the previous changes to the lvm1 code
The system_id and lock_type compat changes do not apply
to the lvm1 code.
---
lib/format1/disk-rep.h | 2 --
lib/format1/import-export.c | 16 ++--------------
2 files changed, 2 insertions(+), 16 deletions(-)
diff --git a/lib/format1/disk-rep.h b/lib/format1/disk-rep.h
index 37f7282..9d1c8a5 100644
--- a/lib/format1/disk-rep.h
+++ b/lib/format1/disk-rep.h
@@ -41,7 +41,6 @@
#define VG_WRITE 0x02 /* " */
#define VG_CLUSTERED 0x04 /* " */
#define VG_SHARED 0x08 /* " */
-#define VG_WRITE_LOCKED 0x10 /* " */
/* logical volume */
#define LV_ACTIVE 0x01 /* lv_status */
@@ -52,7 +51,6 @@
#define LV_WRITE 0x02 /* " */
#define LV_SNAPSHOT 0x04 /* " */
#define LV_SNAPSHOT_ORG 0x08 /* " */
-#define LV_WRITE_LOCKED 0x10 /* " */
#define LV_BADBLOCK_ON 0x01 /* lv_badblock */
diff --git a/lib/format1/import-export.c b/lib/format1/import-export.c
index b898e65..9b387e2 100644
--- a/lib/format1/import-export.c
+++ b/lib/format1/import-export.c
@@ -242,9 +242,6 @@ int import_vg(struct dm_pool *mem,
if (vgd->vg_access & VG_WRITE)
vg->status |= LVM_WRITE;
- if (vgd->vg_access & VG_WRITE_LOCKED)
- vg->status |= LVM_WRITE;
-
if (vgd->vg_access & VG_CLUSTERED)
vg->status |= CLUSTERED;
@@ -269,12 +266,9 @@ int export_vg(struct vg_disk *vgd, struct volume_group *vg)
if (vg->status & LVM_READ)
vgd->vg_access |= VG_READ;
- if ((vg->status & LVM_WRITE) && !vg_flag_write_locked(vg))
+ if (vg->status & LVM_WRITE)
vgd->vg_access |= VG_WRITE;
- if ((vg->status & LVM_WRITE) && vg_flag_write_locked(vg))
- vgd->vg_access |= VG_WRITE_LOCKED;
-
if (vg_is_clustered(vg))
vgd->vg_access |= VG_CLUSTERED;
@@ -326,9 +320,6 @@ int import_lv(struct cmd_context *cmd, struct dm_pool *mem,
if (lvd->lv_access & LV_WRITE)
lv->status |= LVM_WRITE;
- if (lvd->lv_access & LV_WRITE_LOCKED)
- lv->status |= LVM_WRITE;
-
if (lvd->lv_badblock)
lv->status |= BADBLOCK_ON;
@@ -361,12 +352,9 @@ static void _export_lv(struct lv_disk *lvd, struct volume_group *vg,
if (lv->status & LVM_READ)
lvd->lv_access |= LV_READ;
- if ((lv->status & LVM_WRITE) && !vg_flag_write_locked(vg))
+ if (lv->status & LVM_WRITE)
lvd->lv_access |= LV_WRITE;
- if ((lv->status & LVM_WRITE) && vg_flag_write_locked(vg))
- lvd->lv_access |= LV_WRITE_LOCKED;
-
if (lv->status & SPINDOWN_LV)
lvd->lv_status |= LV_SPINDOWN;
8 years, 6 months
master - system_id: make new VGs read-only for old lvm versions
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1e65fdd9ba00ab...
Commit: 1e65fdd9ba00ab249ab07d8b5815c398ded556e3
Parent: c6a57dc4f3af6aa8912fc1f969937e3e3c47f725
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Mar 4 11:30:53 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Mar 5 09:50:43 2015 -0600
system_id: make new VGs read-only for old lvm versions
Previous versions of lvm will not obey the restrictions
imposed by the new system_id, and would allow such a VG
to be written. So, a VG with a new system_id is further
changed to force previous lvm versions to treat it as
read-only. This is done by removing the WRITE flag from
the metadata status line of these VGs, and putting a new
WRITE_LOCKED flag in the flags line of the metadata.
Versions of lvm that recognize WRITE_LOCKED, also obey the
new system_id. For these lvm versions, WRITE_LOCKED is
identical to WRITE, and the rules associated with matching
system_id's are imposed.
A new VG lock_type field is also added that causes the same
WRITE/WRITE_LOCKED transformation when set. A previous
version of lvm will also see a VG with lock_type as read-only.
Versions of lvm that recognize WRITE_LOCKED, must also obey
the lock_type setting. Until the lock_type feature is added,
lvm will fail to read any VG with lock_type set and report an
error about an unsupported lock_type. Once the lock_type
feature is added, lvm will allow VGs with lock_type to be
used according to the rules imposed by the lock_type.
When both system_id and lock_type settings are removed, a VG
is written with the old WRITE status flag, and without the
new WRITE_LOCKED flag. This allows old versions of lvm to
use the VG as before.
---
lib/format1/disk-rep.h | 2 +
lib/format1/import-export.c | 16 ++++++++++-
lib/format_text/export.c | 31 ++++++++++++++++++++++
lib/format_text/flags.c | 2 +
lib/format_text/import_vsn1.c | 15 ++++++++++
lib/metadata/metadata-exported.h | 5 +++-
lib/metadata/metadata.c | 53 ++++++++++++++++++++++++++++++++++++++
lib/metadata/vg.h | 1 +
man/lvmsystemid.7.in | 5 ++-
9 files changed, 125 insertions(+), 5 deletions(-)
diff --git a/lib/format1/disk-rep.h b/lib/format1/disk-rep.h
index 9d1c8a5..37f7282 100644
--- a/lib/format1/disk-rep.h
+++ b/lib/format1/disk-rep.h
@@ -41,6 +41,7 @@
#define VG_WRITE 0x02 /* " */
#define VG_CLUSTERED 0x04 /* " */
#define VG_SHARED 0x08 /* " */
+#define VG_WRITE_LOCKED 0x10 /* " */
/* logical volume */
#define LV_ACTIVE 0x01 /* lv_status */
@@ -51,6 +52,7 @@
#define LV_WRITE 0x02 /* " */
#define LV_SNAPSHOT 0x04 /* " */
#define LV_SNAPSHOT_ORG 0x08 /* " */
+#define LV_WRITE_LOCKED 0x10 /* " */
#define LV_BADBLOCK_ON 0x01 /* lv_badblock */
diff --git a/lib/format1/import-export.c b/lib/format1/import-export.c
index 9b387e2..b898e65 100644
--- a/lib/format1/import-export.c
+++ b/lib/format1/import-export.c
@@ -242,6 +242,9 @@ int import_vg(struct dm_pool *mem,
if (vgd->vg_access & VG_WRITE)
vg->status |= LVM_WRITE;
+ if (vgd->vg_access & VG_WRITE_LOCKED)
+ vg->status |= LVM_WRITE;
+
if (vgd->vg_access & VG_CLUSTERED)
vg->status |= CLUSTERED;
@@ -266,9 +269,12 @@ int export_vg(struct vg_disk *vgd, struct volume_group *vg)
if (vg->status & LVM_READ)
vgd->vg_access |= VG_READ;
- if (vg->status & LVM_WRITE)
+ if ((vg->status & LVM_WRITE) && !vg_flag_write_locked(vg))
vgd->vg_access |= VG_WRITE;
+ if ((vg->status & LVM_WRITE) && vg_flag_write_locked(vg))
+ vgd->vg_access |= VG_WRITE_LOCKED;
+
if (vg_is_clustered(vg))
vgd->vg_access |= VG_CLUSTERED;
@@ -320,6 +326,9 @@ int import_lv(struct cmd_context *cmd, struct dm_pool *mem,
if (lvd->lv_access & LV_WRITE)
lv->status |= LVM_WRITE;
+ if (lvd->lv_access & LV_WRITE_LOCKED)
+ lv->status |= LVM_WRITE;
+
if (lvd->lv_badblock)
lv->status |= BADBLOCK_ON;
@@ -352,9 +361,12 @@ static void _export_lv(struct lv_disk *lvd, struct volume_group *vg,
if (lv->status & LVM_READ)
lvd->lv_access |= LV_READ;
- if (lv->status & LVM_WRITE)
+ if ((lv->status & LVM_WRITE) && !vg_flag_write_locked(vg))
lvd->lv_access |= LV_WRITE;
+ if ((lv->status & LVM_WRITE) && vg_flag_write_locked(vg))
+ lvd->lv_access |= LV_WRITE_LOCKED;
+
if (lv->status & SPINDOWN_LV)
lvd->lv_status |= LV_SPINDOWN;
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index 8232e2f..ec01fcc 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -409,9 +409,23 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
if (fmt)
outfc(f, "# informational", "format = \"%s\"", fmt->name);
+ /*
+ * Removing WRITE and adding WRITE_LOCKED makes it read-only
+ * to old versions of lvm that only look for WRITE.
+ */
+ if ((vg->status & LVM_WRITE) && vg_flag_write_locked(vg)) {
+ vg->status &= ~LVM_WRITE;
+ vg->status |= LVM_WRITE_LOCKED;
+ }
+
if (!_print_flag_config(f, vg->status, VG_FLAGS))
return_0;
+ if (vg->status & LVM_WRITE_LOCKED) {
+ vg->status |= LVM_WRITE;
+ vg->status &= ~LVM_WRITE_LOCKED;
+ }
+
if (!_out_tags(f, &vg->tags))
return_0;
@@ -420,6 +434,9 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
else if (vg->lvm1_system_id && *vg->lvm1_system_id)
outf(f, "system_id = \"%s\"", vg->lvm1_system_id);
+ if (vg->lock_type)
+ outf(f, "lock_type = \"%s\"", vg->lock_type);
+
outsize(f, (uint64_t) vg->extent_size, "extent_size = %u",
vg->extent_size);
outf(f, "max_lv = %u", vg->max_lv);
@@ -615,9 +632,23 @@ static int _print_lv(struct formatter *f, struct logical_volume *lv)
outf(f, "id = \"%s\"", buffer);
+ /*
+ * Removing WRITE and adding WRITE_LOCKED makes it read-only
+ * to old versions of lvm that only look for WRITE.
+ */
+ if ((lv->status & LVM_WRITE) && vg_flag_write_locked(lv->vg)) {
+ lv->status &= ~LVM_WRITE;
+ lv->status |= LVM_WRITE_LOCKED;
+ }
+
if (!_print_flag_config(f, lv->status, LV_FLAGS))
return_0;
+ if (lv->status & LVM_WRITE_LOCKED) {
+ lv->status |= LVM_WRITE;
+ lv->status &= ~LVM_WRITE_LOCKED;
+ }
+
if (!_out_tags(f, &lv->tags))
return_0;
diff --git a/lib/format_text/flags.c b/lib/format_text/flags.c
index cf01271..a975606 100644
--- a/lib/format_text/flags.c
+++ b/lib/format_text/flags.c
@@ -34,6 +34,7 @@ static const struct flag _vg_flags[] = {
{PVMOVE, "PVMOVE", STATUS_FLAG},
{LVM_READ, "READ", STATUS_FLAG},
{LVM_WRITE, "WRITE", STATUS_FLAG},
+ {LVM_WRITE_LOCKED, "WRITE_LOCKED", COMPATIBLE_FLAG},
{CLUSTERED, "CLUSTERED", STATUS_FLAG},
{SHARED, "SHARED", STATUS_FLAG},
{PARTIAL_VG, NULL, 0},
@@ -53,6 +54,7 @@ static const struct flag _pv_flags[] = {
static const struct flag _lv_flags[] = {
{LVM_READ, "READ", STATUS_FLAG},
{LVM_WRITE, "WRITE", STATUS_FLAG},
+ {LVM_WRITE_LOCKED, "WRITE_LOCKED", COMPATIBLE_FLAG},
{FIXED_MINOR, "FIXED_MINOR", STATUS_FLAG},
{VISIBLE_LV, "VISIBLE", STATUS_FLAG},
{PVMOVE, "PVMOVE", STATUS_FLAG},
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 64c08a0..6afe71d 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -550,6 +550,11 @@ static int _read_lvnames(struct format_instance *fid __attribute__((unused)),
return 0;
}
+ if (lv->status & LVM_WRITE_LOCKED) {
+ lv->status |= LVM_WRITE;
+ lv->status &= ~LVM_WRITE_LOCKED;
+ }
+
if (dm_config_has_node(lvn, "creation_time")) {
if (!_read_uint64(lvn, "creation_time", ×tamp)) {
log_error("Invalid creation_time for logical volume %s.",
@@ -785,6 +790,11 @@ static struct volume_group *_read_vg(struct format_instance *fid,
if (dm_config_get_str(vgn, "system_id", &str))
strncpy(system_id, str, NAME_LEN);
+ if (dm_config_get_str(vgn, "lock_type", &str)) {
+ if (!(vg->lock_type = dm_pool_strdup(vg->vgmem, str)))
+ goto bad;
+ }
+
if (!_read_id(&vg->id, vgn, "id")) {
log_error("Couldn't read uuid for volume group %s.", vg->name);
goto bad;
@@ -802,6 +812,11 @@ static struct volume_group *_read_vg(struct format_instance *fid,
goto bad;
}
+ if (vg->status & LVM_WRITE_LOCKED) {
+ vg->status |= LVM_WRITE;
+ vg->status &= ~LVM_WRITE_LOCKED;
+ }
+
if (!_read_int32(vgn, "extent_size", &vg->extent_size)) {
log_error("Couldn't read extent size for volume group %s.",
vg->name);
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 758fa53..8c081d9 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -122,7 +122,8 @@
#define PV_ALLOCATION_PROHIBITED UINT64_C(0x0010000000000000) /* PV - internal use only - allocation prohibited
e.g. to prohibit allocation of a RAID image
on a PV already holing an image of the RAID set */
-/* Next unused flag: UINT64_C(0x0020000000000000) */
+#define LVM_WRITE_LOCKED UINT64_C(0x0020000000000000) /* VG, LV */
+/* Next unused flag: UINT64_C(0x0040000000000000) */
/* Format features flags */
#define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */
@@ -170,6 +171,7 @@
#define FAILED_EXIST 0x00000100U
#define FAILED_RECOVERY 0x00000200U
#define FAILED_SYSTEMID 0x00000400U
+#define FAILED_LOCK_TYPE 0x00000800U
#define SUCCESS 0x00000000U
#define VGMETADATACOPIES_ALL UINT32_MAX
@@ -1167,6 +1169,7 @@ char *generate_lv_name(struct volume_group *vg, const char *format,
int pv_change_metadataignore(struct physical_volume *pv, uint32_t mda_ignore);
+int vg_flag_write_locked(struct volume_group *vg);
int vg_check_write_mode(struct volume_group *vg);
#define vg_is_clustered(vg) (vg_status((vg)) & CLUSTERED)
#define vg_is_exported(vg) (vg_status((vg)) & EXPORTED_VG)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 68651f5..7e440a4 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4257,6 +4257,37 @@ int vg_check_write_mode(struct volume_group *vg)
}
/*
+ * Return 1 if the VG metadata should be written
+ * *without* the WRITE flag in the status line, and
+ * *with* the WRITE_LOCKED flag in the flags line.
+ *
+ * If this is done for a VG, it forces previous versions
+ * of lvm (before the WRITE_LOCKED flag was added), to view
+ * the VG and its LVs as read-only (because the WRITE flag
+ * is missing). Versions of lvm that understand the
+ * WRITE_LOCKED flag know to check the other methods of
+ * access control for the VG, specifically system_id and lock_type.
+ *
+ * So, if a VG has a system_id or lock_type, then the
+ * system_id and lock_type control access to the VG in
+ * addition to its basic writable status. Because previous
+ * lvm versions do not know about system_id or lock_type,
+ * VGs depending on either of these should have WRITE_LOCKED
+ * instead of WRITE to prevent the previous lvm versions from
+ * assuming they can write the VG and its LVs.
+ */
+int vg_flag_write_locked(struct volume_group *vg)
+{
+ if (vg->system_id && vg->system_id[0])
+ return 1;
+
+ if (vg->lock_type && vg->lock_type[0] && strcmp(vg->lock_type, "none"))
+ return 1;
+
+ return 0;
+}
+
+/*
* Performs a set of checks against a VG according to bits set in status
* and returns FAILED_* bits for those that aren't acceptable.
*
@@ -4377,6 +4408,23 @@ static int _access_vg_clustered(struct cmd_context *cmd, struct volume_group *vg
return 1;
}
+static int _access_vg_lock_type(struct cmd_context *cmd, struct volume_group *vg)
+{
+ if (!is_real_vg(vg->name))
+ return 1;
+
+ /*
+ * Until lock_type support is added, reject any VG that has a lock_type.
+ */
+ if (vg->lock_type && vg->lock_type[0] && strcmp(vg->lock_type, "none")) {
+ log_error("Cannot access VG %s with unsupported lock_type %s.",
+ vg->name, vg->lock_type);
+ return 0;
+ }
+
+ return 1;
+}
+
static int _access_vg_systemid(struct cmd_context *cmd, struct volume_group *vg)
{
/*
@@ -4468,6 +4516,11 @@ static int _vg_access_permitted(struct cmd_context *cmd, struct volume_group *vg
return 0;
}
+ if (!_access_vg_lock_type(cmd, vg)) {
+ *failure |= FAILED_LOCK_TYPE;
+ return 0;
+ }
+
if (!_access_vg_systemid(cmd, vg)) {
*failure |= FAILED_SYSTEMID;
return 0;
diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h
index 2467721..67a04a0 100644
--- a/lib/metadata/vg.h
+++ b/lib/metadata/vg.h
@@ -70,6 +70,7 @@ struct volume_group {
const char *old_name; /* Set during vgrename and vgcfgrestore */
const char *system_id;
char *lvm1_system_id;
+ const char *lock_type;
uint32_t extent_size;
uint32_t extent_count;
diff --git a/man/lvmsystemid.7.in b/man/lvmsystemid.7.in
index c5e69be..0881b1e 100644
--- a/man/lvmsystemid.7.in
+++ b/man/lvmsystemid.7.in
@@ -46,8 +46,9 @@ destroyed in the following cases which the user must be careful to avoid:
.IP \[bu] 2
A host using an old version of lvm without the system_id feature will not
-recognize the system_id of other hosts' VGs and will not be stopped from
-using them.
+recognize the system_id of other hosts' VGs. VGs with a new system_id
+are nominally protected from old versions of lvm by appearing to be
+read-only to the old versions.
.IP \[bu] 2
A VG without a system_id can be used without restriction from any host,
8 years, 6 months
master - Revert "systemid: Add ACCESS_NEEDS_SYSTEM_ID VG flag."
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c6a57dc4f3af6a...
Commit: c6a57dc4f3af6aa8912fc1f969937e3e3c47f725
Parent: 06b408ecce9d95f768ace998b83674140bc05abc
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Mar 4 11:11:10 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Mar 5 09:50:43 2015 -0600
Revert "systemid: Add ACCESS_NEEDS_SYSTEM_ID VG flag."
This reverts commit bfbb5d269aa1ed56d9308117b57d4d2da49d53f6.
This will be done differently.
---
lib/format1/format1.c | 2 --
lib/format1/import-export.c | 4 +---
lib/format_text/flags.c | 1 -
lib/format_text/import_vsn1.c | 20 ++++++++------------
lib/metadata/metadata-exported.h | 3 +--
lib/metadata/vg.c | 3 ---
tools/vgchange.c | 6 +-----
7 files changed, 11 insertions(+), 28 deletions(-)
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index 7f37cf5..19df8aa 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -501,8 +501,6 @@ static int _format1_vg_setup(struct format_instance *fid, struct volume_group *v
!generate_lvm1_system_id(vg->cmd, vg->lvm1_system_id, ""))
return_0;
- vg->status &= ~ACCESS_NEEDS_SYSTEM_ID;
-
return 1;
}
diff --git a/lib/format1/import-export.c b/lib/format1/import-export.c
index 4846a8b..9b387e2 100644
--- a/lib/format1/import-export.c
+++ b/lib/format1/import-export.c
@@ -69,10 +69,8 @@ int import_pv(const struct format_type *fmt, struct dm_pool *mem,
memcpy(&pv->vgid, vgd->vg_uuid, sizeof(vg->id));
/* Store system_id from first PV if PV belongs to a VG */
- if (vg && !*vg->lvm1_system_id) {
+ if (vg && !*vg->lvm1_system_id)
strncpy(vg->lvm1_system_id, (char *)pvd->system_id, NAME_LEN);
- vg->status &= ~ACCESS_NEEDS_SYSTEM_ID;
- }
if (vg &&
strncmp(vg->lvm1_system_id, (char *)pvd->system_id, sizeof(pvd->system_id)))
diff --git a/lib/format_text/flags.c b/lib/format_text/flags.c
index 1a4a503..cf01271 100644
--- a/lib/format_text/flags.c
+++ b/lib/format_text/flags.c
@@ -36,7 +36,6 @@ static const struct flag _vg_flags[] = {
{LVM_WRITE, "WRITE", STATUS_FLAG},
{CLUSTERED, "CLUSTERED", STATUS_FLAG},
{SHARED, "SHARED", STATUS_FLAG},
- {ACCESS_NEEDS_SYSTEM_ID, "ACCESS_NEEDS_SYSTEM_ID", STATUS_FLAG},
{PARTIAL_VG, NULL, 0},
{PRECOMMITTED, NULL, 0},
{ARCHIVED_VG, NULL, 0},
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 8ab9363e..64c08a0 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -733,10 +733,11 @@ 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, *system_id, *format_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;
+ char *system_id;
/* skip any top-level values */
for (vgn = cft->root; (vgn && vgn->v); vgn = vgn->sib)
@@ -750,6 +751,9 @@ static struct volume_group *_read_vg(struct format_instance *fid,
if (!(vg = alloc_vg("read_vg", fid->fmt->cmd, vgn->key)))
return_NULL;
+ if (!(system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN + 1)))
+ goto_bad;
+ vg->system_id = system_id;
/*
* The pv hash memorises the pv section names -> pv
@@ -778,6 +782,9 @@ static struct volume_group *_read_vg(struct format_instance *fid,
goto bad;
}
+ if (dm_config_get_str(vgn, "system_id", &str))
+ strncpy(system_id, str, NAME_LEN);
+
if (!_read_id(&vg->id, vgn, "id")) {
log_error("Couldn't read uuid for volume group %s.", vg->name);
goto bad;
@@ -795,17 +802,6 @@ static struct volume_group *_read_vg(struct format_instance *fid,
goto bad;
}
- if (dm_config_get_str(vgn, "system_id", &system_id)) {
- if (!(vg->status & ACCESS_NEEDS_SYSTEM_ID)) {
- if (!(vg->lvm1_system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN + 1)))
- goto_bad;
- strncpy(vg->lvm1_system_id, system_id, NAME_LEN);
- } else if (!(vg->system_id = dm_pool_strdup(vg->vgmem, system_id))) {
- log_error("Failed to allocate memory for system_id in vg_set_system_id.");
- goto bad;
- }
- }
-
if (!_read_int32(vgn, "extent_size", &vg->extent_size)) {
log_error("Couldn't read extent size for volume group %s.",
vg->name);
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 5fbfdef..758fa53 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -60,7 +60,6 @@
#define LVM_WRITE UINT64_C(0x0000000000000200) /* LV, VG */
#define CLUSTERED UINT64_C(0x0000000000000400) /* VG */
-#define ACCESS_NEEDS_SYSTEM_ID UINT64_C(0x0020000000000000) /* VG */
//#define SHARED UINT64_C(0x0000000000000800) /* VG */
/* FIXME Remove when metadata restructuring is completed */
@@ -123,7 +122,7 @@
#define PV_ALLOCATION_PROHIBITED UINT64_C(0x0010000000000000) /* PV - internal use only - allocation prohibited
e.g. to prohibit allocation of a RAID image
on a PV already holing an image of the RAID set */
-/* Next unused flag: UINT64_C(0x0040000000000000) */
+/* Next unused flag: UINT64_C(0x0020000000000000) */
/* Format features flags */
#define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index b23063e..404cc6f 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -615,7 +615,6 @@ int vg_set_system_id(struct volume_group *vg, const char *system_id)
{
if (!system_id || !*system_id) {
vg->system_id = NULL;
- vg->status &= ~ACCESS_NEEDS_SYSTEM_ID;
return 1;
}
@@ -633,8 +632,6 @@ int vg_set_system_id(struct volume_group *vg, const char *system_id)
if (vg->lvm1_system_id)
*vg->lvm1_system_id = '\0';
- vg->status |= ACCESS_NEEDS_SYSTEM_ID;
-
return 1;
}
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 557fe34..36b44a9 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -575,14 +575,10 @@ static int _vgchange_system_id(struct cmd_context *cmd, struct volume_group *vg)
vg->name, vg->system_id, system_id);
vg->system_id = system_id;
+
if (vg->lvm1_system_id)
*vg->lvm1_system_id = '\0';
- if (vg->system_id && *vg->system_id)
- vg->status |= ACCESS_NEEDS_SYSTEM_ID;
- else
- vg->status &= ~ACCESS_NEEDS_SYSTEM_ID;
-
return 1;
}
8 years, 6 months
master - system_id: enable the options in config file and command line
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=06b408ecce9d95...
Commit: 06b408ecce9d95f768ace998b83674140bc05abc
Parent: 190d591fbec672a2e1f77d4709fcee75cc695a06
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Mar 4 11:15:45 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Mar 5 09:50:43 2015 -0600
system_id: enable the options in config file and command line
---
lib/config/config_settings.h | 8 ++++----
tools/commands.h | 7 +++++--
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index f22039a..ef78182 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -194,8 +194,8 @@ cfg_array(global_cache_check_options_CFG, "cache_check_options", global_CFG_SECT
cfg(global_cache_dump_executable_CFG, "cache_dump_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, CACHE_DUMP_CMD, vsn(2, 2, 108), NULL)
cfg(global_cache_repair_executable_CFG, "cache_repair_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, CACHE_REPAIR_CMD, vsn(2, 2, 108), NULL)
cfg_array(global_cache_repair_options_CFG, "cache_repair_options", global_CFG_SECTION, 0, CFG_TYPE_STRING, "#S" DEFAULT_CACHE_REPAIR_OPTIONS, vsn(2, 2, 108), NULL)
-cfg(global_system_id_source_CFG, "system_id_source", global_CFG_SECTION, CFG_DISABLED, CFG_TYPE_STRING, DEFAULT_SYSTEM_ID_SOURCE, vsn(2, 2, 117), NULL)
-cfg(global_system_id_file_CFG, "system_id_file", global_CFG_SECTION, CFG_DISABLED | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(2, 2, 117), NULL)
+cfg(global_system_id_source_CFG, "system_id_source", global_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_SYSTEM_ID_SOURCE, vsn(2, 2, 117), NULL)
+cfg(global_system_id_file_CFG, "system_id_file", global_CFG_SECTION, CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(2, 2, 117), NULL)
cfg(activation_checks_CFG, "checks", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_ACTIVATION_CHECKS, vsn(2, 2, 86), NULL)
cfg(activation_udev_sync_CFG, "udev_sync", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_UDEV_SYNC, vsn(2, 2, 51), NULL)
@@ -282,7 +282,7 @@ cfg(tags_hosttags_CFG, "hosttags", tags_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_H
cfg_section(tag_CFG_SUBSECTION, "tag", tags_CFG_SECTION, CFG_NAME_VARIABLE | CFG_DEFAULT_UNDEFINED, vsn(1, 0, 18), NULL)
cfg(tag_host_list_CFG, "host_list", tag_CFG_SUBSECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(1, 0, 18), NULL)
-cfg(local_system_id_CFG, "system_id", local_CFG_SECTION, CFG_DISABLED | CFG_ALLOW_EMPTY | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(2, 2, 117), NULL)
-cfg_array(local_extra_system_ids_CFG, "extra_system_ids", local_CFG_SECTION, CFG_DISABLED | CFG_ALLOW_EMPTY | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(2, 2, 117), NULL)
+cfg(local_system_id_CFG, "system_id", local_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(2, 2, 117), NULL)
+cfg_array(local_extra_system_ids_CFG, "extra_system_ids", local_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(2, 2, 117), NULL)
cfg(CFG_COUNT, NULL, root_CFG_SECTION, 0, CFG_TYPE_INT, 0, vsn(0, 0, 0), NULL)
diff --git a/tools/commands.h b/tools/commands.h
index 577589e..719c507 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -965,6 +965,7 @@ xx(vgchange,
"\t[--refresh]\n"
"\t[-S|--select Selection]\n"
"\t[--sysinit]\n"
+ "\t[--systemid SystemID]\n"
"\t[-t|--test]\n"
"\t[-u|--uuid]\n"
"\t[-v|--verbose]\n"
@@ -987,7 +988,7 @@ xx(vgchange,
metadataprofile_ARG, monitor_ARG, noudevsync_ARG, metadatacopies_ARG,
vgmetadatacopies_ARG, partial_ARG, physicalextentsize_ARG, poll_ARG,
refresh_ARG, resizeable_ARG, resizable_ARG, select_ARG, sysinit_ARG,
- test_ARG, uuid_ARG)
+ systemid_ARG, test_ARG, uuid_ARG)
xx(vgck,
"Check the consistency of volume group(s)",
@@ -1038,6 +1039,7 @@ xx(vgcreate,
"\t[--[vg]metadatacopies #copies]\n"
"\t[-p|--maxphysicalvolumes MaxPhysicalVolumes]\n"
"\t[-s|--physicalextentsize PhysicalExtentSize[bBsSkKmMgGtTpPeE]]\n"
+ "\t[--systemid SystemID]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
"\t[--version]\n"
@@ -1049,7 +1051,8 @@ xx(vgcreate,
maxphysicalvolumes_ARG, metadataprofile_ARG, metadatatype_ARG,
physicalextentsize_ARG, test_ARG, force_ARG, zero_ARG, labelsector_ARG,
metadatasize_ARG, pvmetadatacopies_ARG, metadatacopies_ARG,
- vgmetadatacopies_ARG, dataalignment_ARG, dataalignmentoffset_ARG)
+ vgmetadatacopies_ARG, dataalignment_ARG, dataalignmentoffset_ARG,
+ systemid_ARG)
xx(vgdisplay,
"Display volume group information",
8 years, 6 months
master - report: fix seg_monitor field to display monitoring status for thick snapshots and mirrors
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=190d591fbec672...
Commit: 190d591fbec672a2e1f77d4709fcee75cc695a06
Parent: 56606b5f21682cfb8f36aef419f0cb7dcf55cce9
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Mar 5 10:45:29 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Mar 5 14:05:34 2015 +0100
report: fix seg_monitor field to display monitoring status for thick snapshots and mirrors
The seg_monitor did not display monitored status for thick snapshots
and mirrors (with mirror log *not* mirrored). The seg monitor did work
correctly even before for other segtypes - thins and raids.
Before (mirrors and snapshots, only mirrors with mirrored log properly displayed monitoring status):
[0] f21/~ # lvs -a -o lv_name,lv_layout,lv_role,seg_monitor vg
LV Layout Role Monitor
mirror mirror public
[mirror_mimage_0] linear private,mirror,image
[mirror_mimage_1] linear private,mirror,image
[mirror_mlog] linear private,mirror,log
mirror_with_mirror_log mirror public monitored
[mirror_with_mirror_log_mimage_0] linear private,mirror,image
[mirror_with_mirror_log_mimage_1] linear private,mirror,image
[mirror_with_mirror_log_mlog] mirror private,mirror,log monitored
[mirror_with_mirror_log_mlog_mimage_0] linear private,mirror,image
[mirror_with_mirror_log_mlog_mimage_1] linear private,mirror,image
thick_origin linear public,origin,thickorigin
thick_snapshot linear public,snapshot,thicksnapshot
With this patch applied (monitoring status displayed for all mirrors and snapshots):
[0] f21/~ # lvs -a -o lv_name,lv_layout,lv_role,seg_monitor vg
LV Layout Role Monitor
mirror mirror public monitored
[mirror_mimage_0] linear private,mirror,image
[mirror_mimage_1] linear private,mirror,image
[mirror_mlog] linear private,mirror,log
mirror_with_mirror_log mirror public monitored
[mirror_with_mirror_log_mimage_0] linear private,mirror,image
[mirror_with_mirror_log_mimage_1] linear private,mirror,image
[mirror_with_mirror_log_mlog] mirror private,mirror,log monitored
[mirror_with_mirror_log_mlog_mimage_0] linear private,mirror,image
[mirror_with_mirror_log_mlog_mimage_1] linear private,mirror,image
thick_origin linear public,origin,thickorigin
thick_snapshot linear public,snapshot,thicksnapshot monitored
---
WHATS_NEW | 1 +
lib/metadata/lv.c | 2 --
lib/report/report.c | 10 +++++-----
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f597980..46783e1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.118 -
=================================
+ Fix seg_monitor field to report status also for mirrors and thick snapshots.
Version 2.02.117 - 4th March 2015
=================================
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index c3c5d4a..10ce906 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -152,8 +152,6 @@ char *lvseg_monitor_dup(struct dm_pool *mem, const struct lv_segment *seg)
if (lv_is_cow(seg->lv) && !lv_is_merging_cow(seg->lv))
segm = first_seg(seg->lv->snapshot->lv);
- else if (seg->log_lv)
- segm = first_seg(seg->log_lv);
// log_debug("Query LV:%s mon:%s segm:%s tgtm:%p segmon:%d statusm:%d", seg->lv->name, segm->lv->name, segm->segtype->name, segm->segtype->ops->target_monitored, seg_monitored(segm), (int)(segm->status & PVMOVE));
if ((dmeventd_monitor_mode() != 1) ||
diff --git a/lib/report/report.c b/lib/report/report.c
index 75928c0..4ef2b04 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -791,14 +791,14 @@ static int _segmonitor_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_segment *seg = (const struct lv_segment *)data;
char *str;
- if (!seg->segtype->ops || !seg->segtype->ops->target_monitored)
- return _field_set_value(field, GET_FIRST_RESERVED_NAME(seg_monitor_undef),
- GET_FIELD_RESERVED_VALUE(seg_monitor_undef));
-
if (!(str = lvseg_monitor_dup(mem, seg)))
return_0;
- return _field_set_value(field, str, NULL);
+ if (*str)
+ return _field_set_value(field, str, NULL);
+
+ return _field_set_value(field, GET_FIRST_RESERVED_NAME(seg_monitor_undef),
+ GET_FIELD_RESERVED_VALUE(seg_monitor_undef));
}
static int _segstart_disp(struct dm_report *rh, struct dm_pool *mem,
8 years, 6 months