master - libdm: report: add more comments about helper macros to get reserved values
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3e0ed83bc8103d...
Commit: 3e0ed83bc8103d36efe0e2dcdfd4b5ad5fd822a8
Parent: 57af48d734f1f7aa985424a1e11287a0975077b9
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Dec 19 09:17:16 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Dec 19 09:23:05 2014 +0100
libdm: report: add more comments about helper macros to get reserved values
Since GET_FIELD_RESERVED_VALUE always returns a pointer, don't reference
it with "&" when used - we already have that pointer value (this is an
addendum to recent commit 028ff309472834e82fe4b849ea4c243feb5098b9).
Only GET_TYPE_RESERVED_VALUE needs to be referenced with "&" as it
returns directly the value of that type.
---
lib/report/report.c | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 818e3fd..d0351f7 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -63,6 +63,23 @@ static const char _str_unknown[] = "unknown";
static const int32_t _reserved_num_undef_32 = INT32_C(-1);
/*
+ * Get type reserved value - the value returned is the direct value of that type.
+ */
+#define GET_TYPE_RESERVED_VALUE(id) _reserved_ ## id
+
+/*
+ * Get field reserved value - the value returned is always a pointer (const void *).
+ */
+#define GET_FIELD_RESERVED_VALUE(id) _reserved_ ## id.value
+
+/*
+ * Get first name assigned to the reserved value - this is the one that
+ * should be reported/displayed. All the other names assigned for the reserved
+ * value are synonyms recognized in selection criteria.
+ */
+#define GET_FIRST_RESERVED_NAME(id) _reserved_ ## id ## _names[0]
+
+/*
* Reserved values and their assigned names.
* The first name is the one that is also used for reporting.
* All names listed are synonyms recognized in selection criteria.
@@ -76,10 +93,6 @@ static const int32_t _reserved_num_undef_32 = INT32_C(-1);
* - 'reserved_value_id_y' (for 1)
* - 'reserved_value_id_n' (for 0)
*/
-#define GET_TYPE_RESERVED_VALUE(id) _reserved_ ## id
-#define GET_FIELD_RESERVED_VALUE(id) _reserved_ ## id.value
-#define GET_FIRST_RESERVED_NAME(id) _reserved_ ## id ## _names[0]
-
#define NUM uint64_t
#define TYPE_RESERVED_VALUE(type, id, desc, value, ...) \
@@ -721,7 +734,7 @@ static int _lvreadahead_disp(struct dm_report *rh, struct dm_pool *mem,
if (lv->read_ahead == DM_READ_AHEAD_AUTO)
return _field_set_value(field, GET_FIRST_RESERVED_NAME(lv_read_ahead_auto),
- &GET_FIELD_RESERVED_VALUE(lv_read_ahead_auto));
+ GET_FIELD_RESERVED_VALUE(lv_read_ahead_auto));
return _size32_disp(rh, mem, field, &lv->read_ahead, private);
}
@@ -1021,7 +1034,7 @@ static int _vgmdacopies_disp(struct dm_report *rh, struct dm_pool *mem,
if (count == VGMETADATACOPIES_UNMANAGED)
return _field_set_value(field, GET_FIRST_RESERVED_NAME(vg_mda_copies_unmanaged),
- &GET_FIELD_RESERVED_VALUE(vg_mda_copies_unmanaged));
+ GET_FIELD_RESERVED_VALUE(vg_mda_copies_unmanaged));
return _uint32_disp(rh, mem, field, &count, private);
}
8 years, 11 months
master - report: fix segfault on NULL value hit in cache_settings field
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=57af48d734f1f7...
Commit: 57af48d734f1f7aa985424a1e11287a0975077b9
Parent: da9da0d8c2201c244d06a713134e96d2a26a0db5
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Dec 18 16:12:50 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Dec 18 17:26:12 2014 +0100
report: fix segfault on NULL value hit in cache_settings field
We have to use empty list, not NULL if we want to denote that the list
has no items. Otherwise, the code further can segfault as it expects
there's always a sane value (= some list), including empty list,
but never NULL.
---
lib/report/report.c | 19 +++++++++++++++----
test/shell/lvs-cache.sh | 3 +++
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 417396c..818e3fd 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -256,16 +256,27 @@ static int _cache_settings_disp(struct dm_report *rh, struct dm_pool *mem,
const struct dm_config_node *settings;
struct dm_list *result;
struct _str_list_append_baton baton;
+ struct dm_list dummy_list; /* dummy list to display "nothing" */
if (seg_is_cache(seg))
seg = first_seg(seg->pool_lv);
- else
- return _field_set_value(field, "", NULL /* TODO: GET_FIRST_RESERVED_NAME(cache_settings_undef) */);
+ else {
+ dm_list_init(&dummy_list);
+ return _field_set_string_list(rh, field, &dummy_list, private, 0);
+ /* TODO: once we have support for STR_LIST reserved values, replace with:
+ * return _field_set_value(field, GET_FIRST_RESERVED_NAME(cache_settings_undef), GET_FIELD_RESERVED_VALUE(cache_settings_undef));
+ */
+ }
if (seg->policy_settings)
settings = seg->policy_settings->child;
- else
- return _field_set_value(field, "", NULL /* TODO: GET_FIRST_RESERVED_NAME(cache_settings_default) */);
+ else {
+ dm_list_init(&dummy_list);
+ return _field_set_string_list(rh, field, &dummy_list, private, 0);
+ /* TODO: once we have support for STR_LIST reserved values, replace with:
+ * return _field_set_value(field, GET_FIRST_RESERVED_NAME(cache_settings_undef), GET_FIELD_RESERVED_VALUE(cache_settings_undef));
+ */
+ }
if (!(result = str_list_create(mem)))
return_0;
diff --git a/test/shell/lvs-cache.sh b/test/shell/lvs-cache.sh
index 5108076..08e83bd 100644
--- a/test/shell/lvs-cache.sh
+++ b/test/shell/lvs-cache.sh
@@ -58,6 +58,9 @@ lvs -o +cache_policy -S 'cache_policy=mq' | not grep foo
lvs -o +cache_policy -S 'cache_policy=undefined' | not grep corigin
lvs -o +cache_policy -S 'cache_policy=undefined' | grep foo
lvs -o +cache_policy -O cache_policy
+lvs -o +cache_settings -S 'cache_settings={migration_threshold=233}' | grep corigin
+lvs -o +cache_settings -S 'cache_settings!={migration_threshold=233}' | grep foo
+lvs -o +cache_policy -O cache_settings
lvremove -f $vg
8 years, 11 months
master - report: properly set "undefined" reserved value for cache_policy field
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=da9da0d8c2201c...
Commit: da9da0d8c2201c244d06a713134e96d2a26a0db5
Parent: 028ff309472834e82fe4b849ea4c243feb5098b9
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Dec 18 15:11:25 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Dec 18 15:21:21 2014 +0100
report: properly set "undefined" reserved value for cache_policy field
Use helper macros to handle reserved values and also define "undefined"
reserved value as:
FIELD_RESERVED_VALUE(cache_policy, cache_policy_undef, "", "", "undefined")
Which means:
- print "" if the cache_policy value is undefined (the first name for this reserved value is "")
- recognize "undefined" reserved name as synonym to ""
(so statements like "lvs -S cache_policy=undefined" are still recognized)
---
lib/report/report.c | 3 ++-
lib/report/values.h | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 5397d45..417396c 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -291,7 +291,8 @@ static int _cache_policy_disp(struct dm_report *rh, struct dm_pool *mem,
if (seg_is_cache(seg))
seg = first_seg(seg->pool_lv);
else
- return _field_set_value(field, "", GET_FIRST_RESERVED_NAME(cache_policy_undef));
+ return _field_set_value(field, GET_FIRST_RESERVED_NAME(cache_policy_undef),
+ GET_FIELD_RESERVED_VALUE(cache_policy_undef));
if (seg->policy_name) {
if (!(cache_policy_name = dm_pool_strdup(mem, seg->policy_name))) {
diff --git a/lib/report/values.h b/lib/report/values.h
index 4e12294..4ea92bd 100644
--- a/lib/report/values.h
+++ b/lib/report/values.h
@@ -86,7 +86,7 @@ FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, "", "read-only-o
FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead_auto, "", &GET_TYPE_RESERVED_VALUE(num_undef_64), "auto")
/* Reserved values for SEG fields */
-FIELD_RESERVED_VALUE(cache_policy, cache_policy_undef, "", "undefined", "undefined")
+FIELD_RESERVED_VALUE(cache_policy, cache_policy_undef, "", "", "", "undefined")
/* TODO the following 2 need STR_LIST support for reserved values
FIELD_RESERVED_VALUE(cache_settings, cache_settings_default, "", "default", "default")
FIELD_RESERVED_VALUE(cache_settings, cache_settings_undef, "", "undefined", "undefined") */
8 years, 11 months
master - cleanup: use helper macros to get reserved value from values.h for vg_mda_copies and lv_read_ahead fields
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=028ff309472834...
Commit: 028ff309472834e82fe4b849ea4c243feb5098b9
Parent: 7e85d4f5f631e3abc9cd3332965a44df505fe396
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Dec 18 14:52:16 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Dec 18 15:07:46 2014 +0100
cleanup: use helper macros to get reserved value from values.h for vg_mda_copies and lv_read_ahead fields
Avoid making a copy of the keyword which is already registered in
values.h for "unmanaged" (vg_mda_copies field) and "auto" reserved
value (lv_read_ahead field). Also use helper macros to handle these
reserved - this is the correct approach - just do not copy the same
thing again and do not mix it! The GET_FIELD_RESERVED_VALUE and
GET_FIRST_RESERVED_NAME macros guarantees this - use it!
In addition to that, rename reserved values:
vg_mda_copies --> vg_mda_copies_unmanaged
lv_read_ahead --> lv_read_ahead_auto
So the field reserved values follows this scheme:
"<field_name>_<reserved_value_name>".
The same applies for type reserved values with this scheme:
"<report type name in lowercase>_<reserved_value_name>"
Add a comment about this scheme for others to follow as well
when adding new fields and their reserved values. This makes
it a bit easier to read the code then.
---
lib/report/report.c | 44 +++++++++++++++++++++++---------------------
lib/report/values.h | 12 ++++++++----
2 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 81e10a1..5397d45 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -57,10 +57,10 @@ static const char _str_unknown[] = "unknown";
/*
* 32 bit signed is casted to 64 bit unsigned in dm_report_field internally!
- * So when stored in the struct, the _reserved_number_undef_32 is actually
- * equal to _reserved_number_undef_64.
+ * So when stored in the struct, the _reserved_num_undef_32 is actually
+ * equal to _reserved_num_undef_64.
*/
-static const int32_t _reserved_number_undef_32 = INT32_C(-1);
+static const int32_t _reserved_num_undef_32 = INT32_C(-1);
/*
* Reserved values and their assigned names.
@@ -171,9 +171,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, GET_FIRST_RESERVED_NAME(number_undef_64), &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, GET_FIRST_RESERVED_NAME(num_undef_64), &GET_TYPE_RESERVED_VALUE(num_undef_64));
else
- return _field_set_value(field, _str_unknown, &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, _str_unknown, &GET_TYPE_RESERVED_VALUE(num_undef_64));
}
static int _string_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -371,7 +371,7 @@ static int _lvkmaj_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(
if (lvdm->info && lvdm->info->exists && lvdm->info->major >= 0)
return dm_report_field_int(rh, field, &lvdm->info->major);
- return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(number_undef_32));
+ return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(num_undef_32));
}
static int _lvkmin_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -383,7 +383,7 @@ static int _lvkmin_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(
if (lvdm->info && lvdm->info->exists && lvdm->info->minor >= 0)
return dm_report_field_int(rh, field, &lvdm->info->minor);
- return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(number_undef_32));
+ return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(num_undef_32));
}
static int _lvstatus_disp(struct dm_report *rh __attribute__((unused)), struct dm_pool *mem,
@@ -708,7 +708,8 @@ 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", &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, GET_FIRST_RESERVED_NAME(lv_read_ahead_auto),
+ &GET_FIELD_RESERVED_VALUE(lv_read_ahead_auto));
return _size32_disp(rh, mem, field, &lv->read_ahead, private);
}
@@ -721,7 +722,7 @@ static int _lvkreadahead_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data;
if (!lvdm->info || !lvdm->info->exists)
- return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(number_undef_32));
+ return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(num_undef_32));
return _size32_disp(rh, mem, field, &lvdm->info->read_ahead, private);
}
@@ -809,7 +810,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_64));
}
static int _thinid_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -821,7 +822,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_64));
}
static int _discards_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1007,7 +1008,8 @@ 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", &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, GET_FIRST_RESERVED_NAME(vg_mda_copies_unmanaged),
+ &GET_FIELD_RESERVED_VALUE(vg_mda_copies_unmanaged));
return _uint32_disp(rh, mem, field, &count, private);
}
@@ -1172,7 +1174,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_64));
}
static int _raidwritebehind_disp(struct dm_report *rh __attribute__((unused)),
@@ -1186,7 +1188,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_64));
}
static int _raidminrecoveryrate_disp(struct dm_report *rh __attribute__((unused)),
@@ -1201,7 +1203,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_64));
}
static int _raidmaxrecoveryrate_disp(struct dm_report *rh __attribute__((unused)),
@@ -1216,7 +1218,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_64));
}
static int _datapercent_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1278,7 +1280,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_64));
}
static int _thincount_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1293,7 +1295,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_64));
}
static int _lvtime_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1648,7 +1650,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, &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, _str_unknown, &GET_TYPE_RESERVED_VALUE(num_undef_64));
merge_failed = snap_percent == LVM_PERCENT_MERGE_FAILED;
return _binary_disp(rh, mem, field, merge_failed, GET_FIRST_RESERVED_NAME(lv_merge_failed_y), private);
@@ -1663,7 +1665,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, &GET_TYPE_RESERVED_VALUE(number_undef_64));
+ return _field_set_value(field, _str_unknown, &GET_TYPE_RESERVED_VALUE(num_undef_64));
snap_invalid = !lv_snapshot_percent(lv, &snap_percent) || snap_percent == DM_PERCENT_INVALID;
return _binary_disp(rh, mem, field, snap_invalid, GET_FIRST_RESERVED_NAME(lv_snapshot_invalid_y), private);
@@ -1775,7 +1777,7 @@ static int _cache_ ## cache_status_field_name ## _disp (struct dm_report *rh, \
{ \
const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data; \
if (lvdm->seg_status->type != SEG_STATUS_CACHE) \
- return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(number_undef_64)); \
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_64)); \
return dm_report_field_uint64(rh, field, (void *) ((char *) lvdm->seg_status->status + offsetof(struct dm_status_cache, cache_status_field_name))); \
}
diff --git a/lib/report/values.h b/lib/report/values.h
index adf22b3..4e12294 100644
--- a/lib/report/values.h
+++ b/lib/report/values.h
@@ -21,9 +21,13 @@
*
* 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.
+ * value for all fields of that type then. When naming type reserved value,
+ * please follow this naming scheme:
+ * <report type name in lowercase>_<reserved_value_name>
*
* FIELD_RESERVED_VALUE defines reserved value bound to a single field.
+ * When naming reserved value for the field, please follow this naming scheme:
+ * <field_name>_<reserved_value_name>
*
* FIELD_BINARY_RESERVED_VALUE is similar to FIELD_RESERVED_VALUE but it
* is specifically designed for defintion of reserved names for fields
@@ -42,7 +46,7 @@
/* *INDENT-OFF* */
/* Per-type reserved values usable for all fields of certain type. */
-TYPE_RESERVED_VALUE(NUM, number_undef_64, "Reserved value for undefined numeric value.", UINT64_C(-1), "-1", "unknown", "undefined", "undef")
+TYPE_RESERVED_VALUE(NUM, num_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")
@@ -56,7 +60,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, "", "writeable", "writeable", "rw", "read-write")
FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_r, "", "read-only", "read-only", "r", "ro")
-FIELD_RESERVED_VALUE(vg_mda_copies, vg_mda_copies, "", &GET_TYPE_RESERVED_VALUE(number_undef_64), "unmanaged")
+FIELD_RESERVED_VALUE(vg_mda_copies, vg_mda_copies_unmanaged, "", &GET_TYPE_RESERVED_VALUE(num_undef_64), "unmanaged")
/* Reserved values for LV fields */
FIELD_RESERVED_BINARY_VALUE(lv_initial_image_sync, lv_initial_image_sync, "", "initial image sync", "sync")
@@ -79,7 +83,7 @@ FIELD_RESERVED_BINARY_VALUE(zero, zero, "", "zero")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_rw, "", "writeable", "writeable", "rw", "read-write")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, "", "read-only", "read-only", "r", "ro")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, "", "read-only-override", "read-only-override", "ro-override", "r-override", "R")
-FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead, "", &GET_TYPE_RESERVED_VALUE(number_undef_64), "auto")
+FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead_auto, "", &GET_TYPE_RESERVED_VALUE(num_undef_64), "auto")
/* Reserved values for SEG fields */
FIELD_RESERVED_VALUE(cache_policy, cache_policy_undef, "", "undefined", "undefined")
8 years, 11 months
master - refactor: rename existing helper macros for reserved value handling and add GET_FIELD_RESERVED_VALUE macro
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7e85d4f5f631e3...
Commit: 7e85d4f5f631e3abc9cd3332965a44df505fe396
Parent: f6f32f39e4ef007fd8566fe32c00975f917fc807
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Dec 18 14:42:14 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Dec 18 14:42:14 2014 +0100
refactor: rename existing helper macros for reserved value handling and add GET_FIELD_RESERVED_VALUE macro
RESERVED(id) --> GET_TYPE_RESERVED_VALUE(id)
FIRST_NAME(id) --> GET_FIRST_RESERVED_NAME(id)
Also add GET_FIELD_RESERVED_VALUE(id) macro to get per-field reserved value.
This makes it much more readable and hopefully it'll make it
easier to use these helper macros when adding new reporting
fields with reserved values if needed.
---
lib/report/report.c | 107 ++++++++++++++++++++++++++-------------------------
lib/report/values.h | 4 +-
2 files changed, 56 insertions(+), 55 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index a23b226..81e10a1 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -76,8 +76,9 @@ 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 GET_TYPE_RESERVED_VALUE(id) _reserved_ ## id
+#define GET_FIELD_RESERVED_VALUE(id) _reserved_ ## id.value
+#define GET_FIRST_RESERVED_NAME(id) _reserved_ ## id ## _names[0]
#define NUM uint64_t
@@ -123,9 +124,9 @@ static const struct dm_report_reserved_value _report_reserved_values[] = {
};
#undef NUM
-#undef TYPE_RESERVED_VALUE_REG
-#undef FIELD_RESERVED_VALUE_REG
-#undef FIELD_RESERVED_BINARY_VALUE_REG
+#undef TYPE_RESERVED_VALUE
+#undef FIELD_RESERVED_VALUE
+#undef FIELD_RESERVED_BINARY_VALUE
static int _field_set_value(struct dm_report_field *field, const void *data, const void *sort)
{
@@ -170,9 +171,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, GET_FIRST_RESERVED_NAME(number_undef_64), &GET_TYPE_RESERVED_VALUE(number_undef_64));
else
- return _field_set_value(field, _str_unknown, &RESERVED(number_undef_64));
+ return _field_set_value(field, _str_unknown, &GET_TYPE_RESERVED_VALUE(number_undef_64));
}
static int _string_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -259,12 +260,12 @@ static int _cache_settings_disp(struct dm_report *rh, struct dm_pool *mem,
if (seg_is_cache(seg))
seg = first_seg(seg->pool_lv);
else
- return _field_set_value(field, "", NULL /* TODO: FIRST_NAME(cache_settings_undef) */);
+ return _field_set_value(field, "", NULL /* TODO: GET_FIRST_RESERVED_NAME(cache_settings_undef) */);
if (seg->policy_settings)
settings = seg->policy_settings->child;
else
- return _field_set_value(field, "", NULL /* TODO: FIRST_NAME(cache_settings_default) */);
+ return _field_set_value(field, "", NULL /* TODO: GET_FIRST_RESERVED_NAME(cache_settings_default) */);
if (!(result = str_list_create(mem)))
return_0;
@@ -290,7 +291,7 @@ static int _cache_policy_disp(struct dm_report *rh, struct dm_pool *mem,
if (seg_is_cache(seg))
seg = first_seg(seg->pool_lv);
else
- return _field_set_value(field, "", FIRST_NAME(cache_policy_undef));
+ return _field_set_value(field, "", GET_FIRST_RESERVED_NAME(cache_policy_undef));
if (seg->policy_name) {
if (!(cache_policy_name = dm_pool_strdup(mem, seg->policy_name))) {
@@ -370,7 +371,7 @@ static int _lvkmaj_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(
if (lvdm->info && lvdm->info->exists && lvdm->info->major >= 0)
return dm_report_field_int(rh, field, &lvdm->info->major);
- return dm_report_field_int32(rh, field, &RESERVED(number_undef_32));
+ return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(number_undef_32));
}
static int _lvkmin_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -382,7 +383,7 @@ static int _lvkmin_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(
if (lvdm->info && lvdm->info->exists && lvdm->info->minor >= 0)
return dm_report_field_int(rh, field, &lvdm->info->minor);
- return dm_report_field_int32(rh, field, &RESERVED(number_undef_32));
+ return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(number_undef_32));
}
static int _lvstatus_disp(struct dm_report *rh __attribute__((unused)), struct dm_pool *mem,
@@ -707,7 +708,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", &GET_TYPE_RESERVED_VALUE(number_undef_64));
return _size32_disp(rh, mem, field, &lv->read_ahead, private);
}
@@ -720,7 +721,7 @@ static int _lvkreadahead_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data;
if (!lvdm->info || !lvdm->info->exists)
- return dm_report_field_int32(rh, field, &RESERVED(number_undef_32));
+ return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(number_undef_32));
return _size32_disp(rh, mem, field, &lvdm->info->read_ahead, private);
}
@@ -808,7 +809,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
}
static int _thinid_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -820,7 +821,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
}
static int _discards_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1006,7 +1007,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", &GET_TYPE_RESERVED_VALUE(number_undef_64));
return _uint32_disp(rh, mem, field, &count, private);
}
@@ -1171,7 +1172,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
}
static int _raidwritebehind_disp(struct dm_report *rh __attribute__((unused)),
@@ -1185,7 +1186,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
}
static int _raidminrecoveryrate_disp(struct dm_report *rh __attribute__((unused)),
@@ -1200,7 +1201,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
}
static int _raidmaxrecoveryrate_disp(struct dm_report *rh __attribute__((unused)),
@@ -1215,7 +1216,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
}
static int _datapercent_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1277,7 +1278,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
}
static int _thincount_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1292,7 +1293,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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64));
}
static int _lvtime_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1336,7 +1337,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_y), private);
+ return _binary_disp(rh, mem, field, allocatable, GET_FIRST_RESERVED_NAME(pv_allocatable_y), private);
}
static int _pvexported_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1344,7 +1345,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_y), private);
+ return _binary_disp(rh, mem, field, exported, GET_FIRST_RESERVED_NAME(pv_exported_y), private);
}
static int _pvmissing_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1352,15 +1353,15 @@ 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_y), private);
+ return _binary_disp(rh, mem, field, missing, GET_FIRST_RESERVED_NAME(pv_missing_y), private);
}
static int _vgpermissions_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
{
- const char *perms = ((const struct volume_group *) data)->status & LVM_WRITE ? FIRST_NAME(vg_permissions_rw)
- : FIRST_NAME(vg_permissions_r);
+ const char *perms = ((const struct volume_group *) data)->status & LVM_WRITE ? GET_FIRST_RESERVED_NAME(vg_permissions_rw)
+ : GET_FIRST_RESERVED_NAME(vg_permissions_r);
return _string_disp(rh, mem, field, &perms, private);
}
@@ -1369,7 +1370,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_y),private);
+ return _binary_disp(rh, mem, field, extendable, GET_FIRST_RESERVED_NAME(vg_extendable_y),private);
}
static int _vgexported_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1377,7 +1378,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_y), private);
+ return _binary_disp(rh, mem, field, exported, GET_FIRST_RESERVED_NAME(vg_exported_y), private);
}
static int _vgpartial_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1385,7 +1386,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_y), private);
+ return _binary_disp(rh, mem, field, partial, GET_FIRST_RESERVED_NAME(vg_partial_y), private);
}
static int _vgallocationpolicy_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1401,7 +1402,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_y), private);
+ return _binary_disp(rh, mem, field, clustered, GET_FIRST_RESERVED_NAME(vg_clustered_y), private);
}
static int _lvlayout_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1448,7 +1449,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_y), private);
+ return _binary_disp(rh, mem, field, initial_image_sync, GET_FIRST_RESERVED_NAME(lv_initial_image_sync_y), private);
}
static int _lvimagesynced_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1465,7 +1466,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_y), private);
+ return _binary_disp(rh, mem, field, image_synced, GET_FIRST_RESERVED_NAME(lv_image_synced_y), private);
}
static int _lvmerging_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1484,7 +1485,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_y), private);
+ return _binary_disp(rh, mem, field, merging, GET_FIRST_RESERVED_NAME(lv_merging_y), private);
}
static int _lvconverting_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1508,11 +1509,11 @@ static int _lvpermissions_disp(struct dm_report *rh, struct dm_pool *mem,
if (!lvdm->info->exists)
perms = _str_unknown;
else if (lvdm->info->read_only)
- perms = FIRST_NAME(lv_permissions_r_override);
+ perms = GET_FIRST_RESERVED_NAME(lv_permissions_r_override);
else
- perms = FIRST_NAME(lv_permissions_rw);
+ perms = GET_FIRST_RESERVED_NAME(lv_permissions_rw);
} else if (lvdm->lv->status & LVM_READ)
- perms = FIRST_NAME(lv_permissions_r);
+ perms = GET_FIRST_RESERVED_NAME(lv_permissions_r);
else
perms = _str_unknown;
}
@@ -1534,7 +1535,7 @@ static int _lvallocationlocked_disp(struct dm_report *rh, struct dm_pool *mem,
{
int alloc_locked = (((const struct logical_volume *) data)->status & LOCKED) != 0;
- return _binary_disp(rh, mem, field, alloc_locked, FIRST_NAME(lv_allocation_locked_y), private);
+ return _binary_disp(rh, mem, field, alloc_locked, GET_FIRST_RESERVED_NAME(lv_allocation_locked_y), private);
}
static int _lvfixedminor_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1543,7 +1544,7 @@ static int _lvfixedminor_disp(struct dm_report *rh, struct dm_pool *mem,
{
int fixed_minor = (((const struct logical_volume *) data)->status & FIXED_MINOR) != 0;
- return _binary_disp(rh, mem, field, fixed_minor, FIRST_NAME(lv_fixed_minor_y), private);
+ return _binary_disp(rh, mem, field, fixed_minor, GET_FIRST_RESERVED_NAME(lv_fixed_minor_y), private);
}
static int _lvactive_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1576,7 +1577,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_y), private);
+ return _binary_disp(rh, mem, field, active_locally, GET_FIRST_RESERVED_NAME(lv_active_locally_y), private);
}
static int _lvactiveremotely_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1616,7 +1617,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_y), private);
+ return _binary_disp(rh, mem, field, active_remotely, GET_FIRST_RESERVED_NAME(lv_active_remotely_y), private);
}
static int _lvactiveexclusively_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1635,7 +1636,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_y), private);
+ return _binary_disp(rh, mem, field, active_exclusively, GET_FIRST_RESERVED_NAME(lv_active_exclusively_y), private);
}
static int _lvmergefailed_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1647,10 +1648,10 @@ 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, &GET_TYPE_RESERVED_VALUE(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);
+ return _binary_disp(rh, mem, field, merge_failed, GET_FIRST_RESERVED_NAME(lv_merge_failed_y), private);
}
static int _lvsnapshotinvalid_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1662,10 +1663,10 @@ 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, &GET_TYPE_RESERVED_VALUE(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);
+ return _binary_disp(rh, mem, field, snap_invalid, GET_FIRST_RESERVED_NAME(lv_snapshot_invalid_y), private);
}
static int _lvsuspended_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1675,7 +1676,7 @@ static int _lvsuspended_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data;
if (lvdm->info->exists)
- return _binary_disp(rh, mem, field, lvdm->info->suspended, FIRST_NAME(lv_suspended_y), private);
+ return _binary_disp(rh, mem, field, lvdm->info->suspended, GET_FIRST_RESERVED_NAME(lv_suspended_y), private);
return _binary_undef_disp(rh, mem, field, private);
}
@@ -1687,7 +1688,7 @@ static int _lvlivetable_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data;
if (lvdm->info->exists)
- return _binary_disp(rh, mem, field, lvdm->info->live_table, FIRST_NAME(lv_live_table_y), private);
+ return _binary_disp(rh, mem, field, lvdm->info->live_table, GET_FIRST_RESERVED_NAME(lv_live_table_y), private);
return _binary_undef_disp(rh, mem, field, private);
}
@@ -1699,7 +1700,7 @@ static int _lvinactivetable_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data;
if (lvdm->info->exists)
- return _binary_disp(rh, mem, field, lvdm->info->inactive_table, FIRST_NAME(lv_inactive_table_y), private);
+ return _binary_disp(rh, mem, field, lvdm->info->inactive_table, GET_FIRST_RESERVED_NAME(lv_inactive_table_y), private);
return _binary_undef_disp(rh, mem, field, private);
}
@@ -1711,7 +1712,7 @@ static int _lvdeviceopen_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data;
if (lvdm->info->exists)
- return _binary_disp(rh, mem, field, lvdm->info->open_count, FIRST_NAME(lv_device_open_y), private);
+ return _binary_disp(rh, mem, field, lvdm->info->open_count, GET_FIRST_RESERVED_NAME(lv_device_open_y), private);
return _binary_undef_disp(rh, mem, field, private);
}
@@ -1723,7 +1724,7 @@ static int _thinzero_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_segment *seg = (const struct lv_segment *) data;
if (seg_is_thin_pool(seg))
- return _binary_disp(rh, mem, field, seg->zero_new_blocks, FIRST_NAME(zero_y), private);
+ return _binary_disp(rh, mem, field, seg->zero_new_blocks, GET_FIRST_RESERVED_NAME(zero_y), private);
return _binary_undef_disp(rh, mem, field, private);
}
@@ -1774,7 +1775,7 @@ static int _cache_ ## cache_status_field_name ## _disp (struct dm_report *rh, \
{ \
const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data; \
if (lvdm->seg_status->type != SEG_STATUS_CACHE) \
- return _field_set_value(field, "", &RESERVED(number_undef_64)); \
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(number_undef_64)); \
return dm_report_field_uint64(rh, field, (void *) ((char *) lvdm->seg_status->status + offsetof(struct dm_status_cache, cache_status_field_name))); \
}
diff --git a/lib/report/values.h b/lib/report/values.h
index b0382c0..adf22b3 100644
--- a/lib/report/values.h
+++ b/lib/report/values.h
@@ -56,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, "", "writeable", "writeable", "rw", "read-write")
FIELD_RESERVED_VALUE(vg_permissions, vg_permissions_r, "", "read-only", "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, "", &GET_TYPE_RESERVED_VALUE(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")
@@ -79,7 +79,7 @@ FIELD_RESERVED_BINARY_VALUE(zero, zero, "", "zero")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_rw, "", "writeable", "writeable", "rw", "read-write")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, "", "read-only", "read-only", "r", "ro")
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, "", "read-only-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, "", &GET_TYPE_RESERVED_VALUE(number_undef_64), "auto")
/* Reserved values for SEG fields */
FIELD_RESERVED_VALUE(cache_policy, cache_policy_undef, "", "undefined", "undefined")
8 years, 11 months
master - report: dup cache policy name string for report in cache_policy field
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f6f32f39e4ef00...
Commit: f6f32f39e4ef007fd8566fe32c00975f917fc807
Parent: aaf25ec6bd2201d4219765d7bfca05636b554145
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Dec 18 11:54:40 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Dec 18 11:54:40 2014 +0100
report: dup cache policy name string for report in cache_policy field
The cache policy name taken as LV segment property must be duped
for report as the VG/LV/seg structure is destroyed after processing,
reporting happens later:
$ valgrind lvs -o+cache_policy
...
==16589== Invalid read of size 1
==16589== at 0x54ABCC3: dm_report_compact_fields
(libdm-report.c:1739)
==16589== by 0x153FC7: _report (reporter.c:619)
==16589== by 0x1540A6: lvs (reporter.c:641)
==16589== by 0x148021: lvm_run_command (lvmcmdline.c:1452)
==16589== by 0x1495CB: lvm2_main (lvmcmdline.c:1907)
==16589== by 0x164712: main (lvm.c:21)
==16589== Address 0x7d465f2 is 8,338 bytes inside a block of size
16,384 free'd
==16589== at 0x4C2ACE9: free (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==16589== by 0x54B8C85: _free_chunk (pool-fast.c:318)
==16589== by 0x54B84FB: dm_pool_destroy (pool-fast.c:78)
==16589== by 0x1E59C7: _free_vg (vg.c:78)
==16589== by 0x1E5A6D: release_vg (vg.c:95)
==16589== by 0x159B6E: _process_lv_vgnameid_list (toollib.c:1967)
==16589== by 0x159DD7: process_each_lv (toollib.c:2030)
==16589== by 0x153ED8: _report (reporter.c:598)
==16589== by 0x1540A6: lvs (reporter.c:641)
==16589== by 0x148021: lvm_run_command (lvmcmdline.c:1452)
==16589== by 0x1495CB: lvm2_main (lvmcmdline.c:1907)
==16589== by 0x164712: main (lvm.c:21)
---
lib/report/report.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 173157d..a23b226 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -285,15 +285,20 @@ static int _cache_policy_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data, void *private)
{
const struct lv_segment *seg = (const struct lv_segment *) data;
+ const char *cache_policy_name;
if (seg_is_cache(seg))
seg = first_seg(seg->pool_lv);
else
return _field_set_value(field, "", FIRST_NAME(cache_policy_undef));
- if (seg->policy_name)
- return _field_set_value(field, seg->policy_name, NULL);
- else {
+ if (seg->policy_name) {
+ if (!(cache_policy_name = dm_pool_strdup(mem, seg->policy_name))) {
+ log_error("dm_pool_strdup failed");
+ return 0;
+ }
+ return _field_set_value(field, cache_policy_name, NULL);
+ } else {
log_error(INTERNAL_ERROR "unexpected NULL policy name");
return_0;
}
8 years, 11 months
master - libdm: report: also check whether field type is supported for field-specific reserved value
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=aaf25ec6bd2201...
Commit: aaf25ec6bd2201d4219765d7bfca05636b554145
Parent: e471ea7890cf555ad920ca67a38254dd2504dabe
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Dec 18 11:29:48 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Dec 18 11:29:48 2014 +0100
libdm: report: also check whether field type is supported for field-specific reserved value
We only checked global per-report-type reserved values for compatibility
with selection code. This patch also adds a check for per-report-field
reserved values. This avoids problems where unsupported report type is
used as reserved value which could cause hard to debug problems
otherwise. So this additional check stops from registering unsupported
and unhandled per-field reserved values.
Registerting such unsupported reserved value is a programmatic error,
so report internal error in this case to stop us from making a mistake
here in the future or even today where STR_LIST fields can't have
reserved values yet.
---
libdm/libdm-report.c | 29 ++++++++++++++++++++++++-----
1 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index e3c3d2f..5ff6cda 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -1995,9 +1995,12 @@ dm_percent_t dm_make_percent(uint64_t numerator, uint64_t denominator)
* Used to check whether the reserved_values definition passed to
* dm_report_init_with_selection contains only supported reserved value types.
*/
-static int _check_reserved_values_supported(const struct dm_report_reserved_value reserved_values[])
+static int _check_reserved_values_supported(const struct dm_report_field_type fields[],
+ const struct dm_report_reserved_value reserved_values[])
{
const struct dm_report_reserved_value *iter;
+ const struct dm_report_field_reserved_value *field_res;
+ const struct dm_report_field_type *field;
static uint32_t supported_reserved_types = DM_REPORT_FIELD_TYPE_NUMBER |
DM_REPORT_FIELD_TYPE_SIZE |
DM_REPORT_FIELD_TYPE_PERCENT |
@@ -2008,9 +2011,25 @@ static int _check_reserved_values_supported(const struct dm_report_reserved_valu
iter = reserved_values;
- while (iter->type) {
- if (!(iter->type & supported_reserved_types))
- return 0;
+ while (iter->value) {
+ if (iter->type) {
+ if (!(iter->type & supported_reserved_types)) {
+ log_error(INTERNAL_ERROR "_check_reserved_values_supported: "
+ "global reserved value for type 0x%x not supported",
+ iter->type);
+ return 0;
+ }
+ } else {
+ field_res = (const struct dm_report_field_reserved_value *) iter->value;
+ field = &fields[field_res->field_num];
+ if (!(field->flags & supported_reserved_types)) {
+ log_error(INTERNAL_ERROR "_check_reserved_values_supported: "
+ "field-specific reserved value of type 0x%x for "
+ "field %s not supported",
+ field->flags & DM_REPORT_FIELD_TYPE_MASK, field->id);
+ return 0;
+ }
+ }
iter++;
}
@@ -2906,7 +2925,7 @@ struct dm_report *dm_report_init_with_selection(uint32_t *report_types,
return rh;
}
- if (!_check_reserved_values_supported(reserved_values)) {
+ if (!_check_reserved_values_supported(fields, reserved_values)) {
log_error(INTERNAL_ERROR "dm_report_init_with_selection: "
"trying to register unsupported reserved value type, "
"skipping report selection");
8 years, 11 months
master - WHATS_NEW: previous commit
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e471ea7890cf55...
Commit: e471ea7890cf555ad920ca67a38254dd2504dabe
Parent: 00ad13eb719607682dfcf17d99ad96cfd5603d14
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Dec 17 15:06:48 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Dec 17 15:06:48 2014 +0100
WHATS_NEW: previous commit
---
WHATS_NEW | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6f289bb..cc11a9a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,6 +1,6 @@
Version 2.02.115 -
=====================================
- Add cache_policy and cache_settings output fields in lvs.
+ Add cache_policy and cache_settings reporting fields.
Add missing recognition for --binary option with {pv,vg,lv}display -C.
Fix vgimportclone to notify lvmetad about changes done if lvmetad is used.
Fix vgimportclone to properly override config if it is missing in lvm.conf.
8 years, 11 months
master - report: Add cache_policy and cache_settings (LV) segment fields.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=00ad13eb719607...
Commit: 00ad13eb719607682dfcf17d99ad96cfd5603d14
Parent: 2e905d454058ef17bbb2b9758c59a5505d1c95be
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Dec 15 20:48:05 2014 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed Dec 17 14:43:12 2014 +0100
report: Add cache_policy and cache_settings (LV) segment fields.
---
WHATS_NEW | 1 +
lib/report/columns.h | 2 +
lib/report/properties.c | 5 +++
lib/report/report.c | 68 ++++++++++++++++++++++++++++++++++++++++++
lib/report/values.h | 6 ++++
test/shell/lvcreate-cache.sh | 3 ++
test/shell/lvs-cache.sh | 65 ++++++++++++++++++++++++++++++++++++++++
7 files changed, 150 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4855e1a..6f289bb 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Add cache_policy and cache_settings output fields in lvs.
Add missing recognition for --binary option with {pv,vg,lv}display -C.
Fix vgimportclone to notify lvmetad about changes done if lvmetad is used.
Fix vgimportclone to properly override config if it is missing in lvm.conf.
diff --git a/lib/report/columns.h b/lib/report/columns.h
index db43e13..1dd2ae0 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -178,6 +178,8 @@ FIELD(SEGS, seg, STR_LIST, "Seg Tags", tags, 8, tags, seg_tags, "Tags, if any.",
FIELD(SEGS, seg, STR, "PE Ranges", list, 9, peranges, seg_pe_ranges, "Ranges of Physical Extents of underlying devices in command line format.", 0)
FIELD(SEGS, seg, STR, "Devices", list, 7, devices, devices, "Underlying devices used with starting extent numbers.", 0)
FIELD(SEGS, seg, STR, "Monitor", list, 7, segmonitor, seg_monitor, "Dmeventd monitoring status of the segment.", 0)
+FIELD(SEGS, seg, STR, "Cache Policy", list, 12, cache_policy, cache_policy, "The cache policy (cached segments only).", 0)
+FIELD(SEGS, seg, STR_LIST, "Cache Settings", list, 14, cache_settings, cache_settings, "Cache settings/parameters (cached segments only).", 0)
FIELD(PVSEGS, pvseg, NUM, "Start", pe, 5, uint32, pvseg_start, "Physical Extent number of start of segment.", 0)
FIELD(PVSEGS, pvseg, NUM, "SSize", len, 5, uint32, pvseg_size, "Number of extents in segment.", 0)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index 2308c36..4796000 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -440,6 +440,11 @@ GET_LVSEG_STR_PROPERTY_FN(devices, lvseg_devices(lvseg->lv->vg->vgmem, lvseg))
GET_LVSEG_STR_PROPERTY_FN(seg_monitor, lvseg_monitor_dup(lvseg->lv->vg->vgmem, lvseg))
#define _seg_monitor_set prop_not_implemented_set
+#define _cache_policy_get prop_not_implemented_get
+#define _cache_policy_set prop_not_implemented_set
+#define _cache_settings_get prop_not_implemented_get
+#define _cache_settings_set prop_not_implemented_set
+
/* PVSEG */
GET_PVSEG_NUM_PROPERTY_FN(pvseg_start, pvseg->pe)
#define _pvseg_start_set prop_not_implemented_set
diff --git a/lib/report/report.c b/lib/report/report.c
index 5637d50..173157d 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -231,6 +231,74 @@ static int _tags_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_string_list(rh, field, tagsl, private, 1);
}
+struct _str_list_append_baton {
+ struct dm_pool *mem;
+ struct dm_list *result;
+};
+
+static int _str_list_append(const char *line, void *baton)
+{
+ struct _str_list_append_baton *b = baton;
+ const char *dup = dm_pool_strdup(b->mem, line);
+ if (!dup)
+ return_0;
+ if (!str_list_add(b->mem, b->result, dup))
+ return_0;
+ return 1;
+}
+
+static int _cache_settings_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;
+ const struct dm_config_node *settings;
+ struct dm_list *result;
+ struct _str_list_append_baton baton;
+
+ if (seg_is_cache(seg))
+ seg = first_seg(seg->pool_lv);
+ else
+ return _field_set_value(field, "", NULL /* TODO: FIRST_NAME(cache_settings_undef) */);
+
+ if (seg->policy_settings)
+ settings = seg->policy_settings->child;
+ else
+ return _field_set_value(field, "", NULL /* TODO: FIRST_NAME(cache_settings_default) */);
+
+ if (!(result = str_list_create(mem)))
+ return_0;
+
+ baton.mem = mem;
+ baton.result = result;
+
+ while (settings) {
+ dm_config_write_one_node(settings, _str_list_append, &baton);
+ settings = settings->sib;
+ };
+
+ return _field_set_string_list(rh, field, result, private, 0);
+}
+
+static int _cache_policy_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_cache(seg))
+ seg = first_seg(seg->pool_lv);
+ else
+ return _field_set_value(field, "", FIRST_NAME(cache_policy_undef));
+
+ if (seg->policy_name)
+ return _field_set_value(field, seg->policy_name, NULL);
+ else {
+ log_error(INTERNAL_ERROR "unexpected NULL policy name");
+ return_0;
+ }
+}
+
static int _modules_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
diff --git a/lib/report/values.h b/lib/report/values.h
index f909ce9..b0382c0 100644
--- a/lib/report/values.h
+++ b/lib/report/values.h
@@ -81,4 +81,10 @@ FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r, "", "read-only", "read-on
FIELD_RESERVED_VALUE(lv_permissions, lv_permissions_r_override, "", "read-only-override", "read-only-override", "ro-override", "r-override", "R")
FIELD_RESERVED_VALUE(lv_read_ahead, lv_read_ahead, "", &RESERVED(number_undef_64), "auto")
+/* Reserved values for SEG fields */
+FIELD_RESERVED_VALUE(cache_policy, cache_policy_undef, "", "undefined", "undefined")
+/* TODO the following 2 need STR_LIST support for reserved values
+FIELD_RESERVED_VALUE(cache_settings, cache_settings_default, "", "default", "default")
+FIELD_RESERVED_VALUE(cache_settings, cache_settings_undef, "", "undefined", "undefined") */
+
/* *INDENT-ON* */
diff --git a/test/shell/lvcreate-cache.sh b/test/shell/lvcreate-cache.sh
index f709d8b..89efc4d 100644
--- a/test/shell/lvcreate-cache.sh
+++ b/test/shell/lvcreate-cache.sh
@@ -230,6 +230,9 @@ lvcreate --type cache-pool -L10 $vg/cpool
lvcreate --type cache -l 1 --cachepool $vg/cpool -n corigin $vg --cachepolicy mq --cachesettings migration_threshold=233
dmsetup status | grep $vg
dmsetup status | grep $vg-corigin | grep 'migration_threshold 233'
+lvchange -an $vg
+lvchange -ay $vg
+dmsetup status | grep $vg-corigin | grep 'migration_threshold 233'
lvremove -f $vg
diff --git a/test/shell/lvs-cache.sh b/test/shell/lvs-cache.sh
new file mode 100644
index 0000000..5108076
--- /dev/null
+++ b/test/shell/lvs-cache.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU 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
+
+# Exercise creation of cache and cache pool volumes
+
+# Full CLI uses --type
+# Shorthand CLI uses -H | --cache
+
+. lib/inittest
+
+aux have_cache 1 3 0 || skip
+aux prepare_vg 5 8000
+
+lvcreate --type cache-pool -L10 $vg/cpool
+lvcreate --type cache -l 1 --cachepool $vg/cpool -n corigin $vg
+lvs -o lv_name,cache_policy
+lvs -o lv_name,cache_settings
+
+lvremove -f $vg
+
+lvcreate --type cache-pool -L10 $vg/cpool
+lvcreate --type cache -l 1 --cachepool $vg/cpool -n corigin $vg --cachepolicy mq \
+ --cachesettings migration_threshold=233
+lvs -o lv_name,cache_policy | grep mq
+lvs -o lv_name,cache_settings | grep migration_threshold=233
+
+lvremove -f $vg
+
+lvcreate --type cache-pool -L10 --cachepolicy mq --cachesettings migration_threshold=233 $vg/cpool
+lvcreate --type cache -l 1 --cachepool $vg/cpool -n corigin $vg
+lvs -o lv_name,cache_policy | grep mq
+lvs -o lv_name,cache_settings | grep migration_threshold=233
+
+lvremove -f $vg
+
+lvcreate --type cache-pool -L10 --cachepolicy mq --cachesettings migration_threshold=233 --cachesettings sequential_threshold=13 $vg/cpool
+lvcreate --type cache -l 1 --cachepool $vg/cpool -n corigin $vg
+lvs -o lv_name,cache_policy | grep mq
+lvs -a -o lv_name,cache_policy -S 'cache_policy=mq' | grep corigin
+lvs -o lv_name,cache_settings | grep migration_threshold=233
+lvs -o lv_name,cache_settings | grep sequential_threshold=13
+
+lvcreate -n foo -l 1 $vg
+lvs -S 'cache_policy=mq' | grep corigin
+lvs -S 'cache_policy=mq' | not grep foo
+lvs -S 'cache_policy=undefined' | not grep corigin
+lvs -S 'cache_policy=undefined' | grep foo
+lvs -o +cache_policy -S 'cache_policy=mq' | grep corigin
+lvs -o +cache_policy -S 'cache_policy=mq' | not grep foo
+lvs -o +cache_policy -S 'cache_policy=undefined' | not grep corigin
+lvs -o +cache_policy -S 'cache_policy=undefined' | grep foo
+lvs -o +cache_policy -O cache_policy
+
+lvremove -f $vg
+
+lvcreate -n foo -l 1 $vg
+lvs -a -S 'cache_policy=undefined' | grep foo
8 years, 11 months
master - tests: skip cache tests in cluster
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3e20bf7e71ace2...
Commit: 3e20bf7e71ace22f554a8c2f7abb7af14d1c90ac
Parent: 40e1d5b269fa76b839e3e8e2e7c9beb2bbbfed5e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Dec 16 11:43:48 2014 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Dec 16 11:43:48 2014 -0600
tests: skip cache tests in cluster
The previous commit disabled cache types with cluster.
Disable the tests also.
---
test/shell/lvchange-cache.sh | 2 ++
test/shell/lvconvert-cache-raid.sh | 2 ++
test/shell/lvconvert-cache-thin.sh | 2 ++
test/shell/lvconvert-cache.sh | 2 ++
test/shell/lvcreate-cache.sh | 2 ++
5 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvchange-cache.sh b/test/shell/lvchange-cache.sh
index 87a217a..3b108c1 100644
--- a/test/shell/lvchange-cache.sh
+++ b/test/shell/lvchange-cache.sh
@@ -11,6 +11,8 @@
. lib/inittest
+test -e LOCAL_CLVMD && skip
+
aux have_cache 1 3 0 || skip
aux prepare_vg 3
diff --git a/test/shell/lvconvert-cache-raid.sh b/test/shell/lvconvert-cache-raid.sh
index faab251..f0e0d19 100644
--- a/test/shell/lvconvert-cache-raid.sh
+++ b/test/shell/lvconvert-cache-raid.sh
@@ -13,6 +13,8 @@
. lib/inittest
+test -e LOCAL_CLVMD && skip
+
aux have_cache 1 3 0 || skip
aux have_raid 1 0 0 || skip
diff --git a/test/shell/lvconvert-cache-thin.sh b/test/shell/lvconvert-cache-thin.sh
index 87256a4..09971b5 100644
--- a/test/shell/lvconvert-cache-thin.sh
+++ b/test/shell/lvconvert-cache-thin.sh
@@ -13,6 +13,8 @@
. lib/inittest
+test -e LOCAL_CLVMD && skip
+
aux have_cache 1 3 0 || skip
aux have_thin 1 0 0 || skip
diff --git a/test/shell/lvconvert-cache.sh b/test/shell/lvconvert-cache.sh
index ed414ed..35b4ba8 100644
--- a/test/shell/lvconvert-cache.sh
+++ b/test/shell/lvconvert-cache.sh
@@ -13,6 +13,8 @@
. lib/inittest
+test -e LOCAL_CLVMD && skip
+
aux have_cache 1 3 0 || skip
aux prepare_vg 5 80
diff --git a/test/shell/lvcreate-cache.sh b/test/shell/lvcreate-cache.sh
index f709d8b..6e9b33a 100644
--- a/test/shell/lvcreate-cache.sh
+++ b/test/shell/lvcreate-cache.sh
@@ -16,6 +16,8 @@
. lib/inittest
+test -e LOCAL_CLVMD && skip
+
aux have_cache 1 3 0 || skip
# FIXME: parallel cache metadata allocator is crashing when used value 8000!
8 years, 11 months