master - report: reserved value: description for undefined value
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e31ec38d8e657d...
Commit: e31ec38d8e657d5f6d6efca6eade083357675276
Parent: 175de52deddbd0727c42d7a3e34d27b6f70f2deb
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Jul 10 13:42:16 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jul 10 13:42:16 2014 +0200
report: reserved value: description for undefined value
---
lib/report/values.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/report/values.h b/lib/report/values.h
index 3ee6192..d8de665 100644
--- a/lib/report/values.h
+++ b/lib/report/values.h
@@ -42,7 +42,7 @@
/* *INDENT-OFF* */
/* Per-type reserved values usable for all fields of certain type. */
-TYPE_RESERVED_VALUE(NUM, number_undef_64, "", UINT64_C(-1), "-1", "unknown", "undefined", "undef")
+TYPE_RESERVED_VALUE(NUM, number_undef_64, "Reserved value for undefined numeric value.", UINT64_C(-1), "-1", "unknown", "undefined", "undef")
/* Reserved values for PV fields */
FIELD_RESERVED_BINARY_VALUE(pv_allocatable, pv_allocatable, "", "allocatable")
9 years, 9 months
master - cleanup: also use values.h for final dm_report_reserved_value array composition
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=175de52deddbd0...
Commit: 175de52deddbd0727c42d7a3e34d27b6f70f2deb
Parent: f598aa38aeee369be912153a2a577520f69e8d88
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Jul 10 13:37:26 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jul 10 13:37:40 2014 +0200
cleanup: also use values.h for final dm_report_reserved_value array composition
---
lib/report/report.c | 64 +++++++++++------------------------------------
lib/report/values.h | 68 +++++++++++++++++++++++++-------------------------
2 files changed, 49 insertions(+), 83 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 1d70016..63b1647 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -73,9 +73,9 @@ static const int32_t _reserved_number_undef_32 = INT32_C(-1);
* All names listed are synonyms recognized in selection criteria.
* For binary-based values we map all reserved names listed onto value 1, blank onto value 0.
*
- * TYPE_RESERVED_VALUE(type, reserved_value_id, value, reserved name, ...)
- * FIELD_RESERVED_VALUE(field_id, reserved_value_id, value, reserved name, ...)
- * FIELD_RESERVED_BINARY_VALUE(field_id, reserved_value_id, value, reserved name for 1, ...)
+ * TYPE_RESERVED_VALUE(type, reserved_value_id, description, value, reserved name, ...)
+ * FIELD_RESERVED_VALUE(field_id, reserved_value_id, description, value, reserved name, ...)
+ * FIELD_RESERVED_BINARY_VALUE(field_id, reserved_value_id, description, reserved name for 1, ...)
*
* Note: FIELD_RESERVED_BINARY_VALUE creates:
* - 'reserved_value_id_y' (for 1)
@@ -86,17 +86,17 @@ static const int32_t _reserved_number_undef_32 = INT32_C(-1);
#define NUM uint64_t
-#define TYPE_RESERVED_VALUE(type, id, value, ...) \
+#define TYPE_RESERVED_VALUE(type, id, desc, value, ...) \
static const char *_reserved_ ## id ## _names[] = { __VA_ARGS__, NULL}; \
static const type _reserved_ ## id = value;
-#define FIELD_RESERVED_VALUE(field_id, id, value, ...) \
+#define FIELD_RESERVED_VALUE(field_id, id, desc, value, ...) \
static const char *_reserved_ ## id ## _names[] = { __VA_ARGS__ , NULL}; \
static const struct dm_report_field_reserved_value _reserved_ ## id = {field_ ## field_id, &value};
-#define FIELD_RESERVED_BINARY_VALUE(field_id, id, ...) \
- FIELD_RESERVED_VALUE(field_id, id ## _y, _one64, __VA_ARGS__, _str_yes) \
- FIELD_RESERVED_VALUE(field_id, id ## _n, _zero64, __VA_ARGS__, _str_no)
+#define FIELD_RESERVED_BINARY_VALUE(field_id, id, desc, ...) \
+ FIELD_RESERVED_VALUE(field_id, id ## _y, desc, _one64, __VA_ARGS__, _str_yes) \
+ FIELD_RESERVED_VALUE(field_id, id ## _n, desc, _zero64, __VA_ARGS__, _str_no)
#include "values.h"
@@ -110,54 +110,20 @@ static const int32_t _reserved_number_undef_32 = INT32_C(-1);
* dm_report_init_with_selection function that initializes report with
* selection criteria. Selection code then recognizes these reserved values
* when parsing selection criteria.
- *
- * TYPE_RESERVED_VALUE_REG(report_type, reserved_value_id, description)
- * FIELD_RESERVED_VALUE_REG(reserved_value_id, description)
- * FIELD_RESERVED_BINARY_BALUE_REG(reserved_value_id, description)
- */
+*/
#define NUM DM_REPORT_FIELD_TYPE_NUMBER
-#define TYPE_RESERVED_VALUE_REG(type, id, description) {type, &_reserved_ ## id, _reserved_ ## id ## _names, description},
+#define TYPE_RESERVED_VALUE(type, id, desc, value, ...) {type, &_reserved_ ## id, _reserved_ ## id ## _names, desc},
-#define FIELD_RESERVED_VALUE_REG(id, description) {DM_REPORT_FIELD_TYPE_NONE, &_reserved_ ## id, _reserved_ ## id ## _names, description},
+#define FIELD_RESERVED_VALUE(field_id, id, desc, value, ...) {DM_REPORT_FIELD_TYPE_NONE, &_reserved_ ## id, _reserved_ ## id ## _names, desc},
-#define FIELD_RESERVED_BINARY_VALUE_REG(id, description) \
- FIELD_RESERVED_VALUE_REG(id ## _y, description) \
- FIELD_RESERVED_VALUE_REG(id ## _n, description)
+#define FIELD_RESERVED_BINARY_VALUE(field_id, id, desc, ...) \
+ FIELD_RESERVED_VALUE(field_id, id ## _y, desc, _one64, __VA_ARGS__) \
+ FIELD_RESERVED_VALUE(field_id, id ## _n, desc, _zero64, __VA_ARGS__)
static const struct dm_report_reserved_value _report_reserved_values[] = {
- TYPE_RESERVED_VALUE_REG(NUM, number_undef_64, "Reserved value for undefined numeric value.")
- FIELD_RESERVED_BINARY_VALUE_REG(pv_allocatable, "pv_allocatable reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(pv_exported, "pv_exported reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(pv_missing, "pv_missing reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(vg_extendable, "vg_extendable reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(vg_exported, "vg_exported reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(vg_partial, "vg_partial reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(vg_clustered, "vg_clustered reserved values")
- FIELD_RESERVED_VALUE_REG(vg_permissions_rw, "vg_permissions reserved values (writeable)")
- FIELD_RESERVED_VALUE_REG(vg_permissions_r, "vg_permissions reserved values (read-only)")
- FIELD_RESERVED_VALUE_REG(vg_mda_copies, "vg_mda_copies reserved values (unmanaged)")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_initial_image_sync, "lv_initial_image_sync reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_image_synced, "lv_image_synced reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_merging, "lv_merging reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_converting, "lv_converting reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_allocation_locked, "lv_allocation_locked reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_fixed_minor, "lv_fixed_minor reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_active_locally, "lv_active_locally reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_active_remotely, "lv_active_remotelly reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_active_exclusively, "lv_active_exclusively reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_merge_failed, "lv_merge_failed reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_snapshot_invalid, "lv_snapshot_invalid reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_suspended, "lv_suspended reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_live_table, "lv_live_table reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_inactive_table, "lv_inactive_table reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_device_open, "lv_device_open reserved values")
- FIELD_RESERVED_BINARY_VALUE_REG(lv_skip_activation, "lv_inactive_table reserved values")
- FIELD_RESERVED_VALUE_REG(lv_permissions_rw, "lv_permissions reserved values (writeable)")
- FIELD_RESERVED_VALUE_REG(lv_permissions_r, "lv_permissions reserved values (read-only)")
- FIELD_RESERVED_VALUE_REG(lv_permissions_r_override, "lv_permissions reserved values (read-only-override)")
- FIELD_RESERVED_VALUE_REG(lv_read_ahead, "lv_read_ahead reserved values (auto)")
+ #include "values.h"
{0, NULL, NULL}
};
diff --git a/lib/report/values.h b/lib/report/values.h
index 5c4b5ab..3ee6192 100644
--- a/lib/report/values.h
+++ b/lib/report/values.h
@@ -34,50 +34,50 @@
*/
/*
- * TYPE_RESERVED_VALUE(type, id, value, reserved_name, ...)
- * FIELD_RESERVED_VALUE(field_id, reserved_value_id, value, reserved_name, ...)
- * FIELD_BINARY_RESERVED_VALUE(field_id, reserved_value_id, reserved_name, ...)
+ * TYPE_RESERVED_VALUE(type, reserved_value_id, description, value, reserved_name, ...)
+ * FIELD_RESERVED_VALUE(field_id, reserved_value_id, description, value, reserved_name, ...)
+ * FIELD_BINARY_RESERVED_VALUE(field_id, reserved_value_id, description, reserved_name for 1, ...)
*/
/* *INDENT-OFF* */
/* Per-type reserved values usable for all fields of certain type. */
-TYPE_RESERVED_VALUE(NUM, number_undef_64, UINT64_C(-1), "-1", "unknown", "undefined", "undef");
+TYPE_RESERVED_VALUE(NUM, number_undef_64, "", UINT64_C(-1), "-1", "unknown", "undefined", "undef")
/* Reserved values for PV fields */
-FIELD_RESERVED_BINARY_VALUE(pv_allocatable, pv_allocatable, "allocatable")
-FIELD_RESERVED_BINARY_VALUE(pv_exported, pv_exported, "exported")
-FIELD_RESERVED_BINARY_VALUE(pv_missing, pv_missing, "missing")
+FIELD_RESERVED_BINARY_VALUE(pv_allocatable, pv_allocatable, "", "allocatable")
+FIELD_RESERVED_BINARY_VALUE(pv_exported, pv_exported, "", "exported")
+FIELD_RESERVED_BINARY_VALUE(pv_missing, pv_missing, "", "missing")
/* Reserved values for VG fields */
-FIELD_RESERVED_BINARY_VALUE(vg_extendable, vg_extendable, "extendable")
-FIELD_RESERVED_BINARY_VALUE(vg_exported, vg_exported, "exported")
-FIELD_RESERVED_BINARY_VALUE(vg_partial, vg_partial, "partial")
-FIELD_RESERVED_BINARY_VALUE(vg_clustered, vg_clustered, "clustered")
-FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_rw, FIRST_NAME(vg_permissions_rw), "writeable", "rw", "read-write")
-FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_r, FIRST_NAME(vg_permissions_r), "read-only", "r", "ro")
-FIELD_RESERVED_VALUE(vg_mda_copies, vg_mda_copies, RESERVED(number_undef_64), "unmanaged")
+FIELD_RESERVED_BINARY_VALUE(vg_extendable, vg_extendable, "", "extendable")
+FIELD_RESERVED_BINARY_VALUE(vg_exported, vg_exported, "", "exported")
+FIELD_RESERVED_BINARY_VALUE(vg_partial, vg_partial, "", "partial")
+FIELD_RESERVED_BINARY_VALUE(vg_clustered, vg_clustered, "", "clustered")
+FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_rw, "", FIRST_NAME(vg_permissions_rw), "writeable", "rw", "read-write")
+FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_r, "", FIRST_NAME(vg_permissions_r), "read-only", "r", "ro")
+FIELD_RESERVED_VALUE(vg_mda_copies, vg_mda_copies, "", RESERVED(number_undef_64), "unmanaged")
/* Reserved values for LV fields */
-FIELD_RESERVED_BINARY_VALUE(lv_initial_image_sync, lv_initial_image_sync, "initial image sync", "sync")
-FIELD_RESERVED_BINARY_VALUE(lv_image_synced, lv_image_synced, "image synced", "synced")
-FIELD_RESERVED_BINARY_VALUE(lv_merging, lv_merging, "merging")
-FIELD_RESERVED_BINARY_VALUE(lv_converting, lv_converting, "converting")
-FIELD_RESERVED_BINARY_VALUE(lv_allocation_locked, lv_allocation_locked, "allocation locked", "locked")
-FIELD_RESERVED_BINARY_VALUE(lv_fixed_minor, lv_fixed_minor, "fixed minor", "fixed")
-FIELD_RESERVED_BINARY_VALUE(lv_active_locally, lv_active_locally, "active locally", "active", "locally")
-FIELD_RESERVED_BINARY_VALUE(lv_active_remotely, lv_active_remotely, "active remotely", "active", "remotely")
-FIELD_RESERVED_BINARY_VALUE(lv_active_exclusively, lv_active_exclusively, "active exclusively", "active", "exclusively")
-FIELD_RESERVED_BINARY_VALUE(lv_merge_failed, lv_merge_failed, "merge failed", "failed")
-FIELD_RESERVED_BINARY_VALUE(lv_snapshot_invalid, lv_snapshot_invalid, "snapshot invalid", "invalid")
-FIELD_RESERVED_BINARY_VALUE(lv_suspended, lv_suspended, "suspended")
-FIELD_RESERVED_BINARY_VALUE(lv_live_table, lv_live_table, "live table present", "live table", "live")
-FIELD_RESERVED_BINARY_VALUE(lv_inactive_table, lv_inactive_table, "inactive table present", "inactive table", "inactive")
-FIELD_RESERVED_BINARY_VALUE(lv_device_open, lv_device_open, "open")
-FIELD_RESERVED_BINARY_VALUE(lv_skip_activation, lv_skip_activation, "skip activation", "skip")
-FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_rw, FIRST_NAME(lv_permissions_rw), "writeable", "rw", "read-write")
-FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, FIRST_NAME(lv_permissions_r), "read-only", "r", "ro")
-FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, FIRST_NAME(lv_permissions_r_override), "read-only-override", "ro-override", "r-override", "R")
-FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead, RESERVED(number_undef_64), "auto")
+FIELD_RESERVED_BINARY_VALUE(lv_initial_image_sync, lv_initial_image_sync, "", "initial image sync", "sync")
+FIELD_RESERVED_BINARY_VALUE(lv_image_synced, lv_image_synced, "", "image synced", "synced")
+FIELD_RESERVED_BINARY_VALUE(lv_merging, lv_merging, "", "merging")
+FIELD_RESERVED_BINARY_VALUE(lv_converting, lv_converting, "", "converting")
+FIELD_RESERVED_BINARY_VALUE(lv_allocation_locked, lv_allocation_locked, "", "allocation locked", "locked")
+FIELD_RESERVED_BINARY_VALUE(lv_fixed_minor, lv_fixed_minor, "", "fixed minor", "fixed")
+FIELD_RESERVED_BINARY_VALUE(lv_active_locally, lv_active_locally, "", "active locally", "active", "locally")
+FIELD_RESERVED_BINARY_VALUE(lv_active_remotely, lv_active_remotely, "", "active remotely", "active", "remotely")
+FIELD_RESERVED_BINARY_VALUE(lv_active_exclusively, lv_active_exclusively, "", "active exclusively", "active", "exclusively")
+FIELD_RESERVED_BINARY_VALUE(lv_merge_failed, lv_merge_failed, "", "merge failed", "failed")
+FIELD_RESERVED_BINARY_VALUE(lv_snapshot_invalid, lv_snapshot_invalid, "", "snapshot invalid", "invalid")
+FIELD_RESERVED_BINARY_VALUE(lv_suspended, lv_suspended, "", "suspended")
+FIELD_RESERVED_BINARY_VALUE(lv_live_table, lv_live_table, "", "live table present", "live table", "live")
+FIELD_RESERVED_BINARY_VALUE(lv_inactive_table, lv_inactive_table, "", "inactive table present", "inactive table", "inactive")
+FIELD_RESERVED_BINARY_VALUE(lv_device_open, lv_device_open, "", "open")
+FIELD_RESERVED_BINARY_VALUE(lv_skip_activation, lv_skip_activation, "", "skip activation", "skip")
+FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_rw, "", FIRST_NAME(lv_permissions_rw), "writeable", "rw", "read-write")
+FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, "", FIRST_NAME(lv_permissions_r), "", "read-only", "r", "ro")
+FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, "", FIRST_NAME(lv_permissions_r_override), "", "read-only-override", "ro-override", "r-override", "R")
+FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead, "", RESERVED(number_undef_64), "auto")
/* *INDENT-ON* */
9 years, 9 months
master - cleanup: report reserved value macros
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f598aa38aeee36...
Commit: f598aa38aeee369be912153a2a577520f69e8d88
Parent: fafd10d564151b91e814f6be3e735bdf0b7d33dd
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Jul 10 11:54:37 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jul 10 11:54:37 2014 +0200
cleanup: report reserved value macros
---
lib/report/report.c | 57 ++++++++++++++++++++++++++++++--------------------
lib/report/values.h | 23 ++++++++++++++------
2 files changed, 50 insertions(+), 30 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index d3dbefc..1d70016 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -58,7 +58,6 @@ static const char const _str_zero[] = "0";
static const char const _str_one[] = "1";
static const char const _str_no[] = "no";
static const char const _str_yes[] = "yes";
-static const char const _str_minus_one[] = "-1";
static const char const _str_unknown[] = "unknown";
/*
@@ -82,20 +81,26 @@ static const int32_t _reserved_number_undef_32 = INT32_C(-1);
* - 'reserved_value_id_y' (for 1)
* - 'reserved_value_id_n' (for 0)
*/
+#define RESERVED(id) _reserved_ ## id
#define FIRST_NAME(id) _reserved_ ## id ## _names[0]
+
+#define NUM uint64_t
+
#define TYPE_RESERVED_VALUE(type, id, value, ...) \
static const char *_reserved_ ## id ## _names[] = { __VA_ARGS__, NULL}; \
static const type _reserved_ ## id = value;
+
#define FIELD_RESERVED_VALUE(field_id, id, value, ...) \
static const char *_reserved_ ## id ## _names[] = { __VA_ARGS__ , NULL}; \
static const struct dm_report_field_reserved_value _reserved_ ## id = {field_ ## field_id, &value};
+
#define FIELD_RESERVED_BINARY_VALUE(field_id, id, ...) \
FIELD_RESERVED_VALUE(field_id, id ## _y, _one64, __VA_ARGS__, _str_yes) \
FIELD_RESERVED_VALUE(field_id, id ## _n, _zero64, __VA_ARGS__, _str_no)
-TYPE_RESERVED_VALUE(uint64_t, number_undef_64, UINT64_C(-1), _str_minus_one, _str_unknown, "undefined", "undef");
#include "values.h"
+#undef NUM
#undef TYPE_RESERVED_VALUE
#undef FIELD_RESERVED_VALUE
#undef FIELD_RESERVED_BINARY_VALUE
@@ -110,14 +115,19 @@ TYPE_RESERVED_VALUE(uint64_t, number_undef_64, UINT64_C(-1), _str_minus_one, _st
* FIELD_RESERVED_VALUE_REG(reserved_value_id, description)
* FIELD_RESERVED_BINARY_BALUE_REG(reserved_value_id, description)
*/
-#define TYPE_RESERVED_VALUE_REG(type, id, description) {DM_REPORT_FIELD_TYPE_ ## type, &_reserved_ ## id, _reserved_ ## id ## _names, description},
+
+#define NUM DM_REPORT_FIELD_TYPE_NUMBER
+
+#define TYPE_RESERVED_VALUE_REG(type, id, description) {type, &_reserved_ ## id, _reserved_ ## id ## _names, description},
+
#define FIELD_RESERVED_VALUE_REG(id, description) {DM_REPORT_FIELD_TYPE_NONE, &_reserved_ ## id, _reserved_ ## id ## _names, description},
+
#define FIELD_RESERVED_BINARY_VALUE_REG(id, description) \
FIELD_RESERVED_VALUE_REG(id ## _y, description) \
FIELD_RESERVED_VALUE_REG(id ## _n, description)
static const struct dm_report_reserved_value _report_reserved_values[] = {
- TYPE_RESERVED_VALUE_REG(NUMBER, number_undef_64, "Reserved value for undefined numeric value.")
+ TYPE_RESERVED_VALUE_REG(NUM, number_undef_64, "Reserved value for undefined numeric value.")
FIELD_RESERVED_BINARY_VALUE_REG(pv_allocatable, "pv_allocatable reserved values")
FIELD_RESERVED_BINARY_VALUE_REG(pv_exported, "pv_exported reserved values")
FIELD_RESERVED_BINARY_VALUE_REG(pv_missing, "pv_missing reserved values")
@@ -151,6 +161,7 @@ static const struct dm_report_reserved_value _report_reserved_values[] = {
{0, NULL, NULL}
};
+#undef NUM
#undef TYPE_RESERVED_VALUE_REG
#undef FIELD_RESERVED_VALUE_REG
#undef FIELD_RESERVED_BINARY_VALUE_REG
@@ -190,9 +201,9 @@ static int _binary_undef_disp(struct dm_report *rh, struct dm_pool *mem __attrib
const struct cmd_context *cmd = (const struct cmd_context *) private;
if (cmd->report_binary_values_as_numeric)
- return _field_set_value(field, FIRST_NAME(number_undef_64), &_reserved_number_undef_64);
+ return _field_set_value(field, FIRST_NAME(number_undef_64), &RESERVED(number_undef_64));
else
- return _field_set_value(field, _str_unknown, &_reserved_number_undef_64);
+ return _field_set_value(field, _str_unknown, &RESERVED(number_undef_64));
}
static int _string_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -317,7 +328,7 @@ static int _lvkmaj_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(
if (lvi->info && lvi->info->exists && lvi->info->major >= 0)
return dm_report_field_int(rh, field, &lvi->info->major);
- return dm_report_field_int32(rh, field, &_reserved_number_undef_32);
+ return dm_report_field_int32(rh, field, &RESERVED(number_undef_32));
}
static int _lvkmin_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -329,7 +340,7 @@ static int _lvkmin_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(
if (lvi->info && lvi->info->exists && lvi->info->minor >= 0)
return dm_report_field_int(rh, field, &lvi->info->minor);
- return dm_report_field_int32(rh, field, &_reserved_number_undef_32);
+ return dm_report_field_int32(rh, field, &RESERVED(number_undef_32));
}
static int _lvstatus_disp(struct dm_report *rh __attribute__((unused)), struct dm_pool *mem,
@@ -654,7 +665,7 @@ static int _lvreadahead_disp(struct dm_report *rh, struct dm_pool *mem,
const struct logical_volume *lv = (const struct logical_volume *) data;
if (lv->read_ahead == DM_READ_AHEAD_AUTO)
- return _field_set_value(field, "auto", &_reserved_number_undef_64);
+ return _field_set_value(field, "auto", &RESERVED(number_undef_64));
return _size32_disp(rh, mem, field, &lv->read_ahead, private);
}
@@ -667,7 +678,7 @@ static int _lvkreadahead_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_with_info *lvi = (const struct lv_with_info *) data;
if (!lvi->info || !lvi->info->exists)
- return dm_report_field_int32(rh, field, &_reserved_number_undef_32);
+ return dm_report_field_int32(rh, field, &RESERVED(number_undef_32));
return _size32_disp(rh, mem, field, &lvi->info->read_ahead, private);
}
@@ -755,7 +766,7 @@ static int _transactionid_disp(struct dm_report *rh, struct dm_pool *mem,
if (seg_is_thin_pool(seg))
return dm_report_field_uint64(rh, field, &seg->transaction_id);
- return _field_set_value(field, "", &_reserved_number_undef_64);
+ return _field_set_value(field, "", &RESERVED(number_undef_64));
}
static int _thinid_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -767,7 +778,7 @@ static int _thinid_disp(struct dm_report *rh, struct dm_pool *mem,
if (seg_is_thin_volume(seg))
return dm_report_field_uint32(rh, field, &seg->device_id);
- return _field_set_value(field, "", &_reserved_number_undef_64);
+ return _field_set_value(field, "", &RESERVED(number_undef_64));
}
static int _discards_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -933,7 +944,7 @@ static int _vgmdacopies_disp(struct dm_report *rh, struct dm_pool *mem,
uint32_t count = vg_mda_copies(vg);
if (count == VGMETADATACOPIES_UNMANAGED)
- return _field_set_value(field, "unmanaged", &_reserved_number_undef_64);
+ return _field_set_value(field, "unmanaged", &RESERVED(number_undef_64));
return _uint32_disp(rh, mem, field, &count, private);
}
@@ -1095,7 +1106,7 @@ static int _raidmismatchcount_disp(struct dm_report *rh __attribute__((unused)),
if (lv_is_raid(lv) && lv_raid_mismatch_count(lv, &mismatch_count))
return dm_report_field_uint64(rh, field, &mismatch_count);
- return _field_set_value(field, "", &_reserved_number_undef_64);
+ return _field_set_value(field, "", &RESERVED(number_undef_64));
}
static int _raidwritebehind_disp(struct dm_report *rh __attribute__((unused)),
@@ -1109,7 +1120,7 @@ static int _raidwritebehind_disp(struct dm_report *rh __attribute__((unused)),
if (lv_is_raid_type(lv) && first_seg(lv)->writebehind)
return dm_report_field_uint32(rh, field, &first_seg(lv)->writebehind);
- return _field_set_value(field, "", &_reserved_number_undef_64);
+ return _field_set_value(field, "", &RESERVED(number_undef_64));
}
static int _raidminrecoveryrate_disp(struct dm_report *rh __attribute__((unused)),
@@ -1124,7 +1135,7 @@ static int _raidminrecoveryrate_disp(struct dm_report *rh __attribute__((unused)
return dm_report_field_uint32(rh, field,
&first_seg(lv)->min_recovery_rate);
- return _field_set_value(field, "", &_reserved_number_undef_64);
+ return _field_set_value(field, "", &RESERVED(number_undef_64));
}
static int _raidmaxrecoveryrate_disp(struct dm_report *rh __attribute__((unused)),
@@ -1139,7 +1150,7 @@ static int _raidmaxrecoveryrate_disp(struct dm_report *rh __attribute__((unused)
return dm_report_field_uint32(rh, field,
&first_seg(lv)->max_recovery_rate);
- return _field_set_value(field, "", &_reserved_number_undef_64);
+ return _field_set_value(field, "", &RESERVED(number_undef_64));
}
/* Called only with lv_is_thin_pool/volume */
@@ -1192,7 +1203,7 @@ static int _metadatapercent_disp(struct dm_report *rh,
if (lv_is_thin_pool(lv))
return _dtpercent_disp(1, rh, field, data, private);
- return _field_set_value(field, "", &_reserved_number_undef_64);
+ return _field_set_value(field, "", &RESERVED(number_undef_64));
}
static int _lvmetadatasize_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1207,7 +1218,7 @@ static int _lvmetadatasize_disp(struct dm_report *rh, struct dm_pool *mem,
return _size64_disp(rh, mem, field, &size, private);
}
- return _field_set_value(field, "", &_reserved_number_undef_64);
+ return _field_set_value(field, "", &RESERVED(number_undef_64));
}
static int _thincount_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1222,7 +1233,7 @@ static int _thincount_disp(struct dm_report *rh, struct dm_pool *mem,
return _uint32_disp(rh, mem, field, &count, private);
}
- return _field_set_value(field, "", &_reserved_number_undef_64);
+ return _field_set_value(field, "", &RESERVED(number_undef_64));
}
static int _lvtime_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1518,7 +1529,7 @@ static int _lvmergefailed_disp(struct dm_report *rh, struct dm_pool *mem,
int merge_failed;
if (!lv_is_cow(lv) || !lv_snapshot_percent(lv, &snap_percent))
- return _field_set_value(field, _str_unknown, &_reserved_number_undef_64);
+ return _field_set_value(field, _str_unknown, &RESERVED(number_undef_64));
merge_failed = snap_percent == LVM_PERCENT_MERGE_FAILED;
return _binary_disp(rh, mem, field, merge_failed, FIRST_NAME(lv_merge_failed_y), private);
@@ -1533,7 +1544,7 @@ static int _lvsnapshotinvalid_disp(struct dm_report *rh, struct dm_pool *mem,
int snap_invalid;
if (!lv_is_cow(lv))
- return _field_set_value(field, _str_unknown, &_reserved_number_undef_64);
+ return _field_set_value(field, _str_unknown, &RESERVED(number_undef_64));
snap_invalid = !lv_snapshot_percent(lv, &snap_percent) || snap_percent == DM_PERCENT_INVALID;
return _binary_disp(rh, mem, field, snap_invalid, FIRST_NAME(lv_snapshot_invalid_y), private);
@@ -1619,7 +1630,7 @@ static int _thinzero_disp(struct dm_report *rh, struct dm_pool *mem,
if (seg_is_thin_pool(seg))
return _uint32_disp(rh, mem, field, &seg->zero_new_blocks, private);
- return _field_set_value(field, "", &_reserved_number_undef_64);
+ return _field_set_value(field, "", &RESERVED(number_undef_64));
}
static int _lvhealthstatus_disp(struct dm_report *rh, struct dm_pool *mem,
diff --git a/lib/report/values.h b/lib/report/values.h
index 4566057..5c4b5ab 100644
--- a/lib/report/values.h
+++ b/lib/report/values.h
@@ -19,22 +19,31 @@
* uses the exact value defined whenever the reserved name is hit, for
* example during selection criteria processing.
*
- * FIELD_RESERVED_VALUE can be used for any field.
+ * TYPE_RESERVED_VALUE defines reserved value that is not bound to any field,
+ * but rather it's bound to a certain type. This can be used as a reserved
+ * value for all fields of that type then.
*
- * FIELD_BINARY_RESERVED_VALUE is specifically designed for fields with
- * binary values where the reserved names given denote the value 1.
+ * FIELD_RESERVED_VALUE defines reserved value bound to a single field.
+ *
+ * FIELD_BINARY_RESERVED_VALUE is similar to FIELD_RESERVED_VALUE but it
+ * is specifically designed for defintion of reserved names for fields
+ * with binary values where the reserved names given denote value 1.
* The first reserved_name given is also used for reporting,
- * others are synonyms.
+ * others are synonyms which are recognized in addition.
*
*/
/*
- * FIELD_RESERVED_VALUE(field_id, reserved_value_id, reserved_name, ...)
+ * TYPE_RESERVED_VALUE(type, id, value, reserved_name, ...)
+ * FIELD_RESERVED_VALUE(field_id, reserved_value_id, value, reserved_name, ...)
* FIELD_BINARY_RESERVED_VALUE(field_id, reserved_value_id, reserved_name, ...)
*/
/* *INDENT-OFF* */
+/* Per-type reserved values usable for all fields of certain type. */
+TYPE_RESERVED_VALUE(NUM, number_undef_64, UINT64_C(-1), "-1", "unknown", "undefined", "undef");
+
/* Reserved values for PV fields */
FIELD_RESERVED_BINARY_VALUE(pv_allocatable, pv_allocatable, "allocatable")
FIELD_RESERVED_BINARY_VALUE(pv_exported, pv_exported, "exported")
@@ -47,7 +56,7 @@ FIELD_RESERVED_BINARY_VALUE(vg_partial, vg_partial, "partial")
FIELD_RESERVED_BINARY_VALUE(vg_clustered, vg_clustered, "clustered")
FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_rw, FIRST_NAME(vg_permissions_rw), "writeable", "rw", "read-write")
FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_r, FIRST_NAME(vg_permissions_r), "read-only", "r", "ro")
-FIELD_RESERVED_VALUE(vg_mda_copies, vg_mda_copies, _reserved_number_undef_64, "unmanaged")
+FIELD_RESERVED_VALUE(vg_mda_copies, vg_mda_copies, RESERVED(number_undef_64), "unmanaged")
/* Reserved values for LV fields */
FIELD_RESERVED_BINARY_VALUE(lv_initial_image_sync, lv_initial_image_sync, "initial image sync", "sync")
@@ -69,6 +78,6 @@ FIELD_RESERVED_BINARY_VALUE(lv_skip_activation, lv_skip_activation, "skip activa
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_rw, FIRST_NAME(lv_permissions_rw), "writeable", "rw", "read-write")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, FIRST_NAME(lv_permissions_r), "read-only", "r", "ro")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, FIRST_NAME(lv_permissions_r_override), "read-only-override", "ro-override", "r-override", "R")
-FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead, _reserved_number_undef_64, "auto")
+FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead, RESERVED(number_undef_64), "auto")
/* *INDENT-ON* */
9 years, 9 months
master - conf: command_profile_template: global/binary_values_as_numeric -> report/binary_values_as_numeric
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fafd10d564151b...
Commit: fafd10d564151b91e814f6be3e735bdf0b7d33dd
Parent: a4e798bd304253b91b906ca77988b11576685d72
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Jul 10 09:48:45 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jul 10 09:48:45 2014 +0200
conf: command_profile_template: global/binary_values_as_numeric -> report/binary_values_as_numeric
---
conf/command_profile_template.profile.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/conf/command_profile_template.profile.in b/conf/command_profile_template.profile.in
index 592a69d..7401aa5 100644
--- a/conf/command_profile_template.profile.in
+++ b/conf/command_profile_template.profile.in
@@ -13,7 +13,6 @@
#
global {
units="h"
- report_binary_values_as_numeric=0
si_unit_consistency=1
suffix=1
lvdisplay_shows_full_device_path=0
@@ -26,6 +25,7 @@ report {
prefixes=0
quoted=1
colums_as_rows=0
+ binary_values_as_numeric=0
devtypes_sort="devtype_name"
devtypes_cols="devtype_name,devtype_max_partitions,devtype_description"
devtypes_cols_verbose="devtype_name,devtype_max_partitions,devtype_description"
9 years, 9 months
master - report: add values.h for per-field reserved value declaration
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a4e798bd304253...
Commit: a4e798bd304253b91b906ca77988b11576685d72
Parent: be75076dfc842945a03fa42073e9e03f51bd3a3c
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Jul 10 09:22:45 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jul 10 09:41:21 2014 +0200
report: add values.h for per-field reserved value declaration
---
lib/report/report.c | 78 +++++++++++++++++++++------------------------------
lib/report/values.h | 74 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 106 insertions(+), 46 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index a2f4541..d3dbefc 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -68,17 +68,6 @@ static const char const _str_unknown[] = "unknown";
*/
static const int32_t _reserved_number_undef_32 = INT32_C(-1);
-#define FIRST_NAME(id) _reserved_ ## id ## _names[0]
-#define TYPE_RESERVED_VALUE(type, id, value, ...) \
- static const char *_reserved_ ## id ## _names[] = { __VA_ARGS__, NULL}; \
- static const type _reserved_ ## id = value;
-#define FIELD_RESERVED_VALUE(field_id, id, value, ...) \
- static const char *_reserved_ ## id ## _names[] = { __VA_ARGS__ , NULL}; \
- static const struct dm_report_field_reserved_value _reserved_ ## id = {field_ ## field_id, &value};
-#define FIELD_RESERVED_BINARY_VALUE(field_id, id, ...) \
- FIELD_RESERVED_VALUE(field_id, id ## _y, _one64, __VA_ARGS__, _str_yes) \
- FIELD_RESERVED_VALUE(field_id, id ## _n, _zero64, __VA_ARGS__, _str_no)
-
/*
* Reserved values and their assigned names.
* The first name is the one that is also used for reporting.
@@ -89,51 +78,44 @@ static const int32_t _reserved_number_undef_32 = INT32_C(-1);
* FIELD_RESERVED_VALUE(field_id, reserved_value_id, value, reserved name, ...)
* FIELD_RESERVED_BINARY_VALUE(field_id, reserved_value_id, value, reserved name for 1, ...)
*
+ * Note: FIELD_RESERVED_BINARY_VALUE creates:
+ * - 'reserved_value_id_y' (for 1)
+ * - 'reserved_value_id_n' (for 0)
*/
+#define FIRST_NAME(id) _reserved_ ## id ## _names[0]
+#define TYPE_RESERVED_VALUE(type, id, value, ...) \
+ static const char *_reserved_ ## id ## _names[] = { __VA_ARGS__, NULL}; \
+ static const type _reserved_ ## id = value;
+#define FIELD_RESERVED_VALUE(field_id, id, value, ...) \
+ static const char *_reserved_ ## id ## _names[] = { __VA_ARGS__ , NULL}; \
+ static const struct dm_report_field_reserved_value _reserved_ ## id = {field_ ## field_id, &value};
+#define FIELD_RESERVED_BINARY_VALUE(field_id, id, ...) \
+ FIELD_RESERVED_VALUE(field_id, id ## _y, _one64, __VA_ARGS__, _str_yes) \
+ FIELD_RESERVED_VALUE(field_id, id ## _n, _zero64, __VA_ARGS__, _str_no)
TYPE_RESERVED_VALUE(uint64_t, number_undef_64, UINT64_C(-1), _str_minus_one, _str_unknown, "undefined", "undef");
-FIELD_RESERVED_BINARY_VALUE(pv_allocatable, pv_allocatable, "allocatable")
-FIELD_RESERVED_BINARY_VALUE(pv_exported, pv_exported, "exported")
-FIELD_RESERVED_BINARY_VALUE(pv_missing, pv_missing, "missing")
-FIELD_RESERVED_BINARY_VALUE(vg_extendable, vg_extendable, "extendable")
-FIELD_RESERVED_BINARY_VALUE(vg_exported, vg_exported, "exported")
-FIELD_RESERVED_BINARY_VALUE(vg_partial, vg_partial, "partial")
-FIELD_RESERVED_BINARY_VALUE(vg_clustered, vg_clustered, "clustered")
-FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_rw, FIRST_NAME(vg_permissions_rw), "writeable", "rw", "read_write")
-FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_r, FIRST_NAME(vg_permissions_r), "read-only", "r", "ro")
-FIELD_RESERVED_VALUE(vg_mda_copies, vg_mda_copies, _reserved_number_undef_64, "unmanaged")
-FIELD_RESERVED_BINARY_VALUE(lv_initial_image_sync, lv_initial_image_sync, "initial image sync", "sync")
-FIELD_RESERVED_BINARY_VALUE(lv_image_synced, lv_image_synced, "image synced", "synced")
-FIELD_RESERVED_BINARY_VALUE(lv_merging, lv_merging, "merging")
-FIELD_RESERVED_BINARY_VALUE(lv_converting, lv_converting, "converting")
-FIELD_RESERVED_BINARY_VALUE(lv_allocation_locked, lv_allocation_locked, "allocation locked", "locked")
-FIELD_RESERVED_BINARY_VALUE(lv_fixed_minor, lv_fixed_minor, "fixed minor", "fixed")
-FIELD_RESERVED_BINARY_VALUE(lv_active_locally, lv_active_locally, "active locally", "active", "locally")
-FIELD_RESERVED_BINARY_VALUE(lv_active_remotely, lv_active_remotely, "active remotely", "active", "remotely")
-FIELD_RESERVED_BINARY_VALUE(lv_active_exclusively, lv_active_exclusively, "active exclusively", "active", "exclusively")
-FIELD_RESERVED_BINARY_VALUE(lv_merge_failed, lv_merge_failed, "merge failed", "failed")
-FIELD_RESERVED_BINARY_VALUE(lv_snapshot_invalid, lv_snapshot_invalid, "snapsot invalid", "invalid")
-FIELD_RESERVED_BINARY_VALUE(lv_suspended, lv_suspended, "suspended")
-FIELD_RESERVED_BINARY_VALUE(lv_live_table, lv_live_table, "live table present", "live table", "live")
-FIELD_RESERVED_BINARY_VALUE(lv_inactive_table, lv_inactive_table, "inactive table present", "inactive table", "inactive")
-FIELD_RESERVED_BINARY_VALUE(lv_device_open, lv_device_open, "open")
-FIELD_RESERVED_BINARY_VALUE(lv_skip_activation, lv_skip_activation, "skip activation", "skip")
-FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_rw, FIRST_NAME(lv_permissions_rw), "writeable", "rw", "read-write")
-FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, FIRST_NAME(lv_permissions_r), "read-only", "r", "ro")
-FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, FIRST_NAME(lv_permissions_r_override), "read-only-override", "ro-override", "r-override", "R")
-FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead, _reserved_number_undef_64, "auto")
+#include "values.h"
+#undef TYPE_RESERVED_VALUE
+#undef FIELD_RESERVED_VALUE
+#undef FIELD_RESERVED_BINARY_VALUE
+
+/*
+ * Create array of reserved values to be registered with reporting code via
+ * dm_report_init_with_selection function that initializes report with
+ * selection criteria. Selection code then recognizes these reserved values
+ * when parsing selection criteria.
+ *
+ * TYPE_RESERVED_VALUE_REG(report_type, reserved_value_id, description)
+ * FIELD_RESERVED_VALUE_REG(reserved_value_id, description)
+ * FIELD_RESERVED_BINARY_BALUE_REG(reserved_value_id, description)
+ */
#define TYPE_RESERVED_VALUE_REG(type, id, description) {DM_REPORT_FIELD_TYPE_ ## type, &_reserved_ ## id, _reserved_ ## id ## _names, description},
#define FIELD_RESERVED_VALUE_REG(id, description) {DM_REPORT_FIELD_TYPE_NONE, &_reserved_ ## id, _reserved_ ## id ## _names, description},
#define FIELD_RESERVED_BINARY_VALUE_REG(id, description) \
FIELD_RESERVED_VALUE_REG(id ## _y, description) \
FIELD_RESERVED_VALUE_REG(id ## _n, description)
-/*
- * Create array of reserved values to be passed for dm_report_init_with_selection
- * function that initializes report with selection criteria. Selection code then
- * recognizes these reserved values when parsing selection criteria.
- */
static const struct dm_report_reserved_value _report_reserved_values[] = {
TYPE_RESERVED_VALUE_REG(NUMBER, number_undef_64, "Reserved value for undefined numeric value.")
FIELD_RESERVED_BINARY_VALUE_REG(pv_allocatable, "pv_allocatable reserved values")
@@ -169,6 +151,10 @@ static const struct dm_report_reserved_value _report_reserved_values[] = {
{0, NULL, NULL}
};
+#undef TYPE_RESERVED_VALUE_REG
+#undef FIELD_RESERVED_VALUE_REG
+#undef FIELD_RESERVED_BINARY_VALUE_REG
+
static int _field_set_value(struct dm_report_field *field, const void *data, const void *sort)
{
dm_report_field_set_value(field, data, sort);
diff --git a/lib/report/values.h b/lib/report/values.h
new file mode 100644
index 0000000..4566057
--- /dev/null
+++ b/lib/report/values.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * 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
+ */
+
+/*
+ * This file defines reserved names for field values.
+ *
+ * This is used for registering reserved names with reporting code that
+ * uses the exact value defined whenever the reserved name is hit, for
+ * example during selection criteria processing.
+ *
+ * FIELD_RESERVED_VALUE can be used for any field.
+ *
+ * FIELD_BINARY_RESERVED_VALUE is specifically designed for fields with
+ * binary values where the reserved names given denote the value 1.
+ * The first reserved_name given is also used for reporting,
+ * others are synonyms.
+ *
+ */
+
+/*
+ * FIELD_RESERVED_VALUE(field_id, reserved_value_id, reserved_name, ...)
+ * FIELD_BINARY_RESERVED_VALUE(field_id, reserved_value_id, reserved_name, ...)
+ */
+
+/* *INDENT-OFF* */
+
+/* Reserved values for PV fields */
+FIELD_RESERVED_BINARY_VALUE(pv_allocatable, pv_allocatable, "allocatable")
+FIELD_RESERVED_BINARY_VALUE(pv_exported, pv_exported, "exported")
+FIELD_RESERVED_BINARY_VALUE(pv_missing, pv_missing, "missing")
+
+/* Reserved values for VG fields */
+FIELD_RESERVED_BINARY_VALUE(vg_extendable, vg_extendable, "extendable")
+FIELD_RESERVED_BINARY_VALUE(vg_exported, vg_exported, "exported")
+FIELD_RESERVED_BINARY_VALUE(vg_partial, vg_partial, "partial")
+FIELD_RESERVED_BINARY_VALUE(vg_clustered, vg_clustered, "clustered")
+FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_rw, FIRST_NAME(vg_permissions_rw), "writeable", "rw", "read-write")
+FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_r, FIRST_NAME(vg_permissions_r), "read-only", "r", "ro")
+FIELD_RESERVED_VALUE(vg_mda_copies, vg_mda_copies, _reserved_number_undef_64, "unmanaged")
+
+/* Reserved values for LV fields */
+FIELD_RESERVED_BINARY_VALUE(lv_initial_image_sync, lv_initial_image_sync, "initial image sync", "sync")
+FIELD_RESERVED_BINARY_VALUE(lv_image_synced, lv_image_synced, "image synced", "synced")
+FIELD_RESERVED_BINARY_VALUE(lv_merging, lv_merging, "merging")
+FIELD_RESERVED_BINARY_VALUE(lv_converting, lv_converting, "converting")
+FIELD_RESERVED_BINARY_VALUE(lv_allocation_locked, lv_allocation_locked, "allocation locked", "locked")
+FIELD_RESERVED_BINARY_VALUE(lv_fixed_minor, lv_fixed_minor, "fixed minor", "fixed")
+FIELD_RESERVED_BINARY_VALUE(lv_active_locally, lv_active_locally, "active locally", "active", "locally")
+FIELD_RESERVED_BINARY_VALUE(lv_active_remotely, lv_active_remotely, "active remotely", "active", "remotely")
+FIELD_RESERVED_BINARY_VALUE(lv_active_exclusively, lv_active_exclusively, "active exclusively", "active", "exclusively")
+FIELD_RESERVED_BINARY_VALUE(lv_merge_failed, lv_merge_failed, "merge failed", "failed")
+FIELD_RESERVED_BINARY_VALUE(lv_snapshot_invalid, lv_snapshot_invalid, "snapshot invalid", "invalid")
+FIELD_RESERVED_BINARY_VALUE(lv_suspended, lv_suspended, "suspended")
+FIELD_RESERVED_BINARY_VALUE(lv_live_table, lv_live_table, "live table present", "live table", "live")
+FIELD_RESERVED_BINARY_VALUE(lv_inactive_table, lv_inactive_table, "inactive table present", "inactive table", "inactive")
+FIELD_RESERVED_BINARY_VALUE(lv_device_open, lv_device_open, "open")
+FIELD_RESERVED_BINARY_VALUE(lv_skip_activation, lv_skip_activation, "skip activation", "skip")
+FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_rw, FIRST_NAME(lv_permissions_rw), "writeable", "rw", "read-write")
+FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, FIRST_NAME(lv_permissions_r), "read-only", "r", "ro")
+FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, FIRST_NAME(lv_permissions_r_override), "read-only-override", "ro-override", "r-override", "R")
+FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead, _reserved_number_undef_64, "auto")
+
+/* *INDENT-ON* */
9 years, 9 months
master - activation: Add "degraded" activation mode
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=be75076dfc8429...
Commit: be75076dfc842945a03fa42073e9e03f51bd3a3c
Parent: a098cba0ebbd0682570cff2fc756a59533321f03
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Jul 9 22:56:11 2014 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Jul 9 22:56:11 2014 -0500
activation: Add "degraded" activation mode
Currently, we have two modes of activation, an unnamed nominal mode
(which I will refer to as "complete") and "partial" mode. The
"complete" mode requires that a volume group be 'complete' - that
is, no missing PVs. If there are any missing PVs, no affected LVs
are allowed to activate - even RAID LVs which might be able to
tolerate a failure. The "partial" mode allows anything to be
activated (or at least attempted). If a non-redundant LV is
missing a portion of its addressable space due to a device failure,
it will be replaced with an error target. RAID LVs will either
activate or fail to activate depending on how badly their
redundancy is compromised.
This patch adds a third option, "degraded" mode. This mode can
be selected via the '--activationmode {complete|degraded|partial}'
option to lvchange/vgchange. It can also be set in lvm.conf.
The "degraded" activation mode allows RAID LVs with a sufficient
level of redundancy to activate (e.g. a RAID5 LV with one device
failure, a RAID6 with two device failures, or RAID1 with n-1
failures). RAID LVs with too many device failures are not allowed
to activate - nor are any non-redundant LVs that may have been
affected. This patch also makes the "degraded" mode the default
activation mode.
The degraded activation mode does not yet work in a cluster. A
new cluster lock flag (LCK_DEGRADED_MODE) will need to be created
to make that work. Currently, there is limited space for this
extra flag and I am looking for possible solutions. One possible
solution is to usurp LCK_CONVERT, as it is not used. When the
locking_type is 3, the degraded mode flag simply gets dropped and
the old ("complete") behavior is exhibited.
---
WHATS_NEW | 1 +
conf/example.conf.in | 25 +++++++++
lib/activate/activate.c | 120 ++++++++++++++++++++++++++++++++++++++++-
lib/activate/dev_manager.c | 9 ++-
lib/commands/toolcontext.h | 1 +
lib/config/config_settings.h | 1 +
lib/config/defaults.h | 1 +
man/lvchange.8.in | 19 +++++++
man/vgchange.8.in | 18 ++++++
tools/args.h | 2 +
tools/commands.h | 8 ++-
tools/lvmcmdline.c | 28 +++++++++-
tools/toollib.c | 3 +-
13 files changed, 226 insertions(+), 10 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 21668f2..29a0aa3 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.108 -
=================================
+ Add "degraded" activation mode and make it the default.
Add separate lv_active_{locally,remotely,exclusively} LV reporting fields.
Recognize "auto"/"unmanaged" values in selection for appropriate fields only.
Add report/binary_values_as_numeric lvm.conf option for binary values as 0/1.
diff --git a/conf/example.conf.in b/conf/example.conf.in
index e1afbb6..11f50f0 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -1011,6 +1011,31 @@ activation {
# are no progress reports, but the process is awoken immediately the
# operation is complete.
polling_interval = 15
+
+ # 'activation_mode' determines how logical volumes are activated if
+ # devices are missing. Possible settings are:
+ #
+ # "complete" - Only allow activation of an LV if all of the PVs
+ # that it uses are available (i.e. the volume group
+ # is complete). There may be a failed PV in the
+ # volume group; but if a particular LV is not on that
+ # PV, it is still allowed to activate in this mode.
+ #
+ # "degraded" - Like "complete", except that RAID logical volumes of
+ # segment type "raid{1,4,5,6,10}" are activated if
+ # they have sufficient redundancy to present the entire
+ # addressable range of the logical volume.
+ #
+ # "partial" - Allow activation for any logical volume - even if
+ # a missing or failed PV would cause a portion of the
+ # logical volume to be inaccessible. (E.g. a stripe
+ # volume that has lost one of its members would be
+ # unable to access a portion of the logical volume.)
+ # This setting is not recommended for normal use.
+ #
+ # This setting was introduced in LVM version 2.02.108. It corresponds
+ # with the '--activationmode' option for lvchange and vgchange.
+ activation_mode = "degraded"
}
# Report settings.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index adaff52..70777fd 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2203,6 +2203,111 @@ out:
return r;
}
+static int _lv_raid_is_redundant(struct logical_volume *lv)
+{
+ struct lv_segment *raid_seg = first_seg(lv);
+ uint32_t copies;
+ uint32_t i, s, rebuilds_per_group = 0;
+ uint32_t failed_components = 0;
+
+ if (!(lv->status & PARTIAL_LV)) {
+ /*
+ * Redundant, but this function shouldn't
+ * be called in this case.
+ */
+ log_error(INTERNAL_ERROR "%s is not a partial LV", lv->name);
+ return 1;
+ }
+
+ if (!lv_is_raid(lv))
+ return 0; /* Not RAID, not redundant */
+
+ if (!strcmp(raid_seg->segtype->name, "raid10")) {
+ /* FIXME: We only support 2-way mirrors in RAID10 currently */
+ copies = 2;
+ for (i = 0; i < raid_seg->area_count * copies; i++) {
+ s = i % raid_seg->area_count;
+ if (!(i % copies))
+ rebuilds_per_group = 0;
+ if ((seg_lv(raid_seg, s)->status & PARTIAL_LV) ||
+ (seg_metalv(raid_seg, s)->status & PARTIAL_LV) ||
+ lv_is_virtual(seg_lv(raid_seg, s)) ||
+ lv_is_virtual(seg_metalv(raid_seg, s)))
+ rebuilds_per_group++;
+ if (rebuilds_per_group >= copies) {
+ log_debug("An entire mirror group "
+ "has failed in %s", lv->name);
+ return 0; /* Not redundant */
+ }
+ }
+ return 1; /* Redundant */
+ }
+
+ for (s = 0; s < raid_seg->area_count; s++) {
+ if ((seg_lv(raid_seg, s)->status & PARTIAL_LV) ||
+ (seg_metalv(raid_seg, s)->status & PARTIAL_LV) ||
+ lv_is_virtual(seg_lv(raid_seg, s)) ||
+ lv_is_virtual(seg_metalv(raid_seg, s)))
+ failed_components++;
+ }
+ if (failed_components == raid_seg->area_count) {
+ log_debug("All components in %s have failed", lv->name);
+ return 0;
+ } else if (raid_seg->segtype->parity_devs &&
+ (failed_components > raid_seg->segtype->parity_devs)) {
+ log_debug("More than %u components from (%s) %s/%s have failed",
+ raid_seg->segtype->parity_devs,
+ raid_seg->segtype->ops->name(raid_seg),
+ lv->vg->name, lv->name);
+ return 0;
+ }
+
+ return 1;
+}
+
+static int _lv_is_not_degraded_capable(struct logical_volume *lv, void *data)
+{
+ int *not_capable = (int *)data;
+ uint32_t s;
+ struct lv_segment *seg;
+
+ if (!(lv->status & PARTIAL_LV))
+ return 1;
+
+ if (lv_is_raid(lv))
+ return _lv_raid_is_redundant(lv);
+
+ /* Ignore RAID sub-LVs. */
+ if (lv_is_raid_type(lv))
+ return 1;
+
+ dm_list_iterate_items(seg, &lv->segments)
+ for (s = 0; s < seg->area_count; s++)
+ if (seg_type(seg, s) != AREA_LV) {
+ log_debug("%s is not capable of degraded mode",
+ lv->name);
+ *not_capable = 1;
+ }
+
+ return 1;
+}
+
+static int lv_is_degraded_capable(struct logical_volume *lv)
+{
+ int not_capable = 0;
+
+ if (!(lv->status & PARTIAL_LV))
+ return 1;
+
+ if (!_lv_is_not_degraded_capable(lv, ¬_capable) || not_capable)
+ return 0;
+
+ if (!for_each_sub_lv(lv, _lv_is_not_degraded_capable, ¬_capable))
+ log_error(INTERNAL_ERROR "for_each_sub_lv failure.");
+
+ return !not_capable;
+}
+
static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
struct lv_activate_opts *laopts, int filter,
struct logical_volume *lv)
@@ -2225,9 +2330,18 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
}
if ((!lv->vg->cmd->partial_activation) && (lv->status & PARTIAL_LV)) {
- log_error("Refusing activation of partial LV %s. Use --partial to override.",
- lv->name);
- goto out;
+ if (!lv_is_degraded_capable(lv)) {
+ log_error("Refusing activation of partial LV %s. "
+ "Use '--activationmode partial' to override.",
+ lv->name);
+ goto out;
+ } else if (!lv->vg->cmd->degraded_activation) {
+ log_error("Refusing activation of partial LV %s. "
+ "Try '--activationmode degraded'.",
+ lv->name);
+ goto out;
+ }
+ log_print_unless_silent("Attempting activation of partial RAID LV, %s.", lv->name);
}
if (lv_has_unknown_segments(lv)) {
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index e30b176..0305bb4 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2067,9 +2067,12 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
stat(name, &info) < 0 || !S_ISBLK(info.st_mode))) ||
(seg_type(seg, s) == AREA_LV && !seg_lv(seg, s))) {
if (!seg->lv->vg->cmd->partial_activation) {
- log_error("Aborting. LV %s is now incomplete "
- "and --partial was not specified.", seg->lv->name);
- return 0;
+ if (!seg->lv->vg->cmd->degraded_activation ||
+ !lv_is_raid_type(seg->lv)) {
+ log_error("Aborting. LV %s is now incomplete "
+ "and '--activationmode partial' was not specified.", seg->lv->name);
+ return 0;
+ }
}
if (!_add_error_area(dm, node, seg, s))
return_0;
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 162af55..d06dd7d 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -86,6 +86,7 @@ struct cmd_context {
unsigned handles_unknown_segments:1;
unsigned use_linear_target:1;
unsigned partial_activation:1;
+ unsigned degraded_activation:1;
unsigned auto_set_activation_skip:1;
unsigned si_unit_consistency:1;
unsigned report_binary_values_as_numeric:1;
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 2ddf888..7289a04 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -212,6 +212,7 @@ cfg(activation_use_mlockall_CFG, "use_mlockall", activation_CFG_SECTION, 0, CFG_
cfg(activation_monitoring_CFG, "monitoring", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_DMEVENTD_MONITOR, vsn(2, 2, 63), NULL)
cfg(activation_polling_interval_CFG, "polling_interval", activation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_INTERVAL, vsn(2, 2, 63), NULL)
cfg(activation_auto_set_activation_skip_CFG, "auto_set_activation_skip", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_AUTO_SET_ACTIVATION_SKIP, vsn(2,2,99), NULL)
+cfg(activation_mode_CFG, "activation_mode", activation_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_ACTIVATION_MODE, vsn(2,2,108), NULL)
cfg(metadata_pvmetadatacopies_CFG, "pvmetadatacopies", metadata_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_INT, DEFAULT_PVMETADATACOPIES, vsn(1, 0, 0), NULL)
cfg(metadata_vgmetadatacopies_CFG, "vgmetadatacopies", metadata_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_INT, DEFAULT_VGMETADATACOPIES, vsn(2, 2, 69), NULL)
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 4200dc8..086f7fd 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -163,6 +163,7 @@
#define DEFAULT_PROCESS_PRIORITY -18
#define DEFAULT_AUTO_SET_ACTIVATION_SKIP 1
+#define DEFAULT_ACTIVATION_MODE "degraded"
#define DEFAULT_USE_LINEAR_TARGET 1
#define DEFAULT_STRIPE_FILLER "error"
#define DEFAULT_RAID_REGION_SIZE 512 /* KB */
diff --git a/man/lvchange.8.in b/man/lvchange.8.in
index f7aee8f..39187f0 100644
--- a/man/lvchange.8.in
+++ b/man/lvchange.8.in
@@ -9,6 +9,8 @@ lvchange \(em change attributes of a logical volume
.RI { y | n }]
.RB [ \-a | \-\-activate
.RI [ a | e | l ]{ y | n }]
+.RB [ \-\-activationmode
+.IR { complete | degraded | partial } ]
.RB [ \-k | \-\-setactivationskip { y | n } ]
.RB [ \-K | \-\-ignoreactivationskip ]
.RB [ \-\-alloc
@@ -18,6 +20,7 @@ lvchange \(em change attributes of a logical volume
.RB [ \-C | \-\-contiguous
.RI { y | n }]
.RB [ \-d | \-\-debug ]
+.RB [ \-\-degraded ]
.RB [ \-\-deltag
.IR Tag ]
.RB [ \-\-detachprofile ]
@@ -97,6 +100,22 @@ To deactivate only on the local node use -aln.
Logical volumes with single-host snapshots are always activated
exclusively because they can only be used on one node at once.
.TP
+.BR \-\-activationmode " {" \fIcomplete | \fIdegraded | \fIpartial }
+The activation mode determines whether logical volumes are allowed to
+activate when there are physical volumes missing (e.g. due to a device
+failure). \fIcomplete is the most restrictive; allowing only those
+logical volumes to be activated that are not affected by the missing
+PVs. \fIdegraded allows RAID logical volumes to be activated even if
+they have PVs missing. (Note that the "mirror" segment type is not
+considered a RAID logical volume. The "raid1" segment type should
+be used instead.) Finally, \fIpartial allows any logical volume to
+be activated even if portions are missing due to a missing or failed
+PV. This last option should only be used when performing recovery or
+repair operations. \fIdegraded is the default mode. To change it, modify
+.B activation_mode
+in
+.BR lvm.conf (5).
+.TP
.BR \-k ", " \-\-setactivationskip " {" \fIy | \fIn }
Controls whether Logical Volumes are persistently flagged to be
skipped during activation. By default, thin snapshot volumes are
diff --git a/man/vgchange.8.in b/man/vgchange.8.in
index 9ea2f65..150b77d 100644
--- a/man/vgchange.8.in
+++ b/man/vgchange.8.in
@@ -12,6 +12,8 @@ vgchange \(em change attributes of a volume group
.RB [ \-a | \-\-activate
.RI [ a | e | l ]
.RI { y | n }]
+.RB [ \-\-activationmode
+.IR { complete | degraded | partial } ]
.RB [ \-K | \-\-ignoreactivationskip ]
.RB [ \-\-monitor
.RI { y | n }]
@@ -98,6 +100,22 @@ on the local node.
Logical volumes with single-host snapshots are always activated
exclusively because they can only be used on one node at once.
.TP
+.BR \-\-activationmode " {" \fIcomplete | \fIdegraded | \fIpartial }
+The activation mode determines whether logical volumes are allowed to
+activate when there are physical volumes missing (e.g. due to a device
+failure). \fIcomplete is the most restrictive; allowing only those
+logical volumes to be activated that are not affected by the missing
+PVs. \fIdegraded allows RAID logical volumes to be activated even if
+they have PVs missing. (Note that the "mirror" segment type is not
+considered a RAID logical volume. The "raid1" segment type should
+be used instead.) Finally, \fIpartial allows any logical volume to
+be activated even if portions are missing due to a missing or failed
+PV. This last option should only be used when performing recovery or
+repair operations. \fIdegraded is the default mode. To change it, modify
+.B activation_mode
+in
+.BR lvm.conf (5).
+.TP
.BR \-K ", " \-\-ignoreactivationskip
Ignore the flag to skip Logical Volumes during activation.
.TP
diff --git a/tools/args.h b/tools/args.h
index d4a8643..9632478 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -109,6 +109,8 @@ arg(ignoreskippedcluster_ARG, '\0', "ignoreskippedcluster", NULL, 0)
arg(splitsnapshot_ARG, '\0', "splitsnapshot", NULL, 0)
arg(readonly_ARG, '\0', "readonly", NULL, 0)
arg(atomic_ARG, '\0', "atomic", NULL, 0)
+arg(activationmode_ARG, '\0', "activationmode", string_arg, 0)
+
/* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
diff --git a/tools/commands.h b/tools/commands.h
index 7d36bc5..5fae835 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -103,6 +103,7 @@ xx(lvchange,
"lvchange\n"
"\t[-A|--autobackup y|n]\n"
"\t[-a|--activate [a|e|l]{y|n}]\n"
+ "\t[--activationmode {complete|degraded|partial}"
"\t[--addtag Tag]\n"
"\t[--alloc AllocationPolicy]\n"
"\t[-C|--contiguous y|n]\n"
@@ -141,7 +142,8 @@ xx(lvchange,
"\t[-Z|--zero {y|n}]\n"
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
- addtag_ARG, alloc_ARG, autobackup_ARG, activate_ARG, available_ARG,
+ activationmode_ARG, addtag_ARG, alloc_ARG, autobackup_ARG, activate_ARG,
+ available_ARG,
contiguous_ARG, deltag_ARG, discards_ARG, detachprofile_ARG, force_ARG,
ignorelockingfailure_ARG, ignoremonitoring_ARG, ignoreactivationskip_ARG,
ignoreskippedcluster_ARG, major_ARG, metadataprofile_ARG, minor_ARG,
@@ -933,6 +935,7 @@ xx(vgchange,
"\t[-v|--verbose] " "\n"
"\t[--version]" "\n"
"\t{-a|--activate [a|e|l]{y|n} |" "\n"
+ "\t[--activationmode {complete|degraded|partial}]" "\n"
"\t -c|--clustered {y|n} |" "\n"
"\t -x|--resizeable {y|n} |" "\n"
"\t -l|--logicalvolume MaxLogicalVolumes |" "\n"
@@ -942,7 +945,8 @@ xx(vgchange,
"\t --deltag Tag}\n"
"\t[VolumeGroupName...]\n",
- addtag_ARG, alloc_ARG, allocation_ARG, autobackup_ARG, activate_ARG,
+ activationmode_ARG, addtag_ARG, alloc_ARG, allocation_ARG, autobackup_ARG,
+ activate_ARG,
available_ARG, clustered_ARG, deltag_ARG, detachprofile_ARG,
ignoreactivationskip_ARG, ignorelockingfailure_ARG, ignoremonitoring_ARG,
ignoreskippedcluster_ARG, logicalvolume_ARG, maxphysicalvolumes_ARG,
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 780e9d0..fc51c4a 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -866,6 +866,8 @@ int version(struct cmd_context *cmd __attribute__((unused)),
static int _get_settings(struct cmd_context *cmd)
{
+ const char *activation_mode;
+
cmd->current_settings = cmd->default_settings;
if (arg_count(cmd, debug_ARG))
@@ -903,10 +905,34 @@ static int _get_settings(struct cmd_context *cmd)
}
cmd->partial_activation = 0;
+ cmd->degraded_activation = 0;
+ activation_mode = find_config_tree_str(cmd, activation_mode_CFG, NULL);
+ if (!activation_mode)
+ activation_mode = DEFAULT_ACTIVATION_MODE;
+
+ if (arg_count(cmd, activationmode_ARG)) {
+ activation_mode = arg_str_value(cmd, activationmode_ARG,
+ activation_mode);
+
+ /* complain only if the two arguments conflict */
+ if (arg_count(cmd, partial_ARG) &&
+ strcmp(activation_mode, "partial")) {
+ log_error("--partial and --activationmode are mutually"
+ " exclusive arguments");
+ return EINVALID_CMD_LINE;
+ }
+ } else if (arg_count(cmd, partial_ARG))
+ activation_mode = "partial";
- if (arg_count(cmd, partial_ARG)) {
+ if (!strcmp(activation_mode, "partial")) {
cmd->partial_activation = 1;
log_warn("PARTIAL MODE. Incomplete logical volumes will be processed.");
+ } else if (!strcmp(activation_mode, "degraded")) {
+ cmd->degraded_activation = 1;
+ log_debug("DEGRADED MODE. Incomplete RAID LVs will be processed.");
+ } else if (strcmp(activation_mode, "complete")) {
+ log_error("Invalid activation mode given.");
+ return EINVALID_CMD_LINE;
}
if (arg_count(cmd, ignorelockingfailure_ARG) || arg_count(cmd, sysinit_ARG))
diff --git a/tools/toollib.c b/tools/toollib.c
index d4c915d..34db90c 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1431,7 +1431,8 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv)
{
if (!cmd->partial_activation && (lv->status & PARTIAL_LV)) {
- log_error("Refusing refresh of partial LV %s. Use --partial to override.",
+ log_error("Refusing refresh of partial LV %s."
+ " Use '--activationmode partial' to override.",
lv->name);
return 0;
}
9 years, 9 months
master - report: Rename common fields to special fields.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a098cba0ebbd06...
Commit: a098cba0ebbd0682570cff2fc756a59533321f03
Parent: 46ea315f09306836cc10826b0e94da4685351d1c
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Jul 9 23:33:09 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Jul 9 23:33:09 2014 +0100
report: Rename common fields to special fields.
Change the help heading from 'Common Fields' to 'Special Fields' for
the fields: selected, help, ?
Remove the code that does 'all' processing with these special fields as
each of them changes the behaviour of the command in an undesirable way.
'lvs -o all,selected' was of course just printing help.
(via internal expansion to 'lv_all,common_all')
and if we ignored the help fields, then '-o common_all' would still
pull in 'selected' and change the way rows were output.
---
libdm/libdm-report.c | 52 ++++++++++++++++++++++---------------------------
1 files changed, 23 insertions(+), 29 deletions(-)
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index ad89cf2..9b4ea87 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -193,10 +193,10 @@ struct row {
/*
* Implicit report types and fields.
*/
-#define COMMON_REPORT_TYPE 0x80000000
-#define COMMON_FIELD_SELECTED_ID "selected"
-#define COMMON_FIELD_HELP_ID "help"
-#define COMMON_FIELD_HELP_ALT_ID "?"
+#define SPECIAL_REPORT_TYPE 0x80000000
+#define SPECIAL_FIELD_SELECTED_ID "selected"
+#define SPECIAL_FIELD_HELP_ID "help"
+#define SPECIAL_FIELD_HELP_ALT_ID "?"
static void *_null_returning_fn(void *obj __attribute__((unused)))
{
@@ -222,26 +222,26 @@ static int _selected_disp(struct dm_report *rh,
return dm_report_field_int(rh, field, &row->selected);
}
-static const struct dm_report_object_type _implicit_common_report_types[] = {
- { COMMON_REPORT_TYPE, "Common", "common_", _null_returning_fn },
+static const struct dm_report_object_type _implicit_special_report_types[] = {
+ { SPECIAL_REPORT_TYPE, "Special", "special_", _null_returning_fn },
{ 0, "", "", NULL }
};
-static const struct dm_report_field_type _implicit_common_report_fields[] = {
- { COMMON_REPORT_TYPE, DM_REPORT_FIELD_TYPE_NUMBER | FLD_CMP_UNCOMPARABLE, 0, 8, COMMON_FIELD_HELP_ID, "Help", _no_report_fn, "Show help." },
- { COMMON_REPORT_TYPE, DM_REPORT_FIELD_TYPE_NUMBER | FLD_CMP_UNCOMPARABLE, 0, 8, COMMON_FIELD_HELP_ALT_ID, "Help", _no_report_fn, "Show help." },
+static const struct dm_report_field_type _implicit_special_report_fields[] = {
+ { SPECIAL_REPORT_TYPE, DM_REPORT_FIELD_TYPE_NUMBER | FLD_CMP_UNCOMPARABLE , 0, 8, SPECIAL_FIELD_HELP_ID, "Help", _no_report_fn, "Show help." },
+ { SPECIAL_REPORT_TYPE, DM_REPORT_FIELD_TYPE_NUMBER | FLD_CMP_UNCOMPARABLE , 0, 8, SPECIAL_FIELD_HELP_ALT_ID, "Help", _no_report_fn, "Show help." },
{ 0, 0, 0, 0, "", "", 0, 0}
};
-static const struct dm_report_field_type _implicit_common_report_fields_with_selection[] = {
- { COMMON_REPORT_TYPE, DM_REPORT_FIELD_TYPE_NUMBER, 0, 8, COMMON_FIELD_SELECTED_ID, "Selected", _selected_disp, "Item passes selection criteria." },
- { COMMON_REPORT_TYPE, DM_REPORT_FIELD_TYPE_NUMBER | FLD_CMP_UNCOMPARABLE, 0, 8, COMMON_FIELD_HELP_ID, "Help", _no_report_fn, "Show help." },
- { COMMON_REPORT_TYPE, DM_REPORT_FIELD_TYPE_NUMBER | FLD_CMP_UNCOMPARABLE, 0, 8, COMMON_FIELD_HELP_ALT_ID, "Help", _no_report_fn, "Show help." },
+static const struct dm_report_field_type _implicit_special_report_fields_with_selection[] = {
+ { SPECIAL_REPORT_TYPE, DM_REPORT_FIELD_TYPE_NUMBER, 0, 8, SPECIAL_FIELD_SELECTED_ID, "Selected", _selected_disp, "Set if item passes selection criteria." },
+ { SPECIAL_REPORT_TYPE, DM_REPORT_FIELD_TYPE_NUMBER | FLD_CMP_UNCOMPARABLE , 0, 8, SPECIAL_FIELD_HELP_ID, "Help", _no_report_fn, "Show help." },
+ { SPECIAL_REPORT_TYPE, DM_REPORT_FIELD_TYPE_NUMBER | FLD_CMP_UNCOMPARABLE , 0, 8, SPECIAL_FIELD_HELP_ALT_ID, "Help", _no_report_fn, "Show help." },
{ 0, 0, 0, 0, "", "", 0, 0}
};
-static const struct dm_report_object_type *_implicit_report_types = _implicit_common_report_types;
-static const struct dm_report_field_type *_implicit_report_fields = _implicit_common_report_fields;
+static const struct dm_report_object_type *_implicit_report_types = _implicit_special_report_types;
+static const struct dm_report_field_type *_implicit_report_fields = _implicit_special_report_fields;
static const struct dm_report_object_type *_find_type(struct dm_report *rh,
uint32_t report_type)
@@ -626,11 +626,10 @@ static void _display_fields_more(struct dm_report *rh,
log_warn("%*.*s", (int) strlen(desc) + 7,
(int) strlen(desc) + 7,
"-------------------------------------------------------------------------------");
- if (display_all_fields_item) {
+ if (display_all_fields_item && type->id != SPECIAL_REPORT_TYPE)
log_warn(" %sall%-*s - %s", type->prefix,
(int) (id_len - 3 - strlen(type->prefix)), "",
"All fields in this section.");
- }
}
/* FIXME Add line-wrapping at terminal width (or 80 cols) */
log_warn(" %-*s - %s%s%s%s%s", (int) id_len, fields[f].id, fields[f].desc,
@@ -783,7 +782,6 @@ static uint32_t _all_match(struct dm_report *rh, const char *field, size_t flen)
}
/* Combine all report types that have a matching prefix. */
- _all_match_combine(_implicit_report_types, unprefixed_all_matched, field, flen, &report_types);
_all_match_combine(rh->types, unprefixed_all_matched, field, flen, &report_types);
return report_types;
@@ -796,10 +794,6 @@ static int _add_all_fields(struct dm_report *rh, uint32_t type)
{
uint32_t f;
- for (f = 0; _implicit_report_fields[f].report_fn; f++)
- if ((_implicit_report_fields[f].type & type) && !_add_field(rh, f, 1, 0))
- return 0;
-
for (f = 0; rh->fields[f].report_fn; f++)
if ((rh->fields[f].type & type) && !_add_field(rh, f, 0, 0))
return 0;
@@ -1030,8 +1024,8 @@ static int _help_requested(struct dm_report *rh)
dm_list_iterate_items(fp, &rh->field_props) {
if (fp->implicit &&
- (!strcmp(_implicit_report_fields[fp->field_num].id, COMMON_FIELD_HELP_ID) ||
- !strcmp(_implicit_report_fields[fp->field_num].id, COMMON_FIELD_HELP_ALT_ID)))
+ (!strcmp(_implicit_report_fields[fp->field_num].id, SPECIAL_FIELD_HELP_ID) ||
+ !strcmp(_implicit_report_fields[fp->field_num].id, SPECIAL_FIELD_HELP_ALT_ID)))
return 1;
}
@@ -1181,7 +1175,7 @@ static void *_report_get_field_data(struct dm_report *rh,
static void *_report_get_implicit_field_data(struct dm_report *rh __attribute__((unused)),
struct field_properties *fp, struct row *row)
{
- if (!strcmp(_implicit_report_fields[fp->field_num].id, COMMON_FIELD_SELECTED_ID))
+ if (!strcmp(_implicit_report_fields[fp->field_num].id, SPECIAL_FIELD_SELECTED_ID))
return row;
return NULL;
@@ -1468,7 +1462,7 @@ int dm_report_object(struct dm_report *rh, void *object)
if (fp->implicit) {
fields = _implicit_report_fields;
- if (!strcmp(fields[fp->field_num].id, COMMON_FIELD_SELECTED_ID))
+ if (!strcmp(fields[fp->field_num].id, SPECIAL_FIELD_SELECTED_ID))
field_sel_status = field;
} else
fields = rh->fields;
@@ -2700,7 +2694,7 @@ struct dm_report *dm_report_init_with_selection(uint32_t *report_types,
struct selection_node *root = NULL;
const char *fin, *next;
- _implicit_report_fields = _implicit_common_report_fields_with_selection;
+ _implicit_report_fields = _implicit_special_report_fields_with_selection;
if (!(rh = dm_report_init(report_types, types, fields, output_fields,
output_separator, output_flags, sort_keys, private_data)))
@@ -2719,8 +2713,8 @@ struct dm_report *dm_report_init_with_selection(uint32_t *report_types,
}
rh->reserved_values = reserved_values;
- if (!strcasecmp(selection, COMMON_FIELD_HELP_ID) ||
- !strcmp(selection, COMMON_FIELD_HELP_ALT_ID)) {
+ if (!strcasecmp(selection, SPECIAL_FIELD_HELP_ID) ||
+ !strcmp(selection, SPECIAL_FIELD_HELP_ALT_ID)) {
_display_fields(rh, 0, 1);
log_warn(" ");
_display_selection_help(rh);
9 years, 9 months
master - report: also recognize 'yes'/'no' for selection criteria on binary fields
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=46ea315f093068...
Commit: 46ea315f09306836cc10826b0e94da4685351d1c
Parent: c1bed36b670660527caf70182c39080764df71d0
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jul 9 15:10:43 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jul 9 15:57:05 2014 +0200
report: also recognize 'yes'/'no' for selection criteria on binary fields
We have 1/"descriptive word"/"yes" for 1 and 0/"no" for 0.
For example (the new recognized values are "yes" and "no"):
$ lvs -o name,device_open fedora vg/lvol1 vg/lvol2
LV DevOpen
root open
swap open
lvol1 open
lvol2
$ lvs -o name,device_open fedora vg/lvol1 vg/lvol2 -S 'device_open=open'
LV DevOpen
root open
swap open
lvol1 open
$ lvs -o name,device_open fedora vg/lvol1 vg/lvol2 -S 'device_open=1'
LV DevOpen
root open
swap open
lvol1 open
$ lvs -o name,device_open fedora vg/lvol1 vg/lvol2 -S 'device_open=yes'
LV DevOpen
root open
swap open
lvol1 open
$ lvs -o name,device_open fedora vg/lvol1 vg/lvol2 -S 'device_open=0'
LV DevOpen
lvol2
$ lvs -o name,device_open fedora vg/lvol1 vg/lvol2 -S 'device_open=no'
LV DevOpen
lvol2
---
lib/report/report.c | 144 +++++++++++++++++++++++++++------------------------
1 files changed, 77 insertions(+), 67 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 198fdfa..a2f4541 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -56,6 +56,8 @@ static const uint64_t _zero64 = UINT64_C(0);
static const uint64_t _one64 = UINT64_C(1);
static const char const _str_zero[] = "0";
static const char const _str_one[] = "1";
+static const char const _str_no[] = "no";
+static const char const _str_yes[] = "yes";
static const char const _str_minus_one[] = "-1";
static const char const _str_unknown[] = "unknown";
@@ -73,6 +75,9 @@ static const int32_t _reserved_number_undef_32 = INT32_C(-1);
#define FIELD_RESERVED_VALUE(field_id, id, value, ...) \
static const char *_reserved_ ## id ## _names[] = { __VA_ARGS__ , NULL}; \
static const struct dm_report_field_reserved_value _reserved_ ## id = {field_ ## field_id, &value};
+#define FIELD_RESERVED_BINARY_VALUE(field_id, id, ...) \
+ FIELD_RESERVED_VALUE(field_id, id ## _y, _one64, __VA_ARGS__, _str_yes) \
+ FIELD_RESERVED_VALUE(field_id, id ## _n, _zero64, __VA_ARGS__, _str_no)
/*
* Reserved values and their assigned names.
@@ -82,35 +87,37 @@ static const int32_t _reserved_number_undef_32 = INT32_C(-1);
*
* TYPE_RESERVED_VALUE(type, reserved_value_id, value, reserved name, ...)
* FIELD_RESERVED_VALUE(field_id, reserved_value_id, value, reserved name, ...)
+ * FIELD_RESERVED_BINARY_VALUE(field_id, reserved_value_id, value, reserved name for 1, ...)
*
*/
+
TYPE_RESERVED_VALUE(uint64_t, number_undef_64, UINT64_C(-1), _str_minus_one, _str_unknown, "undefined", "undef");
-FIELD_RESERVED_VALUE(pv_allocatable, pv_allocatable, _one64, "allocatable")
-FIELD_RESERVED_VALUE(pv_exported, pv_exported, _one64, "exported")
-FIELD_RESERVED_VALUE(pv_missing, pv_missing, _one64, "missing")
-FIELD_RESERVED_VALUE(vg_extendable, vg_extendable, _one64, "extendable")
-FIELD_RESERVED_VALUE(vg_exported, vg_exported, _one64, "exported")
-FIELD_RESERVED_VALUE(vg_partial, vg_partial, _one64, "partial")
-FIELD_RESERVED_VALUE(vg_clustered, vg_clustered, _one64, "clustered")
+FIELD_RESERVED_BINARY_VALUE(pv_allocatable, pv_allocatable, "allocatable")
+FIELD_RESERVED_BINARY_VALUE(pv_exported, pv_exported, "exported")
+FIELD_RESERVED_BINARY_VALUE(pv_missing, pv_missing, "missing")
+FIELD_RESERVED_BINARY_VALUE(vg_extendable, vg_extendable, "extendable")
+FIELD_RESERVED_BINARY_VALUE(vg_exported, vg_exported, "exported")
+FIELD_RESERVED_BINARY_VALUE(vg_partial, vg_partial, "partial")
+FIELD_RESERVED_BINARY_VALUE(vg_clustered, vg_clustered, "clustered")
FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_rw, FIRST_NAME(vg_permissions_rw), "writeable", "rw", "read_write")
FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_r, FIRST_NAME(vg_permissions_r), "read-only", "r", "ro")
FIELD_RESERVED_VALUE(vg_mda_copies, vg_mda_copies, _reserved_number_undef_64, "unmanaged")
-FIELD_RESERVED_VALUE(lv_initial_image_sync, lv_initial_image_sync, _one64, "initial image sync", "sync")
-FIELD_RESERVED_VALUE(lv_image_synced, lv_image_synced, _one64, "image synced", "synced")
-FIELD_RESERVED_VALUE(lv_merging, lv_merging, _one64, "merging")
-FIELD_RESERVED_VALUE(lv_converting, lv_converting, _one64, "converting")
-FIELD_RESERVED_VALUE(lv_allocation_locked, lv_allocation_locked, _one64, "allocation locked", "locked")
-FIELD_RESERVED_VALUE(lv_fixed_minor, lv_fixed_minor, _one64, "fixed minor", "fixed")
-FIELD_RESERVED_VALUE(lv_active_locally, lv_active_locally, _one64, "active locally", "active", "locally")
-FIELD_RESERVED_VALUE(lv_active_remotely, lv_active_remotely, _one64, "active remotely", "active", "remotely")
-FIELD_RESERVED_VALUE(lv_active_exclusively, lv_active_exclusively, _one64, "active exclusively", "active", "exclusively")
-FIELD_RESERVED_VALUE(lv_merge_failed, lv_merge_failed, _one64, "merge failed", "failed")
-FIELD_RESERVED_VALUE(lv_snapshot_invalid, lv_snapshot_invalid, _one64, "snapsot invalid", "invalid")
-FIELD_RESERVED_VALUE(lv_suspended, lv_suspended, _one64, "suspended")
-FIELD_RESERVED_VALUE(lv_live_table, lv_live_table, _one64, "live table present", "live table", "live")
-FIELD_RESERVED_VALUE(lv_inactive_table, lv_inactive_table, _one64, "inactive table present", "inactive table", "inactive")
-FIELD_RESERVED_VALUE(lv_device_open, lv_device_open, _one64, "open")
-FIELD_RESERVED_VALUE(lv_skip_activation, lv_skip_activation, _one64, "skip activation", "skip")
+FIELD_RESERVED_BINARY_VALUE(lv_initial_image_sync, lv_initial_image_sync, "initial image sync", "sync")
+FIELD_RESERVED_BINARY_VALUE(lv_image_synced, lv_image_synced, "image synced", "synced")
+FIELD_RESERVED_BINARY_VALUE(lv_merging, lv_merging, "merging")
+FIELD_RESERVED_BINARY_VALUE(lv_converting, lv_converting, "converting")
+FIELD_RESERVED_BINARY_VALUE(lv_allocation_locked, lv_allocation_locked, "allocation locked", "locked")
+FIELD_RESERVED_BINARY_VALUE(lv_fixed_minor, lv_fixed_minor, "fixed minor", "fixed")
+FIELD_RESERVED_BINARY_VALUE(lv_active_locally, lv_active_locally, "active locally", "active", "locally")
+FIELD_RESERVED_BINARY_VALUE(lv_active_remotely, lv_active_remotely, "active remotely", "active", "remotely")
+FIELD_RESERVED_BINARY_VALUE(lv_active_exclusively, lv_active_exclusively, "active exclusively", "active", "exclusively")
+FIELD_RESERVED_BINARY_VALUE(lv_merge_failed, lv_merge_failed, "merge failed", "failed")
+FIELD_RESERVED_BINARY_VALUE(lv_snapshot_invalid, lv_snapshot_invalid, "snapsot invalid", "invalid")
+FIELD_RESERVED_BINARY_VALUE(lv_suspended, lv_suspended, "suspended")
+FIELD_RESERVED_BINARY_VALUE(lv_live_table, lv_live_table, "live table present", "live table", "live")
+FIELD_RESERVED_BINARY_VALUE(lv_inactive_table, lv_inactive_table, "inactive table present", "inactive table", "inactive")
+FIELD_RESERVED_BINARY_VALUE(lv_device_open, lv_device_open, "open")
+FIELD_RESERVED_BINARY_VALUE(lv_skip_activation, lv_skip_activation, "skip activation", "skip")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_rw, FIRST_NAME(lv_permissions_rw), "writeable", "rw", "read-write")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, FIRST_NAME(lv_permissions_r), "read-only", "r", "ro")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, FIRST_NAME(lv_permissions_r_override), "read-only-override", "ro-override", "r-override", "R")
@@ -118,6 +125,9 @@ FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead, _reserved_number_undef_64, "a
#define TYPE_RESERVED_VALUE_REG(type, id, description) {DM_REPORT_FIELD_TYPE_ ## type, &_reserved_ ## id, _reserved_ ## id ## _names, description},
#define FIELD_RESERVED_VALUE_REG(id, description) {DM_REPORT_FIELD_TYPE_NONE, &_reserved_ ## id, _reserved_ ## id ## _names, description},
+#define FIELD_RESERVED_BINARY_VALUE_REG(id, description) \
+ FIELD_RESERVED_VALUE_REG(id ## _y, description) \
+ FIELD_RESERVED_VALUE_REG(id ## _n, description)
/*
* Create array of reserved values to be passed for dm_report_init_with_selection
@@ -126,32 +136,32 @@ FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead, _reserved_number_undef_64, "a
*/
static const struct dm_report_reserved_value _report_reserved_values[] = {
TYPE_RESERVED_VALUE_REG(NUMBER, number_undef_64, "Reserved value for undefined numeric value.")
- FIELD_RESERVED_VALUE_REG(pv_allocatable, "pv_allocatable reserved values")
- FIELD_RESERVED_VALUE_REG(pv_exported, "pv_exported reserved values")
- FIELD_RESERVED_VALUE_REG(pv_missing, "pv_missing reserved values")
- FIELD_RESERVED_VALUE_REG(vg_extendable, "vg_extendable reserved values")
- FIELD_RESERVED_VALUE_REG(vg_exported, "vg_exported reserved values")
- FIELD_RESERVED_VALUE_REG(vg_partial, "vg_partial reserved values")
- FIELD_RESERVED_VALUE_REG(vg_clustered, "vg_clustered reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(pv_allocatable, "pv_allocatable reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(pv_exported, "pv_exported reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(pv_missing, "pv_missing reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(vg_extendable, "vg_extendable reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(vg_exported, "vg_exported reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(vg_partial, "vg_partial reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(vg_clustered, "vg_clustered reserved values")
FIELD_RESERVED_VALUE_REG(vg_permissions_rw, "vg_permissions reserved values (writeable)")
FIELD_RESERVED_VALUE_REG(vg_permissions_r, "vg_permissions reserved values (read-only)")
FIELD_RESERVED_VALUE_REG(vg_mda_copies, "vg_mda_copies reserved values (unmanaged)")
- FIELD_RESERVED_VALUE_REG(lv_initial_image_sync, "lv_initial_image_sync reserved values")
- FIELD_RESERVED_VALUE_REG(lv_image_synced, "lv_image_synced reserved values")
- FIELD_RESERVED_VALUE_REG(lv_merging, "lv_merging reserved values")
- FIELD_RESERVED_VALUE_REG(lv_converting, "lv_converting reserved values")
- FIELD_RESERVED_VALUE_REG(lv_allocation_locked, "lv_allocation_locked reserved values")
- FIELD_RESERVED_VALUE_REG(lv_fixed_minor, "lv_fixed_minor reserved values")
- FIELD_RESERVED_VALUE_REG(lv_active_locally, "lv_active_locally reserved values")
- FIELD_RESERVED_VALUE_REG(lv_active_remotely, "lv_active_remotelly reserved values")
- FIELD_RESERVED_VALUE_REG(lv_active_exclusively, "lv_active_exclusively reserved values")
- FIELD_RESERVED_VALUE_REG(lv_merge_failed, "lv_merge_failed reserved values")
- FIELD_RESERVED_VALUE_REG(lv_snapshot_invalid, "lv_snapshot_invalid reserved values")
- FIELD_RESERVED_VALUE_REG(lv_suspended, "lv_suspended reserved values")
- FIELD_RESERVED_VALUE_REG(lv_live_table, "lv_live_table reserved values")
- FIELD_RESERVED_VALUE_REG(lv_inactive_table, "lv_inactive_table reserved values")
- FIELD_RESERVED_VALUE_REG(lv_device_open, "lv_device_open reserved values")
- FIELD_RESERVED_VALUE_REG(lv_skip_activation, "lv_inactive_table reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_initial_image_sync, "lv_initial_image_sync reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_image_synced, "lv_image_synced reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_merging, "lv_merging reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_converting, "lv_converting reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_allocation_locked, "lv_allocation_locked reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_fixed_minor, "lv_fixed_minor reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_active_locally, "lv_active_locally reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_active_remotely, "lv_active_remotelly reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_active_exclusively, "lv_active_exclusively reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_merge_failed, "lv_merge_failed reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_snapshot_invalid, "lv_snapshot_invalid reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_suspended, "lv_suspended reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_live_table, "lv_live_table reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_inactive_table, "lv_inactive_table reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_device_open, "lv_device_open reserved values")
+ FIELD_RESERVED_BINARY_VALUE_REG(lv_skip_activation, "lv_inactive_table reserved values")
FIELD_RESERVED_VALUE_REG(lv_permissions_rw, "lv_permissions reserved values (writeable)")
FIELD_RESERVED_VALUE_REG(lv_permissions_r, "lv_permissions reserved values (read-only)")
FIELD_RESERVED_VALUE_REG(lv_permissions_r_override, "lv_permissions reserved values (read-only-override)")
@@ -1270,7 +1280,7 @@ static int _pvallocatable_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data, void *private)
{
int allocatable = (((const struct physical_volume *) data)->status & ALLOCATABLE_PV) != 0;
- return _binary_disp(rh, mem, field, allocatable, FIRST_NAME(pv_allocatable), private);
+ return _binary_disp(rh, mem, field, allocatable, FIRST_NAME(pv_allocatable_y), private);
}
static int _pvexported_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1278,7 +1288,7 @@ static int _pvexported_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data, void *private)
{
int exported = (((const struct physical_volume *) data)->status & EXPORTED_VG) != 0;
- return _binary_disp(rh, mem, field, exported, FIRST_NAME(pv_exported), private);
+ return _binary_disp(rh, mem, field, exported, FIRST_NAME(pv_exported_y), private);
}
static int _pvmissing_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1286,7 +1296,7 @@ static int _pvmissing_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data, void *private)
{
int missing = (((const struct physical_volume *) data)->status & MISSING_PV) != 0;
- return _binary_disp(rh, mem, field, missing, FIRST_NAME(pv_missing), private);
+ return _binary_disp(rh, mem, field, missing, FIRST_NAME(pv_missing_y), private);
}
static int _vgpermissions_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1303,7 +1313,7 @@ static int _vgextendable_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data, void *private)
{
int extendable = (vg_is_resizeable((const struct volume_group *) data)) != 0;
- return _binary_disp(rh, mem, field, extendable, FIRST_NAME(vg_extendable), private);
+ return _binary_disp(rh, mem, field, extendable, FIRST_NAME(vg_extendable_y),private);
}
static int _vgexported_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1311,7 +1321,7 @@ static int _vgexported_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data, void *private)
{
int exported = (vg_is_exported((const struct volume_group *) data)) != 0;
- return _binary_disp(rh, mem, field, exported, FIRST_NAME(vg_exported), private);
+ return _binary_disp(rh, mem, field, exported, FIRST_NAME(vg_exported_y), private);
}
static int _vgpartial_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1319,7 +1329,7 @@ static int _vgpartial_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data, void *private)
{
int partial = (vg_missing_pv_count((const struct volume_group *) data)) != 0;
- return _binary_disp(rh, mem, field, partial, FIRST_NAME(vg_partial), private);
+ return _binary_disp(rh, mem, field, partial, FIRST_NAME(vg_partial_y), private);
}
static int _vgallocationpolicy_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1335,7 +1345,7 @@ static int _vgclustered_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data, void *private)
{
int clustered = (vg_is_clustered((const struct volume_group *) data)) != 0;
- return _binary_disp(rh, mem, field, clustered, FIRST_NAME(vg_clustered), private);
+ return _binary_disp(rh, mem, field, clustered, FIRST_NAME(vg_clustered_y), private);
}
static int _lvvolumetype_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1358,7 +1368,7 @@ static int _lvinitialimagesync_disp(struct dm_report *rh, struct dm_pool *mem,
else
initial_image_sync = 0;
- return _binary_disp(rh, mem, field, initial_image_sync, FIRST_NAME(lv_initial_image_sync), private);
+ return _binary_disp(rh, mem, field, initial_image_sync, FIRST_NAME(lv_initial_image_sync_y), private);
}
static int _lvimagesynced_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1375,7 +1385,7 @@ static int _lvimagesynced_disp(struct dm_report *rh, struct dm_pool *mem,
else
image_synced = 0;
- return _binary_disp(rh, mem, field, image_synced, FIRST_NAME(lv_image_synced), private);
+ return _binary_disp(rh, mem, field, image_synced, FIRST_NAME(lv_image_synced_y), private);
}
static int _lvmerging_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1394,7 +1404,7 @@ static int _lvmerging_disp(struct dm_report *rh, struct dm_pool *mem,
else
merging = 0;
- return _binary_disp(rh, mem, field, merging, FIRST_NAME(lv_merging), private);
+ return _binary_disp(rh, mem, field, merging, FIRST_NAME(lv_merging_y), private);
}
static int _lvconverting_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1440,7 +1450,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), private);
+ return _binary_disp(rh, mem, field, alloc_locked, FIRST_NAME(lv_allocation_locked_y), private);
}
static int _lvfixedminor_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1448,7 +1458,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), private);
+ return _binary_disp(rh, mem, field, fixed_minor, FIRST_NAME(lv_fixed_minor_y), private);
}
static int _lvactive_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1478,7 +1488,7 @@ static int _lvactivelocally_disp(struct dm_report *rh, struct dm_pool *mem,
} else
active_locally = lv_is_active(lv);
- return _binary_disp(rh, mem, field, active_locally, FIRST_NAME(lv_active_locally), private);
+ return _binary_disp(rh, mem, field, active_locally, FIRST_NAME(lv_active_locally_y), private);
}
static int _lvactiveremotely_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1494,7 +1504,7 @@ static int _lvactiveremotely_disp(struct dm_report *rh, struct dm_pool *mem,
} else
active_remotely = 0;
- return _binary_disp(rh, mem, field, active_remotely, FIRST_NAME(lv_active_remotely), private);
+ return _binary_disp(rh, mem, field, active_remotely, FIRST_NAME(lv_active_remotely_y), private);
}
static int _lvactiveexclusively_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1510,7 +1520,7 @@ static int _lvactiveexclusively_disp(struct dm_report *rh, struct dm_pool *mem,
} else
active_exclusively = lv_is_active(lv);
- return _binary_disp(rh, mem, field, active_exclusively, FIRST_NAME(lv_active_exclusively), private);
+ return _binary_disp(rh, mem, field, active_exclusively, FIRST_NAME(lv_active_exclusively_y), private);
}
static int _lvmergefailed_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1525,7 +1535,7 @@ static int _lvmergefailed_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_value(field, _str_unknown, &_reserved_number_undef_64);
merge_failed = snap_percent == LVM_PERCENT_MERGE_FAILED;
- return _binary_disp(rh, mem, field, merge_failed, FIRST_NAME(lv_merge_failed), private);
+ return _binary_disp(rh, mem, field, merge_failed, FIRST_NAME(lv_merge_failed_y), private);
}
static int _lvsnapshotinvalid_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1540,7 +1550,7 @@ static int _lvsnapshotinvalid_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_value(field, _str_unknown, &_reserved_number_undef_64);
snap_invalid = !lv_snapshot_percent(lv, &snap_percent) || snap_percent == DM_PERCENT_INVALID;
- return _binary_disp(rh, mem, field, snap_invalid, FIRST_NAME(lv_snapshot_invalid), private);
+ return _binary_disp(rh, mem, field, snap_invalid, FIRST_NAME(lv_snapshot_invalid_y), private);
}
static int _lvsuspended_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1550,7 +1560,7 @@ static int _lvsuspended_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_with_info *lvi = (const struct lv_with_info *) data;
if (lvi->info->exists)
- return _binary_disp(rh, mem, field, lvi->info->suspended, FIRST_NAME(lv_suspended), private);
+ return _binary_disp(rh, mem, field, lvi->info->suspended, FIRST_NAME(lv_suspended_y), private);
return _binary_undef_disp(rh, mem, field, private);
}
@@ -1562,7 +1572,7 @@ static int _lvlivetable_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_with_info *lvi = (const struct lv_with_info *) data;
if (lvi->info->exists)
- return _binary_disp(rh, mem, field, lvi->info->live_table, FIRST_NAME(lv_live_table), private);
+ return _binary_disp(rh, mem, field, lvi->info->live_table, FIRST_NAME(lv_live_table_y), private);
return _binary_undef_disp(rh, mem, field, private);
}
@@ -1574,7 +1584,7 @@ static int _lvinactivetable_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_with_info *lvi = (const struct lv_with_info *) data;
if (lvi->info->exists)
- return _binary_disp(rh, mem, field, lvi->info->inactive_table, FIRST_NAME(lv_inactive_table), private);
+ return _binary_disp(rh, mem, field, lvi->info->inactive_table, FIRST_NAME(lv_inactive_table_y), private);
return _binary_undef_disp(rh, mem, field, private);
}
@@ -1586,7 +1596,7 @@ static int _lvdeviceopen_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_with_info *lvi = (const struct lv_with_info *) data;
if (lvi->info->exists)
- return _binary_disp(rh, mem, field, lvi->info->open_count, FIRST_NAME(lv_device_open), private);
+ return _binary_disp(rh, mem, field, lvi->info->open_count, FIRST_NAME(lv_device_open_y), private);
return _binary_undef_disp(rh, mem, field, private);
}
9 years, 9 months
master - cleanup: move _lvactive_disp and _thinzero_disp under 'attribute' display functions
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c1bed36b670660...
Commit: c1bed36b670660527caf70182c39080764df71d0
Parent: bccc2bef33af081264bbc356e37efe89ef78b796
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jul 9 14:37:01 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jul 9 15:57:05 2014 +0200
cleanup: move _lvactive_disp and _thinzero_disp under 'attribute' display functions
So all attribute reporting functions are all in one section of code
for quick orientation (all these functions are defined in the order
of their attribute character displayed in pv/vg/lv_attr field).
---
lib/report/report.c | 52 +++++++++++++++++++++++++-------------------------
1 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index d28c767..198fdfa 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -750,18 +750,6 @@ static int _chunksize_disp(struct dm_report *rh, struct dm_pool *mem,
return _size64_disp(rh, mem, field, &size, private);
}
-static int _thinzero_disp(struct dm_report *rh, struct dm_pool *mem,
- struct dm_report_field *field,
- const void *data, void *private)
-{
- const struct lv_segment *seg = (const struct lv_segment *) data;
-
- if (seg_is_thin_pool(seg))
- return _uint32_disp(rh, mem, field, &seg->zero_new_blocks, private);
-
- return _field_set_value(field, "", &_reserved_number_undef_64);
-}
-
static int _transactionid_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
@@ -1275,20 +1263,6 @@ static int _lvhost_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_value(field, repstr, NULL);
}
-static int _lvactive_disp(struct dm_report *rh, struct dm_pool *mem,
- struct dm_report_field *field,
- const void *data, void *private)
-{
- char *repstr;
-
- if (!(repstr = lv_active_dup(mem, (const struct logical_volume *) data))) {
- log_error("Failed to allocate buffer for active.");
- return 0;
- }
-
- return _field_set_value(field, repstr, NULL);
-}
-
/* PV/VG/LV Attributes */
static int _pvallocatable_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1477,6 +1451,20 @@ static int _lvfixedminor_disp(struct dm_report *rh, struct dm_pool *mem,
return _binary_disp(rh, mem, field, fixed_minor, FIRST_NAME(lv_fixed_minor), private);
}
+static int _lvactive_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ char *repstr;
+
+ if (!(repstr = lv_active_dup(mem, (const struct logical_volume *) data))) {
+ log_error("Failed to allocate buffer for active.");
+ return 0;
+ }
+
+ return _field_set_value(field, repstr, NULL);
+}
+
static int _lvactivelocally_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
@@ -1626,6 +1614,18 @@ static int _lvtargettype_disp(struct dm_report *rh, struct dm_pool *mem,
return _string_disp(rh, mem, field, &target_type, private);
}
+static int _thinzero_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const struct lv_segment *seg = (const struct lv_segment *) data;
+
+ if (seg_is_thin_pool(seg))
+ return _uint32_disp(rh, mem, field, &seg->zero_new_blocks, private);
+
+ return _field_set_value(field, "", &_reserved_number_undef_64);
+}
+
static int _lvhealthstatus_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
9 years, 9 months
master - report: add lv_active_{locally, remotely, exclusively} LV reporting fields
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bccc2bef33af08...
Commit: bccc2bef33af081264bbc356e37efe89ef78b796
Parent: b6ac8819f694d0b28fc592e89f01a8cf8e4f1802
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jul 9 14:28:50 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jul 9 15:57:05 2014 +0200
report: add lv_active_{locally,remotely,exclusively} LV reporting fields
lv_active_{locally,remotely,exclusively} display the original
"lv_active" field in a more separate way so that we can create
selection criteria in a binary-based form (yes/no).
---
WHATS_NEW | 1 +
lib/report/columns.h | 3 ++
lib/report/properties.c | 6 +++++
lib/report/report.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d4649e4..21668f2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.108 -
=================================
+ Add separate lv_active_{locally,remotely,exclusively} LV reporting fields.
Recognize "auto"/"unmanaged" values in selection for appropriate fields only.
Add report/binary_values_as_numeric lvm.conf option for binary values as 0/1.
Add --binary arg to pvs,vgs,lvs and {pv,vg,lv}display -C for 0/1 on reports.
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 5013834..3d3d76e 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -53,6 +53,9 @@ FIELD(LVS, lv, STR, "TargetType", lvid, 10, lvtargettype, lv_target_type, "Kerne
FIELD(LVS, lv, STR, "Health", lvid, 15, lvhealthstatus, lv_health_status, "LV health status.", 0)
FIELD(LVS, lv, BIN, "SkipAct", lvid, 15, lvskipactivation, lv_skip_activation, "Set if LV is skipped on activation.", 0)
FIELD(LVS, lv, STR, "Active", lvid, 6, lvactive, lv_active, "Active state of the LV.", 0)
+FIELD(LVS, lv, BIN, "ActiveLoc", lvid, 10, lvactivelocally, lv_active_locally, "Set if the LV is active locally.", 0)
+FIELD(LVS, lv, BIN, "ActiveRem", lvid, 10, lvactiveremotely, lv_active_remotely, "Set if the LV is active remotely.", 0)
+FIELD(LVS, lv, BIN, "ActiveExcl", lvid, 10, lvactiveexclusively, lv_active_exclusively, "Set if the LV is active exclusively.", 0)
FIELD(LVS, lv, NUM, "Maj", major, 3, int32, lv_major, "Persistent major number or -1 if not persistent.", 0)
FIELD(LVS, lv, NUM, "Min", minor, 3, int32, lv_minor, "Persistent minor number or -1 if not persistent.", 0)
FIELD(LVS, lv, SIZ, "Rahead", lvid, 6, lvreadahead, lv_read_ahead, "Read ahead setting in current units.", 0)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index 8fb1e92..b4e183f 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -196,6 +196,12 @@ GET_PV_NUM_PROPERTY_FN(pv_ba_size, SECTOR_SIZE * pv->ba_size)
#define _lv_allocation_policy_get prop_not_implemented_get
#define _lv_allocation_locked_set prop_not_implemented_set
#define _lv_allocation_locked_get prop_not_implemented_get
+#define _lv_active_locally_set prop_not_implemented_set
+#define _lv_active_locally_get prop_not_implemented_get
+#define _lv_active_remotely_set prop_not_implemented_set
+#define _lv_active_remotely_get prop_not_implemented_get
+#define _lv_active_exclusively_set prop_not_implemented_set
+#define _lv_active_exclusively_get prop_not_implemented_get
#define _lv_fixed_minor_set prop_not_implemented_set
#define _lv_fixed_minor_get prop_not_implemented_get
#define _lv_merge_failed_set prop_not_implemented_set
diff --git a/lib/report/report.c b/lib/report/report.c
index adcd2be..d28c767 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -101,6 +101,9 @@ FIELD_RESERVED_VALUE(lv_merging, lv_merging, _one64, "merging")
FIELD_RESERVED_VALUE(lv_converting, lv_converting, _one64, "converting")
FIELD_RESERVED_VALUE(lv_allocation_locked, lv_allocation_locked, _one64, "allocation locked", "locked")
FIELD_RESERVED_VALUE(lv_fixed_minor, lv_fixed_minor, _one64, "fixed minor", "fixed")
+FIELD_RESERVED_VALUE(lv_active_locally, lv_active_locally, _one64, "active locally", "active", "locally")
+FIELD_RESERVED_VALUE(lv_active_remotely, lv_active_remotely, _one64, "active remotely", "active", "remotely")
+FIELD_RESERVED_VALUE(lv_active_exclusively, lv_active_exclusively, _one64, "active exclusively", "active", "exclusively")
FIELD_RESERVED_VALUE(lv_merge_failed, lv_merge_failed, _one64, "merge failed", "failed")
FIELD_RESERVED_VALUE(lv_snapshot_invalid, lv_snapshot_invalid, _one64, "snapsot invalid", "invalid")
FIELD_RESERVED_VALUE(lv_suspended, lv_suspended, _one64, "suspended")
@@ -139,6 +142,9 @@ static const struct dm_report_reserved_value _report_reserved_values[] = {
FIELD_RESERVED_VALUE_REG(lv_converting, "lv_converting reserved values")
FIELD_RESERVED_VALUE_REG(lv_allocation_locked, "lv_allocation_locked reserved values")
FIELD_RESERVED_VALUE_REG(lv_fixed_minor, "lv_fixed_minor reserved values")
+ FIELD_RESERVED_VALUE_REG(lv_active_locally, "lv_active_locally reserved values")
+ FIELD_RESERVED_VALUE_REG(lv_active_remotely, "lv_active_remotelly reserved values")
+ FIELD_RESERVED_VALUE_REG(lv_active_exclusively, "lv_active_exclusively reserved values")
FIELD_RESERVED_VALUE_REG(lv_merge_failed, "lv_merge_failed reserved values")
FIELD_RESERVED_VALUE_REG(lv_snapshot_invalid, "lv_snapshot_invalid reserved values")
FIELD_RESERVED_VALUE_REG(lv_suspended, "lv_suspended reserved values")
@@ -1471,6 +1477,54 @@ static int _lvfixedminor_disp(struct dm_report *rh, struct dm_pool *mem,
return _binary_disp(rh, mem, field, fixed_minor, FIRST_NAME(lv_fixed_minor), private);
}
+static int _lvactivelocally_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const struct logical_volume *lv = (const struct logical_volume *) data;
+ int active_locally;
+
+ if (vg_is_clustered(lv->vg)) {
+ lv = lv_lock_holder(lv);
+ active_locally = lv_is_active_locally(lv);
+ } else
+ active_locally = lv_is_active(lv);
+
+ return _binary_disp(rh, mem, field, active_locally, FIRST_NAME(lv_active_locally), private);
+}
+
+static int _lvactiveremotely_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const struct logical_volume *lv = (const struct logical_volume *) data;
+ int active_remotely;
+
+ if (vg_is_clustered(lv->vg)) {
+ lv = lv_lock_holder(lv);
+ active_remotely = lv_is_active_but_not_locally(lv);
+ } else
+ active_remotely = 0;
+
+ return _binary_disp(rh, mem, field, active_remotely, FIRST_NAME(lv_active_remotely), private);
+}
+
+static int _lvactiveexclusively_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const struct logical_volume *lv = (const struct logical_volume *) data;
+ int active_exclusively;
+
+ if (vg_is_clustered(lv->vg)) {
+ lv = lv_lock_holder(lv);
+ active_exclusively = lv_is_active_exclusive(lv);
+ } else
+ active_exclusively = lv_is_active(lv);
+
+ return _binary_disp(rh, mem, field, active_exclusively, FIRST_NAME(lv_active_exclusively), private);
+}
+
static int _lvmergefailed_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
9 years, 9 months