master - clean-up: better macro usage
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b87a7683e23c2c...
Commit: b87a7683e23c2c309f11929a488230570daf0dc0
Parent: 4a853361b01feda77031901eb2828c6ecabe760f
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Tue Sep 16 21:24:14 2014 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Tue Sep 16 21:24:14 2014 -0500
clean-up: better macro usage
Use 'lv_is_mirror' instead of 'lv_is_mirrored && !lv_is_raid' - both
are the same as asking if the non-RAID mirror implementation is being
used.
---
tools/lvconvert.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index c252745..c7eb02d 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2659,7 +2659,7 @@ static int _lvconvert_pool(struct cmd_context *cmd,
display_lvname(metadata_lv));
return 0;
}
- if (lv_is_mirrored(metadata_lv) && !lv_is_raid_type(metadata_lv)) {
+ if (lv_is_mirror(metadata_lv)) {
log_error("Mirror logical volumes cannot be used "
"for pool metadata.");
log_error("Try \"raid1\" segment type instead.");
@@ -2699,7 +2699,7 @@ static int _lvconvert_pool(struct cmd_context *cmd,
return 0;
}
- if (lv_is_mirrored(pool_lv) && !lv_is_raid_type(pool_lv)) {
+ if (lv_is_mirror(pool_lv)) {
log_error("Mirror logical volumes cannot be used as pools.\n"
"Try \"raid1\" segment type instead.");
return 0;
9 years
master - vgchange: disable cluster convert for active LVs
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4a853361b01fed...
Commit: 4a853361b01feda77031901eb2828c6ecabe760f
Parent: 1ce21c19d5894b889a6d8da67c8a159709c3dda9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Sep 16 11:41:28 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Sep 16 11:42:41 2014 +0200
vgchange: disable cluster convert for active LVs
While we could probably reacquire some type of lock when
going from non-clustered to clustered vg, we don't have any
single road back to drop the lock and keep LV active.
For now keep it safe and prohibit conversion when LV
is active in the VG.
---
WHATS_NEW | 1 +
lib/metadata/vg.c | 42 +++++++++++++++++-------------------------
test/shell/vgchange-usage.sh | 11 +++++++++++
3 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d3f926d..6c12186 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Disable vgchange of clustered attribute with any active LV in VG.
Use va_copy to properly pass va_list through functions.
Add function to detect rotational devices.
Review internal checks for mirror/raid/pvmove volumes.
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 8ebec99..acda5be 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -519,36 +519,24 @@ int vg_set_alloc_policy(struct volume_group *vg, alloc_policy_t alloc)
return 1;
}
+/*
+ * We do not currently support switching the cluster attribute
+ * with any active logical volumes.
+ *
+ * FIXME: resolve logic with reacquiring proper top-level LV locks
+ * and we likely can't giveup DLM locks for active LVs...
+ */
int vg_set_clustered(struct volume_group *vg, int clustered)
{
struct lv_list *lvl;
+ struct logical_volume *lv;
- /*
- * We do not currently support switching the cluster attribute
- * on active mirrors, snapshots or RAID logical volumes.
- */
dm_list_iterate_items(lvl, &vg->lvs) {
- if (lv_is_active(lvl->lv) &&
- (lv_is_mirrored(lvl->lv) || lv_is_raid_type(lvl->lv))) {
- log_error("%s logical volumes must be inactive "
- "when changing the cluster attribute.",
- lv_is_raid_type(lvl->lv) ? "RAID" : "Mirror");
- return 0;
- }
-
- if (clustered) {
- if (lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) {
- log_error("Volume group %s contains snapshots "
- "that are not yet supported.",
- vg->name);
- return 0;
- }
- }
-
- if ((lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) &&
- lv_is_active(lvl->lv)) {
- log_error("Snapshot logical volumes must be inactive "
- "when changing the cluster attribute.");
+ /* For COW, check lock for origin */
+ lv = lv_is_cow(lvl->lv) ? origin_from_cow(lvl->lv) : lvl->lv;
+ if (lv_is_active(lv)) {
+ log_error("Can't change cluster attribute with active "
+ "oogical volume %s.", display_lvname(lv));
return 0;
}
}
@@ -557,6 +545,10 @@ int vg_set_clustered(struct volume_group *vg, int clustered)
vg->status |= CLUSTERED;
else
vg->status &= ~CLUSTERED;
+
+ log_debug_metadata("Setting volume group %s as %sclustered.",
+ vg->name, clustered ? "" : "not " );
+
return 1;
}
diff --git a/test/shell/vgchange-usage.sh b/test/shell/vgchange-usage.sh
index 6ba3f69..ff80722 100644
--- a/test/shell/vgchange-usage.sh
+++ b/test/shell/vgchange-usage.sh
@@ -89,16 +89,27 @@ fail vgchange -cy |& tee out
grep "y/n" out
check vg_attr_bit cluster $vg "-"
+lvcreate -l1 $vg
+
# check on cluster
# either skipped as clustered (non-cluster), or already clustered (on cluster)
if test -e LOCAL_CLVMD ; then
+ # can't switch with active LV
+ not vgchange -cy $vg
+ lvchange -an $vg
vgchange -cy $vg
fail vgchange -cy $vg
check vg_attr_bit cluster $vg "c"
+ lvchange -ay $vg
+ not vgchange -cn $vg
+ lvchange -an $vg
vgchange -cn $vg
else
# no clvmd is running
fail vgchange -cy $vg
+ # can't switch with active LV
+ not vgchange --yes -cy $vg
+ lvchange -an $vg
vgchange --yes -cy $vg
fail vgchange --yes -cy $vg
fail vgs $vg |& tee out
9 years
master - va_list: properly pass va_list through functions
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1ce21c19d5894b...
Commit: 1ce21c19d5894b889a6d8da67c8a159709c3dda9
Parent: b9c16b750694c4ec03d05bc9e4a12cecc4d9450f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 15 15:33:56 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Sep 16 11:42:40 2014 +0200
va_list: properly pass va_list through functions
Code should not just pass va_list arg through the function
as args could be passed in many strange ways.
Use va_copy().
For details look in i.e.:
http://julipedia.meroh.net/2011/09/using-vacopy-to-safely-pass-ap.html
---
WHATS_NEW | 1 +
lib/format_text/export.c | 5 ++++-
libdaemon/client/daemon-client.c | 16 ++++++++++++----
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5b8a32f..d3f926d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Use va_copy to properly pass va_list through functions.
Add function to detect rotational devices.
Review internal checks for mirror/raid/pvmove volumes.
Track mirror segment type with separate MIRROR flag.
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index 7ffb4e3..c2453f2 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -190,9 +190,12 @@ static int _out_with_comment_raw(struct formatter *f,
const char *fmt, va_list ap)
{
int n;
+ va_list apc;
+ va_copy(apc, ap);
n = vsnprintf(f->data.buf.start + f->data.buf.used,
- f->data.buf.size - f->data.buf.used, fmt, ap);
+ f->data.buf.size - f->data.buf.used, fmt, apc);
+ va_end(apc);
/* If metadata doesn't fit, extend buffer */
if (n < 0 || (n + f->data.buf.used + 2 > f->data.buf.size)) {
diff --git a/libdaemon/client/daemon-client.c b/libdaemon/client/daemon-client.c
index a11b604..d0b8951 100644
--- a/libdaemon/client/daemon-client.c
+++ b/libdaemon/client/daemon-client.c
@@ -129,12 +129,16 @@ daemon_reply daemon_send_simple_v(daemon_handle h, const char *id, va_list ap)
static const daemon_reply err = { .error = ENOMEM };
daemon_request rq = { .cft = NULL };
daemon_reply repl;
+ va_list apc;
+ va_copy(apc, ap);
if (!buffer_append_f(&rq.buffer, "request = %s", id, NULL) ||
- !buffer_append_vf(&rq.buffer, ap)) {
+ !buffer_append_vf(&rq.buffer, apc)) {
+ va_end(apc);
buffer_destroy(&rq.buffer);
return err;
}
+ va_end(apc);
repl = daemon_send(h, rq);
buffer_destroy(&rq.buffer);
@@ -181,13 +185,17 @@ bad:
int daemon_request_extend_v(daemon_request r, va_list ap)
{
+ int res;
+ va_list apc;
+
if (!r.cft)
return 0;
- if (!config_make_nodes_v(r.cft, NULL, r.cft->root, ap))
- return 0;
+ va_copy(apc, ap);
+ res = config_make_nodes_v(r.cft, NULL, r.cft->root, apc) ? 1 : 0;
+ va_end(apc);
- return 1;
+ return res;
}
int daemon_request_extend(daemon_request r, ...)
9 years
master - devices: Detect rotational devices.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b9c16b750694c4...
Commit: b9c16b750694c4ec03d05bc9e4a12cecc4d9450f
Parent: 979be63f2537373b49e47aa3e8ce3f9bf2a4279f
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Sep 16 00:44:25 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Sep 16 00:44:25 2014 +0100
devices: Detect rotational devices.
Add dev_is_rotational() for future use by allocation code.
---
WHATS_NEW | 1 +
lib/device/dev-type.c | 57 ++++++++++++++++++++++++++++++-------------------
lib/device/dev-type.h | 2 +
3 files changed, 38 insertions(+), 22 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 70d8a9a..5b8a32f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Add function to detect rotational devices.
Review internal checks for mirror/raid/pvmove volumes.
Track mirror segment type with separate MIRROR flag.
Fix cmirror endian conversions.
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index ecceb2d..6fcfa08 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -655,23 +655,25 @@ static int _snprintf_attr(char *buf, size_t buf_size, const char *sysfs_dir,
static unsigned long _dev_topology_attribute(struct dev_types *dt,
const char *attribute,
- struct device *dev)
+ struct device *dev,
+ unsigned long default_value)
{
const char *sysfs_dir = dm_sysfs_dir();
char path[PATH_MAX], buffer[64];
FILE *fp;
struct stat info;
dev_t uninitialized_var(primary);
- unsigned long result = 0UL;
+ unsigned long result = default_value;
+ unsigned long value = 0UL;
if (!attribute || !*attribute)
- return_0;
+ goto_out;
if (!sysfs_dir || !*sysfs_dir)
- return_0;
+ goto_out;
if (!_snprintf_attr(path, sizeof(path), sysfs_dir, attribute, dev->dev))
- return_0;
+ goto_out;
/*
* check if the desired sysfs attribute exists
@@ -681,72 +683,79 @@ static unsigned long _dev_topology_attribute(struct dev_types *dt,
if (stat(path, &info) == -1) {
if (errno != ENOENT) {
log_sys_debug("stat", path);
- return 0;
+ goto out;
}
if (!dev_get_primary_dev(dt, dev, &primary))
- return 0;
+ goto out;
/* get attribute from partition's primary device */
if (!_snprintf_attr(path, sizeof(path), sysfs_dir, attribute, primary))
- return_0;
+ goto_out;
if (stat(path, &info) == -1) {
if (errno != ENOENT)
log_sys_debug("stat", path);
- return 0;
+ goto out;
}
}
if (!(fp = fopen(path, "r"))) {
log_sys_debug("fopen", path);
- return 0;
+ goto out;
}
if (!fgets(buffer, sizeof(buffer), fp)) {
log_sys_debug("fgets", path);
- goto out;
+ goto out_close;
}
- if (sscanf(buffer, "%lu", &result) != 1) {
+ if (sscanf(buffer, "%lu", &value) != 1) {
log_warn("sysfs file %s not in expected format: %s", path, buffer);
- goto out;
+ goto out_close;
}
- log_very_verbose("Device %s %s is %lu bytes.",
- dev_name(dev), attribute, result);
+ log_very_verbose("Device %s: %s is %lu%s.",
+ dev_name(dev), attribute, result, default_value ? "" : " bytes");
-out:
+ result = value >> SECTOR_SHIFT;
+
+out_close:
if (fclose(fp))
log_sys_debug("fclose", path);
- return result >> SECTOR_SHIFT;
+out:
+ return result;
}
unsigned long dev_alignment_offset(struct dev_types *dt, struct device *dev)
{
- return _dev_topology_attribute(dt, "alignment_offset", dev);
+ return _dev_topology_attribute(dt, "alignment_offset", dev, 0UL);
}
unsigned long dev_minimum_io_size(struct dev_types *dt, struct device *dev)
{
- return _dev_topology_attribute(dt, "queue/minimum_io_size", dev);
+ return _dev_topology_attribute(dt, "queue/minimum_io_size", dev, 0UL);
}
unsigned long dev_optimal_io_size(struct dev_types *dt, struct device *dev)
{
- return _dev_topology_attribute(dt, "queue/optimal_io_size", dev);
+ return _dev_topology_attribute(dt, "queue/optimal_io_size", dev, 0UL);
}
unsigned long dev_discard_max_bytes(struct dev_types *dt, struct device *dev)
{
- return _dev_topology_attribute(dt, "queue/discard_max_bytes", dev);
+ return _dev_topology_attribute(dt, "queue/discard_max_bytes", dev, 0UL);
}
unsigned long dev_discard_granularity(struct dev_types *dt, struct device *dev)
{
- return _dev_topology_attribute(dt, "queue/discard_granularity", dev);
+ return _dev_topology_attribute(dt, "queue/discard_granularity", dev, 0UL);
}
+int dev_is_rotational(struct dev_types *dt, struct device *dev)
+{
+ return (int) _dev_topology_attribute(dt, "queue/rotational", dev, 1UL);
+}
#else
int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
@@ -779,4 +788,8 @@ unsigned long dev_discard_granularity(struct dev_types *dt, struct device *dev)
return 0UL;
}
+int dev_is_rotational(struct dev_types *dt, struct device *dev)
+{
+ return 1;
+}
#endif
diff --git a/lib/device/dev-type.h b/lib/device/dev-type.h
index b1520ee..8dcd4c8 100644
--- a/lib/device/dev-type.h
+++ b/lib/device/dev-type.h
@@ -82,4 +82,6 @@ unsigned long dev_optimal_io_size(struct dev_types *dt, struct device *dev);
unsigned long dev_discard_max_bytes(struct dev_types *dt, struct device *dev);
unsigned long dev_discard_granularity(struct dev_types *dt, struct device *dev);
+int dev_is_rotational(struct dev_types *dt, struct device *dev);
+
#endif
9 years
master - mirrors: Fix checks for mirror/raid/pvmove LVs.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=979be63f253737...
Commit: 979be63f2537373b49e47aa3e8ce3f9bf2a4279f
Parent: 829e5a40373a2ef1721dc9210350c86c4b9d70f7
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Sep 16 00:13:46 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Sep 16 00:13:46 2014 +0100
mirrors: Fix checks for mirror/raid/pvmove LVs.
Try to enforce consistent macro usage along these lines:
lv_is_mirror - mirror that uses the original dm-raid1 implementation
(segment type "mirror")
lv_is_mirror_type - also includes internal mirror image and log LVs
lv_is_raid - raid volume that uses the new dm-raid implementation
(segment type "raid")
lv_is_raid_type - also includes internal raid image / log / metadata LVs
lv_is_mirrored - LV is mirrored using either kernel implementation
(excludes non-mirror modes like raid5 etc.)
lv_is_pvmove - internal pvmove volume
---
WHATS_NEW | 3 +++
lib/activate/dev_manager.c | 2 +-
lib/format_text/flags.c | 1 +
lib/format_text/import_vsn1.c | 3 +++
lib/metadata/lv.c | 4 ++--
lib/metadata/lv_manip.c | 23 +++++++++++++++--------
lib/metadata/metadata-exported.h | 6 ++++--
lib/metadata/mirror.c | 10 +++++++---
lib/metadata/raid_manip.c | 1 +
lib/metadata/segtype.h | 3 +++
lib/mirror/mirrored.c | 2 +-
lib/report/report.c | 3 +--
tools/lvchange.c | 2 +-
tools/pvmove.c | 2 +-
tools/vgreduce.c | 2 +-
15 files changed, 45 insertions(+), 22 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3c02440..70d8a9a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,8 @@
Version 2.02.112 -
=====================================
+ Review internal checks for mirror/raid/pvmove volumes.
+ Track mirror segment type with separate MIRROR flag.
+ Fix cmirror endian conversions.
Introduce lv_is_pvmove/locked/converting/merging macros.
Avoid leaving linear logical volume when thin pool creation fails.
Demote an error to a warning when devices known to lvmetad are filtered out.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index c5581eb..4ee5a25 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2917,7 +2917,7 @@ static int _tree_action(struct dev_manager *dm, struct logical_volume *lv,
break;
case SUSPEND:
dm_tree_skip_lockfs(root);
- if (!dm->flush_required && !seg_is_raid(first_seg(lv)) && lv_is_mirrored(lv) && !lv_is_pvmove(lv))
+ if (!dm->flush_required && lv_is_mirror(lv) && !lv_is_pvmove(lv))
dm_tree_use_no_flush_suspend(root);
/* Fall through */
case SUSPEND_WITH_LOCKFS:
diff --git a/lib/format_text/flags.c b/lib/format_text/flags.c
index bc48952..55681d4 100644
--- a/lib/format_text/flags.c
+++ b/lib/format_text/flags.c
@@ -67,6 +67,7 @@ static const struct flag _lv_flags[] = {
{RAID, NULL, 0},
{RAID_META, NULL, 0},
{RAID_IMAGE, NULL, 0},
+ {MIRROR, NULL, 0},
{MIRROR_IMAGE, NULL, 0},
{MIRROR_LOG, NULL, 0},
{MIRRORED, NULL, 0},
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 9ddf99e..174b3bf 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -386,6 +386,9 @@ static int _read_segment(struct logical_volume *lv, const struct dm_config_node
*/
_insert_segment(lv, seg);
+ if (seg_is_mirror(seg))
+ lv->status |= MIRROR;
+
if (seg_is_mirrored(seg))
lv->status |= MIRRORED;
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index a8ad2d2..3ebb14d 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -361,7 +361,7 @@ char *lv_move_pv_dup(struct dm_pool *mem, const struct logical_volume *lv)
if (seg->status & PVMOVE) {
if (seg_type(seg, 0) == AREA_LV) { /* atomic pvmove */
mimage0_lv = seg_lv(seg, 0);
- if (!lv_is_mirrored(mimage0_lv)) {
+ if (!lv_is_mirror_image(mimage0_lv)) {
log_error(INTERNAL_ERROR
"Bad pvmove structure");
return NULL;
@@ -648,7 +648,7 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
repstr[0] = 'C';
else if (lv_is_raid(lv))
repstr[0] = (lv->status & LV_NOTSYNCED) ? 'R' : 'r';
- else if (lv_is_mirrored(lv))
+ else if (lv_is_mirror(lv))
repstr[0] = (lv->status & LV_NOTSYNCED) ? 'M' : 'm';
else if (lv_is_thin_volume(lv))
repstr[0] = lv_is_merging_origin(lv) ?
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6d80dfb..58bc79b 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -231,6 +231,10 @@ static int _lv_layout_and_role_raid(struct dm_pool *mem,
if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_RAID]) ||
!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_METADATA]))
goto_bad;
+ } else if (lv_is_pvmove(lv)) {
+ if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_PVMOVE]) ||
+ !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_RAID]))
+ goto_bad;
} else
top_level = 1;
@@ -464,7 +468,7 @@ int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
}
/* Mirrors and related */
- if ((lv_is_mirror_type(lv) || lv_is_pvmove(lv)) && !lv_is_raid(lv) &&
+ if ((lv_is_mirror_type(lv) || lv_is_pvmove(lv)) &&
!_lv_layout_and_role_mirror(mem, lv, *layout, *role, &public_lv))
goto_bad;
@@ -985,6 +989,12 @@ struct lv_segment *alloc_lv_segment(const struct segment_type *segtype,
if (log_lv && !attach_mirror_log(seg, log_lv))
return_NULL;
+ if (segtype_is_mirror(segtype))
+ lv->status |= MIRROR;
+
+ if (segtype_is_mirrored(segtype))
+ lv->status |= MIRRORED;
+
return seg;
}
@@ -1347,9 +1357,10 @@ int replace_lv_with_error_segment(struct logical_volume *lv)
* an error segment, we should also clear any flags
* that suggest it is anything other than "error".
*/
- lv->status &= ~(MIRRORED|PVMOVE|LOCKED);
+ /* FIXME Check for other flags that need removing */
+ lv->status &= ~(MIRROR|MIRRORED|PVMOVE|LOCKED);
- /* FIXME: Should we bug if we find a log_lv attached? */
+ /* FIXME Check for any attached LVs that will become orphans e.g. mirror logs */
if (!lv_add_virtual_segment(lv, 0, len, get_segtype_from_string(lv->vg->cmd, "error"), NULL))
return_0;
@@ -1858,9 +1869,6 @@ static int _setup_alloced_segment(struct logical_volume *lv, uint64_t status,
lv->le_count += extents;
lv->size += (uint64_t) extents *lv->vg->extent_size;
- if (segtype_is_mirrored(segtype))
- lv->status |= MIRRORED;
-
return 1;
}
@@ -6723,8 +6731,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- if (lv_is_mirror_type(org) &&
- !seg_is_raid(first_seg(org))) {
+ if (lv_is_mirror_type(org)) {
log_warn("WARNING: Snapshots of mirrors can deadlock under rare device failures.");
log_warn("WARNING: Consider using the raid1 mirror type to avoid this.");
log_warn("WARNING: See global/mirror_segtype_default in lvm.conf.");
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 0026ba9..01b04ff 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -67,6 +67,7 @@
#define LOCKED UINT64_C(0x0000000000004000) /* LV */
#define MIRRORED UINT64_C(0x0000000000008000) /* LV - internal use only */
//#define VIRTUAL UINT64_C(0x0000000000010000) /* LV - internal use only */
+#define MIRROR UINT64_C(0x0002000000000000) /* LV - Internal use only */
#define MIRROR_LOG UINT64_C(0x0000000000020000) /* LV - Internal use only */
#define MIRROR_IMAGE UINT64_C(0x0000000000040000) /* LV - Internal use only */
@@ -115,7 +116,7 @@
#define CACHE_POOL_METADATA UINT64_C(0x0000800000000000) /* LV - Internal use only */
#define CACHE UINT64_C(0x0001000000000000) /* LV - Internal use only */
-/* Next unused flag: UINT64_C(0x0002000000000000) */
+/* Next unused flag: UINT64_C(0x0004000000000000) */
/* Format features flags */
#define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */
@@ -181,7 +182,8 @@
#define lv_is_mirror_image(lv) (((lv)->status & MIRROR_IMAGE) ? 1 : 0)
#define lv_is_mirror_log(lv) (((lv)->status & MIRROR_LOG) ? 1 : 0)
-#define lv_is_mirror_type(lv) (((lv)->status & (MIRROR_LOG | MIRROR_IMAGE | MIRRORED)) ? 1 : 0)
+#define lv_is_mirror(lv) (((lv)->status & MIRROR) ? 1 : 0)
+#define lv_is_mirror_type(lv) (((lv)->status & (MIRROR | MIRROR_LOG | MIRROR_IMAGE)) ? 1 : 0)
#define lv_is_pvmove(lv) (((lv)->status & PVMOVE) ? 1 : 0)
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 4505eb9..0fc9314 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -742,6 +742,7 @@ static int _split_mirror_images(struct logical_volume *lv,
detached_log_lv = detach_mirror_log(mirrored_seg);
if (!remove_layer_from_lv(lv, sub_lv))
return_0;
+ lv->status &= ~MIRROR;
lv->status &= ~MIRRORED;
lv->status &= ~LV_NOTSYNCED;
}
@@ -941,6 +942,7 @@ static int _remove_mirror_images(struct logical_volume *lv,
* mirror. Fix up the flags if we only have one image left.
*/
if (lv_mirror_count(lv) == 1) {
+ lv->status &= ~MIRROR;
lv->status &= ~MIRRORED;
lv->status &= ~LV_NOTSYNCED;
}
@@ -957,6 +959,7 @@ static int _remove_mirror_images(struct logical_volume *lv,
/* All mirror images are gone.
* It can happen for vgreduce --removemissing. */
detached_log_lv = detach_mirror_log(mirrored_seg);
+ lv->status &= ~MIRROR;
lv->status &= ~MIRRORED;
lv->status &= ~LV_NOTSYNCED;
if (!replace_lv_with_error_segment(lv))
@@ -1502,9 +1505,10 @@ const char *get_pvmove_pvname_from_lv_mirr(struct logical_volume *lv_mirr)
dm_list_iterate_items(seg, &lv_mirr->segments) {
if (!seg_is_mirrored(seg))
continue;
- if (seg_type(seg, 0) != AREA_PV)
- continue;
- return dev_name(seg_dev(seg, 0));
+ if (seg_type(seg, 0) == AREA_PV)
+ return dev_name(seg_dev(seg, 0));
+ if (seg_type(seg, 0) == AREA_LV)
+ return dev_name(seg_dev(first_seg(seg_lv(seg, 0)), 0));
}
return NULL;
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index c9ac405..f494f11 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1403,6 +1403,7 @@ static int _convert_mirror_to_raid1(struct logical_volume *lv,
log_debug_metadata("Setting new segtype for %s", lv->name);
seg->segtype = new_segtype;
+ lv->status &= ~MIRROR;
lv->status &= ~MIRRORED;
lv->status |= RAID;
seg->status |= RAID;
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index 080cf4e..e0c46df 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -43,11 +43,13 @@ struct dev_manager;
#define SEG_THIN_VOLUME 0x00001000U
#define SEG_CACHE 0x00002000U
#define SEG_CACHE_POOL 0x00004000U
+#define SEG_MIRROR 0x00008000U
#define SEG_UNKNOWN 0x80000000U
#define segtype_is_cache(segtype) ((segtype)->flags & SEG_CACHE ? 1 : 0)
#define segtype_is_cache_pool(segtype) ((segtype)->flags & SEG_CACHE_POOL ? 1 : 0)
#define segtype_is_mirrored(segtype) ((segtype)->flags & SEG_AREAS_MIRRORED ? 1 : 0)
+#define segtype_is_mirror(segtype) ((segtype)->flags & SEG_MIRROR ? 1 : 0)
#define segtype_is_pool(segtype) ((segtype)->flags & (SEG_CACHE_POOL | SEG_THIN_POOL) ? 1 : 0)
#define segtype_is_raid(segtype) ((segtype)->flags & SEG_RAID ? 1 : 0)
#define segtype_is_striped(segtype) ((segtype)->flags & SEG_AREAS_STRIPED ? 1 : 0)
@@ -59,6 +61,7 @@ struct dev_manager;
#define seg_is_cache(seg) segtype_is_cache((seg)->segtype)
#define seg_is_cache_pool(seg) segtype_is_cache_pool((seg)->segtype)
#define seg_is_linear(seg) (seg_is_striped(seg) && ((seg)->area_count == 1))
+#define seg_is_mirror(seg) segtype_is_mirror((seg)->segtype)
#define seg_is_mirrored(seg) segtype_is_mirrored((seg)->segtype)
#define seg_is_pool(seg) segtype_is_pool((seg)->segtype)
#define seg_is_raid(seg) segtype_is_raid((seg)->segtype)
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index 1ab06ce..74a8e37 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -628,7 +628,7 @@ struct segment_type *init_segtype(struct cmd_context *cmd)
segtype->ops = &_mirrored_ops;
segtype->name = "mirror";
segtype->private = NULL;
- segtype->flags = SEG_AREAS_MIRRORED;
+ segtype->flags = SEG_MIRROR | SEG_AREAS_MIRRORED;
#ifdef DEVMAPPER_SUPPORT
# ifdef DMEVENTD
diff --git a/lib/report/report.c b/lib/report/report.c
index 24bc437..c34aa5e 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1042,8 +1042,7 @@ static int _copypercent_disp(struct dm_report *rh,
dm_percent_t percent = DM_PERCENT_INVALID;
if (((lv_is_raid(lv) && lv_raid_percent(lv, &percent)) ||
- ((lv_is_pvmove(lv) || lv_is_mirrored(lv)) &&
- lv_mirror_percent(lv->vg->cmd, lv, 0, &percent, NULL))) &&
+ (lv_is_mirror(lv) && lv_mirror_percent(lv->vg->cmd, lv, 0, &percent, NULL))) &&
(percent != DM_PERCENT_INVALID)) {
percent = copy_percent(lv);
return dm_report_field_percent(rh, field, &percent);
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 3ac5165..e0e3b03 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -287,7 +287,7 @@ static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
dm_list_init(&device_list);
- if (!lv_is_mirrored(lv) && !seg_is_raid(seg)) {
+ if (!seg_is_mirror(seg) && !seg_is_raid(seg)) {
log_error("Unable to resync %s. It is not RAID or mirrored.",
lv->name);
return 0;
diff --git a/tools/pvmove.c b/tools/pvmove.c
index 5b458b1..a9d750d 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -325,7 +325,7 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
*
* Allow clustered mirror, but not raid mirror.
*/
- if (vg_is_clustered(lv->vg) && (!lv_is_mirror_type(lv) || lv_is_raid(lv)))
+ if (vg_is_clustered(lv->vg) && !lv_is_mirror_type(lv))
continue;
if (!lv_is_on_pvs(lv, source_pvl))
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index 62162af..970f61c 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -95,7 +95,7 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
goto restart;
}
- if (lv_is_mirrored(lv)) {
+ if (lv_is_mirror(lv)) {
if (!mirror_remove_missing(cmd, lv, 1))
return_0;
goto restart;
9 years
master - cmirror: fix endian issues on s390
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=829e5a40373a2e...
Commit: 829e5a40373a2ef1721dc9210350c86c4b9d70f7
Parent: e9216eedfe8189947c506041d8fc9e879fac6d58
Author: Liuhua Wang <lwang(a)suse.com>
AuthorDate: Sat Sep 13 02:08:28 2014 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Sep 15 16:08:35 2014 -0500
cmirror: fix endian issues on s390
Cmirrord has endian bugs, which cause failure to lvcreate a mirrored lv
on s390.
- data_size is uint32, should not use xlate64 to convert, which will
cause data_size 0 after xlate.
- request_type and data_size still used by local(v5_data_switch),
should convert later. If request_type xlate too early, it will
cause request_type judge error; if data_size xlate too early, it
will cause coredump in case DM_ULOG_CLEAR_REGION.
- when receiving package in clog_request_from_network. vp[0] will always
be little endian. We could use xlate64(vp[0]) == vp[0] to decide if
the local node is little endian or not.
Signed-off-by: Lidong Zhong<lzhong(a)suse.com> & Liuhua Wang <lwang(a)suse.com>
Signed-off-by: Jonathan Brassow <jbrassow(a)redhat.com>
---
daemons/cmirrord/compat.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/daemons/cmirrord/compat.c b/daemons/cmirrord/compat.c
index 3f7a9b5..4955f50 100644
--- a/daemons/cmirrord/compat.c
+++ b/daemons/cmirrord/compat.c
@@ -126,13 +126,14 @@ static int v5_endian_to_network(struct clog_request *rq)
u_rq->error = xlate32(u_rq->error);
u_rq->seq = xlate32(u_rq->seq);
- u_rq->request_type = xlate32(u_rq->request_type);
- u_rq->data_size = xlate64(u_rq->data_size);
rq->originator = xlate32(rq->originator);
v5_data_endian_switch(rq, 1);
+ u_rq->request_type = xlate32(u_rq->request_type);
+ u_rq->data_size = xlate32(u_rq->data_size);
+
return size;
}
@@ -167,7 +168,7 @@ static int v5_endian_from_network(struct clog_request *rq)
u_rq->error = xlate32(u_rq->error);
u_rq->seq = xlate32(u_rq->seq);
u_rq->request_type = xlate32(u_rq->request_type);
- u_rq->data_size = xlate64(u_rq->data_size);
+ u_rq->data_size = xlate32(u_rq->data_size);
rq->originator = xlate32(rq->originator);
@@ -187,7 +188,7 @@ int clog_request_from_network(void *data, size_t data_len)
switch (version) {
case 5: /* Upstream */
- if (version == unconverted_version)
+ if (version == vp[0])
return 0;
break;
case 4: /* RHEL 5.[45] */
9 years
master - cleanup: fix last commit
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e9216eedfe8189...
Commit: e9216eedfe8189947c506041d8fc9e879fac6d58
Parent: 2360ce3551f2989f1cc2af06c3d3a0a0f1429bce
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Mon Sep 15 22:04:14 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Mon Sep 15 22:04:14 2014 +0100
cleanup: fix last commit
---
tools/lvchange.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index c3d0b6a..3ac5165 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -287,7 +287,7 @@ static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
dm_list_init(&device_list);
- if (lv_is_mirrored(lv) && !seg_is_raid(seg)) {
+ if (!lv_is_mirrored(lv) && !seg_is_raid(seg)) {
log_error("Unable to resync %s. It is not RAID or mirrored.",
lv->name);
return 0;
9 years
master - cleanup: Use lv_is_ macros.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2360ce3551f298...
Commit: 2360ce3551f2989f1cc2af06c3d3a0a0f1429bce
Parent: 10a448eb2fdc795d144f13ba4a7d83351eb8c9df
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Mon Sep 15 21:33:53 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Mon Sep 15 21:33:53 2014 +0100
cleanup: Use lv_is_ macros.
Use lv_is_* macros throughout the code base, introducing
lv_is_pvmove, lv_is_locked, lv_is_converting and lv_is_merging.
lv_is_mirror_type no longer includes pvmove.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 12 ++--
lib/activate/dev_manager.c | 9 +--
lib/display/display.c | 4 +-
lib/format_text/export.c | 4 +-
lib/format_text/import_vsn1.c | 2 +-
lib/metadata/lv.c | 36 +++++-----
lib/metadata/lv_manip.c | 40 ++++++------
lib/metadata/merge.c | 10 ++--
lib/metadata/metadata-exported.h | 141 ++++++++++++++++++++-----------------
lib/metadata/metadata.c | 2 +-
lib/metadata/mirror.c | 20 +++---
lib/metadata/snapshot_manip.c | 3 +-
lib/report/report.c | 12 ++--
lib/snapshot/snapshot.c | 1 +
liblvm/lvm_lv.c | 4 +-
tools/lvchange.c | 20 +++---
tools/lvconvert.c | 40 ++++++------
tools/lvrename.c | 4 +-
tools/pvmove.c | 15 ++--
tools/toollib.c | 10 ++--
tools/vgchange.c | 6 +-
tools/vgreduce.c | 4 +-
tools/vgsplit.c | 4 +-
24 files changed, 208 insertions(+), 196 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c48b979..3c02440 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Introduce lv_is_pvmove/locked/converting/merging macros.
Avoid leaving linear logical volume when thin pool creation fails.
Demote an error to a warning when devices known to lvmetad are filtered out.
Re-order filter evaluation, making component filters global.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 9a4a1c3..2091fa1 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1273,7 +1273,7 @@ static int _lv_activate_lv(struct logical_volume *lv, struct lv_activate_opts *l
int r;
struct dev_manager *dm;
- if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, (lv->status & PVMOVE) ? 0 : 1)))
+ if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, !lv_is_pvmove(lv))))
return_0;
if (!(r = dev_manager_activate(dm, lv, laopts)))
@@ -1290,7 +1290,7 @@ static int _lv_preload(struct logical_volume *lv, struct lv_activate_opts *laopt
struct dev_manager *dm;
int old_readonly = laopts->read_only;
- if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, (lv->status & PVMOVE) ? 0 : 1)))
+ if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, !lv_is_pvmove(lv))))
goto_out;
laopts->read_only = _passes_readonly_filter(lv->vg->cmd, lv);
@@ -1332,7 +1332,7 @@ static int _lv_suspend_lv(struct logical_volume *lv, struct lv_activate_opts *la
* When we are asked to manipulate (normally suspend/resume) the PVMOVE
* device directly, we don't want to touch the devices that use it.
*/
- if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, (lv->status & PVMOVE) ? 0 : 1)))
+ if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, !lv_is_pvmove(lv))))
return_0;
if (!(r = dev_manager_suspend(dm, lv, laopts, lockfs, flush_required)))
@@ -1872,8 +1872,8 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
* tables for all the changed LVs here, as the relationships
* are not found by walking the new metadata.
*/
- if (!(incore_lv->status & LOCKED) &&
- (ondisk_lv->status & LOCKED) &&
+ if (!lv_is_locked(incore_lv) &&
+ lv_is_locked(ondisk_lv) &&
(pvmove_lv = find_pvmove_lv_in_lv(ondisk_lv))) {
/* Preload all the LVs above the PVMOVE LV */
dm_list_iterate_items(sl, &pvmove_lv->segs_using_this_lv) {
@@ -1951,7 +1951,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
* can be called separately for each LV safely.
*/
if ((incore_lv->vg->status & PRECOMMITTED) &&
- (incore_lv->status & LOCKED) && find_pvmove_lv_in_lv(incore_lv)) {
+ lv_is_locked(incore_lv) && find_pvmove_lv_in_lv(incore_lv)) {
if (!_lv_suspend_lv(incore_lv, laopts, lockfs, flush_required)) {
critical_section_dec(cmd, "failed precommitted suspend");
if (pvmove_lv)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index d336afc..c5581eb 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1150,7 +1150,7 @@ int dev_manager_raid_message(struct dev_manager *dm,
struct dm_task *dmt;
const char *layer = lv_layer(lv);
- if (!(lv->status & RAID)) {
+ if (!lv_is_raid(lv)) {
log_error(INTERNAL_ERROR "%s/%s is not a RAID logical volume",
lv->vg->name, lv->name);
return 0;
@@ -1978,7 +1978,7 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
return_0;
/* Add any LVs referencing a PVMOVE LV unless told not to. */
- if (dm->track_pvmove_deps && lv->status & PVMOVE) {
+ if (dm->track_pvmove_deps && lv_is_pvmove(lv)) {
dm->track_pvmove_deps = 0;
dm_list_iterate_items(sl, &lv->segs_using_this_lv)
if (!_add_lv_to_dtree(dm, dtree, sl->seg->lv, origin_only))
@@ -2729,7 +2729,7 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
dm_tree_node_set_read_ahead(dnode, read_ahead, read_ahead_flags);
/* Add any LVs referencing a PVMOVE LV unless told not to */
- if (dm->track_pvmove_deps && (lv->status & PVMOVE))
+ if (dm->track_pvmove_deps && lv_is_pvmove(lv))
dm_list_iterate_items(sl, &lv->segs_using_this_lv)
if (!_add_new_lv_to_dtree(dm, dtree, sl->seg->lv, laopts, NULL))
return_0;
@@ -2917,8 +2917,7 @@ static int _tree_action(struct dev_manager *dm, struct logical_volume *lv,
break;
case SUSPEND:
dm_tree_skip_lockfs(root);
- if (!dm->flush_required && !seg_is_raid(first_seg(lv)) &&
- (lv->status & MIRRORED) && !(lv->status & PVMOVE))
+ if (!dm->flush_required && !seg_is_raid(first_seg(lv)) && lv_is_mirrored(lv) && !lv_is_pvmove(lv))
dm_tree_use_no_flush_suspend(root);
/* Fall through */
case SUSPEND_WITH_LOCKFS:
diff --git a/lib/display/display.c b/lib/display/display.c
index 1b92b31..d12c393 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -587,10 +587,10 @@ int lvdisplay_full(struct cmd_context *cmd,
display_size(cmd, (uint64_t) snap_seg->chunk_size));
}
- if (lv->status & MIRRORED) {
+ if (lv_is_mirrored(lv)) {
mirror_seg = first_seg(lv);
log_print("Mirrored volumes %" PRIu32, mirror_seg->area_count);
- if (lv->status & CONVERTING)
+ if (lv_is_converting(lv))
log_print("LV type Mirror undergoing conversion");
}
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index bea97de..7ffb4e3 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -563,8 +563,8 @@ int out_areas(struct formatter *f, const struct lv_segment *seg,
}
/* RAID devices are laid-out in metadata/data pairs */
- if (!(seg_lv(seg, s)->status & RAID_IMAGE) ||
- !(seg_metalv(seg, s)->status & RAID_META)) {
+ if (!lv_is_raid_image(seg_lv(seg, s)) ||
+ !lv_is_raid_metadata(seg_metalv(seg, s))) {
log_error("RAID segment has non-RAID areas");
return 0;
}
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 7d4304e..9ddf99e 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -99,7 +99,7 @@ static int _is_converting(struct logical_volume *lv)
{
struct lv_segment *seg;
- if (lv->status & MIRRORED) {
+ if (lv_is_mirrored(lv)) {
seg = first_seg(lv);
/* Can't use is_temporary_mirror() because the metadata for
* seg_lv may not be read in and flags may not be set yet. */
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 0fbdfff..a8ad2d2 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -340,7 +340,7 @@ char *lv_convert_lv_dup(struct dm_pool *mem, const struct logical_volume *lv)
{
struct lv_segment *seg;
- if (lv->status & (CONVERTING|MIRRORED)) {
+ if (lv_is_converting(lv) || lv_is_mirrored(lv)) {
seg = first_seg(lv);
/* Temporary mirror is always area_num == 0 */
@@ -361,7 +361,7 @@ char *lv_move_pv_dup(struct dm_pool *mem, const struct logical_volume *lv)
if (seg->status & PVMOVE) {
if (seg_type(seg, 0) == AREA_LV) { /* atomic pvmove */
mimage0_lv = seg_lv(seg, 0);
- if (!lv_is_mirror_type(mimage0_lv)) {
+ if (!lv_is_mirrored(mimage0_lv)) {
log_error(INTERNAL_ERROR
"Bad pvmove structure");
return NULL;
@@ -505,7 +505,7 @@ int lv_raid_image_in_sync(const struct logical_volume *lv)
if (!lv_is_active_locally(lv))
return 0; /* Assume not in-sync */
- if (!(lv->status & RAID_IMAGE)) {
+ if (!lv_is_raid_image(lv)) {
log_error(INTERNAL_ERROR "%s is not a RAID image", lv->name);
return 0;
}
@@ -573,7 +573,7 @@ int lv_raid_healthy(const struct logical_volume *lv)
return 0;
}
- if (lv->status & RAID)
+ if (lv_is_raid(lv))
raid_seg = first_seg(lv);
else if ((seg = first_seg(lv)))
raid_seg = get_only_segment_using_this_lv(seg->lv);
@@ -592,7 +592,7 @@ int lv_raid_healthy(const struct logical_volume *lv)
if (!lv_raid_dev_health(raid_seg->lv, &raid_health))
return_0;
- if (lv->status & RAID) {
+ if (lv_is_raid(lv)) {
if (strchr(raid_health, 'D'))
return 0;
else
@@ -601,8 +601,8 @@ int lv_raid_healthy(const struct logical_volume *lv)
/* Find out which sub-LV this is. */
for (s = 0; s < raid_seg->area_count; s++)
- if (((lv->status & RAID_IMAGE) && (seg_lv(raid_seg, s) == lv)) ||
- ((lv->status & RAID_META) && (seg_metalv(raid_seg,s) == lv)))
+ if ((lv_is_raid_image(lv) && (seg_lv(raid_seg, s) == lv)) ||
+ (lv_is_raid_metadata(lv) && (seg_metalv(raid_seg,s) == lv)))
break;
if (s == raid_seg->area_count) {
log_error(INTERNAL_ERROR
@@ -633,7 +633,7 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
if (!*lv->name)
goto out;
- if (lv->status & PVMOVE)
+ if (lv_is_pvmove(lv))
repstr[0] = 'p';
else if (lv->status & CONVERTING)
repstr[0] = 'c';
@@ -646,22 +646,22 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
repstr[0] = 'e';
else if (lv_is_cache_type(lv))
repstr[0] = 'C';
- else if (lv->status & RAID)
+ else if (lv_is_raid(lv))
repstr[0] = (lv->status & LV_NOTSYNCED) ? 'R' : 'r';
- else if (lv->status & MIRRORED)
+ else if (lv_is_mirrored(lv))
repstr[0] = (lv->status & LV_NOTSYNCED) ? 'M' : 'm';
else if (lv_is_thin_volume(lv))
repstr[0] = lv_is_merging_origin(lv) ?
'O' : (lv_is_merging_thin_snapshot(lv) ? 'S' : 'V');
- else if (lv->status & VIRTUAL)
+ else if (lv_is_virtual(lv))
repstr[0] = 'v';
else if (lv_is_thin_pool(lv))
repstr[0] = 't';
else if (lv_is_thin_pool_data(lv))
repstr[0] = 'T';
- else if (lv->status & MIRROR_IMAGE)
+ else if (lv_is_mirror_image(lv))
repstr[0] = (lv_mirror_image_in_sync(lv)) ? 'i' : 'I';
- else if (lv->status & RAID_IMAGE)
+ else if (lv_is_raid_image(lv))
/*
* Visible RAID_IMAGES are sub-LVs that have been exposed for
* top-level use by being split from the RAID array with
@@ -669,7 +669,7 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
*/
repstr[0] = (!lv_is_visible(lv) && lv_raid_image_in_sync(lv)) ?
'i' : 'I';
- else if (lv->status & MIRROR_LOG)
+ else if (lv_is_mirror_log(lv))
repstr[0] = 'l';
else if (lv_is_cow(lv))
repstr[0] = (lv_is_merging_cow(lv)) ? 'S' : 's';
@@ -678,7 +678,7 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
else
repstr[0] = '-';
- if (lv->status & PVMOVE)
+ if (lv_is_pvmove(lv))
repstr[1] = '-';
else if (lv->status & LVM_WRITE)
repstr[1] = 'w';
@@ -689,7 +689,7 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
repstr[2] = alloc_policy_char(lv->alloc);
- if (lv->status & LOCKED)
+ if (lv_is_locked(lv))
repstr[2] = toupper(repstr[2]);
repstr[3] = (lv->status & FIXED_MINOR) ? 'm' : '-';
@@ -743,7 +743,7 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
repstr[6] = 'C';
else if (lv_is_raid_type(lv))
repstr[6] = 'r';
- else if (lv_is_mirror_type(lv))
+ else if (lv_is_mirror_type(lv) || lv_is_pvmove(lv))
repstr[6] = 'm';
else if (lv_is_cow(lv) || lv_is_origin(lv))
repstr[6] = 's';
@@ -770,7 +770,7 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
repstr[8] = 'X'; /* Unknown */
else if (!lv_raid_healthy(lv))
repstr[8] = 'r'; /* RAID needs 'r'efresh */
- else if (lv->status & RAID) {
+ else if (lv_is_raid(lv)) {
if (lv_raid_mismatch_count(lv, &n) && n)
repstr[8] = 'm'; /* RAID has 'm'ismatches */
} else if (lv->status & LV_WRITEMOSTLY)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 12585ef..6d80dfb 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -191,7 +191,7 @@ static int _lv_layout_and_role_mirror(struct dm_pool *mem,
if (lv_is_mirrored(lv) &&
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_MIRROR]))
goto_bad;
- } else if (lv->status & PVMOVE) {
+ } else if (lv_is_pvmove(lv)) {
if (!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_PVMOVE]) ||
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_MIRROR]))
goto_bad;
@@ -464,7 +464,7 @@ int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
}
/* Mirrors and related */
- if (lv_is_mirror_type(lv) && !lv_is_raid(lv) &&
+ if ((lv_is_mirror_type(lv) || lv_is_pvmove(lv)) && !lv_is_raid(lv) &&
!_lv_layout_and_role_mirror(mem, lv, *layout, *role, &public_lv))
goto_bad;
@@ -1035,9 +1035,9 @@ static int _release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t
return 1;
}
- if ((seg_lv(seg, s)->status & MIRROR_IMAGE) ||
- (seg_lv(seg, s)->status & THIN_POOL_DATA) ||
- (seg_lv(seg, s)->status & CACHE_POOL_DATA)) {
+ if (lv_is_mirror_image(seg_lv(seg, s)) ||
+ lv_is_thin_pool_data(seg_lv(seg, s)) ||
+ lv_is_cache_pool_data(seg_lv(seg, s))) {
if (!lv_reduce(seg_lv(seg, s), area_reduction))
return_0; /* FIXME: any upper level reporting */
return 1;
@@ -1052,7 +1052,7 @@ static int _release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t
return_0;
}
- if (seg_lv(seg, s)->status & RAID_IMAGE) {
+ if (lv_is_raid_image(seg_lv(seg, s))) {
/*
* FIXME: Use lv_reduce not lv_remove
* We use lv_remove for now, because I haven't figured out
@@ -3203,7 +3203,7 @@ int lv_add_segmented_mirror_image(struct alloc_handle *ah,
struct segment_type *segtype;
struct logical_volume *orig_lv, *copy_lv;
- if (!(lv->status & PVMOVE)) {
+ if (!lv_is_pvmove(lv)) {
log_error(INTERNAL_ERROR
"Non-pvmove LV, %s, passed as argument", lv->name);
return 0;
@@ -3803,7 +3803,7 @@ static int _rename_single_lv(struct logical_volume *lv, char *new_name)
return 0;
}
- if (lv->status & LOCKED) {
+ if (lv_is_locked(lv)) {
log_error("Cannot rename locked LV %s", lv->name);
return 0;
}
@@ -3954,7 +3954,7 @@ int lv_rename_update(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
- if (lv->status & LOCKED) {
+ if (lv_is_locked(lv)) {
log_error("Cannot rename locked LV %s", lv->name);
return 0;
}
@@ -4316,7 +4316,7 @@ static int _lvresize_check_lv(struct cmd_context *cmd, struct logical_volume *lv
return 0;
}
- if (lv->status & (RAID_IMAGE | RAID_META)) {
+ if (lv_is_raid_image(lv) || lv_is_raid_metadata(lv)) {
log_error("Cannot resize a RAID %s directly",
(lv->status & RAID_IMAGE) ? "image" :
"metadata area");
@@ -4356,12 +4356,12 @@ static int _lvresize_check_lv(struct cmd_context *cmd, struct logical_volume *lv
return 0;
}
- if (lv->status & LOCKED) {
+ if (lv_is_locked(lv)) {
log_error("Can't resize locked LV %s", lv->name);
return 0;
}
- if (lv->status & CONVERTING) {
+ if (lv_is_converting(lv)) {
log_error("Can't resize %s while lvconvert in progress", lv->name);
return 0;
}
@@ -5379,19 +5379,19 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
- if (lv->status & MIRROR_IMAGE) {
+ if (lv_is_mirror_image(lv)) {
log_error("Can't remove logical volume %s used by a mirror",
lv->name);
return 0;
}
- if (lv->status & MIRROR_LOG) {
+ if (lv_is_mirror_log(lv)) {
log_error("Can't remove logical volume %s used as mirror log",
lv->name);
return 0;
}
- if (lv->status & (RAID_META | RAID_IMAGE)) {
+ if (lv_is_raid_metadata(lv) || lv_is_raid_image(lv)) {
log_error("Can't remove logical volume %s used as RAID device",
lv->name);
return 0;
@@ -5405,7 +5405,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
} else if (lv_is_thin_volume(lv))
pool_lv = first_seg(lv)->pool_lv;
- if (lv->status & LOCKED) {
+ if (lv_is_locked(lv)) {
log_error("Can't remove locked LV %s", lv->name);
return 0;
}
@@ -6615,7 +6615,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- if (pool_lv->status & LOCKED) {
+ if (lv_is_locked(pool_lv)) {
log_error("Caching locked devices is not supported.");
return NULL;
}
@@ -6641,7 +6641,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- if (org->status & LOCKED) {
+ if (lv_is_locked(org)) {
log_error("Caching locked devices is not supported.");
return NULL;
}
@@ -6670,7 +6670,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- if (org->status & LOCKED) {
+ if (lv_is_locked(org)) {
log_error("Snapshots of locked devices are not supported.");
return NULL;
}
@@ -6703,7 +6703,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
"supported yet.");
return NULL;
}
- if (org->status & LOCKED) {
+ if (lv_is_locked(org)) {
log_error("Snapshots of locked devices are not "
"supported yet");
return NULL;
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index 5aa7d00..37026d1 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -45,12 +45,12 @@ int lv_merge_segments(struct logical_volume *lv)
* having a matching segment structure.
*/
- if (lv->status & LOCKED || lv->status & PVMOVE)
+ if (lv_is_locked(lv) || lv_is_pvmove(lv))
return 1;
- if ((lv->status & MIRROR_IMAGE) &&
+ if (lv_is_mirror_image(lv) &&
(seg = get_only_segment_using_this_lv(lv)) &&
- (seg->lv->status & LOCKED || seg->lv->status & PVMOVE))
+ (lv_is_locked(seg->lv) || lv_is_pvmove(seg->lv)))
return 1;
dm_list_iterate_safe(segh, t, &lv->segments) {
@@ -159,7 +159,7 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
* Check mirror log - which is attached to the mirrored seg
*/
if (complete_vg && seg->log_lv && seg_is_mirrored(seg)) {
- if (!(seg->log_lv->status & MIRROR_LOG)) {
+ if (!lv_is_mirror_log(seg->log_lv)) {
log_error("LV %s: segment %u log LV %s is not "
"a mirror log",
lv->name, seg_count, seg->log_lv->name);
@@ -346,7 +346,7 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
}
if (complete_vg && seg_lv(seg, s) &&
- (seg_lv(seg, s)->status & MIRROR_IMAGE) &&
+ lv_is_mirror_image(seg_lv(seg, s)) &&
(!(seg2 = find_seg_by_le(seg_lv(seg, s),
seg_le(seg, s))) ||
find_mirror_seg(seg2) != seg)) {
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index b0ca632..0026ba9 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -42,62 +42,62 @@
/* Various flags */
/* Note that the bits no longer necessarily correspond to LVM1 disk format */
-#define PARTIAL_VG UINT64_C(0x00000001) /* VG */
-#define EXPORTED_VG UINT64_C(0x00000002) /* VG PV */
-#define RESIZEABLE_VG UINT64_C(0x00000004) /* VG */
+#define PARTIAL_VG UINT64_C(0x0000000000000001) /* VG */
+#define EXPORTED_VG UINT64_C(0x0000000000000002) /* VG PV */
+#define RESIZEABLE_VG UINT64_C(0x0000000000000004) /* VG */
/* May any free extents on this PV be used or must they be left free? */
-#define ALLOCATABLE_PV UINT64_C(0x00000008) /* PV */
+#define ALLOCATABLE_PV UINT64_C(0x0000000000000008) /* PV */
#define ARCHIVED_VG ALLOCATABLE_PV /* VG, reuse same bit */
-//#define SPINDOWN_LV UINT64_C(0x00000010) /* LV */
-//#define BADBLOCK_ON UINT64_C(0x00000020) /* LV */
-#define VISIBLE_LV UINT64_C(0x00000040) /* LV */
-#define FIXED_MINOR UINT64_C(0x00000080) /* LV */
+//#define SPINDOWN_LV UINT64_C(0x0000000000000010) /* LV */
+//#define BADBLOCK_ON UINT64_C(0x0000000000000020) /* LV */
+#define VISIBLE_LV UINT64_C(0x0000000000000040) /* LV */
+#define FIXED_MINOR UINT64_C(0x0000000000000080) /* LV */
-#define LVM_READ UINT64_C(0x00000100) /* LV, VG */
-#define LVM_WRITE UINT64_C(0x00000200) /* LV, VG */
+#define LVM_READ UINT64_C(0x0000000000000100) /* LV, VG */
+#define LVM_WRITE UINT64_C(0x0000000000000200) /* LV, VG */
-#define CLUSTERED UINT64_C(0x00000400) /* VG */
-//#define SHARED UINT64_C(0x00000800) /* VG */
+#define CLUSTERED UINT64_C(0x0000000000000400) /* VG */
+//#define SHARED UINT64_C(0x0000000000000800) /* VG */
/* FIXME Remove when metadata restructuring is completed */
-#define SNAPSHOT UINT64_C(0x00001000) /* LV - internal use only */
-#define PVMOVE UINT64_C(0x00002000) /* VG LV SEG */
-#define LOCKED UINT64_C(0x00004000) /* LV */
-#define MIRRORED UINT64_C(0x00008000) /* LV - internal use only */
-//#define VIRTUAL UINT64_C(0x00010000) /* LV - internal use only */
-#define MIRROR_LOG UINT64_C(0x00020000) /* LV */
-#define MIRROR_IMAGE UINT64_C(0x00040000) /* LV */
-
-#define LV_NOTSYNCED UINT64_C(0x00080000) /* LV */
-#define LV_REBUILD UINT64_C(0x00100000) /* LV */
-//#define PRECOMMITTED UINT64_C(0x00200000) /* VG - internal use only */
-#define CONVERTING UINT64_C(0x00400000) /* LV */
-
-#define MISSING_PV UINT64_C(0x00800000) /* PV */
-#define PARTIAL_LV UINT64_C(0x01000000) /* LV - derived flag, not
+#define SNAPSHOT UINT64_C(0x0000000000001000) /* LV - internal use only */
+#define PVMOVE UINT64_C(0x0000000000002000) /* VG LV SEG */
+#define LOCKED UINT64_C(0x0000000000004000) /* LV */
+#define MIRRORED UINT64_C(0x0000000000008000) /* LV - internal use only */
+//#define VIRTUAL UINT64_C(0x0000000000010000) /* LV - internal use only */
+#define MIRROR_LOG UINT64_C(0x0000000000020000) /* LV - Internal use only */
+#define MIRROR_IMAGE UINT64_C(0x0000000000040000) /* LV - Internal use only */
+
+#define LV_NOTSYNCED UINT64_C(0x0000000000080000) /* LV */
+#define LV_REBUILD UINT64_C(0x0000000000100000) /* LV */
+//#define PRECOMMITTED UINT64_C(0x0000000000200000) /* VG - internal use only */
+#define CONVERTING UINT64_C(0x0000000000400000) /* LV */
+
+#define MISSING_PV UINT64_C(0x0000000000800000) /* PV */
+#define PARTIAL_LV UINT64_C(0x0000000001000000) /* LV - derived flag, not
written out in metadata*/
-//#define POSTORDER_FLAG UINT64_C(0x02000000) /* Not real flags, reserved for
-//#define POSTORDER_OPEN_FLAG UINT64_C(0x04000000) temporary use inside vg_read_internal. */
-//#define VIRTUAL_ORIGIN UINT64_C(0x08000000) /* LV - internal use only */
+//#define POSTORDER_FLAG UINT64_C(0x0000000002000000) /* Not real flags, reserved for
+//#define POSTORDER_OPEN_FLAG UINT64_C(0x0000000004000000) temporary use inside vg_read_internal. */
+//#define VIRTUAL_ORIGIN UINT64_C(0x0000000008000000) /* LV - internal use only */
-#define MERGING UINT64_C(0x10000000) /* LV SEG */
+#define MERGING UINT64_C(0x0000000010000000) /* LV SEG */
-#define REPLICATOR UINT64_C(0x20000000) /* LV -internal use only for replicator */
-#define REPLICATOR_LOG UINT64_C(0x40000000) /* LV -internal use only for replicator-dev */
-#define UNLABELLED_PV UINT64_C(0x80000000) /* PV -this PV had no label written yet */
+#define REPLICATOR UINT64_C(0x0000000020000000) /* LV -internal use only for replicator */
+#define REPLICATOR_LOG UINT64_C(0x0000000040000000) /* LV -internal use only for replicator-dev */
+#define UNLABELLED_PV UINT64_C(0x0000000080000000) /* PV -this PV had no label written yet */
-#define RAID UINT64_C(0x0000000100000000) /* LV */
-#define RAID_META UINT64_C(0x0000000200000000) /* LV */
-#define RAID_IMAGE UINT64_C(0x0000000400000000) /* LV */
+#define RAID UINT64_C(0x0000000100000000) /* LV - Internal use only */
+#define RAID_META UINT64_C(0x0000000200000000) /* LV - Internal use only */
+#define RAID_IMAGE UINT64_C(0x0000000400000000) /* LV - Internal use only */
-#define THIN_VOLUME UINT64_C(0x0000001000000000) /* LV */
-#define THIN_POOL UINT64_C(0x0000002000000000) /* LV */
-#define THIN_POOL_DATA UINT64_C(0x0000004000000000) /* LV */
-#define THIN_POOL_METADATA UINT64_C(0x0000008000000000) /* LV */
-#define POOL_METADATA_SPARE UINT64_C(0x0000010000000000) /* LV internal */
+#define THIN_VOLUME UINT64_C(0x0000001000000000) /* LV - Internal use only */
+#define THIN_POOL UINT64_C(0x0000002000000000) /* LV - Internal use only */
+#define THIN_POOL_DATA UINT64_C(0x0000004000000000) /* LV - Internal use only */
+#define THIN_POOL_METADATA UINT64_C(0x0000008000000000) /* LV - Internal use only */
+#define POOL_METADATA_SPARE UINT64_C(0x0000010000000000) /* LV - Internal use only */
#define LV_WRITEMOSTLY UINT64_C(0x0000020000000000) /* LV (RAID1) */
@@ -110,10 +110,12 @@
this flag dropped during single
LVM command execution. */
-#define CACHE_POOL UINT64_C(0x0000200000000000) /* LV */
-#define CACHE_POOL_DATA UINT64_C(0x0000400000000000) /* LV */
-#define CACHE_POOL_METADATA UINT64_C(0x0000800000000000) /* LV */
-#define CACHE UINT64_C(0x0001000000000000) /* LV */
+#define CACHE_POOL UINT64_C(0x0000200000000000) /* LV - Internal use only */
+#define CACHE_POOL_DATA UINT64_C(0x0000400000000000) /* LV - Internal use only */
+#define CACHE_POOL_METADATA UINT64_C(0x0000800000000000) /* LV - Internal use only */
+#define CACHE UINT64_C(0x0001000000000000) /* LV - Internal use only */
+
+/* Next unused flag: UINT64_C(0x0002000000000000) */
/* Format features flags */
#define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */
@@ -162,34 +164,43 @@
#define vg_is_archived(vg) (((vg)->status & ARCHIVED_VG) ? 1 : 0)
+#define lv_is_locked(lv) (((lv)->status & LOCKED) ? 1 : 0)
+#define lv_is_virtual(lv) (((lv)->status & VIRTUAL) ? 1 : 0)
+#define lv_is_merging(lv) (((lv)->status & MERGING) ? 1 : 0)
+#define lv_is_converting(lv) (((lv)->status & CONVERTING) ? 1 : 0)
#define lv_is_external_origin(lv) (((lv)->external_count > 0) ? 1 : 0)
-#define lv_is_thin_volume(lv) (((lv)->status & (THIN_VOLUME)) ? 1 : 0)
-#define lv_is_thin_pool(lv) (((lv)->status & (THIN_POOL)) ? 1 : 0)
-#define lv_is_used_thin_pool(lv) (lv_is_thin_pool(lv) && !dm_list_empty(&(lv)->segs_using_this_lv))
-#define lv_is_thin_pool_data(lv) (((lv)->status & (THIN_POOL_DATA)) ? 1 : 0)
-#define lv_is_thin_pool_metadata(lv) (((lv)->status & (THIN_POOL_METADATA)) ? 1 : 0)
-#define lv_is_mirrored(lv) (((lv)->status & (MIRRORED)) ? 1 : 0)
-#define lv_is_rlog(lv) (((lv)->status & (REPLICATOR_LOG)) ? 1 : 0)
+#define lv_is_thin_volume(lv) (((lv)->status & THIN_VOLUME) ? 1 : 0)
+#define lv_is_thin_pool(lv) (((lv)->status & THIN_POOL) ? 1 : 0)
+#define lv_is_used_thin_pool(lv) (lv_is_thin_pool(lv) && !dm_list_empty(&(lv)->segs_using_this_lv))
+#define lv_is_thin_pool_data(lv) (((lv)->status & THIN_POOL_DATA) ? 1 : 0)
+#define lv_is_thin_pool_metadata(lv) (((lv)->status & THIN_POOL_METADATA) ? 1 : 0)
#define lv_is_thin_type(lv) (((lv)->status & (THIN_POOL | THIN_VOLUME | THIN_POOL_DATA | THIN_POOL_METADATA)) ? 1 : 0)
-#define lv_is_mirror_type(lv) (((lv)->status & (MIRROR_LOG | MIRROR_IMAGE | MIRRORED | PVMOVE)) ? 1 : 0)
-#define lv_is_mirror_image(lv) (((lv)->status & (MIRROR_IMAGE)) ? 1 : 0)
-#define lv_is_mirror_log(lv) (((lv)->status & (MIRROR_LOG)) ? 1 : 0)
-#define lv_is_raid(lv) (((lv)->status & (RAID)) ? 1 : 0)
-#define lv_is_raid_image(lv) (((lv)->status & (RAID_IMAGE)) ? 1 : 0)
-#define lv_is_raid_metadata(lv) (((lv)->status & (RAID_META)) ? 1 : 0)
+
+#define lv_is_mirrored(lv) (((lv)->status & MIRRORED) ? 1 : 0)
+
+#define lv_is_mirror_image(lv) (((lv)->status & MIRROR_IMAGE) ? 1 : 0)
+#define lv_is_mirror_log(lv) (((lv)->status & MIRROR_LOG) ? 1 : 0)
+#define lv_is_mirror_type(lv) (((lv)->status & (MIRROR_LOG | MIRROR_IMAGE | MIRRORED)) ? 1 : 0)
+
+#define lv_is_pvmove(lv) (((lv)->status & PVMOVE) ? 1 : 0)
+
+#define lv_is_raid(lv) (((lv)->status & RAID) ? 1 : 0)
+#define lv_is_raid_image(lv) (((lv)->status & RAID_IMAGE) ? 1 : 0)
+#define lv_is_raid_metadata(lv) (((lv)->status & RAID_META) ? 1 : 0)
#define lv_is_raid_type(lv) (((lv)->status & (RAID | RAID_IMAGE | RAID_META)) ? 1 : 0)
-#define lv_is_cache(lv) (((lv)->status & (CACHE)) ? 1 : 0)
-#define lv_is_cache_pool(lv) (((lv)->status & (CACHE_POOL)) ? 1 : 0)
-#define lv_is_cache_pool_data(lv) (((lv)->status & (CACHE_POOL_DATA)) ? 1 : 0)
-#define lv_is_cache_pool_metadata(lv) (((lv)->status & (CACHE_POOL_METADATA)) ? 1 : 0)
+#define lv_is_cache(lv) (((lv)->status & CACHE) ? 1 : 0)
+#define lv_is_cache_pool(lv) (((lv)->status & CACHE_POOL) ? 1 : 0)
+#define lv_is_cache_pool_data(lv) (((lv)->status & CACHE_POOL_DATA) ? 1 : 0)
+#define lv_is_cache_pool_metadata(lv) (((lv)->status & CACHE_POOL_METADATA) ? 1 : 0)
#define lv_is_cache_type(lv) (((lv)->status & (CACHE | CACHE_POOL | CACHE_POOL_DATA | CACHE_POOL_METADATA)) ? 1 : 0)
-#define lv_is_virtual(lv) (((lv)->status & (VIRTUAL)) ? 1 : 0)
#define lv_is_pool(lv) (((lv)->status & (CACHE_POOL | THIN_POOL)) ? 1 : 0)
#define lv_is_pool_metadata(lv) (((lv)->status & (CACHE_POOL_METADATA | THIN_POOL_METADATA)) ? 1 : 0)
-#define lv_is_pool_metadata_spare(lv) (((lv)->status & (POOL_METADATA_SPARE)) ? 1 : 0)
+#define lv_is_pool_metadata_spare(lv) (((lv)->status & POOL_METADATA_SPARE) ? 1 : 0)
+
+#define lv_is_rlog(lv) (((lv)->status & REPLICATOR_LOG) ? 1 : 0)
int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
struct dm_list **layout, struct dm_list **role);
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index f8ffe30..2900ccc 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2586,7 +2586,7 @@ int vg_validate(struct volume_group *vg)
}
dm_list_iterate_items(lvl, &vg->lvs) {
- if (!(lvl->lv->status & PVMOVE))
+ if (!lv_is_pvmove(lvl->lv))
continue;
dm_list_iterate_items(seg, &lvl->lv->segments) {
if (seg_is_mirrored(seg)) {
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 985bde0..4505eb9 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -42,9 +42,7 @@
*/
int is_temporary_mirror_layer(const struct logical_volume *lv)
{
- if (lv->status & MIRROR_IMAGE
- && lv->status & MIRRORED
- && !(lv->status & LOCKED))
+ if (lv_is_mirror_image(lv) && lv_is_mirrored(lv) && !lv_is_locked(lv))
return 1;
return 0;
@@ -58,7 +56,7 @@ struct logical_volume *find_temporary_mirror(const struct logical_volume *lv)
{
struct lv_segment *seg;
- if (!(lv->status & MIRRORED))
+ if (!lv_is_mirrored(lv))
return NULL;
seg = first_seg(lv);
@@ -109,7 +107,7 @@ uint32_t lv_mirror_count(const struct logical_volume *lv)
struct lv_segment *seg;
uint32_t s, mirrors;
- if (!(lv->status & MIRRORED))
+ if (!lv_is_mirrored(lv))
return 1;
seg = first_seg(lv);
@@ -118,7 +116,7 @@ uint32_t lv_mirror_count(const struct logical_volume *lv)
if (!strcmp(seg->segtype->name, "raid10"))
return 2;
- if (lv->status & PVMOVE)
+ if (lv_is_pvmove(lv))
return seg->area_count;
mirrors = 0;
@@ -612,7 +610,7 @@ static int _split_mirror_images(struct logical_volume *lv,
struct lv_list *lvl;
struct cmd_context *cmd = lv->vg->cmd;
- if (!(lv->status & MIRRORED)) {
+ if (!lv_is_mirrored(lv)) {
log_error("Unable to split non-mirrored LV, %s",
lv->name);
return 0;
@@ -950,7 +948,7 @@ static int _remove_mirror_images(struct logical_volume *lv,
if (remove_log && !detached_log_lv)
detached_log_lv = detach_mirror_log(mirrored_seg);
- if (lv->status & PVMOVE)
+ if (lv_is_pvmove(lv))
dm_list_iterate_items(pvmove_seg, &lv->segments)
pvmove_seg->status |= PVMOVE;
} else if (new_area_count == 0) {
@@ -1524,7 +1522,7 @@ struct logical_volume *find_pvmove_lv_in_lv(struct logical_volume *lv)
for (s = 0; s < seg->area_count; s++) {
if (seg_type(seg, s) != AREA_LV)
continue;
- if (seg_lv(seg, s)->status & PVMOVE)
+ if (lv_is_pvmove(seg_lv(seg, s)))
return seg_lv(seg, s);
}
}
@@ -2116,7 +2114,7 @@ int lv_add_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
if (vg_is_clustered(lv->vg)) {
/* FIXME: move this test out of this function */
/* Skip test for pvmove mirrors, it can use local mirror */
- if (!(lv->status & (PVMOVE | LOCKED)) &&
+ if (!lv_is_pvmove(lv) && !lv_is_locked(lv) &&
lv_is_active(lv) &&
!lv_is_active_exclusive_locally(lv) && /* lv_is_active_remotely */
!_cluster_mirror_is_available(lv)) {
@@ -2251,7 +2249,7 @@ int lv_remove_mirrors(struct cmd_context *cmd __attribute__((unused)),
/* MIRROR_BY_LV */
if (seg_type(seg, 0) == AREA_LV &&
- seg_lv(seg, 0)->status & MIRROR_IMAGE)
+ lv_is_mirror_image(seg_lv(seg, 0)))
return remove_mirror_images(lv, new_mirrors + 1,
is_removable, removable_baton,
log_count ? 1U : 0);
diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c
index 278edc8..dfad615 100644
--- a/lib/metadata/snapshot_manip.c
+++ b/lib/metadata/snapshot_manip.c
@@ -136,12 +136,13 @@ int lv_is_virtual_origin(const struct logical_volume *lv)
int lv_is_merging_origin(const struct logical_volume *origin)
{
- return (origin->status & MERGING) ? 1 : 0;
+ return lv_is_merging(origin);
}
int lv_is_merging_cow(const struct logical_volume *snapshot)
{
struct lv_segment *snap_seg = find_snapshot(snapshot);
+
/* checks lv_segment's status to see if cow is merging */
return (snap_seg && (snap_seg->status & MERGING)) ? 1 : 0;
}
diff --git a/lib/report/report.c b/lib/report/report.c
index f315df4..24bc437 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1042,9 +1042,8 @@ static int _copypercent_disp(struct dm_report *rh,
dm_percent_t percent = DM_PERCENT_INVALID;
if (((lv_is_raid(lv) && lv_raid_percent(lv, &percent)) ||
-
- ((lv->status & (PVMOVE | MIRRORED)) &&
- lv_mirror_percent(lv->vg->cmd, lv, 0, &percent, NULL))) &&
+ ((lv_is_pvmove(lv) || lv_is_mirrored(lv)) &&
+ lv_mirror_percent(lv->vg->cmd, lv, 0, &percent, NULL))) &&
(percent != DM_PERCENT_INVALID)) {
percent = copy_percent(lv);
return dm_report_field_percent(rh, field, &percent);
@@ -1406,7 +1405,8 @@ static int _lvconverting_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
{
- int converting = (((const struct logical_volume *) data)->status & CONVERTING) != 0;
+ int converting = lv_is_converting((const struct logical_volume *) data);
+
return _binary_disp(rh, mem, field, converting, "converting", private);
}
@@ -1417,7 +1417,7 @@ static int _lvpermissions_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_with_info *lvi = (const struct lv_with_info *) data;
const char *perms = "";
- if (!(lvi->lv->status & PVMOVE)) {
+ if (!lv_is_pvmove(lvi->lv)) {
if (lvi->lv->status & LVM_WRITE) {
if (!lvi->info->exists)
perms = _str_unknown;
@@ -1447,6 +1447,7 @@ static int _lvallocationlocked_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data, void *private)
{
int alloc_locked = (((const struct logical_volume *) data)->status & LOCKED) != 0;
+
return _binary_disp(rh, mem, field, alloc_locked, FIRST_NAME(lv_allocation_locked_y), private);
}
@@ -1455,6 +1456,7 @@ static int _lvfixedminor_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data, void *private)
{
int fixed_minor = (((const struct logical_volume *) data)->status & FIXED_MINOR) != 0;
+
return _binary_disp(rh, mem, field, fixed_minor, FIRST_NAME(lv_fixed_minor_y), private);
}
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index afa1a90..0557f45 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -92,6 +92,7 @@ static int _snap_text_export(const struct lv_segment *seg, struct formatter *f)
{
outf(f, "chunk_size = %u", seg->chunk_size);
outf(f, "origin = \"%s\"", seg->origin->name);
+
if (!(seg->status & MERGING))
outf(f, "cow_store = \"%s\"", seg->cow->name);
else
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index 89d0e92..3af1f62 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -295,13 +295,13 @@ static int _lvm_lv_activate(lv_t lv)
return -1;
/* FIXME: handle pvmove stuff later */
- if (lv->status & LOCKED) {
+ if (lv_is_locked(lv)) {
log_error("Unable to activate locked LV");
return -1;
}
/* FIXME: handle lvconvert stuff later */
- if (lv->status & CONVERTING) {
+ if (lv_is_converting(lv)) {
log_error("Unable to activate LV with in-progress lvconvert");
return -1;
}
diff --git a/tools/lvchange.c b/tools/lvchange.c
index bbb030f..c3d0b6a 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -41,7 +41,7 @@ static int lvchange_permission(struct cmd_context *cmd,
return 0;
}
- if ((lv->status & MIRRORED) && (vg_is_clustered(lv->vg)) &&
+ if (lv_is_mirrored(lv) && vg_is_clustered(lv->vg) &&
lv_info(cmd, lv, 0, &info, 0, 0) && info.exists) {
log_error("Cannot change permissions of mirror \"%s\" "
"while active.", lv->name);
@@ -49,9 +49,9 @@ static int lvchange_permission(struct cmd_context *cmd,
}
/* Not allowed to change permissions on RAID sub-LVs directly */
- if ((lv->status & RAID_META) || (lv->status & RAID_IMAGE)) {
+ if (lv_is_raid_metadata(lv) || lv_is_raid_image(lv)) {
log_error("Cannot change permissions of RAID %s \"%s\"",
- (lv->status & RAID_IMAGE) ? "image" :
+ lv_is_raid_image(lv) ? "image" :
"metadata area", lv->name);
return 0;
}
@@ -137,7 +137,7 @@ static int lvchange_monitoring(struct cmd_context *cmd,
}
/* do not monitor pvmove lv's */
- if (lv->status & PVMOVE)
+ if (lv_is_pvmove(lv))
return 1;
if ((dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) &&
@@ -287,18 +287,18 @@ static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
dm_list_init(&device_list);
- if (!(lv->status & MIRRORED) && !seg_is_raid(seg)) {
+ if (lv_is_mirrored(lv) && !seg_is_raid(seg)) {
log_error("Unable to resync %s. It is not RAID or mirrored.",
lv->name);
return 0;
}
- if (lv->status & PVMOVE) {
+ if (lv_is_pvmove(lv)) {
log_error("Unable to resync pvmove volume %s", lv->name);
return 0;
}
- if (lv->status & LOCKED) {
+ if (lv_is_locked(lv)) {
log_error("Unable to resync locked volume %s", lv->name);
return 0;
}
@@ -859,19 +859,19 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
return ECMD_FAILED;
}
- if (lv->status & PVMOVE) {
+ if (lv_is_pvmove(lv)) {
log_error("Unable to change pvmove LV %s", lv->name);
if (arg_count(cmd, activate_ARG))
log_error("Use 'pvmove --abort' to abandon a pvmove");
return ECMD_FAILED;
}
- if (lv->status & MIRROR_LOG) {
+ if (lv_is_mirror_log(lv)) {
log_error("Unable to change mirror log LV %s directly", lv->name);
return ECMD_FAILED;
}
- if (lv->status & MIRROR_IMAGE) {
+ if (lv_is_mirror_image(lv)) {
log_error("Unable to change mirror image LV %s directly",
lv->name);
return ECMD_FAILED;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index a04a7fc..c252745 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -677,7 +677,7 @@ static int _finish_lvconvert_mirror(struct cmd_context *cmd,
struct logical_volume *lv,
struct dm_list *lvs_changed __attribute__((unused)))
{
- if (!(lv->status & CONVERTING))
+ if (!lv_is_converting(lv))
return 1;
if (!collapse_mirrored_lv(lv)) {
@@ -968,7 +968,7 @@ static int _failed_logs_count(struct logical_volume *lv)
unsigned s;
struct logical_volume *log_lv = first_seg(lv)->log_lv;
if (log_lv && (log_lv->status & PARTIAL_LV)) {
- if (log_lv->status & MIRRORED)
+ if (lv_is_mirrored(log_lv))
ret += _failed_mirrors_count(log_lv);
else
ret += 1;
@@ -1109,7 +1109,7 @@ static int _lv_update_mirrored_log(struct logical_volume *lv,
return 1;
log_lv = first_seg(_original_lv(lv))->log_lv;
- if (!log_lv || !(log_lv->status & MIRRORED))
+ if (!log_lv || !lv_is_mirrored(log_lv))
return 1;
old_log_count = _get_log_count(lv);
@@ -1252,7 +1252,7 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd,
*new_mimage_count = *old_mimage_count;
*new_log_count = *old_log_count;
- if (find_temporary_mirror(lv) || (lv->status & CONVERTING))
+ if (find_temporary_mirror(lv) || lv_is_converting(lv))
lp->need_polling = 1;
return 1;
}
@@ -1337,7 +1337,7 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd,
/*
* Region size must not change on existing mirrors
*/
- if (arg_count(cmd, regionsize_ARG) && (lv->status & MIRRORED) &&
+ if (arg_count(cmd, regionsize_ARG) && lv_is_mirrored(lv) &&
(lp->region_size != first_seg(lv)->region_size)) {
log_error("Mirror log region size cannot be changed on "
"an existing mirror.");
@@ -1348,7 +1348,7 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd,
* For the most part, we cannot handle multi-segment mirrors. Bail out
* early if we have encountered one.
*/
- if ((lv->status & MIRRORED) && dm_list_size(&lv->segments) != 1) {
+ if (lv_is_mirrored(lv) && dm_list_size(&lv->segments) != 1) {
log_error("Logical volume %s has multiple "
"mirror segments.", lv->name);
return 0;
@@ -1378,7 +1378,7 @@ static int _lvconvert_mirrors_aux(struct cmd_context *cmd,
uint32_t old_mimage_count = lv_mirror_count(lv);
uint32_t old_log_count = _get_log_count(lv);
- if ((lp->mirrors == 1) && !(lv->status & MIRRORED)) {
+ if ((lp->mirrors == 1) && !lv_is_mirrored(lv)) {
log_warn("Logical volume %s is already not mirrored.",
lv->name);
return 1;
@@ -1396,7 +1396,7 @@ static int _lvconvert_mirrors_aux(struct cmd_context *cmd,
/*
* Up-convert from linear to mirror
*/
- if (!(lv->status & MIRRORED)) {
+ if (!lv_is_mirrored(lv)) {
/* FIXME Share code with lvcreate */
/*
@@ -1442,7 +1442,7 @@ static int _lvconvert_mirrors_aux(struct cmd_context *cmd,
* Is there already a convert in progress? We do not
* currently allow more than one.
*/
- if (find_temporary_mirror(lv) || (lv->status & CONVERTING)) {
+ if (find_temporary_mirror(lv) || lv_is_converting(lv)) {
log_error("%s is already being converted. Unable to start another conversion.",
lv->name);
return 0;
@@ -1523,7 +1523,7 @@ out:
/*
* Converting the log type
*/
- if ((lv->status & MIRRORED) && (old_log_count != new_log_count)) {
+ if (lv_is_mirrored(lv) && (old_log_count != new_log_count)) {
if (!_lv_update_log_type(cmd, lp, lv,
operable_pvs, new_log_count))
return_0;
@@ -1959,7 +1959,7 @@ static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volu
if (!vg_check_status(vg, LVM_WRITE))
return_ECMD_FAILED;
- if (lv_is_mirror_type(cow) || lv_is_raid_type(cow) || lv_is_thin_type(cow)) {
+ if (lv_is_pvmove(cow) || lv_is_mirror_type(cow) || lv_is_raid_type(cow) || lv_is_thin_type(cow)) {
log_error("LV %s/%s type is unsupported with --splitsnapshot.", vg->name, cow->name);
return ECMD_FAILED;
}
@@ -2000,7 +2000,7 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,
{
struct logical_volume *org;
- if (lv->status & MIRRORED) {
+ if (lv_is_mirrored(lv)) {
log_error("Unable to convert mirrored LV \"%s\" into a snapshot.", lv->name);
return 0;
}
@@ -2025,11 +2025,11 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,
if (!cow_has_min_chunks(lv->vg, lv->le_count, lp->chunk_size))
return_0;
- if (org->status & (LOCKED|PVMOVE|MIRRORED) || lv_is_cow(org)) {
+ if (lv_is_locked(org) || lv_is_pvmove(org) || lv_is_mirrored(org) || lv_is_cow(org)) {
log_error("Unable to convert an LV into a snapshot of a %s LV.",
- org->status & LOCKED ? "locked" :
- org->status & PVMOVE ? "pvmove" :
- org->status & MIRRORED ? "mirrored" :
+ lv_is_locked(org) ? "locked" :
+ lv_is_pvmove(org) ? "pvmove" :
+ lv_is_mirrored(org) ? "mirrored" :
"snapshot");
return 0;
}
@@ -2665,7 +2665,7 @@ static int _lvconvert_pool(struct cmd_context *cmd,
log_error("Try \"raid1\" segment type instead.");
return 0;
}
- if (metadata_lv->status & LOCKED) {
+ if (lv_is_locked(metadata_lv)) {
log_error("Can't convert locked LV %s.",
display_lvname(metadata_lv));
return 0;
@@ -3031,7 +3031,7 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp = handle;
struct dm_list *failed_pvs;
- if (lv->status & LOCKED) {
+ if (lv_is_locked(lv)) {
log_error("Cannot convert locked LV %s", lv->name);
return ECMD_FAILED;
}
@@ -3042,7 +3042,7 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
return ECMD_FAILED;
}
- if (lv->status & PVMOVE) {
+ if (lv_is_pvmove(lv)) {
log_error("Unable to convert pvmove LV %s", lv->name);
return ECMD_FAILED;
}
@@ -3112,7 +3112,7 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
_remove_missing_empty_pv(lv->vg, failed_pvs);
} else if (arg_count(cmd, mirrors_ARG) ||
arg_count(cmd, splitmirrors_ARG) ||
- (lv->status & MIRRORED)) {
+ lv_is_mirrored(lv)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
diff --git a/tools/lvrename.c b/tools/lvrename.c
index 3bf4793..eeff76d 100644
--- a/tools/lvrename.c
+++ b/tools/lvrename.c
@@ -111,9 +111,9 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
goto bad;
}
- if (lvl->lv->status & (RAID_IMAGE | RAID_META)) {
+ if (lv_is_raid_image(lvl->lv) || lv_is_raid_metadata(lvl->lv)) {
log_error("Cannot rename a RAID %s directly",
- (lvl->lv->status & RAID_IMAGE) ? "image" :
+ lv_is_raid_image(lvl->lv) ? "image" :
"metadata area");
goto bad;
}
diff --git a/tools/pvmove.c b/tools/pvmove.c
index 3448af4..5b458b1 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -322,19 +322,18 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
* RAID, thin and snapshot-related LVs are not
* processed in a cluster, so we don't have to
* worry about avoiding certain PVs in that context.
+ *
+ * Allow clustered mirror, but not raid mirror.
*/
- if (vg_is_clustered(lv->vg)) {
- /* Allow clustered mirror, but not raid mirror. */
- if (!lv_is_mirror_type(lv) || lv_is_raid(lv))
- continue;
- }
+ if (vg_is_clustered(lv->vg) && (!lv_is_mirror_type(lv) || lv_is_raid(lv)))
+ continue;
if (!lv_is_on_pvs(lv, source_pvl))
continue;
- if (lv->status & (CONVERTING | MERGING)) {
+ if (lv_is_converting(lv) || lv_is_merging(lv)) {
log_error("Unable to pvmove when %s volumes are present",
- (lv->status & CONVERTING) ?
+ lv_is_converting(lv) ?
"converting" : "merging");
return NULL;
}
@@ -423,7 +422,7 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
continue;
}
- if (lv->status & LOCKED) {
+ if (lv_is_locked(lv)) {
lv_skipped = 1;
log_print_unless_silent("Skipping locked LV %s", lv->name);
continue;
diff --git a/tools/toollib.c b/tools/toollib.c
index b160ead..7be5b5a 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1440,7 +1440,7 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
if (background_polling() &&
is_change_activating(activate) &&
- (lv->status & (PVMOVE|CONVERTING|MERGING)))
+ (lv_is_pvmove(lv) || lv_is_converting(lv) || lv_is_merging(lv)))
lv_spawn_background_polling(cmd, lv);
return r;
@@ -1509,19 +1509,19 @@ void lv_spawn_background_polling(struct cmd_context *cmd,
{
const char *pvname;
- if ((lv->status & PVMOVE) &&
+ if (lv_is_pvmove(lv) &&
(pvname = get_pvmove_pvname_from_lv_mirr(lv))) {
log_verbose("Spawning background pvmove process for %s",
pvname);
pvmove_poll(cmd, pvname, 1);
- } else if ((lv->status & LOCKED) &&
- (pvname = get_pvmove_pvname_from_lv(lv))) {
+ } else if (lv_is_locked(lv) &&
+ (pvname = get_pvmove_pvname_from_lv(lv))) {
log_verbose("Spawning background pvmove process for %s",
pvname);
pvmove_poll(cmd, pvname, 1);
}
- if (lv->status & (CONVERTING|MERGING)) {
+ if (lv_is_converting(lv) || lv_is_merging(lv)) {
log_verbose("Spawning background lvconvert process for %s",
lv->name);
lvconvert_poll(cmd, lv, 1);
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 88dc180..29e2d8a 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -36,7 +36,7 @@ static int _monitor_lvs_in_vg(struct cmd_context *cmd,
/*
* FIXME: Need to consider all cases... PVMOVE, etc
*/
- if (lv->status & PVMOVE)
+ if (lv_is_pvmove(lv))
continue;
if (!monitor_dev_for_events(cmd, lv, 0, reg)) {
@@ -67,7 +67,7 @@ static int _poll_lvs_in_vg(struct cmd_context *cmd,
lv_active = info.exists;
if (lv_active &&
- (lv->status & (PVMOVE|CONVERTING|MERGING))) {
+ (lv_is_pvmove(lv) || lv_is_converting(lv) || lv_is_merging(lv))) {
lv_spawn_background_polling(cmd, lv);
count++;
}
@@ -121,7 +121,7 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
/* Can't deactivate a pvmove LV */
/* FIXME There needs to be a controlled way of doing this */
- if ((lv->status & PVMOVE) && !is_change_activating(activate))
+ if (lv_is_pvmove(lv) && !is_change_activating(activate))
continue;
if (lv_activation_skip(lv, activate, arg_count(cmd, ignoreactivationskip_ARG)))
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index 0ade4fa..62162af 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -95,13 +95,13 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
goto restart;
}
- if (lv->status & MIRRORED) {
+ if (lv_is_mirrored(lv)) {
if (!mirror_remove_missing(cmd, lv, 1))
return_0;
goto restart;
}
- if (arg_count(cmd, mirrorsonly_ARG) &&!(lv->status & MIRRORED)) {
+ if (arg_count(cmd, mirrorsonly_ARG) && !lv_is_mirrored(lv)) {
log_error("Non-mirror-image LV %s found: can't remove.", lv->name);
continue;
}
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 1a8e237..ad2eb48 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -71,7 +71,7 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
if (lv_is_raid(lv))
continue;
- if ((lv->status & MIRRORED))
+ if (lv_is_mirrored(lv))
continue;
if (lv_is_thin_pool(lv) ||
@@ -192,7 +192,7 @@ static int _move_mirrors(struct volume_group *vg_from,
if (lv_is_raid(lv))
continue;
- if (!(lv->status & MIRRORED))
+ if (!lv_is_mirrored(lv))
continue;
seg = first_seg(lv);
9 years
master - tests: update lv_no_exists
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=10a448eb2fdc79...
Commit: 10a448eb2fdc795d144f13ba4a7d83351eb8c9df
Parent: f435bef957cea11a16d15ea10a1d85193bacd736
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 15 13:45:43 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 15 13:51:19 2014 +0200
tests: update lv_no_exists
On successful exit path remove debug.log file.
---
test/lib/check.sh | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index cd29ef4..add8fb8 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -259,8 +259,9 @@ lv_exists() {
lv_not_exists() {
local vg=$1
if test $# -le 1 ; then
- lvl $vg &>/dev/null || return
- die "$vg expected to not exist but it does!"
+ if lvl $vg &>/dev/null ; then
+ die "$vg expected to not exist but it does!"
+ fi
else
while [ $# -gt 1 ]; do
shift
@@ -268,6 +269,7 @@ lv_not_exists() {
die "$vg/$1 expected to not exist but it does!"
done
fi
+ rm -f debug.log
}
pv_field() {
9 years
master - test: test there is no leak of LV on error path
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f435bef957cea1...
Commit: f435bef957cea11a16d15ea10a1d85193bacd736
Parent: 75a5de1462c30f364c7d478a4f74f355ce559ae9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 15 13:44:41 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 15 13:51:19 2014 +0200
test: test there is no leak of LV on error path
---
test/shell/thin-volume-list.sh | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/test/shell/thin-volume-list.sh b/test/shell/thin-volume-list.sh
index b53e772..31f4034 100644
--- a/test/shell/thin-volume-list.sh
+++ b/test/shell/thin-volume-list.sh
@@ -38,6 +38,11 @@ aux lvmconf "activation/volume_list = [ \"$vg1\" ]"
# Pool is not active - so it cannot create thin volume
not lvcreate -V10 -T $vg/pool
+# Cannot create even new pool
+# check there are not left devices (RHBZ #1140128)
+not lvcreate -L10 -T $vg/new_pool
+check lv_not_exists $vg/new_pool
+
aux lvmconf "activation/volume_list = [ \"$vg\" ]"
lvcreate -V10 -T $vg/pool
9 years