master - raid: Tidy dm_get_status_raid. [HM]
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1056894f1f1d48...
Commit: 1056894f1f1d48eb295d283859473cd9bc6b9df5
Parent: cf393466976a226faba924c6d14fa04bd7b37c89
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Mar 22 21:39:52 2016 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Mar 22 21:39:52 2016 +0000
raid: Tidy dm_get_status_raid. [HM]
---
libdm/libdm-targets.c | 89 +++++++++++++++++++++++++++++-------------------
1 files changed, 54 insertions(+), 35 deletions(-)
diff --git a/libdm/libdm-targets.c b/libdm/libdm-targets.c
index 8a8a328..b91c7e9 100644
--- a/libdm/libdm-targets.c
+++ b/libdm/libdm-targets.c
@@ -67,6 +67,23 @@ static const char *_skip_fields(const char *p, unsigned nr)
}
/*
+ * Count number of single-space delimited fields.
+ * Number of fields is number of spaces plus one.
+ */
+static unsigned _count_fields(const char *p)
+{
+ unsigned nr = 1;
+
+ if (!p || !*p)
+ return 0;
+
+ while ((p = _skip_fields(p, 1)))
+ nr++;
+
+ return nr;
+}
+
+/*
* Various RAID status versions include:
* Versions < 1.5.0 (4 fields):
* <raid_type> <#devs> <health_str> <sync_ratio>
@@ -77,69 +94,71 @@ 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;
+ unsigned num_fields;
+ const char *p, *pp, *msg_fields = "";
+ struct dm_status_raid *s = NULL;
- if (!params || !(p = strchr(params, ' '))) {
- log_error("Failed to parse invalid raid params.");
- return 0;
- }
- p++;
+ if ((num_fields = _count_fields(params)) < 4)
+ goto_bad;
- /* second field holds the device count */
- if (sscanf(p, "%d", &i) != 1)
- return_0;
+ /* Second field holds the device count */
+ msg_fields = "<#devs> ";
+ if (!(p = _skip_fields(params, 1)) || (sscanf(p, "%d", &i) != 1))
+ goto_bad;
+ msg_fields = "";
if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_raid))))
- return_0;
+ goto_bad;
if (!(s->raid_type = dm_pool_zalloc(mem, p - params)))
goto_bad; /* memory is freed when pool is destroyed */
- if (!(s->dev_health = dm_pool_zalloc(mem, i + 1)))
+ if (!(s->dev_health = dm_pool_zalloc(mem, i + 1))) /* Space for health chars */
goto_bad;
+ msg_fields = "<raid_type> <#devices> <health_chars> and <sync_ratio> ";
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;
+ &s->total_regions) != 5)
+ goto_bad;
/*
* All pre-1.5.0 version parameters are read. Now we check
- * for additional 1.5.0+ parameters.
+ * for additional 1.5.0+ parameters (i.e. num_fields at least 6).
*
* 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 */
+ if (num_fields < 6)
+ goto out;
- pp = p;
- if (!(p = strchr(p, ' '))) {
- log_error(INTERNAL_ERROR "Bad RAID status received.");
- goto bad;
- }
- p++;
+ msg_fields = "<sync_action> and <mismatch_cnt> ";
- if (!(s->sync_action = dm_pool_zalloc(mem, p - pp)))
+ /* Skip pre-1.5.0 params */
+ if (!(p = _skip_fields(params, 4)) || !(pp = _skip_fields(p, 1)))
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;
- }
+ if (!(s->sync_action = dm_pool_zalloc(mem, pp - p)))
+ goto_bad;
+
+ if (sscanf(p, "%s %" PRIu64, s->sync_action, &s->mismatch_count) != 2)
+ goto_bad;
+
+out:
+ *status = s;
return 1;
+
bad:
- dm_pool_free(mem, s);
+ log_error("Failed to parse %sraid params: %s", msg_fields, params);
+
+ if (s)
+ dm_pool_free(mem, s);
+
+ *status = NULL;
return 0;
}
8 years, 1 month
master - libdm: Move _skip_fields within file.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cf393466976a22...
Commit: cf393466976a226faba924c6d14fa04bd7b37c89
Parent: 65d2d66d02133fc6df1baba74a7fe0883ed2a6e0
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Mar 22 19:27:34 2016 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Mar 22 19:35:14 2016 +0000
libdm: Move _skip_fields within file.
---
libdm/libdm-targets.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/libdm/libdm-targets.c b/libdm/libdm-targets.c
index fd74336..8a8a328 100644
--- a/libdm/libdm-targets.c
+++ b/libdm/libdm-targets.c
@@ -55,6 +55,18 @@ int dm_get_status_snapshot(struct dm_pool *mem, const char *params,
}
/*
+ * Skip nr fields each delimited by a single space.
+ * FIXME Don't assume single space.
+ */
+static const char *_skip_fields(const char *p, unsigned nr)
+{
+ while (p && nr-- && (p = strchr(p, ' ')))
+ p++;
+
+ return p;
+}
+
+/*
* Various RAID status versions include:
* Versions < 1.5.0 (4 fields):
* <raid_type> <#devs> <health_str> <sync_ratio>
@@ -133,17 +145,6 @@ bad:
}
/*
- * Skip nr fields delimited by a single space.
- */
-static const char *_skip_fields(const char *p, unsigned nr)
-{
- while (p && nr-- && (p = strchr(p, ' ')))
- p++;
-
- 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>
8 years, 1 month
master - libdm: Change _advance_to_next_word to _skip_fields
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=65d2d66d02133f...
Commit: 65d2d66d02133fc6df1baba74a7fe0883ed2a6e0
Parent: 1216efdf152043bd04e8db170b5b3fb569bef329
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Mar 22 19:26:13 2016 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Mar 22 19:26:13 2016 +0000
libdm: Change _advance_to_next_word to _skip_fields
---
libdm/libdm-targets.c | 31 +++++++++++++++----------------
1 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/libdm/libdm-targets.c b/libdm/libdm-targets.c
index bd6e5e2..fd74336 100644
--- a/libdm/libdm-targets.c
+++ b/libdm/libdm-targets.c
@@ -132,14 +132,13 @@ bad:
return 0;
}
-static const char *_advance_to_next_word(const char *str, int count)
+/*
+ * Skip nr fields delimited by a single space.
+ */
+static const char *_skip_fields(const char *p, unsigned nr)
{
- int i;
- const char *p;
-
- for (p = str, i = 0; i < count; i++, p++)
- if (!(p = strchr(p, ' ')))
- return NULL;
+ while (p && nr-- && (p = strchr(p, ' ')))
+ p++;
return p;
}
@@ -228,7 +227,7 @@ int dm_get_status_cache(struct dm_pool *mem, const char *params,
goto bad;
/* Now jump to "features" section */
- if (!(p = _advance_to_next_word(params, 12)))
+ if (!(p = _skip_fields(params, 12)))
goto bad;
/* Read in features */
@@ -240,31 +239,31 @@ int dm_get_status_cache(struct dm_pool *mem, const char *params,
else
log_error("Unknown feature in status: %s", params);
- if (!(p = _advance_to_next_word(p, 1)))
+ if (!(p = _skip_fields(p, 1)))
goto bad;
}
/* Read in core_args. */
if (sscanf(p, "%d ", &s->core_argc) != 1)
goto bad;
- if (s->core_argc &&
+ if ((s->core_argc > 0) &&
(!(s->core_argv = dm_pool_zalloc(mem, sizeof(char *) * s->core_argc)) ||
- !(p = _advance_to_next_word(p, 1)) ||
+ !(p = _skip_fields(p, 1)) ||
!(str = dm_pool_strdup(mem, p)) ||
- !(p = _advance_to_next_word(p, s->core_argc)) ||
+ !(p = _skip_fields(p, (unsigned) 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)) ||
+ if (!(p = _skip_fields(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)) ||
+ !(p = _skip_fields(p, 1)) ||
!(str = dm_pool_strdup(mem, p)) ||
(dm_split_words(str, s->policy_argc, 0, s->policy_argv) != s->policy_argc)))
goto bad;
@@ -444,7 +443,7 @@ int dm_get_status_mirror(struct dm_pool *mem, const char *params,
for (i = 0; i < num_devs ; ++i)
s->devs[i].health = pos[i];
- if (!(pos = _advance_to_next_word(pos, argc)))
+ if (!(pos = _skip_fields(pos, argc)))
goto_out;
if (sscanf(pos, "%u %n", &argc, &used) != 1)
@@ -458,7 +457,7 @@ int dm_get_status_mirror(struct dm_pool *mem, const char *params,
goto out;
}
} else {
- if (!(p = _advance_to_next_word(pos, 1)))
+ if (!(p = _skip_fields(pos, 1)))
goto_out;
/* disk, cluster-disk */
8 years, 1 month
master - activate: Use macros for target and module names.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1216efdf152043...
Commit: 1216efdf152043bd04e8db170b5b3fb569bef329
Parent: 94f78e0183e2517199e19d0473a7d5480660db0a
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Mar 22 17:46:15 2016 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Mar 22 17:46:15 2016 +0000
activate: Use macros for target and module names.
---
WHATS_NEW | 1 +
daemons/dmeventd/plugins/mirror/dmeventd_mirror.c | 3 +-
lib/activate/activate.h | 24 +++++++++++++++
lib/activate/dev_manager.c | 32 ++++++++++----------
lib/cache_segtype/cache.c | 6 ++--
lib/error/errseg.c | 6 ++--
lib/metadata/snapshot_manip.c | 2 +-
lib/mirror/mirrored.c | 12 ++++----
lib/raid/raid.c | 4 +-
lib/snapshot/snapshot.c | 14 ++++----
lib/striped/striped.c | 4 +-
lib/zero/zero.c | 4 +-
12 files changed, 69 insertions(+), 43 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 029405d..32528a2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.148 -
==================================
+ Replace hard-coded module and target names with macros.
Add pv_major and pv_minor report fields.
Detect and warn about mismatch between devices used and assumed for an LV.
diff --git a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
index 25d1063..ee10874 100644
--- a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
+++ b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
@@ -15,6 +15,7 @@
#include "lib.h"
#include "libdevmapper-event.h"
#include "dmeventd_lvm.h"
+#include "activate.h" /* For TARGET_NAME* */
/* FIXME Reformat to 80 char lines. */
@@ -137,7 +138,7 @@ void process_event(struct dm_task *dmt,
continue;
}
- if (strcmp(target_type, "mirror")) {
+ if (strcmp(target_type, TARGET_NAME_MIRROR)) {
log_info("%s has unmirrored portion.", device);
continue;
}
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index 74afb95..64c026e 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -239,4 +239,28 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check);
*/
void fs_unlock(void);
+#define TARGET_NAME_CACHE "cache"
+#define TARGET_NAME_ERROR "error"
+#define TARGET_NAME_ERROR_OLD "erro" /* Truncated in older kernels */
+#define TARGET_NAME_LINEAR "linear"
+#define TARGET_NAME_MIRROR "mirror"
+#define TARGET_NAME_RAID "raid"
+#define TARGET_NAME_SNAPSHOT "snapshot"
+#define TARGET_NAME_SNAPSHOT_MERGE "snapshot-merge"
+#define TARGET_NAME_SNAPSHOT_ORIGIN "snapshot-origin"
+#define TARGET_NAME_STRIPED "striped"
+#define TARGET_NAME_THIN "thin"
+#define TARGET_NAME_THIN_POOL "thin-pool"
+#define TARGET_NAME_ZERO "zero"
+
+#define MODULE_NAME_CLUSTERED_MIRROR "clog"
+#define MODULE_NAME_CACHE TARGET_NAME_CACHE
+#define MODULE_NAME_ERROR TARGET_NAME_ERROR
+#define MODULE_NAME_LOG_CLUSTERED "log-clustered"
+#define MODULE_NAME_LOG_USERSPACE "log-userspace"
+#define MODULE_NAME_MIRROR TARGET_NAME_MIRROR
+#define MODULE_NAME_SNAPSHOT TARGET_NAME_SNAPSHOT
+#define MODULE_NAME_RAID TARGET_NAME_RAID
+#define MODULE_NAME_ZERO TARGET_NAME_ZERO
+
#endif
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 8e56b7a..5761ede 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -130,9 +130,9 @@ static int _get_segment_status_from_target_params(const char *target_name,
* linear/striped, old snapshots and raids have proper
* segment selected for status!
*/
- if (strcmp(target_name, "cache") &&
- strcmp(target_name, "thin-pool") &&
- strcmp(target_name, "thin"))
+ if (strcmp(target_name, TARGET_NAME_CACHE) &&
+ strcmp(target_name, TARGET_NAME_THIN_POOL) &&
+ strcmp(target_name, TARGET_NAME_THIN))
return 1;
if (!(segtype = get_segtype_from_string(seg_status->seg->lv->vg->cmd, target_name)))
@@ -354,7 +354,7 @@ static int _ignore_blocked_mirror_devices(struct device *dev,
&target_type, ¶ms);
if ((s == start) && (l == length) &&
target_type && params) {
- if (strcmp(target_type, "mirror"))
+ if (strcmp(target_type, TARGET_NAME_MIRROR))
goto_out;
if (((p = strstr(params, " block_on_error")) &&
@@ -430,13 +430,13 @@ static int _ignore_suspended_snapshot_component(struct device *dev)
do {
next = dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
- if (!target_type || !strcmp(target_type, "snapshot")) {
+ if (!target_type || !strcmp(target_type, TARGET_NAME_SNAPSHOT)) {
if (!params || sscanf(params, "%d:%d %d:%d", &major1, &minor1, &major2, &minor2) != 4) {
log_error("Incorrect snapshot table found");
goto_out;
}
r = r || _device_is_suspended(major1, minor1) || _device_is_suspended(major2, minor2);
- } else if (!strcmp(target_type, "snapshot-origin")) {
+ } else if (!strcmp(target_type, TARGET_NAME_SNAPSHOT_ORIGIN)) {
if (!params || sscanf(params, "%d:%d", &major1, &minor1) != 2) {
log_error("Incorrect snapshot-origin table found");
goto_out;
@@ -604,7 +604,7 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
next = dm_get_next_target(dmt, next, &start, &length,
&target_type, ¶ms);
- if (check.check_blocked && target_type && !strcmp(target_type, "mirror")) {
+ if (check.check_blocked && target_type && !strcmp(target_type, TARGET_NAME_MIRROR)) {
if (ignore_lvm_mirrors()) {
log_debug_activation("%s: Scanning mirror devices is disabled.", dev_name(dev));
goto out;
@@ -639,20 +639,20 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
* in a stack - use proper dm tree to check this instead.
*/
if (check.check_suspended && target_type &&
- (!strcmp(target_type, "snapshot") || !strcmp(target_type, "snapshot-origin")) &&
+ (!strcmp(target_type, TARGET_NAME_SNAPSHOT) || !strcmp(target_type, TARGET_NAME_SNAPSHOT_ORIGIN)) &&
_ignore_suspended_snapshot_component(dev)) {
log_debug_activation("%s: %s device %s not usable.", dev_name(dev), target_type, name);
goto out;
}
/* TODO: extend check struct ? */
- if (target_type && !strcmp(target_type, "thin") &&
+ if (target_type && !strcmp(target_type, TARGET_NAME_THIN) &&
!_ignore_unusable_thins(dev)) {
log_debug_activation("%s: %s device %s not usable.", dev_name(dev), target_type, name);
goto out;
}
- if (target_type && strcmp(target_type, "error"))
+ if (target_type && strcmp(target_type, TARGET_NAME_ERROR))
only_error_target = 0;
} while (next);
@@ -1160,7 +1160,7 @@ int dev_manager_snapshot_percent(struct dev_manager *dm,
/*
* Try and get some info on this device.
*/
- if (!_percent(dm, name, dlid, "snapshot", 0, NULL, percent,
+ if (!_percent(dm, name, dlid, TARGET_NAME_SNAPSHOT, 0, NULL, percent,
NULL, fail_if_percent_unsupported))
return_0;
@@ -1318,7 +1318,7 @@ int dev_manager_cache_status(struct dev_manager *dm,
dm_get_next_target(dmt, NULL, &start, &length, &type, ¶ms);
- if (!type || strcmp(type, "cache")) {
+ if (!type || strcmp(type, TARGET_NAME_CACHE)) {
log_error("Expected cache segment type but got %s instead",
type ? type : "NULL");
goto out;
@@ -1412,7 +1412,7 @@ int dev_manager_thin_pool_percent(struct dev_manager *dm,
return_0;
log_debug_activation("Getting device status percentage for %s", name);
- if (!(_percent(dm, name, dlid, "thin-pool", 0,
+ if (!(_percent(dm, name, dlid, TARGET_NAME_THIN_POOL, 0,
(metadata) ? lv : NULL, percent, NULL, 1)))
return_0;
@@ -1473,7 +1473,7 @@ int dev_manager_thin_device_id(struct dev_manager *dm,
goto out;
}
- if (!target_type || strcmp(target_type, "thin")) {
+ if (!target_type || strcmp(target_type, TARGET_NAME_THIN)) {
log_error("Unexpected target type %s found for thin %s.",
target_type, display_lvname(lv));
goto out;
@@ -2217,7 +2217,7 @@ static int _add_error_area(struct dev_manager *dm, struct dm_tree_node *node,
char *dlid;
uint64_t extent_size = seg->lv->vg->extent_size;
- if (!strcmp(dm->cmd->stripe_filler, "error")) {
+ if (!strcmp(dm->cmd->stripe_filler, TARGET_NAME_ERROR)) {
/*
* FIXME, the tree pointer is first field of dm_tree_node, but
* we don't have the struct definition available.
@@ -2690,7 +2690,7 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
dinfo->open_count)) {
if (seg_is_thin_volume(seg) ||
/* FIXME Is there anything simpler to check for instead? */
- !lv_has_target_type(dm->mem, lv, NULL, "snapshot-merge"))
+ !lv_has_target_type(dm->mem, lv, NULL, TARGET_NAME_SNAPSHOT_MERGE))
laopts->no_merging = 1;
}
}
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index a645756..a65892e 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -230,10 +230,10 @@ static int _target_present(struct cmd_context *cmd,
if (!_cache_checked) {
_cache_checked = 1;
- if (!(_cache_present = target_present(cmd, "cache", 1)))
+ if (!(_cache_present = target_present(cmd, TARGET_NAME_CACHE, 1)))
return 0;
- if (!target_version("cache", &maj, &min, &patchlevel))
+ if (!target_version(TARGET_NAME_CACHE, &maj, &min, &patchlevel))
return_0;
if ((maj < 1) ||
@@ -294,7 +294,7 @@ static int _modules_needed(struct dm_pool *mem,
const struct lv_segment *seg __attribute__((unused)),
struct dm_list *modules)
{
- if (!str_list_add(mem, modules, "cache")) {
+ if (!str_list_add(mem, modules, MODULE_NAME_CACHE)) {
log_error("String list allocation failed for cache module.");
return 0;
}
diff --git a/lib/error/errseg.c b/lib/error/errseg.c
index c489b0a..6b355fc 100644
--- a/lib/error/errseg.c
+++ b/lib/error/errseg.c
@@ -55,8 +55,8 @@ static int _errseg_target_present(struct cmd_context *cmd,
/* Reported truncated in older kernels */
if (!_errseg_checked) {
_errseg_checked = 1;
- _errseg_present = target_present(cmd, "error", 0) ||
- target_present(cmd, "erro", 0);
+ _errseg_present = target_present(cmd, TARGET_NAME_ERROR, 0) ||
+ target_present(cmd, TARGET_NAME_ERROR_OLD, 0);
}
return _errseg_present;
@@ -66,7 +66,7 @@ static int _errseg_modules_needed(struct dm_pool *mem,
const struct lv_segment *seg __attribute__((unused)),
struct dm_list *modules)
{
- if (!str_list_add(mem, modules, "error")) {
+ if (!str_list_add(mem, modules, MODULE_NAME_ERROR)) {
log_error("error module string list allocation failed");
return 0;
}
diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c
index e8a4dc5..d28d7c1 100644
--- a/lib/metadata/snapshot_manip.c
+++ b/lib/metadata/snapshot_manip.c
@@ -301,7 +301,7 @@ int vg_remove_snapshot(struct logical_volume *cow)
* - IMPORTANT: avoids preload if inactivate merge is pending
*/
if (lv_has_target_type(origin->vg->vgmem, origin, NULL,
- "snapshot-merge")) {
+ TARGET_NAME_SNAPSHOT_MERGE)) {
/*
* preload origin to:
* - allow proper release of -cow
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index 2572182..c4ba70a 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -404,7 +404,7 @@ static int _mirrored_target_present(struct cmd_context *cmd,
if (!_mirrored_checked) {
_mirrored_checked = 1;
- if (!(_mirrored_present = target_present(cmd, "mirror", 1)))
+ if (!(_mirrored_present = target_present(cmd, TARGET_NAME_MIRROR, 1)))
return 0;
/*
@@ -421,7 +421,7 @@ static int _mirrored_target_present(struct cmd_context *cmd,
*/
/* FIXME Move this into libdevmapper */
- if (target_version("mirror", &maj, &min, &patchlevel) &&
+ if (target_version(TARGET_NAME_MIRROR, &maj, &min, &patchlevel) &&
maj == 1 &&
((min >= 1) ||
(min == 0 && driver_version(vsn, sizeof(vsn)) &&
@@ -445,9 +445,9 @@ static int _mirrored_target_present(struct cmd_context *cmd,
if (!uname(&uts) &&
(sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel) == 3) &&
KERNEL_VERSION(kmaj, kmin, krel) < KERNEL_VERSION(2, 6, 31)) {
- if (module_present(cmd, "log-clustered"))
+ if (module_present(cmd, MODULE_NAME_LOG_CLUSTERED))
_mirror_attributes |= MIRROR_LOG_CLUSTERED;
- } else if (module_present(cmd, "log-userspace"))
+ } else if (module_present(cmd, MODULE_NAME_LOG_USERSPACE))
_mirror_attributes |= MIRROR_LOG_CLUSTERED;
if (!(_mirror_attributes & MIRROR_LOG_CLUSTERED))
@@ -510,12 +510,12 @@ static int _mirrored_modules_needed(struct dm_pool *mem,
return_0;
if (vg_is_clustered(seg->lv->vg) &&
- !str_list_add(mem, modules, "clog")) {
+ !str_list_add(mem, modules, MODULE_NAME_CLUSTERED_MIRROR)) {
log_error("cluster log string list allocation failed");
return 0;
}
- if (!str_list_add(mem, modules, "mirror")) {
+ if (!str_list_add(mem, modules, MODULE_NAME_MIRROR)) {
log_error("mirror string list allocation failed");
return 0;
}
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 36f455d..67c355a 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -322,7 +322,7 @@ static int _raid_target_present(struct cmd_context *cmd,
if (!_raid_checked) {
_raid_checked = 1;
- if (!(_raid_present = target_present(cmd, "raid", 1)))
+ if (!(_raid_present = target_present(cmd, TARGET_NAME_RAID, 1)))
return 0;
if (!target_version("raid", &maj, &min, &patchlevel))
@@ -347,7 +347,7 @@ static int _raid_modules_needed(struct dm_pool *mem,
const struct lv_segment *seg __attribute__((unused)),
struct dm_list *modules)
{
- if (!str_list_add(mem, modules, "raid")) {
+ if (!str_list_add(mem, modules, MODULE_NAME_RAID)) {
log_error("raid module string list allocation failed");
return 0;
}
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index e443d60..a80f283 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -29,7 +29,7 @@ static const char *_snap_target_name(const struct lv_segment *seg,
const struct lv_activate_opts *laopts)
{
if (!laopts->no_merging && (seg->status & MERGING))
- return "snapshot-merge";
+ return TARGET_NAME_SNAPSHOT_MERGE;
return lvseg_name(seg);
}
@@ -99,7 +99,7 @@ static int _snap_text_export(const struct lv_segment *seg, struct formatter *f)
#ifdef DEVMAPPER_SUPPORT
static int _snap_target_status_compatible(const char *type)
{
- return (strcmp(type, "snapshot-merge") == 0);
+ return (strcmp(type, TARGET_NAME_SNAPSHOT_MERGE) == 0);
}
static int _snap_target_percent(void **target_state __attribute__((unused)),
@@ -151,11 +151,11 @@ static int _snap_target_present(struct cmd_context *cmd,
if (!_snap_checked) {
_snap_checked = 1;
- if (!(_snap_present = target_present(cmd, "snapshot", 1) &&
- target_present(cmd, "snapshot-origin", 0)))
+ if (!(_snap_present = target_present(cmd, TARGET_NAME_SNAPSHOT, 1) &&
+ target_present(cmd, TARGET_NAME_SNAPSHOT_ORIGIN, 0)))
return 0;
- if (target_version("snapshot", &maj, &min, &patchlevel) &&
+ if (target_version(TARGET_NAME_SNAPSHOT, &maj, &min, &patchlevel) &&
(maj > 1 ||
(maj == 1 && (min >= 12 || (min == 10 && patchlevel >= 2)))))
_snap_attrs |= SNAPSHOT_FEATURE_FIXED_LEAK;
@@ -169,7 +169,7 @@ static int _snap_target_present(struct cmd_context *cmd,
/* TODO: test everything at once */
if (_snap_present && seg && (seg->status & MERGING)) {
if (!_snap_merge_checked) {
- _snap_merge_present = target_present(cmd, "snapshot-merge", 0);
+ _snap_merge_present = target_present(cmd, TARGET_NAME_SNAPSHOT_MERGE, 0);
_snap_merge_checked = 1;
}
return _snap_merge_present;
@@ -218,7 +218,7 @@ static int _snap_modules_needed(struct dm_pool *mem,
const struct lv_segment *seg __attribute__((unused)),
struct dm_list *modules)
{
- if (!str_list_add(mem, modules, "snapshot")) {
+ if (!str_list_add(mem, modules, MODULE_NAME_SNAPSHOT)) {
log_error("snapshot string list allocation failed");
return 0;
}
diff --git a/lib/striped/striped.c b/lib/striped/striped.c
index 83ba606..530e48e 100644
--- a/lib/striped/striped.c
+++ b/lib/striped/striped.c
@@ -197,8 +197,8 @@ static int _striped_target_present(struct cmd_context *cmd,
if (!_striped_checked) {
_striped_checked = 1;
- _striped_present = target_present(cmd, "linear", 0) &&
- target_present(cmd, "striped", 0);
+ _striped_present = target_present(cmd, TARGET_NAME_LINEAR, 0) &&
+ target_present(cmd, TARGET_NAME_STRIPED, 0);
}
return _striped_present;
diff --git a/lib/zero/zero.c b/lib/zero/zero.c
index c4c3f84..fc021cd 100644
--- a/lib/zero/zero.c
+++ b/lib/zero/zero.c
@@ -50,7 +50,7 @@ static int _zero_target_present(struct cmd_context *cmd,
if (!_zero_checked) {
_zero_checked = 1;
- _zero_present = target_present(cmd, "zero", 1);
+ _zero_present = target_present(cmd, TARGET_NAME_ZERO, 1);
}
return _zero_present;
@@ -60,7 +60,7 @@ static int _zero_modules_needed(struct dm_pool *mem,
const struct lv_segment *seg __attribute__((unused)),
struct dm_list *modules)
{
- if (!str_list_add(mem, modules, "zero")) {
+ if (!str_list_add(mem, modules, MODULE_NAME_ZERO)) {
log_error("zero module string list allocation failed");
return 0;
}
8 years, 1 month
master - coverity: fix some issues reported by coverity for recent code
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=94f78e0183e251...
Commit: 94f78e0183e2517199e19d0473a7d5480660db0a
Parent: 3d26d283ea7234ee3e4499b53f185696e0c5e15c
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Mar 22 16:03:51 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Mar 22 16:03:55 2016 +0100
coverity: fix some issues reported by coverity for recent code
---
lib/device/dev-cache.c | 19 ++++++++++---------
lib/metadata/metadata.c | 15 ++++++++++-----
2 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 06438d9..c0267a9 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -366,6 +366,7 @@ static int _get_sysfs_value(const char *path, char *buf, size_t buf_size)
{
FILE *fp;
size_t len;
+ int r = 0;
if (!(fp = fopen(path, "r"))) {
log_sys_error("fopen", path);
@@ -374,23 +375,23 @@ static int _get_sysfs_value(const char *path, char *buf, size_t buf_size)
if (!fgets(buf, buf_size, fp)) {
log_sys_error("fgets", path);
- if (fclose(fp))
- log_sys_error("fclose", path);
- return 0;
+ goto out;
}
if (!(len = strlen(buf)) || (len == 1 && buf[0] == '\n')) {
log_error("_get_sysfs_value: %s: no value", path);
- return 0;
+ goto out;
}
if (buf[len - 1] == '\n')
buf[len - 1] = '\0';
+ r = 1;
+out:
if (fclose(fp))
log_sys_error("fclose", path);
- return 1;
+ return r;
}
static int _get_dm_uuid_from_sysfs(char *buf, size_t buf_size, int major, int minor)
@@ -427,14 +428,14 @@ static struct dm_list *_get_or_add_list_by_index_key(struct dm_hash_table *idx,
return list;
}
-static struct device *_get_device_for_sysfs_dev_name_using_devno(const char *dev_name)
+static struct device *_get_device_for_sysfs_dev_name_using_devno(const char *devname)
{
char path[PATH_MAX];
char buf[PATH_MAX];
int major, minor;
- if (dm_snprintf(path, sizeof(path), "%sblock/%s/dev", dm_sysfs_dir(), dev_name) < 0) {
- log_error("_get_device_for_non_dm_dev: %s: dm_snprintf failed", dev_name);
+ if (dm_snprintf(path, sizeof(path), "%sblock/%s/dev", dm_sysfs_dir(), devname) < 0) {
+ log_error("_get_device_for_non_dm_dev: %s: dm_snprintf failed", devname);
return NULL;
}
@@ -442,7 +443,7 @@ static struct device *_get_device_for_sysfs_dev_name_using_devno(const char *dev
return_NULL;
if (sscanf(buf, "%d:%d", &major, &minor) != 2) {
- log_error("_get_device_for_non_dm_dev: %s: failed to get major and minor number", dev_name);
+ log_error("_get_device_for_non_dm_dev: %s: failed to get major and minor number", devname);
return NULL;
}
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 2c5ede5..ecdb5af 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4600,8 +4600,10 @@ static int _check_devs_used_correspond_with_lv(struct dm_pool *mem, struct dm_li
if (!found_inconsistent) {
dm_pool_begin_object(mem, 32);
found_inconsistent = 1;
- } else
- dm_pool_grow_object(mem, DEV_LIST_DELIM, sizeof(DEV_LIST_DELIM) - 1);
+ } else {
+ if (!dm_pool_grow_object(mem, DEV_LIST_DELIM, sizeof(DEV_LIST_DELIM) - 1))
+ goto_bad;
+ }
if (!dm_pool_grow_object(mem, dev_name(dev), 0))
goto_bad;
}
@@ -4610,7 +4612,8 @@ static int _check_devs_used_correspond_with_lv(struct dm_pool *mem, struct dm_li
if (!found_inconsistent)
return 1;
- dm_pool_grow_object(mem, "\0", 1);
+ if (!dm_pool_grow_object(mem, "\0", 1))
+ goto_bad;
used_devnames = dm_pool_end_object(mem);
found_inconsistent = 0;
@@ -4628,7 +4631,8 @@ static int _check_devs_used_correspond_with_lv(struct dm_pool *mem, struct dm_li
dm_pool_begin_object(mem, 32);
found_inconsistent = 1;
} else {
- dm_pool_grow_object(mem, DEV_LIST_DELIM, sizeof(DEV_LIST_DELIM) - 1);
+ if (!dm_pool_grow_object(mem, DEV_LIST_DELIM, sizeof(DEV_LIST_DELIM) - 1))
+ goto_bad;
}
if (!dm_pool_grow_object(mem, dev_name(dev), 0))
goto bad;
@@ -4638,7 +4642,8 @@ static int _check_devs_used_correspond_with_lv(struct dm_pool *mem, struct dm_li
}
if (found_inconsistent) {
- dm_pool_grow_object(mem, "\0", 1);
+ if (!dm_pool_grow_object(mem, "\0", 1))
+ goto_bad;
assumed_devnames = dm_pool_end_object(mem);
}
8 years, 1 month
master - tests: update vg-check-devs-used.sh
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3d26d283ea7234...
Commit: 3d26d283ea7234ee3e4499b53f185696e0c5e15c
Parent: 6a915270fc7837d18c2e6daf55d75c3763bc2866
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Mar 22 11:18:16 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Mar 22 11:18:22 2016 +0100
tests: update vg-check-devs-used.sh
Snapshot needs to be activated exclusively in cluster...
---
test/shell/vg-check-devs-used.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/shell/vg-check-devs-used.sh b/test/shell/vg-check-devs-used.sh
index 09109e5..c978b9e 100644
--- a/test/shell/vg-check-devs-used.sh
+++ b/test/shell/vg-check-devs-used.sh
@@ -26,8 +26,8 @@ lvremove -ff $vg
# Also test if sub LVs with suffixes are correctly processed.
# Check with thick snapshot which has sub LVs with -real and -cow suffix in UUID.
-lvcreate -l1 -n $lv $vg
-lvcreate -l1 -s $vg/$lv
+lvcreate -l1 -aey -n $lv $vg
+lvcreate -l1 -aey -s $vg/$lv
pvs 2>err
not grep "WARNING: Device mismatch detected for $vg/$lv" err
8 years, 1 month
master - tests: update vg-check-devs-used.sh
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6a915270fc7837...
Commit: 6a915270fc7837d18c2e6daf55d75c3763bc2866
Parent: ed002ed22adc61dfe477c3d42c9aae356f450d2c
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Mar 22 11:13:28 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Mar 22 11:13:28 2016 +0100
tests: update vg-check-devs-used.sh
---
test/shell/vg-check-devs-used.sh | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/test/shell/vg-check-devs-used.sh b/test/shell/vg-check-devs-used.sh
index b368227..09109e5 100644
--- a/test/shell/vg-check-devs-used.sh
+++ b/test/shell/vg-check-devs-used.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2016 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@@ -21,4 +21,14 @@ dd if="$dev1" of="$dev3" bs=1M
pvs --config "devices/global_filter = [ \"a|$dev2|\", \"a|$dev3|\", \"r|.*|\" ]" 2>err
grep "WARNING: Device mismatch detected for $vg/$lv which is accessing $dev1 instead of $dev3" err
+dd if=/dev/zero of="$dev3" bs=1M count=8
+lvremove -ff $vg
+
+# Also test if sub LVs with suffixes are correctly processed.
+# Check with thick snapshot which has sub LVs with -real and -cow suffix in UUID.
+lvcreate -l1 -n $lv $vg
+lvcreate -l1 -s $vg/$lv
+pvs 2>err
+not grep "WARNING: Device mismatch detected for $vg/$lv" err
+
vgremove -ff $vg
8 years, 1 month
master - dev: also count with suffixes in UUID for LVs when constructing VGID and LVID index
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ed002ed22adc61...
Commit: ed002ed22adc61dfe477c3d42c9aae356f450d2c
Parent: 2a47f0957fb95136985c97d0b7b4580044e3f68d
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Mar 22 10:28:01 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Mar 22 10:52:24 2016 +0100
dev: also count with suffixes in UUID for LVs when constructing VGID and LVID index
UUID for LV is either "LVM-<vg_uuid><lv_uuid>" or "LVM-<vg_uuid><lv_uuid>-<suffix>".
The code before just checked the length of the UUID based on the first
template, not the variant with suffix - so LVs with this suffix were not
processed properly.
For example a thin pool LV (as an example of an LV that contains
sub LVs where UUIDs have suffixes):
[0] fedora/~ # lsblk -s /dev/vg/lvol1
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vg-lvol1 253:8 0 4M 0 lvm
`-vg-pool-tpool 253:6 0 116M 0 lvm
|-vg-pool_tmeta 253:2 0 4M 0 lvm
| `-sda 8:0 0 128M 0 disk
`-vg-pool_tdata 253:3 0 116M 0 lvm
`-sda 8:0 0 128M 0 disk
Before this patch (spurious warning message about device mismatch):
[0] fedora/~ # pvs
WARNING: Device mismatch detected for vg/lvol1 which is accessing /dev/mapper/vg-pool-tpool instead of (null).
PV VG Fmt Attr PSize PFree
/dev/sda vg lvm2 a-- 124.00m 0
With this patch applied (no spurious warning message about device mismatch):
[0] fedora/~ # pvs
PV VG Fmt Attr PSize PFree
/dev/sda vg lvm2 a-- 124.00m 0
---
lib/device/dev-cache.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index bcee783..06438d9 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -453,13 +453,23 @@ static struct device *_get_device_for_sysfs_dev_name_using_devno(const char *dev
static int _get_vgid_and_lvid_for_dev(struct device *dev)
{
- size_t lvm_prefix_len = strlen(UUID_PREFIX);
+ static size_t lvm_prefix_len = sizeof(UUID_PREFIX) - 1;
+ static size_t lvm_uuid_len = sizeof(UUID_PREFIX) - 1 + 2 * ID_LEN;
char uuid[DM_UUID_LEN];
+ size_t uuid_len;
if (!_get_dm_uuid_from_sysfs(uuid, sizeof(uuid), (int) MAJOR(dev->dev), (int) MINOR(dev->dev)))
return_0;
- if (strlen(uuid) == (2 * ID_LEN + 4) &&
+ uuid_len = strlen(uuid);
+
+ /*
+ * UUID for LV is either "LVM-<vg_uuid><lv_uuid>" or "LVM-<vg_uuid><lv_uuid>-<suffix>",
+ * where vg_uuid and lv_uuid has length of ID_LEN and suffix len is not restricted
+ * (only restricted by whole DM UUID max len).
+ */
+ if (((uuid_len == lvm_uuid_len) ||
+ ((uuid_len > lvm_uuid_len) && (uuid[lvm_uuid_len] == '-'))) &&
!strncmp(uuid, UUID_PREFIX, lvm_prefix_len)) {
/* Separate VGID and LVID part from DM UUID. */
if (!(dev->vgid = dm_pool_strndup(_cache.mem, uuid + lvm_prefix_len, ID_LEN)) ||
8 years, 1 month
master - dev: also check for blank sysfs value containing only '\n'
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2a47f0957fb951...
Commit: 2a47f0957fb95136985c97d0b7b4580044e3f68d
Parent: e69e81388dd84598a37b8b77c17c393bf570cf75
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Mar 22 09:29:24 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Mar 22 09:29:24 2016 +0100
dev: also check for blank sysfs value containing only '\n'
---
lib/device/dev-cache.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index d912dea..bcee783 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -379,7 +379,7 @@ static int _get_sysfs_value(const char *path, char *buf, size_t buf_size)
return 0;
}
- if (!(len = strlen(buf))) {
+ if (!(len = strlen(buf)) || (len == 1 && buf[0] == '\n')) {
log_error("_get_sysfs_value: %s: no value", path);
return 0;
}
8 years, 1 month
master - report: Add pv_major, pv_minor to reports.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e69e81388dd845...
Commit: e69e81388dd84598a37b8b77c17c393bf570cf75
Parent: 16b127259761da212bc7ba6ab3c95b42fe0fe276
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Mar 22 00:12:08 2016 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Mar 22 00:12:08 2016 +0000
report: Add pv_major, pv_minor to reports.
---
WHATS_NEW | 1 +
lib/report/columns.h | 2 ++
lib/report/properties.c | 4 ++++
lib/report/report.c | 18 ++++++++++++++++++
4 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0f81021..029405d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.148 -
==================================
+ Add pv_major and pv_minor report fields.
Detect and warn about mismatch between devices used and assumed for an LV.
Version 2.02.147 - 19th March 2016
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 4439047..7f5e11d 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -126,6 +126,8 @@ FIELD(LABEL, label, STR, "Fmt", type, 0, pvfmt, pv_fmt, "Type of metadata.", 0)
FIELD(LABEL, label, STR, "PV UUID", type, 38, pvuuid, pv_uuid, "Unique identifier.", 0)
FIELD(LABEL, label, SIZ, "DevSize", dev, 0, devsize, dev_size, "Size of underlying device in current units.", 0)
FIELD(LABEL, label, STR, "PV", dev, 10, dev_name, pv_name, "Name.", 0)
+FIELD(LABEL, label, STR, "Maj", dev, 0, devmajor, pv_major, "Device major number.", 0)
+FIELD(LABEL, label, STR, "Min", dev, 0, devminor, pv_minor, "Device minor number.", 0)
FIELD(LABEL, label, SIZ, "PMdaFree", type, 9, pvmdafree, pv_mda_free, "Free metadata area space on this device in current units.", 0)
FIELD(LABEL, label, SIZ, "PMdaSize", type, 9, pvmdasize, pv_mda_size, "Size of smallest metadata area on this device in current units.", 0)
FIELD(LABEL, label, NUM, "PExtVsn", type, 0, pvextvsn, pv_ext_vsn, "PV header extension version.", 0)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index 62c81b9..7c9bb0c 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -194,6 +194,10 @@ GET_PV_NUM_PROPERTY_FN(pv_ba_size, SECTOR_SIZE * pv->ba_size)
#define _pv_ext_vsn_set prop_not_implemented_set
#define _pv_in_use_get prop_not_implemented_get
#define _pv_in_use_set prop_not_implemented_set
+#define _pv_major_get prop_not_implemented_set
+#define _pv_major_set prop_not_implemented_set
+#define _pv_minor_get prop_not_implemented_set
+#define _pv_minor_set prop_not_implemented_set
#define _vg_permissions_set prop_not_implemented_set
#define _vg_permissions_get prop_not_implemented_get
diff --git a/lib/report/report.c b/lib/report/report.c
index 7070092..5009ecc 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1289,6 +1289,24 @@ static int _uuid_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_value(field, repstr, NULL);
}
+static int _devminor_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ int devminor = (int) MINOR((*(const struct device * const *) data)->dev);
+
+ return dm_report_field_int(rh, field, &devminor);
+}
+
+static int _devmajor_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ int devmajor = (int) MAJOR((*(const struct device * const *) data)->dev);
+
+ return dm_report_field_int(rh, field, &devmajor);
+}
+
static int _dev_name_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
8 years, 1 month