master - lockd: add VG name to debug logging
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=309979d5789191...
Commit: 309979d57891912b977edbd89970bf25614ee9eb
Parent: c805fa7c40ffd704523093edf4749e362f5c46ae
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 29 14:07:08 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Sep 29 14:07:08 2015 -0500
lockd: add VG name to debug logging
Add the VG name to the new debug logging in
the previous commit.
---
lib/cache/lvmetad.c | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 0545aff..db15866 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -37,7 +37,7 @@ static struct cmd_context *_lvmetad_cmd = NULL;
static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct volume_group *vg);
-static int _log_debug_inequality(struct dm_config_node *a, struct dm_config_node *b)
+static int _log_debug_inequality(const char *name, struct dm_config_node *a, struct dm_config_node *b)
{
int result = 0;
int final_result = 0;
@@ -50,51 +50,51 @@ static int _log_debug_inequality(struct dm_config_node *a, struct dm_config_node
if (!strcmp(a->key, b->key)) {
if (a->v->type == DM_CFG_STRING && b->v->type == DM_CFG_STRING)
- log_debug_lvmetad("VG metadata inequality at %s / %s: %s / %s",
- a->key, b->key, av->v.str, bv->v.str);
+ log_debug_lvmetad("VG %s metadata inequality at %s / %s: %s / %s",
+ name, a->key, b->key, av->v.str, bv->v.str);
else if (a->v->type == DM_CFG_INT && b->v->type == DM_CFG_INT)
- log_debug_lvmetad("VG metadata inequality at %s / %s: %li / %li",
- a->key, b->key, (int64_t)av->v.i, (int64_t)bv->v.i);
+ log_debug_lvmetad("VG %s metadata inequality at %s / %s: %li / %li",
+ name, a->key, b->key, (int64_t)av->v.i, (int64_t)bv->v.i);
else
- log_debug_lvmetad("VG metadata inequality at %s / %s: type %d / type %d",
- a->key, b->key, av->type, bv->type);
+ log_debug_lvmetad("VG %s metadata inequality at %s / %s: type %d / type %d",
+ name, a->key, b->key, av->type, bv->type);
} else {
- log_debug_lvmetad("VG metadata inequality at %s / %s", a->key, b->key);
+ log_debug_lvmetad("VG %s metadata inequality at %s / %s", name, a->key, b->key);
}
final_result = result;
}
}
if (a->v && !b->v) {
- log_debug_lvmetad("VG metadata inequality at %s / %s", a->key, b->key);
+ log_debug_lvmetad("VG %s metadata inequality at %s / %s", name, a->key, b->key);
final_result = 1;
}
if (!a->v && b->v) {
- log_debug_lvmetad("VG metadata inequality at %s / %s", a->key, b->key);
+ log_debug_lvmetad("VG %s metadata inequality at %s / %s", name, a->key, b->key);
final_result = -1;
}
if (a->child && b->child) {
- result = _log_debug_inequality(a->child, b->child);
+ result = _log_debug_inequality(name, a->child, b->child);
if (result)
final_result = result;
}
if (a->sib && b->sib) {
- result = _log_debug_inequality(a->sib, b->sib);
+ result = _log_debug_inequality(name, a->sib, b->sib);
if (result)
final_result = result;
}
if (a->sib && !b->sib) {
- log_debug_lvmetad("VG metadata inequality at %s / %s", a->key, b->key);
+ log_debug_lvmetad("VG %s metadata inequality at %s / %s", name, a->key, b->key);
final_result = 1;
}
if (!a->sib && b->sib) {
- log_debug_lvmetad("VG metadata inequality at %s / %s", a->key, b->key);
+ log_debug_lvmetad("VG %s metadata inequality at %s / %s", name, a->key, b->key);
final_result = -1;
}
@@ -1261,7 +1261,7 @@ static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct vo
if (compare_config(vgmeta_ret->root, vgmeta->root)) {
log_error("VG %s metadata comparison failed for device %s vs %s",
vg->name, dev_name(pvl->pv->dev), save_dev ? dev_name(save_dev) : "none");
- _log_debug_inequality(vgmeta_ret->root, vgmeta->root);
+ _log_debug_inequality(vg->name, vgmeta_ret->root, vgmeta->root);
dm_config_destroy(vgmeta);
dm_config_destroy(vgmeta_ret);
release_vg(baton.vg);
7 years, 12 months
master - lockd: add debug logging for metadata error
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c805fa7c40ffd7...
Commit: c805fa7c40ffd704523093edf4749e362f5c46ae
Parent: 634bf8c953caba4550463281fc0a90ee43c80c8d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 29 13:40:52 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Sep 29 13:51:24 2015 -0500
lockd: add debug logging for metadata error
When lvmetad_pvscan_vg() reads VG metadata from each PV,
it compares it to the last one to verify it matches.
If the VG metadata does not match on the PVs, an error
is printed and it fails to read the VG. In this error
case, use log_debug to show the differences between
the two unmatching copies of the metadata.
---
lib/cache/lvmetad.c | 70 +++++++++++++++++++++++++++++++++++++++-
libdaemon/client/config-util.c | 2 +-
libdaemon/client/config-util.h | 1 +
3 files changed, 71 insertions(+), 2 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 721c4a2..0545aff 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -37,6 +37,70 @@ static struct cmd_context *_lvmetad_cmd = NULL;
static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct volume_group *vg);
+static int _log_debug_inequality(struct dm_config_node *a, struct dm_config_node *b)
+{
+ int result = 0;
+ int final_result = 0;
+
+ if (a->v && b->v) {
+ result = compare_value(a->v, b->v);
+ if (result) {
+ struct dm_config_value *av = a->v;
+ struct dm_config_value *bv = b->v;
+
+ if (!strcmp(a->key, b->key)) {
+ if (a->v->type == DM_CFG_STRING && b->v->type == DM_CFG_STRING)
+ log_debug_lvmetad("VG metadata inequality at %s / %s: %s / %s",
+ a->key, b->key, av->v.str, bv->v.str);
+ else if (a->v->type == DM_CFG_INT && b->v->type == DM_CFG_INT)
+ log_debug_lvmetad("VG metadata inequality at %s / %s: %li / %li",
+ a->key, b->key, (int64_t)av->v.i, (int64_t)bv->v.i);
+ else
+ log_debug_lvmetad("VG metadata inequality at %s / %s: type %d / type %d",
+ a->key, b->key, av->type, bv->type);
+ } else {
+ log_debug_lvmetad("VG metadata inequality at %s / %s", a->key, b->key);
+ }
+ final_result = result;
+ }
+ }
+
+ if (a->v && !b->v) {
+ log_debug_lvmetad("VG metadata inequality at %s / %s", a->key, b->key);
+ final_result = 1;
+ }
+
+ if (!a->v && b->v) {
+ log_debug_lvmetad("VG metadata inequality at %s / %s", a->key, b->key);
+ final_result = -1;
+ }
+
+ if (a->child && b->child) {
+ result = _log_debug_inequality(a->child, b->child);
+ if (result)
+ final_result = result;
+ }
+
+ if (a->sib && b->sib) {
+ result = _log_debug_inequality(a->sib, b->sib);
+ if (result)
+ final_result = result;
+ }
+
+
+ if (a->sib && !b->sib) {
+ log_debug_lvmetad("VG metadata inequality at %s / %s", a->key, b->key);
+ final_result = 1;
+ }
+
+ if (!a->sib && b->sib) {
+ log_debug_lvmetad("VG metadata inequality at %s / %s", a->key, b->key);
+ final_result = -1;
+ }
+
+ return final_result;
+}
+
void lvmetad_disconnect(void)
{
if (_lvmetad_connected)
@@ -1136,6 +1200,7 @@ static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct vo
struct format_instance *fid;
struct format_instance_ctx fic = { .type = 0 };
struct _lvmetad_pvscan_baton baton;
+ struct device *save_dev = NULL;
dm_list_iterate_items(pvl, &vg->pvs) {
/* missing pv */
@@ -1191,9 +1256,12 @@ static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct vo
if (!vgmeta_ret) {
vgmeta_ret = vgmeta;
+ save_dev = pvl->pv->dev;
} else {
if (compare_config(vgmeta_ret->root, vgmeta->root)) {
- log_error("VG metadata comparison failed");
+ log_error("VG %s metadata comparison failed for device %s vs %s",
+ vg->name, dev_name(pvl->pv->dev), save_dev ? dev_name(save_dev) : "none");
+ _log_debug_inequality(vgmeta_ret->root, vgmeta->root);
dm_config_destroy(vgmeta);
dm_config_destroy(vgmeta_ret);
release_vg(baton.vg);
diff --git a/libdaemon/client/config-util.c b/libdaemon/client/config-util.c
index 023257e..ec5ea98 100644
--- a/libdaemon/client/config-util.c
+++ b/libdaemon/client/config-util.c
@@ -289,7 +289,7 @@ static int close_enough(double d1, double d2)
return fabs(d1 - d2) < DBL_EPSILON;
}
-static int compare_value(struct dm_config_value *a, struct dm_config_value *b)
+int compare_value(struct dm_config_value *a, struct dm_config_value *b)
{
int r = 0;
diff --git a/libdaemon/client/config-util.h b/libdaemon/client/config-util.h
index 0e7de7e..c56c268 100644
--- a/libdaemon/client/config-util.h
+++ b/libdaemon/client/config-util.h
@@ -42,6 +42,7 @@ struct dm_config_node *make_config_node(struct dm_config_tree *cft,
struct dm_config_node *parent,
struct dm_config_node *pre_sib);
+int compare_value(struct dm_config_value *a, struct dm_config_value *b);
int compare_config(struct dm_config_node *a, struct dm_config_node *b);
struct dm_config_node *make_text_node(struct dm_config_tree *cft,
7 years, 12 months
master - lockd: fix rescanning VG metadata
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=634bf8c953caba...
Commit: 634bf8c953caba4550463281fc0a90ee43c80c8d
Parent: be393f6722bd89f3fe98ab1be2f1dd41609a0172
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 29 11:07:59 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Sep 29 11:28:48 2015 -0500
lockd: fix rescanning VG metadata
One host changes a VG, making the cached VG on another
host invalid. The other host then rereads the VG from
disk to get the latest copy. If the first host removed
a PV from the VG, the second host attempts to reread the
VG from old PV when rescanning. Reading the VG from the
removed PV fails, causing vg_read to return "VG not found".
The fix is to simply not fail when a VG is not found while
rereading a PV and continue without it.
(This doesn't happen if the second host happens to first
run a command like 'vgs' that triggers a global revalidation
of metadata.)
---
lib/cache/lvmetad.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 0fff65a..721c4a2 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -1122,6 +1122,8 @@ static int _lvmetad_pvscan_single(struct metadata_area *mda, void *baton)
* due to something like an lvcreate from another host.
* This is limited to changes that only affect the vg (not global state like
* orphan PVs), so we only need to reread mdas on the vg's existing pvs.
+ * But, a previous PV in the VG may have been removed since we last read
+ * the VG, and that PV may have been reused for another VG.
*/
static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct volume_group *vg)
@@ -1160,9 +1162,25 @@ static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct vo
lvmcache_foreach_mda(info, _lvmetad_pvscan_single, &baton);
+ /*
+ * The PV may have been removed from the VG by another host
+ * since we last read the VG.
+ */
if (!baton.vg) {
+ log_debug_lvmetad("Did not find VG %s in scan of PV %s", vg->name, dev_name(pvl->pv->dev));
lvmcache_fmt(info)->ops->destroy_instance(baton.fid);
- return NULL;
+ continue;
+ }
+
+ /*
+ * The PV may have been removed from the VG and used for a
+ * different VG since we last read the VG.
+ */
+ if (strcmp(baton.vg->name, vg->name)) {
+ log_debug_lvmetad("Did not find VG %s in scan of PV %s which is now VG %s",
+ vg->name, dev_name(pvl->pv->dev), baton.vg->name);
+ release_vg(baton.vg);
+ continue;
}
if (!(vgmeta = export_vg_to_config_tree(baton.vg))) {
7 years, 12 months
master - raid: Introduce DEFAULT_RAID_MAX_IMAGES
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=be393f6722bd89...
Commit: be393f6722bd89f3fe98ab1be2f1dd41609a0172
Parent: d94ff2092709c600524f732b8bc98cd692562bcb
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Mon Sep 28 21:38:40 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Mon Sep 28 21:38:40 2015 +0100
raid: Introduce DEFAULT_RAID_MAX_IMAGES
Prepare to allow for the number of images in a raid set to be
larger than the limit for old-style dm raid1.
---
lib/config/defaults.h | 2 ++
tools/lvcreate.c | 15 ++++++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index f84eb19..cd5d121 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -63,6 +63,8 @@
#define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
#define DEFAULT_MIRROR_IMAGE_FAULT_POLICY "remove"
#define DEFAULT_MIRROR_MAX_IMAGES 8 /* limited by kernel DM_KCOPYD_MAX_REGIONS */
+#define DEFAULT_RAID_MAX_IMAGES 8
+
#define DEFAULT_RAID_FAULT_POLICY "warn"
#define DEFAULT_DMEVENTD_RAID_LIB "libdevmapper-event-lvm2raid.so"
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 80c336a..0debf40 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -500,14 +500,23 @@ static int _read_mirror_and_raid_params(struct cmd_context *cmd,
struct lvcreate_params *lp)
{
int pagesize = lvm_getpagesize();
+ unsigned max_images;
+ const char *segtype_name;
/* Common mirror and raid params */
if (arg_count(cmd, mirrors_ARG)) {
lp->mirrors = arg_uint_value(cmd, mirrors_ARG, 0) + 1;
+ if (segtype_is_raid1(lp->segtype)) {
+ segtype_name = SEG_TYPE_NAME_RAID1;
+ max_images = DEFAULT_RAID_MAX_IMAGES;
+ } else {
+ segtype_name = SEG_TYPE_NAME_MIRROR;
+ max_images = DEFAULT_MIRROR_MAX_IMAGES;
+ }
- if (lp->mirrors > DEFAULT_MIRROR_MAX_IMAGES) {
- log_error("Only up to " DM_TO_STRING(DEFAULT_MIRROR_MAX_IMAGES)
- " images in mirror supported currently.");
+ if (lp->mirrors > max_images) {
+ log_error("Only up to %u images in %s supported currently.",
+ max_images, segtype_name);
return 0;
}
7 years, 12 months
master - raid: Fail if kernel status denominator is zero.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d94ff2092709c6...
Commit: d94ff2092709c600524f732b8bc98cd692562bcb
Parent: 0173c260d8270465f1895044b34609008962cc00
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Mon Sep 28 20:45:44 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Mon Sep 28 20:45:44 2015 +0100
raid: Fail if kernel status denominator is zero.
---
lib/raid/raid.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index f75e1f7..0814cba 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -280,8 +280,8 @@ static int _raid_target_percent(void **target_state,
else
break;
}
- if (!pos || (sscanf(pos, FMTu64 "/" FMTu64 "%n",
- &numerator, &denominator, &i) != 2)) {
+ if (!pos || (sscanf(pos, FMTu64 "/" FMTu64 "%n", &numerator, &denominator, &i) != 2) ||
+ !denominator) {
log_error("Failed to parse %s status fraction: %s",
(seg) ? seg->segtype->name : "segment", params);
return 0;
7 years, 12 months
master - libdm: Move status fns from deptree to targets.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0173c260d82704...
Commit: 0173c260d8270465f1895044b34609008962cc00
Parent: 9d815e5f5a17963a09b103177770e9af80c90e0f
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Mon Sep 28 20:28:31 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Mon Sep 28 20:28:31 2015 +0100
libdm: Move status fns from deptree to targets.
libdm-deptree is only for functions working with dm tree nodes.
---
WHATS_NEW_DM | 1 +
libdm/Makefile.in | 9 +-
libdm/libdm-common.h | 2 +
libdm/libdm-deptree.c | 344 +-----------------------------------------------
libdm/libdm-targets.c | 357 +++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 366 insertions(+), 347 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index b665bbc..c1c48ea 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.110 -
======================================
+ Move target status functions out of libdm-deptree.
Correct use of max_write_behind parameter when generating raid target line.
Fix dm-event systemd service to make sure it is executed before mounting.
diff --git a/libdm/Makefile.in b/libdm/Makefile.in
index 1b924ce..6b7cc48 100644
--- a/libdm/Makefile.in
+++ b/libdm/Makefile.in
@@ -21,13 +21,14 @@ SOURCES =\
datastruct/hash.c \
datastruct/list.c \
libdm-common.c \
- libdm-file.c \
+ libdm-config.c \
libdm-deptree.c \
- libdm-string.c \
+ libdm-file.c \
libdm-report.c \
- libdm-timestamp.c \
libdm-stats.c \
- libdm-config.c \
+ libdm-string.c \
+ libdm-targets.c \
+ libdm-timestamp.c \
mm/dbg_malloc.c \
mm/pool.c \
regex/matcher.c \
diff --git a/libdm/libdm-common.h b/libdm/libdm-common.h
index 4705a77..0083015 100644
--- a/libdm/libdm-common.h
+++ b/libdm/libdm-common.h
@@ -51,4 +51,6 @@ void selinux_release(void);
void inc_suspended(void);
void dec_suspended(void);
+int parse_thin_pool_status(const char *params, struct dm_status_thin_pool *s);
+
#endif
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index b5067f5..ef283e9 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -1427,48 +1427,6 @@ static int _suspend_node(const char *name, uint32_t major, uint32_t minor,
return r;
}
-static int _thin_pool_parse_status(const char *params,
- struct dm_status_thin_pool *s)
-{
- int pos;
-
- if (!params) {
- log_error("Failed to parse invalid thin params.");
- return 0;
- }
-
- /* FIXME: add support for held metadata root */
- if (sscanf(params, FMTu64 " " FMTu64 "/" FMTu64 " " FMTu64 "/" FMTu64 "%n",
- &s->transaction_id,
- &s->used_metadata_blocks,
- &s->total_metadata_blocks,
- &s->used_data_blocks,
- &s->total_data_blocks, &pos) < 5) {
- log_error("Failed to parse thin pool params: %s.", params);
- return 0;
- }
-
- /* New status flags */
- if (strstr(params + pos, "no_discard_passdown"))
- s->discards = DM_THIN_DISCARDS_NO_PASSDOWN;
- else if (strstr(params + pos, "ignore_discard"))
- s->discards = DM_THIN_DISCARDS_IGNORE;
- else /* default discard_passdown */
- s->discards = DM_THIN_DISCARDS_PASSDOWN;
-
- if (strstr(params + pos, "ro "))
- s->read_only = 1;
- else if (strstr(params + pos, "fail"))
- s->fail = 1;
- else if (strstr(params + pos, "out_of_data_space"))
- s->out_of_data_space = 1;
-
- if (strstr(params + pos, "error_if_no_space"))
- s->error_if_no_space = 1;
-
- return 1;
-}
-
static int _thin_pool_get_status(struct dm_tree_node *dnode,
struct dm_status_thin_pool *s)
{
@@ -1501,7 +1459,7 @@ static int _thin_pool_get_status(struct dm_tree_node *dnode,
goto out;
}
- if (!_thin_pool_parse_status(params, s))
+ if (!parse_thin_pool_status(params, s))
goto_out;
log_debug_activation("Found transaction id %" PRIu64 " for thin pool %s "
@@ -3103,45 +3061,6 @@ int dm_tree_node_add_snapshot_merge_target(struct dm_tree_node *node,
merge_uuid, 1, chunk_size);
}
-int dm_get_status_snapshot(struct dm_pool *mem, const char *params,
- struct dm_status_snapshot **status)
-{
- struct dm_status_snapshot *s;
- int r;
-
- if (!params) {
- log_error("Failed to parse invalid snapshot params.");
- return 0;
- }
-
- if (!(s = dm_pool_zalloc(mem, sizeof(*s)))) {
- log_error("Failed to allocate snapshot status structure.");
- return 0;
- }
-
- r = sscanf(params, FMTu64 "/" FMTu64 " " FMTu64,
- &s->used_sectors, &s->total_sectors,
- &s->metadata_sectors);
-
- if (r == 3 || r == 2)
- s->has_metadata_sectors = (r == 3);
- else if (!strcmp(params, "Invalid"))
- s->invalid = 1;
- else if (!strcmp(params, "Merge failed"))
- s->merge_failed = 1;
- else if (!strcmp(params, "Overflow"))
- s->overflow = 1;
- else {
- dm_pool_free(mem, s);
- log_error("Failed to parse snapshot params: %s.", params);
- return 0;
- }
-
- *status = s;
-
- return 1;
-}
-
int dm_tree_node_add_error_target(struct dm_tree_node *node,
uint64_t size)
{
@@ -3313,84 +3232,6 @@ int dm_tree_node_add_raid_target(struct dm_tree_node *node,
return dm_tree_node_add_raid_target_with_params(node, size, ¶ms);
}
-/*
- * Various RAID status versions include:
- * Versions < 1.5.0 (4 fields):
- * <raid_type> <#devs> <health_str> <sync_ratio>
- * Versions 1.5.0+ (6 fields):
- * <raid_type> <#devs> <health_str> <sync_ratio> <sync_action> <mismatch_cnt>
- */
-int dm_get_status_raid(struct dm_pool *mem, const char *params,
- struct dm_status_raid **status)
-{
- int i;
- const char *pp, *p;
- struct dm_status_raid *s;
-
- if (!params || !(p = strchr(params, ' '))) {
- log_error("Failed to parse invalid raid params.");
- return 0;
- }
- p++;
-
- /* second field holds the device count */
- if (sscanf(p, "%d", &i) != 1)
- return_0;
-
- if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_raid))))
- return_0;
-
- if (!(s->raid_type = dm_pool_zalloc(mem, p - params)))
- goto_bad; /* memory is freed went pool is destroyed */
-
- if (!(s->dev_health = dm_pool_zalloc(mem, i + 1)))
- goto_bad;
-
- if (sscanf(params, "%s %u %s %" PRIu64 "/%" PRIu64,
- s->raid_type,
- &s->dev_count,
- s->dev_health,
- &s->insync_regions,
- &s->total_regions) != 5) {
- log_error("Failed to parse raid params: %s", params);
- goto bad;
- }
-
- *status = s;
-
- /*
- * All pre-1.5.0 version parameters are read. Now we check
- * for additional 1.5.0+ parameters.
- *
- * Note that 'sync_action' will be NULL (and mismatch_count
- * will be 0) if the kernel returns a pre-1.5.0 status.
- */
- for (p = params, i = 0; i < 4; i++, p++)
- if (!(p = strchr(p, ' ')))
- return 1; /* return pre-1.5.0 status */
-
- pp = p;
- if (!(p = strchr(p, ' '))) {
- log_error(INTERNAL_ERROR "Bad RAID status received.");
- goto bad;
- }
- p++;
-
- if (!(s->sync_action = dm_pool_zalloc(mem, p - pp)))
- goto_bad;
-
- if (sscanf(pp, "%s %" PRIu64, s->sync_action, &s->mismatch_count) != 2) {
- log_error("Failed to parse raid params: %s", params);
- goto bad;
- }
-
- return 1;
-bad:
- dm_pool_free(mem, s);
-
- return 0;
-}
-
int dm_tree_node_add_cache_target(struct dm_tree_node *node,
uint64_t size,
uint64_t feature_flags, /* DM_CACHE_FEATURE_* */
@@ -3482,143 +3323,6 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
return 1;
}
-static const char *advance_to_next_word(const char *str, int count)
-{
- int i;
- const char *p;
-
- for (p = str, i = 0; i < count; i++, p++)
- if (!(p = strchr(p, ' ')))
- return NULL;
-
- return p;
-}
-
-/*
- * <metadata block size> <#used metadata blocks>/<#total metadata blocks>
- * <cache block size> <#used cache blocks>/<#total cache blocks>
- * <#read hits> <#read misses> <#write hits> <#write misses>
- * <#demotions> <#promotions> <#dirty> <#features> <features>*
- * <#core args> <core args>* <policy name> <#policy args> <policy args>*
- *
- * metadata block size : Fixed block size for each metadata block in
- * sectors
- * #used metadata blocks : Number of metadata blocks used
- * #total metadata blocks : Total number of metadata blocks
- * cache block size : Configurable block size for the cache device
- * in sectors
- * #used cache blocks : Number of blocks resident in the cache
- * #total cache blocks : Total number of cache blocks
- * #read hits : Number of times a READ bio has been mapped
- * to the cache
- * #read misses : Number of times a READ bio has been mapped
- * to the origin
- * #write hits : Number of times a WRITE bio has been mapped
- * to the cache
- * #write misses : Number of times a WRITE bio has been
- * mapped to the origin
- * #demotions : Number of times a block has been removed
- * from the cache
- * #promotions : Number of times a block has been moved to
- * the cache
- * #dirty : Number of blocks in the cache that differ
- * from the origin
- * #feature args : Number of feature args to follow
- * feature args : 'writethrough' (optional)
- * #core args : Number of core arguments (must be even)
- * core args : Key/value pairs for tuning the core
- * e.g. migration_threshold
- * *policy name : Name of the policy
- * #policy args : Number of policy arguments to follow (must be even)
- * policy args : Key/value pairs
- * e.g. sequential_threshold
- */
-int dm_get_status_cache(struct dm_pool *mem, const char *params,
- struct dm_status_cache **status)
-{
- int i, feature_argc;
- char *str;
- const char *p, *pp;
- struct dm_status_cache *s;
-
- if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_cache))))
- return_0;
-
- /* Read in args that have definitive placement */
- if (sscanf(params,
- " %" PRIu32
- " %" PRIu64 "/%" PRIu64
- " %" PRIu32
- " %" PRIu64 "/%" PRIu64
- " %" PRIu64 " %" PRIu64
- " %" PRIu64 " %" PRIu64
- " %" PRIu64 " %" PRIu64
- " %" PRIu64
- " %d",
- &s->metadata_block_size,
- &s->metadata_used_blocks, &s->metadata_total_blocks,
- &s->block_size, /* AKA, chunk_size */
- &s->used_blocks, &s->total_blocks,
- &s->read_hits, &s->read_misses,
- &s->write_hits, &s->write_misses,
- &s->demotions, &s->promotions,
- &s->dirty_blocks,
- &feature_argc) != 14)
- goto bad;
-
- /* Now jump to "features" section */
- if (!(p = advance_to_next_word(params, 12)))
- goto bad;
-
- /* Read in features */
- for (i = 0; i < feature_argc; i++) {
- if (!strncmp(p, "writethrough ", 13))
- s->feature_flags |= DM_CACHE_FEATURE_WRITETHROUGH;
- else if (!strncmp(p, "writeback ", 10))
- s->feature_flags |= DM_CACHE_FEATURE_WRITEBACK;
- else
- log_error("Unknown feature in status: %s", params);
-
- if (!(p = advance_to_next_word(p, 1)))
- goto bad;
- }
-
- /* Read in core_args. */
- if (sscanf(p, "%d ", &s->core_argc) != 1)
- goto bad;
- if (s->core_argc &&
- (!(s->core_argv = dm_pool_zalloc(mem, sizeof(char *) * s->core_argc)) ||
- !(p = advance_to_next_word(p, 1)) ||
- !(str = dm_pool_strdup(mem, p)) ||
- !(p = advance_to_next_word(p, s->core_argc)) ||
- (dm_split_words(str, s->core_argc, 0, s->core_argv) != s->core_argc)))
- goto bad;
-
- /* Read in policy args */
- pp = p;
- if (!(p = advance_to_next_word(p, 1)) ||
- !(s->policy_name = dm_pool_zalloc(mem, (p - pp))))
- goto bad;
- if (sscanf(pp, "%s %d", s->policy_name, &s->policy_argc) != 2)
- goto bad;
- if (s->policy_argc &&
- (!(s->policy_argv = dm_pool_zalloc(mem, sizeof(char *) * s->policy_argc)) ||
- !(p = advance_to_next_word(p, 1)) ||
- !(str = dm_pool_strdup(mem, p)) ||
- (dm_split_words(str, s->policy_argc, 0, s->policy_argv) != s->policy_argc)))
- goto bad;
-
- *status = s;
- return 1;
-
-bad:
- log_error("Failed to parse cache params: %s", params);
- dm_pool_free(mem, s);
- *status = NULL;
-
- return 0;
-}
-
int dm_tree_node_add_replicator_target(struct dm_tree_node *node,
uint64_t size,
const char *rlog_uuid,
@@ -4045,52 +3749,6 @@ int dm_tree_node_set_thin_external_origin(struct dm_tree_node *node,
return 1;
}
-int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,
- struct dm_status_thin_pool **status)
-{
- struct dm_status_thin_pool *s;
-
- if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_thin_pool)))) {
- log_error("Failed to allocate thin_pool status structure.");
- return 0;
- }
-
- if (!_thin_pool_parse_status(params, s)) {
- dm_pool_free(mem, s);
- return_0;
- }
-
- *status = s;
-
- return 1;
-}
-
-int dm_get_status_thin(struct dm_pool *mem, const char *params,
- struct dm_status_thin **status)
-{
- struct dm_status_thin *s;
-
- if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_thin)))) {
- log_error("Failed to allocate thin status structure.");
- return 0;
- }
-
- if (strchr(params, '-')) {
- s->mapped_sectors = 0;
- s->highest_mapped_sector = 0;
- } else if (sscanf(params, FMTu64 " " FMTu64,
- &s->mapped_sectors,
- &s->highest_mapped_sector) != 2) {
- dm_pool_free(mem, s);
- log_error("Failed to parse thin params: %s.", params);
- return 0;
- }
-
- *status = s;
-
- return 1;
-}
-
static int _add_area(struct dm_tree_node *node, struct load_segment *seg, struct dm_tree_node *dev_node, uint64_t offset)
{
struct seg_area *area;
diff --git a/libdm/libdm-targets.c b/libdm/libdm-targets.c
new file mode 100644
index 0000000..f22ad9c
--- /dev/null
+++ b/libdm/libdm-targets.c
@@ -0,0 +1,357 @@
+/*
+ * Copyright (C) 2005-2015 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of the device-mapper userspace tools.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "dmlib.h"
+#include "libdm-common.h"
+
+int dm_get_status_snapshot(struct dm_pool *mem, const char *params,
+ struct dm_status_snapshot **status)
+{
+ struct dm_status_snapshot *s;
+ int r;
+
+ if (!params) {
+ log_error("Failed to parse invalid snapshot params.");
+ return 0;
+ }
+
+ if (!(s = dm_pool_zalloc(mem, sizeof(*s)))) {
+ log_error("Failed to allocate snapshot status structure.");
+ return 0;
+ }
+
+ r = sscanf(params, FMTu64 "/" FMTu64 " " FMTu64,
+ &s->used_sectors, &s->total_sectors,
+ &s->metadata_sectors);
+
+ if (r == 3 || r == 2)
+ s->has_metadata_sectors = (r == 3);
+ else if (!strcmp(params, "Invalid"))
+ s->invalid = 1;
+ else if (!strcmp(params, "Merge failed"))
+ s->merge_failed = 1;
+ else if (!strcmp(params, "Overflow"))
+ s->overflow = 1;
+ else {
+ dm_pool_free(mem, s);
+ log_error("Failed to parse snapshot params: %s.", params);
+ return 0;
+ }
+
+ *status = s;
+
+ return 1;
+}
+
+/*
+ * Various RAID status versions include:
+ * Versions < 1.5.0 (4 fields):
+ * <raid_type> <#devs> <health_str> <sync_ratio>
+ * Versions 1.5.0+ (6 fields):
+ * <raid_type> <#devs> <health_str> <sync_ratio> <sync_action> <mismatch_cnt>
+ */
+int dm_get_status_raid(struct dm_pool *mem, const char *params,
+ struct dm_status_raid **status)
+{
+ int i;
+ const char *pp, *p;
+ struct dm_status_raid *s;
+
+ if (!params || !(p = strchr(params, ' '))) {
+ log_error("Failed to parse invalid raid params.");
+ return 0;
+ }
+ p++;
+
+ /* second field holds the device count */
+ if (sscanf(p, "%d", &i) != 1)
+ return_0;
+
+ if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_raid))))
+ return_0;
+
+ if (!(s->raid_type = dm_pool_zalloc(mem, p - params)))
+ goto_bad; /* memory is freed went pool is destroyed */
+
+ if (!(s->dev_health = dm_pool_zalloc(mem, i + 1)))
+ goto_bad;
+
+ if (sscanf(params, "%s %u %s %" PRIu64 "/%" PRIu64,
+ s->raid_type,
+ &s->dev_count,
+ s->dev_health,
+ &s->insync_regions,
+ &s->total_regions) != 5) {
+ log_error("Failed to parse raid params: %s", params);
+ goto bad;
+ }
+
+ *status = s;
+
+ /*
+ * All pre-1.5.0 version parameters are read. Now we check
+ * for additional 1.5.0+ parameters.
+ *
+ * Note that 'sync_action' will be NULL (and mismatch_count
+ * will be 0) if the kernel returns a pre-1.5.0 status.
+ */
+ for (p = params, i = 0; i < 4; i++, p++)
+ if (!(p = strchr(p, ' ')))
+ return 1; /* return pre-1.5.0 status */
+
+ pp = p;
+ if (!(p = strchr(p, ' '))) {
+ log_error(INTERNAL_ERROR "Bad RAID status received.");
+ goto bad;
+ }
+ p++;
+
+ if (!(s->sync_action = dm_pool_zalloc(mem, p - pp)))
+ goto_bad;
+
+ if (sscanf(pp, "%s %" PRIu64, s->sync_action, &s->mismatch_count) != 2) {
+ log_error("Failed to parse raid params: %s", params);
+ goto bad;
+ }
+
+ return 1;
+bad:
+ dm_pool_free(mem, s);
+
+ return 0;
+}
+
+static const char *_advance_to_next_word(const char *str, int count)
+{
+ int i;
+ const char *p;
+
+ for (p = str, i = 0; i < count; i++, p++)
+ if (!(p = strchr(p, ' ')))
+ return NULL;
+
+ return p;
+}
+
+/*
+ * <metadata block size> <#used metadata blocks>/<#total metadata blocks>
+ * <cache block size> <#used cache blocks>/<#total cache blocks>
+ * <#read hits> <#read misses> <#write hits> <#write misses>
+ * <#demotions> <#promotions> <#dirty> <#features> <features>*
+ * <#core args> <core args>* <policy name> <#policy args> <policy args>*
+ *
+ * metadata block size : Fixed block size for each metadata block in
+ * sectors
+ * #used metadata blocks : Number of metadata blocks used
+ * #total metadata blocks : Total number of metadata blocks
+ * cache block size : Configurable block size for the cache device
+ * in sectors
+ * #used cache blocks : Number of blocks resident in the cache
+ * #total cache blocks : Total number of cache blocks
+ * #read hits : Number of times a READ bio has been mapped
+ * to the cache
+ * #read misses : Number of times a READ bio has been mapped
+ * to the origin
+ * #write hits : Number of times a WRITE bio has been mapped
+ * to the cache
+ * #write misses : Number of times a WRITE bio has been
+ * mapped to the origin
+ * #demotions : Number of times a block has been removed
+ * from the cache
+ * #promotions : Number of times a block has been moved to
+ * the cache
+ * #dirty : Number of blocks in the cache that differ
+ * from the origin
+ * #feature args : Number of feature args to follow
+ * feature args : 'writethrough' (optional)
+ * #core args : Number of core arguments (must be even)
+ * core args : Key/value pairs for tuning the core
+ * e.g. migration_threshold
+ * *policy name : Name of the policy
+ * #policy args : Number of policy arguments to follow (must be even)
+ * policy args : Key/value pairs
+ * e.g. sequential_threshold
+ */
+int dm_get_status_cache(struct dm_pool *mem, const char *params,
+ struct dm_status_cache **status)
+{
+ int i, feature_argc;
+ char *str;
+ const char *p, *pp;
+ struct dm_status_cache *s;
+
+ if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_cache))))
+ return_0;
+
+ /* Read in args that have definitive placement */
+ if (sscanf(params,
+ " %" PRIu32
+ " %" PRIu64 "/%" PRIu64
+ " %" PRIu32
+ " %" PRIu64 "/%" PRIu64
+ " %" PRIu64 " %" PRIu64
+ " %" PRIu64 " %" PRIu64
+ " %" PRIu64 " %" PRIu64
+ " %" PRIu64
+ " %d",
+ &s->metadata_block_size,
+ &s->metadata_used_blocks, &s->metadata_total_blocks,
+ &s->block_size, /* AKA, chunk_size */
+ &s->used_blocks, &s->total_blocks,
+ &s->read_hits, &s->read_misses,
+ &s->write_hits, &s->write_misses,
+ &s->demotions, &s->promotions,
+ &s->dirty_blocks,
+ &feature_argc) != 14)
+ goto bad;
+
+ /* Now jump to "features" section */
+ if (!(p = _advance_to_next_word(params, 12)))
+ goto bad;
+
+ /* Read in features */
+ for (i = 0; i < feature_argc; i++) {
+ if (!strncmp(p, "writethrough ", 13))
+ s->feature_flags |= DM_CACHE_FEATURE_WRITETHROUGH;
+ else if (!strncmp(p, "writeback ", 10))
+ s->feature_flags |= DM_CACHE_FEATURE_WRITEBACK;
+ else
+ log_error("Unknown feature in status: %s", params);
+
+ if (!(p = _advance_to_next_word(p, 1)))
+ goto bad;
+ }
+
+ /* Read in core_args. */
+ if (sscanf(p, "%d ", &s->core_argc) != 1)
+ goto bad;
+ if (s->core_argc &&
+ (!(s->core_argv = dm_pool_zalloc(mem, sizeof(char *) * s->core_argc)) ||
+ !(p = _advance_to_next_word(p, 1)) ||
+ !(str = dm_pool_strdup(mem, p)) ||
+ !(p = _advance_to_next_word(p, s->core_argc)) ||
+ (dm_split_words(str, s->core_argc, 0, s->core_argv) != s->core_argc)))
+ goto bad;
+
+ /* Read in policy args */
+ pp = p;
+ if (!(p = _advance_to_next_word(p, 1)) ||
+ !(s->policy_name = dm_pool_zalloc(mem, (p - pp))))
+ goto bad;
+ if (sscanf(pp, "%s %d", s->policy_name, &s->policy_argc) != 2)
+ goto bad;
+ if (s->policy_argc &&
+ (!(s->policy_argv = dm_pool_zalloc(mem, sizeof(char *) * s->policy_argc)) ||
+ !(p = _advance_to_next_word(p, 1)) ||
+ !(str = dm_pool_strdup(mem, p)) ||
+ (dm_split_words(str, s->policy_argc, 0, s->policy_argv) != s->policy_argc)))
+ goto bad;
+
+ *status = s;
+ return 1;
+
+bad:
+ log_error("Failed to parse cache params: %s", params);
+ dm_pool_free(mem, s);
+ *status = NULL;
+
+ return 0;
+}
+
+int parse_thin_pool_status(const char *params, struct dm_status_thin_pool *s)
+{
+ int pos;
+
+ if (!params) {
+ log_error("Failed to parse invalid thin params.");
+ return 0;
+ }
+
+ /* FIXME: add support for held metadata root */
+ if (sscanf(params, FMTu64 " " FMTu64 "/" FMTu64 " " FMTu64 "/" FMTu64 "%n",
+ &s->transaction_id,
+ &s->used_metadata_blocks,
+ &s->total_metadata_blocks,
+ &s->used_data_blocks,
+ &s->total_data_blocks, &pos) < 5) {
+ log_error("Failed to parse thin pool params: %s.", params);
+ return 0;
+ }
+
+ /* New status flags */
+ if (strstr(params + pos, "no_discard_passdown"))
+ s->discards = DM_THIN_DISCARDS_NO_PASSDOWN;
+ else if (strstr(params + pos, "ignore_discard"))
+ s->discards = DM_THIN_DISCARDS_IGNORE;
+ else /* default discard_passdown */
+ s->discards = DM_THIN_DISCARDS_PASSDOWN;
+
+ if (strstr(params + pos, "ro "))
+ s->read_only = 1;
+ else if (strstr(params + pos, "fail"))
+ s->fail = 1;
+ else if (strstr(params + pos, "out_of_data_space"))
+ s->out_of_data_space = 1;
+
+ if (strstr(params + pos, "error_if_no_space"))
+ s->error_if_no_space = 1;
+
+ return 1;
+}
+
+int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,
+ struct dm_status_thin_pool **status)
+{
+ struct dm_status_thin_pool *s;
+
+ if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_thin_pool)))) {
+ log_error("Failed to allocate thin_pool status structure.");
+ return 0;
+ }
+
+ if (!parse_thin_pool_status(params, s)) {
+ dm_pool_free(mem, s);
+ return_0;
+ }
+
+ *status = s;
+
+ return 1;
+}
+
+int dm_get_status_thin(struct dm_pool *mem, const char *params,
+ struct dm_status_thin **status)
+{
+ struct dm_status_thin *s;
+
+ if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_thin)))) {
+ log_error("Failed to allocate thin status structure.");
+ return 0;
+ }
+
+ if (strchr(params, '-')) {
+ s->mapped_sectors = 0;
+ s->highest_mapped_sector = 0;
+ } else if (sscanf(params, FMTu64 " " FMTu64,
+ &s->mapped_sectors,
+ &s->highest_mapped_sector) != 2) {
+ dm_pool_free(mem, s);
+ log_error("Failed to parse thin params: %s.", params);
+ return 0;
+ }
+
+ *status = s;
+
+ return 1;
+}
7 years, 12 months
master - raid: Use loop for text uint32_t parameter import.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9d815e5f5a1796...
Commit: 9d815e5f5a17963a09b103177770e9af80c90e0f
Parent: 7097663dddad0716059783219e9e3d4748db8188
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Mon Sep 28 14:21:00 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Mon Sep 28 14:28:03 2015 +0100
raid: Use loop for text uint32_t parameter import.
Plus some other tidying up of the same file.
---
lib/raid/raid.c | 77 ++++++++++++++++++++-----------------------------------
1 files changed, 28 insertions(+), 49 deletions(-)
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 8c6bb72..f75e1f7 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -55,7 +55,7 @@ static int _raid_text_import_areas(struct lv_segment *seg,
const struct dm_config_value *cv)
{
unsigned int s;
- struct logical_volume *lv1;
+ struct logical_volume *lv;
const char *seg_name = dm_config_parent_name(sn);
if (!seg->area_count) {
@@ -75,23 +75,23 @@ static int _raid_text_import_areas(struct lv_segment *seg,
}
/* Metadata device comes first */
- if (!(lv1 = find_lv(seg->lv->vg, cv->v.str))) {
+ if (!(lv = find_lv(seg->lv->vg, cv->v.str))) {
log_error("Couldn't find volume '%s' for segment '%s'.",
cv->v.str ? : "NULL", seg_name);
return 0;
}
- if (!set_lv_segment_area_lv(seg, s, lv1, 0, RAID_META))
- return_0;
+ if (!set_lv_segment_area_lv(seg, s, lv, 0, RAID_META))
+ return_0;
/* Data device comes second */
cv = cv->next;
- if (!(lv1 = find_lv(seg->lv->vg, cv->v.str))) {
+ if (!(lv = find_lv(seg->lv->vg, cv->v.str))) {
log_error("Couldn't find volume '%s' for segment '%s'.",
cv->v.str ? : "NULL", seg_name);
return 0;
}
- if (!set_lv_segment_area_lv(seg, s, lv1, 0, RAID_IMAGE))
- return_0;
+ if (!set_lv_segment_area_lv(seg, s, lv, 0, RAID_IMAGE))
+ return_0;
}
/*
@@ -111,49 +111,28 @@ static int _raid_text_import(struct lv_segment *seg,
struct dm_hash_table *pv_hash)
{
const struct dm_config_value *cv;
+ const struct {
+ const char *name;
+ uint32_t *var;
+ } raid_attr_import[] = {
+ { "region_size", &seg->region_size },
+ { "stripe_size", &seg->stripe_size },
+ { "writebehind", &seg->writebehind },
+ { "min_recovery_rate", &seg->min_recovery_rate },
+ { "max_recovery_rate", &seg->max_recovery_rate },
+ }, *aip = raid_attr_import;
+ int i;
- if (dm_config_has_node(sn, "region_size")) {
- if (!dm_config_get_uint32(sn, "region_size", &seg->region_size)) {
- log_error("Couldn't read 'region_size' for "
- "segment %s of logical volume %s.",
- dm_config_parent_name(sn), seg->lv->name);
- return 0;
- }
- }
- if (dm_config_has_node(sn, "stripe_size")) {
- if (!dm_config_get_uint32(sn, "stripe_size", &seg->stripe_size)) {
- log_error("Couldn't read 'stripe_size' for "
- "segment %s of logical volume %s.",
- dm_config_parent_name(sn), seg->lv->name);
- return 0;
- }
- }
- if (dm_config_has_node(sn, "writebehind")) {
- if (!dm_config_get_uint32(sn, "writebehind", &seg->writebehind)) {
- log_error("Couldn't read 'writebehind' for "
- "segment %s of logical volume %s.",
- dm_config_parent_name(sn), seg->lv->name);
- return 0;
- }
- }
- if (dm_config_has_node(sn, "min_recovery_rate")) {
- if (!dm_config_get_uint32(sn, "min_recovery_rate",
- &seg->min_recovery_rate)) {
- log_error("Couldn't read 'min_recovery_rate' for "
- "segment %s of logical volume %s.",
- dm_config_parent_name(sn), seg->lv->name);
- return 0;
- }
- }
- if (dm_config_has_node(sn, "max_recovery_rate")) {
- if (!dm_config_get_uint32(sn, "max_recovery_rate",
- &seg->max_recovery_rate)) {
- log_error("Couldn't read 'max_recovery_rate' for "
- "segment %s of logical volume %s.",
- dm_config_parent_name(sn), seg->lv->name);
- return 0;
+ for (i = 0; i < DM_ARRAY_SIZE(raid_attr_import); i++, aip++) {
+ if (dm_config_has_node(sn, aip->name)) {
+ if (!dm_config_get_uint32(sn, aip->name, aip->var)) {
+ log_error("Couldn't read '%s' for segment %s of logical volume %s.",
+ aip->name, dm_config_parent_name(sn), seg->lv->name);
+ return 0;
+ }
}
}
+
if (!dm_config_get_list(sn, "raids", &cv)) {
log_error("Couldn't find RAID array for "
"segment %s of logical volume %s.",
@@ -162,7 +141,7 @@ static int _raid_text_import(struct lv_segment *seg,
}
if (!_raid_text_import_areas(seg, sn, cv)) {
- log_error("Failed to import RAID images");
+ log_error("Failed to import RAID component pairs.");
return 0;
}
7 years, 12 months
master - test: Cope with stripe rounding message change.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7097663dddad07...
Commit: 7097663dddad0716059783219e9e3d4748db8188
Parent: eab099b22190cfaf68f013e785dd13c43277fea1
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Mon Sep 28 12:25:31 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Mon Sep 28 12:25:31 2015 +0100
test: Cope with stripe rounding message change.
---
test/shell/lvcreate-striped-mirror.sh | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvcreate-striped-mirror.sh b/test/shell/lvcreate-striped-mirror.sh
index 735b396..776dbf7 100644
--- a/test/shell/lvcreate-striped-mirror.sh
+++ b/test/shell/lvcreate-striped-mirror.sh
@@ -46,12 +46,12 @@ check mirror_images_redundant $vg $lv7
lvremove -ff $vg
lvcreate -aey --nosync -i3 -l4 --type mirror -m1 --mirrorlog core -n $lv1 $vg 2>&1 | tee log
-grep "Rounding size (4 extents) up to .* (6 extents)" log
+grep "Rounding size .*(4 extents) up to .*(6 extents)" log
lvcreate -aey --nosync -i3 -l4 --type mirror -m2 --mirrorlog core -n $lv2 $vg 2>&1 | tee log
-grep "Rounding size (4 extents) up to .* (6 extents)" log
+grep "Rounding size .*(4 extents) up to .*(6 extents)" log
lvcreate -aey --nosync -i3 -l2 --type mirror -m2 --mirrorlog core -n $lv3 $vg 2>&1 | tee log
-grep "Rounding size (2 extents) up to .* (3 extents)" log
+grep "Rounding size .*(2 extents) up to .*(3 extents)" log
lvremove -ff $vg
7 years, 12 months
master - segtypes: Use flags in raid segtype macros.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=eab099b22190cf...
Commit: eab099b22190cfaf68f013e785dd13c43277fea1
Parent: 3036620b488800027d1ec37b5cbe65f6f180e9c7
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Sep 24 20:26:33 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Sep 24 20:43:18 2015 +0100
segtypes: Use flags in raid segtype macros.
---
lib/metadata/segtype.h | 33 +++++++++++++++++----------------
1 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index 09034e9..72c64f9 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -101,20 +101,22 @@ struct dev_manager;
#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_raid1(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID1))
-#define segtype_is_raid4(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID4))
-#define segtype_is_raid5(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID5))
-#define segtype_is_any_raid5(segtype) (!strncmp((segtype)->name, SEG_TYPE_NAME_RAID5, strlen(SEG_TYPE_NAME_RAID5)))
-#define segtype_is_raid5_la(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID5_LA))
-#define segtype_is_raid5_ra(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID5_RA))
-#define segtype_is_raid5_ls(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID5_LS))
-#define segtype_is_raid5_rs(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID5_RS))
-#define segtype_is_any_raid6(segtype) (!strncmp((segtype)->name, SEG_TYPE_NAME_RAID6, strlen(SEG_TYPE_NAME_RAID6)))
-#define segtype_is_raid6_zr(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID6_ZR))
-#define segtype_is_raid6_nr(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID6_NR))
-#define segtype_is_raid6_nc(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID6_NC))
-#define segtype_is_raid10(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_RAID10))
-#define segtype_is_snapshot(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_SNAPSHOT))
+#define segtype_is_raid1(segtype) ((segtype)->flags & SEG_RAID1 ? 1 : 0)
+#define segtype_is_raid4(segtype) ((segtype)->flags & SEG_RAID4 ? 1 : 0)
+#define segtype_is_any_raid5(segtype) ((segtype)->flags & \
+ (SEG_RAID5_LS|SEG_RAID5_LA|SEG_RAID5_RS|SEG_RAID5_RA|SEG_RAID5_N) ? 1 : 0)
+#define segtype_is_raid5_la(segtype) ((segtype)->flags & SEG_RAID5_LA ? 1 : 0)
+#define segtype_is_raid5_ra(segtype) ((segtype)->flags & SEG_RAID5_RA ? 1 : 0)
+#define segtype_is_raid5_ls(segtype) ((segtype)->flags & SEG_RAID5_LS ? 1 : 0)
+#define segtype_is_raid5_rs(segtype) ((segtype)->flags & SEG_RAID5_RS ? 1 : 0)
+#define segtype_is_any_raid6(segtype) ((segtype)->flags & \
+ (SEG_RAID6_ZR|SEG_RAID6_NC|SEG_RAID6_NR| \
+ SEG_RAID6_LA_6|SEG_RAID6_LS_6|SEG_RAID6_RA_6|SEG_RAID6_RS_6|SEG_RAID6_N_6) ? 1 : 0)
+#define segtype_is_raid6_nc(segtype) ((segtype)->flags & SEG_RAID6_NC ? 1 : 0)
+#define segtype_is_raid6_nr(segtype) ((segtype)->flags & SEG_RAID6_NR ? 1 : 0)
+#define segtype_is_raid6_zr(segtype) ((segtype)->flags & SEG_RAID6_ZR ? 1 : 0)
+#define segtype_is_raid10(segtype) ((segtype)->flags & SEG_RAID10 ? 1 : 0)
+#define segtype_is_snapshot(segtype) ((segtype)->flags & SEG_SNAPSHOT ? 1 : 0)
#define segtype_is_striped(segtype) ((segtype)->flags & SEG_AREAS_STRIPED ? 1 : 0)
#define segtype_is_thin(segtype) ((segtype)->flags & (SEG_THIN_POOL|SEG_THIN_VOLUME) ? 1 : 0)
#define segtype_is_thin_pool(segtype) ((segtype)->flags & SEG_THIN_POOL ? 1 : 0)
@@ -131,7 +133,6 @@ struct dev_manager;
#define seg_is_raid(seg) segtype_is_raid((seg)->segtype)
#define seg_is_raid1(seg) segtype_is_raid1((seg)->segtype)
#define seg_is_raid4(seg) segtype_is_raid4((seg)->segtype)
-#define seg_is_raid5(seg) segtype_is_raid5((seg)->segtype)
#define seg_is_any_raid5(seg) segtype_is_any_raid5((seg)->segtype)
#define seg_is_raid5_la(seg) segtype_is_raid5_la((seg)->segtype)
#define seg_is_raid5_ra(seg) segtype_is_raid5_ra((seg)->segtype)
@@ -144,7 +145,7 @@ struct dev_manager;
#define seg_is_raid10(seg) segtype_is_raid10((seg)->segtype)
#define seg_is_replicator(seg) ((seg)->segtype->flags & SEG_REPLICATOR ? 1 : 0)
#define seg_is_replicator_dev(seg) ((seg)->segtype->flags & SEG_REPLICATOR_DEV ? 1 : 0)
-#define seg_is_snapshot(seg) ((seg)->segtype->flags & SEG_SNAPSHOT ? 1 : 0)
+#define seg_is_snapshot(seg) segtype_is_snapshot((seg)->segtype)
#define seg_is_striped(seg) segtype_is_striped((seg)->segtype)
#define seg_is_thin(seg) segtype_is_thin((seg)->segtype)
#define seg_is_thin_pool(seg) segtype_is_thin_pool((seg)->segtype)
8 years
master - raid: Add a segtype flag for each raid type.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3036620b488800...
Commit: 3036620b488800027d1ec37b5cbe65f6f180e9c7
Parent: d40830a2b13595943ca51d4bfd6249527a0972cf
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Sep 24 20:17:57 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Sep 24 20:17:57 2015 +0100
raid: Add a segtype flag for each raid type.
---
lib/metadata/segtype.h | 22 +++++++++++++++++++++-
lib/raid/raid.c | 24 ++++++++++++------------
2 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index fd833cd..09034e9 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -46,6 +46,26 @@ struct dev_manager;
#define SEG_MIRROR 0x0000000000008000ULL
#define SEG_ONLY_EXCLUSIVE 0x0000000000010000ULL /* In cluster only exlusive activation */
#define SEG_CAN_ERROR_WHEN_FULL 0x0000000000020000ULL
+
+#define SEG_RAID1 0x0000000000100000ULL
+#define SEG_RAID10 0x0000000000200000ULL
+#define SEG_RAID4 0x0000000000400000ULL
+#define SEG_RAID5_N 0x0000000000800000ULL
+#define SEG_RAID5_LA 0x0000000001000000ULL
+#define SEG_RAID5_LS 0x0000000002000000ULL
+#define SEG_RAID5_RA 0x0000000004000000ULL
+#define SEG_RAID5_RS 0x0000000008000000ULL
+#define SEG_RAID5 SEG_RAID5_LS
+#define SEG_RAID6_NC 0x0000000010000000ULL
+#define SEG_RAID6_NR 0x0000000020000000ULL
+#define SEG_RAID6_ZR 0x0000000040000000ULL
+#define SEG_RAID6_LA_6 0x0000000080000000ULL
+#define SEG_RAID6_LS_6 0x0000000100000000ULL
+#define SEG_RAID6_RA_6 0x0000000200000000ULL
+#define SEG_RAID6_RS_6 0x0000000400000000ULL
+#define SEG_RAID6_N_6 0x0000000800000000ULL
+#define SEG_RAID6 SEG_RAID6_ZR
+
#define SEG_UNKNOWN 0x8000000000000000ULL
#define SEG_TYPE_NAME_LINEAR "linear"
@@ -141,7 +161,7 @@ struct segment_type {
struct dm_list list; /* Internal */
uint64_t flags;
- uint32_t parity_devs; /* Parity drives required by segtype */
+ uint32_t parity_devs; /* Parity drives required by segtype */
struct segtype_handler *ops;
const char *name;
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index df22b54..8c6bb72 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -437,18 +437,18 @@ static const struct raid_type {
unsigned parity;
uint64_t extra_flags;
} _raid_types[] = {
- { SEG_TYPE_NAME_RAID1, 0, SEG_AREAS_MIRRORED },
- { SEG_TYPE_NAME_RAID10, 0, SEG_AREAS_MIRRORED },
- { SEG_TYPE_NAME_RAID4, 1 },
- { SEG_TYPE_NAME_RAID5, 1 },
- { SEG_TYPE_NAME_RAID5_LA, 1 },
- { SEG_TYPE_NAME_RAID5_LS, 1 },
- { SEG_TYPE_NAME_RAID5_RA, 1 },
- { SEG_TYPE_NAME_RAID5_RS, 1 },
- { SEG_TYPE_NAME_RAID6, 2 },
- { SEG_TYPE_NAME_RAID6_NC, 2 },
- { SEG_TYPE_NAME_RAID6_NR, 2 },
- { SEG_TYPE_NAME_RAID6_ZR, 2 }
+ { SEG_TYPE_NAME_RAID1, 0, SEG_RAID1 | SEG_AREAS_MIRRORED },
+ { SEG_TYPE_NAME_RAID10, 0, SEG_RAID10 | SEG_AREAS_MIRRORED },
+ { SEG_TYPE_NAME_RAID4, 1, SEG_RAID4 },
+ { SEG_TYPE_NAME_RAID5, 1, SEG_RAID5 },
+ { SEG_TYPE_NAME_RAID5_LA, 1, SEG_RAID5_LA },
+ { SEG_TYPE_NAME_RAID5_LS, 1, SEG_RAID5_LS },
+ { SEG_TYPE_NAME_RAID5_RA, 1, SEG_RAID5_RA },
+ { SEG_TYPE_NAME_RAID5_RS, 1, SEG_RAID5_RS },
+ { SEG_TYPE_NAME_RAID6, 2, SEG_RAID6 },
+ { SEG_TYPE_NAME_RAID6_NC, 2, SEG_RAID6_NC },
+ { SEG_TYPE_NAME_RAID6_NR, 2, SEG_RAID6_NR },
+ { SEG_TYPE_NAME_RAID6_ZR, 2, SEG_RAID6_ZR }
};
static struct segment_type *_init_raid_segtype(struct cmd_context *cmd,
8 years