master - dev-type: print log_sys_debug
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a94abc0fdd33b3...
Commit: a94abc0fdd33b31cd292d9b9a61ddceb7b72208f
Parent: ac60c876c43d0ebc7e642dcc92528b974bd7b9f5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jul 3 12:03:16 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jul 4 12:31:17 2014 +0200
dev-type: print log_sys_debug
For non-fatal error use log_sys_debug as the tool
is not stopping on these errors.
---
lib/device/dev-type.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index e0cae45..0d91017 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -676,7 +676,7 @@ static unsigned long _dev_topology_attribute(struct dev_types *dt,
*/
if (stat(path, &info) == -1) {
if (errno != ENOENT) {
- log_sys_error("stat", path);
+ log_sys_debug("stat", path);
return 0;
}
if (!dev_get_primary_dev(dt, dev, &primary))
@@ -688,24 +688,23 @@ static unsigned long _dev_topology_attribute(struct dev_types *dt,
if (stat(path, &info) == -1) {
if (errno != ENOENT)
- log_sys_error("stat", path);
+ log_sys_debug("stat", path);
return 0;
}
}
if (!(fp = fopen(path, "r"))) {
- log_sys_error("fopen", path);
+ log_sys_debug("fopen", path);
return 0;
}
if (!fgets(buffer, sizeof(buffer), fp)) {
- log_sys_error("fgets", path);
+ log_sys_debug("fgets", path);
goto out;
}
if (sscanf(buffer, "%lu", &result) != 1) {
- log_error("sysfs file %s not in expected format: %s", path,
- buffer);
+ log_warn("sysfs file %s not in expected format: %s", path, buffer);
goto out;
}
@@ -714,7 +713,7 @@ static unsigned long _dev_topology_attribute(struct dev_types *dt,
out:
if (fclose(fp))
- log_sys_error("fclose", path);
+ log_sys_debug("fclose", path);
return result >> SECTOR_SHIFT;
}
9 years, 9 months
master - vgsplit: Improve message when LV still active.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ac60c876c43d0e...
Commit: ac60c876c43d0ebc7e642dcc92528b974bd7b9f5
Parent: 137ed3081adca8ecec933bd5f5e34c1fa3e2ffef
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Jul 4 01:13:51 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Jul 4 01:13:51 2014 +0100
vgsplit: Improve message when LV still active.
Mention parent LV as well as the LV triggering the warning.
Still leaves some confusing cases but its not worth fixing them
at the moment.
(Thin pool inactive but a thin volume active => deactivate thin vol.
Inactive mirror/raid with pvmove in progress => complete pvmove and
active&deactivate mirror/raid.
If new VG already exists it requires some LVs to be inactive
unnecessarily.)
---
lib/metadata/lv.c | 21 ++++++++++++++-------
lib/metadata/lv.h | 1 +
tools/vgsplit.c | 12 ++++++++----
3 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 18066f0..308b93d 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -231,22 +231,29 @@ char *lv_fullname_dup(struct dm_pool *mem, const struct logical_volume *lv)
return dm_pool_strdup(mem, lvfullname);
}
-char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv)
+struct logical_volume *lv_parent(const struct logical_volume *lv)
{
- const char *parent = "";
+ struct logical_volume *parent_lv = NULL;
if (lv_is_visible(lv))
;
else if (lv_is_mirror_image(lv) || lv_is_mirror_log(lv))
- parent = get_only_segment_using_this_lv(lv)->lv->name;
+ parent_lv = get_only_segment_using_this_lv(lv)->lv;
else if (lv_is_raid_image(lv) || lv_is_raid_metadata(lv))
- parent = get_only_segment_using_this_lv(lv)->lv->name;
+ parent_lv = get_only_segment_using_this_lv(lv)->lv;
else if (lv_is_cache_pool_data(lv) || lv_is_cache_pool_metadata(lv))
- parent = get_only_segment_using_this_lv(lv)->lv->name;
+ parent_lv = get_only_segment_using_this_lv(lv)->lv;
else if (lv_is_thin_pool_data(lv) || lv_is_thin_pool_metadata(lv))
- parent = get_only_segment_using_this_lv(lv)->lv->name;
+ parent_lv = get_only_segment_using_this_lv(lv)->lv;
+
+ return parent_lv;
+}
+
+char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv)
+{
+ struct logical_volume *parent_lv = lv_parent(lv);
- return dm_pool_strdup(mem, parent);
+ return dm_pool_strdup(mem, parent_lv ? parent_lv->name : "");
}
char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv)
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index 47ade92..f298162 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -73,6 +73,7 @@ char *lv_pool_lv_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_name_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_fullname_dup(struct dm_pool *mem, const struct logical_volume *lv);
+struct logical_volume *lv_parent(const struct logical_volume *lv);
char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
uint32_t lv_kernel_read_ahead(const struct logical_volume *lv);
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 9b0f616..5478e78 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -18,10 +18,10 @@
static int _lv_is_in_vg(struct volume_group *vg, struct logical_volume *lv)
{
- if (lv->vg == vg)
- return 1;
+ if (!lv || lv->vg != vg)
+ return 0;
- return 0;
+ return 1;
}
static int _move_one_lv(struct volume_group *vg_from,
@@ -29,9 +29,13 @@ static int _move_one_lv(struct volume_group *vg_from,
struct dm_list *lvh)
{
struct logical_volume *lv = dm_list_item(lvh, struct lv_list)->lv;
+ struct logical_volume *parent_lv;
if (lv_is_active(lv)) {
- log_error("Logical volume \"%s\" must be inactive", lv->name);
+ if ((parent_lv = lv_parent(lv)))
+ log_error("Logical volume %s (part of %s) must be inactive.", display_lvname(lv), parent_lv->name);
+ else
+ log_error("Logical volume %s must be inactive.", display_lvname(lv));
return 0;
}
9 years, 9 months
master - report: Add lv_parent field.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=137ed3081adca8...
Commit: 137ed3081adca8ecec933bd5f5e34c1fa3e2ffef
Parent: 1e1c2769a7092959e5c0076767b4973d4e4dc37c
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Jul 3 23:49:34 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Jul 3 23:49:34 2014 +0100
report: Add lv_parent field.
Only defined for thin/cache/raid/mirror at this stage as it
relies on get_only_segment_using_this_lv().
---
WHATS_NEW | 2 +-
lib/metadata/lv.c | 18 ++++++++++++++++++
lib/metadata/lv.h | 1 +
lib/metadata/lv_manip.c | 2 +-
lib/metadata/metadata.h | 2 +-
lib/report/columns.h | 1 +
lib/report/properties.c | 2 ++
lib/report/report.c | 13 +++++++++++++
8 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 96c4c65..5a1e214 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,7 +1,7 @@
Version 2.02.108 -
=================================
Fix VG component of lvid in vgsplit/vgmerge and check in vg_validate.
- Add lv_full_name and lv_dm_path fields to reports.
+ Add lv_full_name, lv_parent and lv_dm_path fields to reports.
Change lv_path field to suppress devices that never appear in /dev/vg.
Postpone thin pool lvconvert prompts (2.02.107).
Require --yes option to skip prompt to lvconvert thin pool chunksize.
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index c38cbe3..18066f0 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -231,6 +231,24 @@ char *lv_fullname_dup(struct dm_pool *mem, const struct logical_volume *lv)
return dm_pool_strdup(mem, lvfullname);
}
+char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv)
+{
+ const char *parent = "";
+
+ if (lv_is_visible(lv))
+ ;
+ else if (lv_is_mirror_image(lv) || lv_is_mirror_log(lv))
+ parent = get_only_segment_using_this_lv(lv)->lv->name;
+ else if (lv_is_raid_image(lv) || lv_is_raid_metadata(lv))
+ parent = get_only_segment_using_this_lv(lv)->lv->name;
+ else if (lv_is_cache_pool_data(lv) || lv_is_cache_pool_metadata(lv))
+ parent = get_only_segment_using_this_lv(lv)->lv->name;
+ else if (lv_is_thin_pool_data(lv) || lv_is_thin_pool_metadata(lv))
+ parent = get_only_segment_using_this_lv(lv)->lv->name;
+
+ return dm_pool_strdup(mem, parent);
+}
+
char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv)
{
struct dm_list *modules;
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index 86db501..47ade92 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -73,6 +73,7 @@ char *lv_pool_lv_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_name_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_fullname_dup(struct dm_pool *mem, const struct logical_volume *lv);
+char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
uint32_t lv_kernel_read_ahead(const struct logical_volume *lv);
uint64_t lvseg_start(const struct lv_segment *seg);
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 537ec30..306a34b 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -342,7 +342,7 @@ int remove_seg_from_segs_using_this_lv(struct logical_volume *lv,
*
* In general, walk through lv->segs_using_this_lv.
*/
-struct lv_segment *get_only_segment_using_this_lv(struct logical_volume *lv)
+struct lv_segment *get_only_segment_using_this_lv(const struct logical_volume *lv)
{
struct seg_list *sl;
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 4c5ad33..518dd21 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -428,7 +428,7 @@ int lv_split_segment(struct logical_volume *lv, uint32_t le);
*/
int add_seg_to_segs_using_this_lv(struct logical_volume *lv, struct lv_segment *seg);
int remove_seg_from_segs_using_this_lv(struct logical_volume *lv, struct lv_segment *seg);
-struct lv_segment *get_only_segment_using_this_lv(struct logical_volume *lv);
+struct lv_segment *get_only_segment_using_this_lv(const struct logical_volume *lv);
int for_each_sub_lv(struct logical_volume *lv,
int (*fn)(struct logical_volume *lv, void *data),
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 418e67a..8d42387 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -33,6 +33,7 @@ FIELD(LVS, lv, STR, "LV", lvid, 4, lvname, lv_name, "Name. LVs created for inte
FIELD(LVS, lv, STR, "LV", lvid, 4, lvfullname, lv_full_name, "Full name of LV including its VG, namely VG/LV.", 0)
FIELD(LVS, lv, STR, "Path", lvid, 4, lvpath, lv_path, "Full pathname for LV. Blank for internal LVs.", 0)
FIELD(LVS, lv, STR, "DMPath", lvid, 6, lvdmpath, lv_dm_path, "Internal device-mapper pathname for LV (in /dev/mapper directory).", 0)
+FIELD(LVS, lv, STR, "Parent", lvid, 6, lvparent, lv_parent, "For LVs that are components of another LV, the parent LV.", 0)
FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, lv_attr, "Various attributes - see man page.", 0)
FIELD(LVS, lv, STR, "Active", lvid, 6, lvactive, lv_active, "Active state of the LV.", 0)
FIELD(LVS, lv, NUM, "Maj", major, 3, int32, lv_major, "Persistent major number or -1 if not persistent.", 0)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index 9692de8..d6f14f1 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -170,6 +170,8 @@ GET_LV_STR_PROPERTY_FN(lv_path, lv_path_dup(lv->vg->vgmem, lv))
#define _lv_path_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(lv_dm_path, lv_dmpath_dup(lv->vg->vgmem, lv))
#define _lv_dm_path_set prop_not_implemented_set
+GET_LV_STR_PROPERTY_FN(lv_parent, lv_parent_dup(lv->vg->vgmem, lv))
+#define _lv_parent_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(lv_attr, lv_attr_dup(lv->vg->vgmem, lv))
#define _lv_attr_set prop_not_implemented_set
GET_LV_NUM_PROPERTY_FN(lv_major, lv->major)
diff --git a/lib/report/report.c b/lib/report/report.c
index fca1133..3b71989 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -324,6 +324,19 @@ static int _lvfullname_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_value(field, repstr, NULL);
}
+static int _lvparent_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private __attribute__((unused)))
+{
+ const struct logical_volume *lv = (const struct logical_volume *) data;
+ char *repstr;
+
+ if (!(repstr = lv_parent_dup(mem, lv)))
+ return_0;
+
+ return _field_set_value(field, repstr, NULL);
+}
+
static int _datalv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
struct dm_report_field *field,
const void *data, void *private __attribute__((unused)))
9 years, 9 months
master - vgsplit: Fix VG component of lvid.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1e1c2769a70929...
Commit: 1e1c2769a7092959e5c0076767b4973d4e4dc37c
Parent: 64ce3a8066ead3bc2ee16e9cc286d68057bbe956
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Jul 3 19:06:04 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Jul 3 19:06:04 2014 +0100
vgsplit: Fix VG component of lvid.
Fix VG component of lvid in vgsplit and vgmerge
Update vg_validate() to detect the error.
Call lv_is_active() before moving LV into new VG, not after.
---
WHATS_NEW | 1 +
lib/metadata/metadata.c | 12 ++++++++++++
tools/vgmerge.c | 1 +
tools/vgsplit.c | 16 +++++++---------
4 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 625d58f..96c4c65 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.108 -
=================================
+ Fix VG component of lvid in vgsplit/vgmerge and check in vg_validate.
Add lv_full_name and lv_dm_path fields to reports.
Change lv_path field to suppress devices that never appear in /dev/vg.
Postpone thin pool lvconvert prompts (2.02.107).
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 0a6e9e9..50d44ec 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2331,6 +2331,7 @@ int vg_validate(struct volume_group *vg)
struct lv_segment *seg;
struct dm_str_list *sl;
char uuid[64] __attribute__((aligned(8)));
+ char uuid2[64] __attribute__((aligned(8)));
int r = 1;
unsigned hidden_lv_count = 0, lv_count = 0, lv_visible_count = 0;
unsigned pv_count = 0;
@@ -2427,6 +2428,17 @@ int vg_validate(struct volume_group *vg)
r = 0;
}
+ if (!id_equal(&lvl->lv->lvid.id[0], &lvl->lv->vg->id)) {
+ if (!id_write_format(&lvl->lv->lvid.id[0], uuid,
+ sizeof(uuid)))
+ stack;
+ if (!id_write_format(&lvl->lv->vg->id, uuid2,
+ sizeof(uuid2)))
+ stack;
+ log_error(INTERNAL_ERROR "LV %s has VG UUID %s but its VG %s has UUID %s",
+ lvl->lv->name, uuid, lvl->lv->vg->name, uuid2);
+ r = 0;
+ }
if (lv_is_cow(lvl->lv))
num_snapshots++;
diff --git a/tools/vgmerge.c b/tools/vgmerge.c
index 3782779..a17a636 100644
--- a/tools/vgmerge.c
+++ b/tools/vgmerge.c
@@ -133,6 +133,7 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
dm_list_iterate_items(lvl1, &vg_from->lvs) {
lvl1->lv->vg = vg_to;
+ lvl1->lv->lvid.id[0] = lvl1->lv->vg->id;
}
while (!dm_list_empty(&vg_from->lvs)) {
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index fb67919..9b0f616 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -16,14 +16,10 @@
#include "tools.h"
#include "metadata.h" /* for 'get_only_segment_using_this_lv' */
-/* FIXME Why not (lv->vg == vg) ? */
static int _lv_is_in_vg(struct volume_group *vg, struct logical_volume *lv)
{
- struct lv_list *lvl;
-
- dm_list_iterate_items(lvl, &vg->lvs)
- if (lv == lvl->lv)
- return 1;
+ if (lv->vg == vg)
+ return 1;
return 0;
}
@@ -34,14 +30,16 @@ static int _move_one_lv(struct volume_group *vg_from,
{
struct logical_volume *lv = dm_list_item(lvh, struct lv_list)->lv;
- dm_list_move(&vg_to->lvs, lvh);
- lv->vg = vg_to;
-
if (lv_is_active(lv)) {
log_error("Logical volume \"%s\" must be inactive", lv->name);
return 0;
}
+ dm_list_move(&vg_to->lvs, lvh);
+ lv->vg = vg_to;
+
+ lv->lvid.id[0] = lv->vg->id;
+
/* Moved pool metadata spare LV */
if (vg_from->pool_metadata_spare_lv == lv) {
vg_to->pool_metadata_spare_lv = lv;
9 years, 9 months
master - report: Add lv_dm_path and lv_full_name fields.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=64ce3a8066ead3...
Commit: 64ce3a8066ead3bc2ee16e9cc286d68057bbe956
Parent: 5bfa2ec21d79b090276676076917808207ad4dd1
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Jul 2 17:24:05 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Jul 2 17:24:05 2014 +0100
report: Add lv_dm_path and lv_full_name fields.
---
WHATS_NEW | 1 +
lib/display/display.c | 7 ++-----
lib/metadata/lv.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
lib/metadata/lv.h | 2 ++
lib/report/columns.h | 4 +++-
lib/report/properties.c | 4 ++++
lib/report/report.c | 26 ++++++++++++++++++++++++++
7 files changed, 81 insertions(+), 8 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c55b3fb..625d58f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.108 -
=================================
+ Add lv_full_name and lv_dm_path fields to reports.
Change lv_path field to suppress devices that never appear in /dev/vg.
Postpone thin pool lvconvert prompts (2.02.107).
Require --yes option to skip prompt to lvconvert thin pool chunksize.
diff --git a/lib/display/display.c b/lib/display/display.c
index fd785ed..cd204a0 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -95,11 +95,8 @@ const char *get_percent_string(percent_type_t def)
const char *display_lvname(const struct logical_volume *lv)
{
- char buf[NAME_LEN * 2 + 2];
-
- (void) snprintf(buf, sizeof(buf), "%s/%s", lv->vg->name, lv->name);
-
- return dm_pool_strdup(lv->vg->cmd->mem, buf) ? : lv->name; /* at least LV name... */
+ /* On allocation failure, just return the LV name. */
+ return lv_fullname_dup(lv->vg->cmd->mem, lv) ? : lv->name;
}
#define BASE_UNKNOWN 0
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 55395ce..c38cbe3 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -219,6 +219,18 @@ char *lv_name_dup(struct dm_pool *mem, const struct logical_volume *lv)
return dm_pool_strdup(mem, lv->name);
}
+char *lv_fullname_dup(struct dm_pool *mem, const struct logical_volume *lv)
+{
+ char lvfullname[NAME_LEN * 2 + 2];
+
+ if (dm_snprintf(lvfullname, sizeof(lvfullname), "%s/%s", lv->vg->name, lv->name) < 0) {
+ log_error("lvfullname snprintf failed");
+ return NULL;
+ }
+
+ return dm_pool_strdup(mem, lvfullname);
+}
+
char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv)
{
struct dm_list *modules;
@@ -379,13 +391,42 @@ char *lv_path_dup(struct dm_pool *mem, const struct logical_volume *lv)
if (!(repstr = dm_pool_zalloc(mem, len))) {
log_error("dm_pool_alloc failed");
- return 0;
+ return NULL;
}
if (dm_snprintf(repstr, len, "%s%s/%s",
lv->vg->cmd->dev_dir, lv->vg->name, lv->name) < 0) {
log_error("lvpath snprintf failed");
- return 0;
+ return NULL;
+ }
+
+ return repstr;
+}
+
+char *lv_dmpath_dup(struct dm_pool *mem, const struct logical_volume *lv)
+{
+ char *name;
+ char *repstr;
+ size_t len;
+
+ if (!*lv->vg->name)
+ return dm_pool_strdup(mem, "");
+
+ if (!(name = dm_build_dm_name(mem, lv->vg->name, lv->name, NULL))) {
+ log_error("dm_build_dm_name failed");
+ return NULL;
+ }
+
+ len = strlen(dm_dir()) + strlen(name) + 2;
+
+ if (!(repstr = dm_pool_zalloc(mem, len))) {
+ log_error("dm_pool_alloc failed");
+ return NULL;
+ }
+
+ if (dm_snprintf(repstr, len, "%s/%s", dm_dir(), name) < 0) {
+ log_error("lv_dmpath snprintf failed");
+ return NULL;
}
return repstr;
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index 51920b0..86db501 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -60,6 +60,7 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_uuid_dup(const struct logical_volume *lv);
char *lv_tags_dup(const struct logical_volume *lv);
char *lv_path_dup(struct dm_pool *mem, const struct logical_volume *lv);
+char *lv_dmpath_dup(struct dm_pool *mem, const struct logical_volume *lv);
uint64_t lv_origin_size(const struct logical_volume *lv);
char *lv_move_pv_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_convert_lv_dup(struct dm_pool *mem, const struct logical_volume *lv);
@@ -71,6 +72,7 @@ char *lv_metadata_lv_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_pool_lv_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_name_dup(struct dm_pool *mem, const struct logical_volume *lv);
+char *lv_fullname_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
uint32_t lv_kernel_read_ahead(const struct logical_volume *lv);
uint64_t lvseg_start(const struct lv_segment *seg);
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 70a3b65..418e67a 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -30,7 +30,9 @@
/* *INDENT-OFF* */
FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, lv_uuid, "Unique identifier.", 0)
FIELD(LVS, lv, STR, "LV", lvid, 4, lvname, lv_name, "Name. LVs created for internal use are enclosed in brackets.", 0)
-FIELD(LVS, lv, STR, "Path", lvid, 4, lvpath, lv_path, "Full pathname for LV.", 0)
+FIELD(LVS, lv, STR, "LV", lvid, 4, lvfullname, lv_full_name, "Full name of LV including its VG, namely VG/LV.", 0)
+FIELD(LVS, lv, STR, "Path", lvid, 4, lvpath, lv_path, "Full pathname for LV. Blank for internal LVs.", 0)
+FIELD(LVS, lv, STR, "DMPath", lvid, 6, lvdmpath, lv_dm_path, "Internal device-mapper pathname for LV (in /dev/mapper directory).", 0)
FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, lv_attr, "Various attributes - see man page.", 0)
FIELD(LVS, lv, STR, "Active", lvid, 6, lvactive, lv_active, "Active state of the LV.", 0)
FIELD(LVS, lv, NUM, "Maj", major, 3, int32, lv_major, "Persistent major number or -1 if not persistent.", 0)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index ce3ed53..9692de8 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -164,8 +164,12 @@ GET_LV_STR_PROPERTY_FN(lv_uuid, lv_uuid_dup(lv))
#define _lv_uuid_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(lv_name, lv_name_dup(lv->vg->vgmem, lv))
#define _lv_name_set prop_not_implemented_set
+GET_LV_STR_PROPERTY_FN(lv_full_name, lv_fullname_dup(lv->vg->vgmem, lv))
+#define _lv_full_name_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(lv_path, lv_path_dup(lv->vg->vgmem, lv))
#define _lv_path_set prop_not_implemented_set
+GET_LV_STR_PROPERTY_FN(lv_dm_path, lv_dmpath_dup(lv->vg->vgmem, lv))
+#define _lv_dm_path_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(lv_attr, lv_attr_dup(lv->vg->vgmem, lv))
#define _lv_attr_set prop_not_implemented_set
GET_LV_NUM_PROPERTY_FN(lv_major, lv->major)
diff --git a/lib/report/report.c b/lib/report/report.c
index 34b7b07..fca1133 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -311,6 +311,19 @@ static int _lvname_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_value(field, repstr, lvname);
}
+static int _lvfullname_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private __attribute__((unused)))
+{
+ const struct logical_volume *lv = (const struct logical_volume *) data;
+ char *repstr;
+
+ if (!(repstr = lv_fullname_dup(mem, lv)))
+ return_0;
+
+ return _field_set_value(field, repstr, NULL);
+}
+
static int _datalv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
struct dm_report_field *field,
const void *data, void *private __attribute__((unused)))
@@ -364,6 +377,19 @@ static int _lvpath_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_value(field, repstr, NULL);
}
+static int _lvdmpath_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private __attribute__((unused)))
+{
+ const struct logical_volume *lv = (const struct logical_volume *) data;
+ char *repstr;
+
+ if (!(repstr = lv_dmpath_dup(mem, lv)))
+ return_0;
+
+ return _field_set_value(field, repstr, NULL);
+}
+
static int _origin_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: Exclude hidden devices from lv_path field.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5bfa2ec21d79b0...
Commit: 5bfa2ec21d79b090276676076917808207ad4dd1
Parent: c6811dd51218e88467d91a1b2b309bbfed5eaf0e
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Jul 2 14:57:00 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Jul 2 14:57:00 2014 +0100
report: Exclude hidden devices from lv_path field.
---
WHATS_NEW | 1 +
lib/metadata/lv.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index dfbb4e3..c55b3fb 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.108 -
=================================
+ Change lv_path field to suppress devices that never appear in /dev/vg.
Postpone thin pool lvconvert prompts (2.02.107).
Require --yes option to skip prompt to lvconvert thin pool chunksize.
Support lvremove -ff to remove thin volumes from broken thin pools.
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index f1d93a9..55395ce 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -370,7 +370,8 @@ char *lv_path_dup(struct dm_pool *mem, const struct logical_volume *lv)
char *repstr;
size_t len;
- if (!*lv->vg->name)
+ /* Only for visible devices that get a link from /dev/vg */
+ if (!*lv->vg->name || !lv_is_visible(lv) || lv_is_thin_pool(lv))
return dm_pool_strdup(mem, "");
len = strlen(lv->vg->cmd->dev_dir) + strlen(lv->vg->name) +
9 years, 9 months
master - tests: ensure data hits cow
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c6811dd51218e8...
Commit: c6811dd51218e88467d91a1b2b309bbfed5eaf0e
Parent: 39bd6bb89e364e72808870e2ad88ddf79b591a3f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 2 15:02:56 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 2 15:10:10 2014 +0200
tests: ensure data hits cow
---
test/shell/lvextend-snapshot-dmeventd.sh | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvextend-snapshot-dmeventd.sh b/test/shell/lvextend-snapshot-dmeventd.sh
index af8a927..3d9ce1f 100644
--- a/test/shell/lvextend-snapshot-dmeventd.sh
+++ b/test/shell/lvextend-snapshot-dmeventd.sh
@@ -17,6 +17,7 @@ extend() {
write_() {
dd if=/dev/zero of="$DM_DEV_DIR/$vg/snap" bs=1k count=$2 seek=$1
+ sync
}
percent_() {
9 years, 9 months
master - cleanup: drop inline and add prefix _ for static
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=39bd6bb89e364e...
Commit: 39bd6bb89e364e72808870e2ad88ddf79b591a3f
Parent: d1094ec4c662bef5e11bc67578d3fa4607940b93
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 2 15:09:06 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 2 15:09:06 2014 +0200
cleanup: drop inline and add prefix _ for static
Leave inline decision on compiler.
Add '_'prefix for static functions.
---
tools/lvconvert.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 4f29416..2a2a398 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -211,11 +211,11 @@ static int _check_conversion_type(struct cmd_context *cmd, const char *type_str)
}
/* -s/--snapshot and --type snapshot are synonyms */
-static inline int snapshot_type_requested(struct cmd_context *cmd, const char *type_str) {
+static int _snapshot_type_requested(struct cmd_context *cmd, const char *type_str) {
return (arg_count(cmd, snapshot_ARG) || !strcmp(type_str, "snapshot"));
}
/* mirror/raid* (1,10,4,5,6 and their variants) reshape */
-static inline int mirror_or_raid_type_requested(struct cmd_context *cmd, const char *type_str) {
+static int _mirror_or_raid_type_requested(struct cmd_context *cmd, const char *type_str) {
return (arg_count(cmd, mirrors_ARG) || !strncmp(type_str, "raid", 4) || !strcmp(type_str, "mirror"));
}
@@ -239,8 +239,8 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
if (arg_count(cmd, splitsnapshot_ARG))
lp->splitsnapshot = 1;
- if ((snapshot_type_requested(cmd, type_str) || arg_count(cmd, merge_ARG)) &&
- (arg_count(cmd, mirrorlog_ARG) || mirror_or_raid_type_requested(cmd, type_str) ||
+ if ((_snapshot_type_requested(cmd, type_str) || arg_count(cmd, merge_ARG)) &&
+ (arg_count(cmd, mirrorlog_ARG) || _mirror_or_raid_type_requested(cmd, type_str) ||
arg_count(cmd, repair_ARG) || arg_count(cmd, thinpool_ARG))) {
log_error("--snapshot/--type snapshot or --merge argument "
"cannot be mixed with --mirrors/--type mirror/--type raid*, "
@@ -249,7 +249,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
}
if ((arg_count(cmd, stripes_long_ARG) || arg_count(cmd, stripesize_ARG)) &&
- !(mirror_or_raid_type_requested(cmd, type_str) ||
+ !(_mirror_or_raid_type_requested(cmd, type_str) ||
arg_count(cmd, repair_ARG) ||
arg_count(cmd, thinpool_ARG))) {
log_error("--stripes or --stripesize argument is only valid "
@@ -274,15 +274,15 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
if (!arg_count(cmd, background_ARG))
lp->wait_completion = 1;
- if (snapshot_type_requested(cmd, type_str))
+ if (_snapshot_type_requested(cmd, type_str))
lp->snapshot = 1;
- if (snapshot_type_requested(cmd, type_str) && arg_count(cmd, merge_ARG)) {
+ if (_snapshot_type_requested(cmd, type_str) && arg_count(cmd, merge_ARG)) {
log_error("--snapshot and --merge are mutually exclusive");
return 0;
}
- if (arg_count(cmd, splitmirrors_ARG) && mirror_or_raid_type_requested(cmd, type_str)) {
+ if (arg_count(cmd, splitmirrors_ARG) && _mirror_or_raid_type_requested(cmd, type_str)) {
log_error("--mirrors/--type mirror/--type raid* and --splitmirrors are "
"mutually exclusive");
return 0;
@@ -304,7 +304,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
cache_pool ? "type cache_" : "thin");
return 0;
}
- if (mirror_or_raid_type_requested(cmd, type_str)) {
+ if (_mirror_or_raid_type_requested(cmd, type_str)) {
log_error("--%spool and --mirrors/--type mirror/--type raid* are mutually exlusive.",
cache_pool ? "type cache_" : "thin");
return 0;
@@ -314,7 +314,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
cache_pool ? "type cache_" : "thin");
return 0;
}
- if (snapshot_type_requested(cmd, type_str)) {
+ if (_snapshot_type_requested(cmd, type_str)) {
log_error("--%spool and --snapshot/--type snapshot are mutually exlusive.",
cache_pool ? "type cache_" : "thin");
return 0;
9 years, 9 months
master - tests: replace cat with $(<
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d1094ec4c662be...
Commit: d1094ec4c662bef5e11bc67578d3fa4607940b93
Parent: b22ab4dab0dcf78d86ff64c3412cf175118d1785
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 30 21:00:08 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 2 10:45:44 2014 +0200
tests: replace cat with $(<
Use shell built-in $(<
Print lvm.conf in use for test.
---
test/lib/aux.sh | 41 +++++++++++++++++------------------
test/shell/dmeventd-restart.sh | 2 +-
test/shell/lvmetad-disabled.sh | 4 +-
test/shell/lvmetad-override.sh | 2 +-
test/shell/lvmetad-pvscan-nomda.sh | 2 +-
test/shell/lvmetad-restart.sh | 2 +-
test/shell/lvmetad-warning.sh | 2 +-
test/shell/pvmove-restart.sh | 4 +-
test/shell/report-select.sh | 2 +-
9 files changed, 30 insertions(+), 31 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 76b93ef..7b96ad4 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -185,8 +185,8 @@ teardown_devs() {
if test -f SCSI_DEBUG_DEV; then
test "${LVM_TEST_PARALLEL:-0}" -eq 1 || modprobe -r scsi_debug
else
- test ! -f LOOP || losetup -d $(cat LOOP) || true
- test ! -f LOOPFILE || rm -f $(cat LOOPFILE)
+ test ! -f LOOP || losetup -d $(< LOOP) || true
+ test ! -f LOOPFILE || rm -f $(< LOOPFILE)
fi
rm -f DEVICES # devs is set in prepare_devs()
rm -f LOOP
@@ -207,9 +207,9 @@ teardown_devs() {
kill_sleep_kill_() {
if test -s "$1" ; then
- if kill -TERM "$(cat $1)" ; then
+ if kill -TERM "$(< $1)" ; then
if test "$2" -eq 0 ; then sleep .1 ; else sleep 1 ; fi
- kill -KILL "$(cat $1)" 2>/dev/null || true
+ kill -KILL "$(< $1)" 2>/dev/null || true
fi
fi
}
@@ -253,7 +253,7 @@ prepare_loop() {
local i
local slash
- test -f LOOP && LOOP=$(cat LOOP)
+ test -f LOOP && LOOP=$(< LOOP)
echo -n "## preparing loop device..."
# skip if prepare_scsi_debug_dev() was used
@@ -598,8 +598,8 @@ generate_config() {
else
LVM_VERIFY_UDEV=${LVM_VERIFY_UDEV:-1}
fi
- test -f $config_values || {
- cat > $config_values <<-EOF
+ test -f "$config_values" || {
+ cat > "$config_values" <<-EOF
devices/dir = "$DM_DEV_DIR"
devices/scan = "$DM_DEV_DIR"
devices/filter = "a|.*|"
@@ -639,20 +639,19 @@ EOF
local v
for v in "$@"; do
- echo "$v" >> $config_values
- done
+ echo "$v"
+ done >> "$config_values"
- rm -f $config
local s
- for s in $(cat $config_values | cut -f1 -d/ | sort | uniq); do
- echo "$s {" >> $config
+ for s in $(cut -f1 -d/ "$config_values" | sort | uniq); do
+ echo "$s {"
local k
- for k in $(grep ^"$s"/ $config_values | cut -f1 -d= | sed -e 's, *$,,' | sort | uniq); do
- grep "^$k" $config_values | tail -n 1 | sed -e "s,^$s/, ," >> $config
+ for k in $(grep ^"$s"/ "$config_values" | cut -f1 -d= | sed -e 's, *$,,' | sort | uniq); do
+ grep "^$k" "$config_values" | tail -n 1 | sed -e "s,^$s/, ,"
done
- echo "}" >> $config
- echo >> $config
- done
+ echo "}"
+ echo
+ done | tee "$config"
}
lvmconf() {
@@ -666,7 +665,7 @@ profileconf() {
shift
generate_config "$@"
test -d etc/profile || mkdir etc/profile
- mv -f PROFILE_$profile_name etc/profile/$profile_name.profile
+ mv -f "PROFILE_$profile_name" "etc/profile/$profile_name.profile"
}
prepare_profiles() {
@@ -690,7 +689,7 @@ api() {
}
mirror_recovery_works() {
- case $(uname -r) in
+ case "$(uname -r)" in
3.3.4-5.fc17.i686|3.3.4-5.fc17.x86_64) return 1 ;;
esac
}
@@ -729,7 +728,7 @@ raid456_replace_works() {
# http://www.redhat.com/archives/dm-devel/2014-March/msg00008.html
# so we need to put here exlusion for kernes which do trace SLUB
#
- case $(uname -r) in
+ case "$(uname -r)" in
3.6.*.fc18.i686*|3.6.*.fc18.x86_64) return 1 ;;
3.9.*.fc19.i686*|3.9.*.fc19.x86_64) return 1 ;;
3.1[0123].*.fc18.i686*|3.1[0123].*.fc18.x86_64) return 1 ;;
@@ -835,7 +834,7 @@ dmsetup_wrapped() {
dmsetup "$@"
}
-test -f DEVICES && devs=$(cat DEVICES)
+test -f DEVICES && devs=$(< DEVICES)
if test "$1" = dmsetup; then
shift
diff --git a/test/shell/dmeventd-restart.sh b/test/shell/dmeventd-restart.sh
index 366b4d2..a94ede1 100644
--- a/test/shell/dmeventd-restart.sh
+++ b/test/shell/dmeventd-restart.sh
@@ -30,7 +30,7 @@ lvchange --monitor y --verbose $vg/4way 2>&1 | tee lvchange.out
grep 'already monitored' lvchange.out
# now try what happens if no dmeventd is running
-kill -9 $(cat LOCAL_DMEVENTD)
+kill -9 $(< LOCAL_DMEVENTD)
rm LOCAL_DMEVENTD
dmeventd -R -f &
diff --git a/test/shell/lvmetad-disabled.sh b/test/shell/lvmetad-disabled.sh
index acb5f82..efdca16 100644
--- a/test/shell/lvmetad-disabled.sh
+++ b/test/shell/lvmetad-disabled.sh
@@ -12,7 +12,7 @@
. lib/inittest
test -e LOCAL_LVMETAD || skip
-kill $(cat LOCAL_LVMETAD)
+kill $(< LOCAL_LVMETAD)
while test -e "$TESTDIR/lvmetad.socket"; do echo -n .; sleep .1; done # wait for the socket close
test ! -e "$LVM_LVMETAD_PIDFILE"
@@ -25,5 +25,5 @@ pvs 2>&1 | not grep "lvmetad is running"
aux lvmconf "global/use_lvmetad = 0"
pvs 2>&1 | grep "lvmetad is running"
-kill $(cat "$LVM_LVMETAD_PIDFILE")
+kill $(< "$LVM_LVMETAD_PIDFILE")
not ls "$LVM_LVMETAD_PIDFILE"
diff --git a/test/shell/lvmetad-override.sh b/test/shell/lvmetad-override.sh
index ff4ad18..27f15cb 100644
--- a/test/shell/lvmetad-override.sh
+++ b/test/shell/lvmetad-override.sh
@@ -16,7 +16,7 @@ aux prepare_pvs 2
vgcreate $vg1 $dev1 $dev2
lvchange -ay $vg1 2>&1 | not grep "Failed to connect"
-kill $(cat LOCAL_LVMETAD)
+kill $(< LOCAL_LVMETAD)
lvchange -ay $vg1 2>&1 | grep "Failed to connect"
lvchange -aay $vg1 --sysinit 2>&1 | not grep "Failed to connect"
lvchange -ay $vg1 --config 'global { use_lvmetad = 0 }' 2>&1 | not grep "Failed to connect"
diff --git a/test/shell/lvmetad-pvscan-nomda.sh b/test/shell/lvmetad-pvscan-nomda.sh
index c55cafb..39604d0 100644
--- a/test/shell/lvmetad-pvscan-nomda.sh
+++ b/test/shell/lvmetad-pvscan-nomda.sh
@@ -12,7 +12,7 @@
. lib/inittest
test -e LOCAL_LVMETAD || skip
-kill $(cat LOCAL_LVMETAD)
+kill $(< LOCAL_LVMETAD)
rm LOCAL_LVMETAD
aux prepare_devs 2
diff --git a/test/shell/lvmetad-restart.sh b/test/shell/lvmetad-restart.sh
index 6377c57..e4136df 100644
--- a/test/shell/lvmetad-restart.sh
+++ b/test/shell/lvmetad-restart.sh
@@ -17,7 +17,7 @@ aux prepare_pvs 2
vgcreate $vg1 "$dev1" "$dev2"
vgs | grep $vg1
-kill $(cat LOCAL_LVMETAD)
+kill $(< LOCAL_LVMETAD)
aux prepare_lvmetad
vgs | grep $vg1
diff --git a/test/shell/lvmetad-warning.sh b/test/shell/lvmetad-warning.sh
index 1c6c62b..52bd885 100644
--- a/test/shell/lvmetad-warning.sh
+++ b/test/shell/lvmetad-warning.sh
@@ -17,7 +17,7 @@ aux prepare_pvs 2
vgcreate $vg1 "$dev1" "$dev2"
lvchange -ay $vg1 2>&1 | not grep "Failed to connect"
-kill $(cat LOCAL_LVMETAD)
+kill $(< LOCAL_LVMETAD)
lvchange -ay $vg1 2>&1 | grep "Failed to connect"
lvchange -aay $vg1 --sysinit 2>&1 | tee sysinit.txt
not grep "Failed to connect" sysinit.txt
diff --git a/test/shell/pvmove-restart.sh b/test/shell/pvmove-restart.sh
index af079ea..f480aaa 100644
--- a/test/shell/pvmove-restart.sh
+++ b/test/shell/pvmove-restart.sh
@@ -53,7 +53,7 @@ if test -e LOCAL_CLVMD ; then
# as clvmd starts to abort on internal errors on various
# errors, based on the fact pvmove is killed -9
# Restart clvmd
- kill $(cat LOCAL_CLVMD)
+ kill $(< LOCAL_CLVMD)
for i in $(seq 1 100) ; do
test $i -eq 100 && die "Shutdown of clvmd is too slow."
test -e "$CLVMD_PIDFILE" || break
@@ -64,7 +64,7 @@ fi
if test -e LOCAL_LVMETAD ; then
# Restart lvmetad
- kill $(cat LOCAL_LVMETAD)
+ kill $(< LOCAL_LVMETAD)
aux prepare_lvmetad
fi
diff --git a/test/shell/report-select.sh b/test/shell/report-select.sh
index 8181cd2..cdd45ed 100644
--- a/test/shell/report-select.sh
+++ b/test/shell/report-select.sh
@@ -58,7 +58,7 @@ function result()
# the number of lines on output must match
test $items_found -eq $# || {
echo " >>> NUMBER OF ITEMS EXPECTED: $# ($@)"
- echo " >>> NUMBER OF ITEMS FOUND: $items_found ($(cat $OUT_LOG_FILE))"
+ echo " >>> NUMBER OF ITEMS FOUND: $items_found ($(< $OUT_LOG_FILE))"
return 1
}
9 years, 9 months
master - tests: avoid hiding results in local
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b22ab4dab0dcf7...
Commit: b22ab4dab0dcf78d86ff64c3412cf175118d1785
Parent: d1dcbe085370ba194b6598bb9440550edb7f184f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 30 20:04:24 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 2 10:45:43 2014 +0200
tests: avoid hiding results in local
There is a difference between:
local a=$(shell)
and
local a
a=$(shell)
The first return exit code from shells' local command.
---
test/shell/fsadm.sh | 3 +-
test/shell/lvchange-raid.sh | 10 ++++++--
test/shell/lvconvert-mirror-basic.sh | 2 +-
test/shell/lvcreate-signature-wiping.sh | 3 +-
test/shell/mirror-names.sh | 4 ++-
test/shell/mirror-vgreduce-removemissing.sh | 11 ++++++---
test/shell/snapshot-merge.sh | 4 ++-
test/shell/topology-support.sh | 30 +++++++++++---------------
8 files changed, 38 insertions(+), 29 deletions(-)
diff --git a/test/shell/fsadm.sh b/test/shell/fsadm.sh
index 612d2b7..368e747 100644
--- a/test/shell/fsadm.sh
+++ b/test/shell/fsadm.sh
@@ -75,7 +75,8 @@ fscheck_reiserfs()
check_missing()
{
- eval local t=$\check_$1
+ local t
+ eval t=$\check_$1
test -z "$t" && return 0
test "$t" = skip && return 1
echo "WARNING: fsadm test skipped $1 tests, $t tool is missing."
diff --git a/test/shell/lvchange-raid.sh b/test/shell/lvchange-raid.sh
index e35f4de..a0a0d2a 100644
--- a/test/shell/lvchange-raid.sh
+++ b/test/shell/lvchange-raid.sh
@@ -29,9 +29,13 @@ aux prepare_vg 6
run_writemostly_check() {
local vg=$1
local lv=${2}${THIN_POSTFIX}
- local segtype=$(get lv_field $vg/$lv segtype -a)
- local d0=$(get lv_devices $vg/${lv}_rimage_0)
- local d1=$(get lv_devices $vg/${lv}_rimage_1)
+ local segtype=
+ local d0
+ local d1
+
+ segtype=$(get lv_field $vg/$lv segtype -a)
+ d0=$(get lv_devices $vg/${lv}_rimage_0)
+ d1=$(get lv_devices $vg/${lv}_rimage_1)
printf "#\n#\n#\n# %s/%s (%s): run_writemostly_check\n#\n#\n#\n" \
$vg $lv $segtype
diff --git a/test/shell/lvconvert-mirror-basic.sh b/test/shell/lvconvert-mirror-basic.sh
index 6fcff70..07bafb9 100644
--- a/test/shell/lvconvert-mirror-basic.sh
+++ b/test/shell/lvconvert-mirror-basic.sh
@@ -43,7 +43,7 @@ test_lvconvert() {
local finish_count=$3
local finish_count_p1=$(($finish_count + 1))
local finish_log_type=$4
- local dev_array=("$dev1" "$dev2" "$dev3" "$dev4" "$dev5")
+ local dev_array=( "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" )
local start_log_count
local finish_log_count
local max_log_count
diff --git a/test/shell/lvcreate-signature-wiping.sh b/test/shell/lvcreate-signature-wiping.sh
index 388c542..32ef363 100644
--- a/test/shell/lvcreate-signature-wiping.sh
+++ b/test/shell/lvcreate-signature-wiping.sh
@@ -18,7 +18,8 @@ init_lv_() {
}
test_blkid_() {
- local type=$(blkid -s TYPE -o value -c /dev/null "$DM_DEV_DIR/$vg/$lv1")
+ local type
+ type=$(blkid -s TYPE -o value -c /dev/null "$DM_DEV_DIR/$vg/$lv1")
test "$type" = "swap"
}
diff --git a/test/shell/mirror-names.sh b/test/shell/mirror-names.sh
index 8094798..0e064ed 100644
--- a/test/shell/mirror-names.sh
+++ b/test/shell/mirror-names.sh
@@ -22,7 +22,9 @@ lv_devices_() {
local lv=$1
shift
local devices=$@
- local devs=$(get lv_field $lv devices -a | sed 's/([0-9]*)//g; s/ //g; s/,/ /g')
+ local devs
+
+ devs=$(get lv_devices "$lv")
for d in $devs; do
(echo "$devices" | grep $d) || return 1
diff --git a/test/shell/mirror-vgreduce-removemissing.sh b/test/shell/mirror-vgreduce-removemissing.sh
index 62847ae..fd71696 100644
--- a/test/shell/mirror-vgreduce-removemissing.sh
+++ b/test/shell/mirror-vgreduce-removemissing.sh
@@ -75,9 +75,10 @@ rest_pvs_()
local num=$2
local rem=
local n
+ local dev
for n in $(seq 1 $(($index - 1))) $(seq $(($index + 1)) $num); do
- eval local dev=$\dev$n
+ eval dev=$\dev$n
rem="$rem $dev"
done
@@ -223,6 +224,7 @@ done
test_3way_mirror_plus_1_fail_3_()
{
local index=$1
+ local dev
lvcreate -an -Zn -l2 --type mirror -m2 -n $lv1 $vg "$dev1" "$dev2" "$dev3" "$dev5":$BLOCKS
lvconvert -m+1 $vg/$lv1 "$dev4"
@@ -232,9 +234,9 @@ test_3way_mirror_plus_1_fail_3_()
aux disable_dev $(rest_pvs_ $index 4)
vgreduce --removemissing --force $vg
lvs -a -o+devices $vg
- eval local dev=\$dev$n
+ eval dev=\$dev$n
check linear $vg $lv1
- check lv_on $vg $lv1 "$dev"
+ check lv_on $vg $lv1 "$dev"
}
for n in $(seq 1 4); do
@@ -278,6 +280,7 @@ done
test_2way_mirror_plus_2_fail_3_()
{
local index=$1
+ local dev
lvcreate -an -Zn -l2 --type mirror -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev5":$BLOCKS
lvconvert -m+2 $vg/$lv1 "$dev3" "$dev4"
@@ -286,7 +289,7 @@ test_2way_mirror_plus_2_fail_3_()
aux disable_dev $(rest_pvs_ $index 4)
vgreduce --removemissing --force $vg
lvs -a -o+devices $vg
- eval local dev=\$dev$n
+ eval dev=\$dev$n
mimages_are_on_ $lv1 "$dev" || lv_is_on_ $lv1 "$dev"
not mirrorlog_is_on_ $lv1 "$dev5"
}
diff --git a/test/shell/snapshot-merge.sh b/test/shell/snapshot-merge.sh
index 0117cdc..44d6c24 100644
--- a/test/shell/snapshot-merge.sh
+++ b/test/shell/snapshot-merge.sh
@@ -25,7 +25,9 @@ setup_merge_() {
local VG_NAME=$1
local LV_NAME=$2
local NUM_EXTRA_SNAPS=${3:-0}
- local BASE_SNAP_LV_NAME=$(snap_lv_name_ $LV_NAME)
+ local BASE_SNAP_LV_NAME
+
+ BASE_SNAP_LV_NAME=$(snap_lv_name_ $LV_NAME)
lvcreate -aey -n $LV_NAME -l 50%FREE $VG_NAME
lvcreate -s -n $BASE_SNAP_LV_NAME -l 20%FREE ${VG_NAME}/${LV_NAME}
diff --git a/test/shell/topology-support.sh b/test/shell/topology-support.sh
index a1af6d7..caebb3d 100644
--- a/test/shell/topology-support.sh
+++ b/test/shell/topology-support.sh
@@ -14,23 +14,17 @@
which mkfs.ext3 || skip
check_logical_block_size() {
- local DEV_=$(cat SCSI_DEBUG_DEV)
# Verify logical_block_size - requires Linux >= 2.6.31
- SYSFS_LOGICAL_BLOCK_SIZE=$(echo /sys/block/$(basename $DEV_)/queue/logical_block_size)
- if [ -f "$SYSFS_LOGICAL_BLOCK_SIZE" ] ; then
- ACTUAL_LOGICAL_BLOCK_SIZE=$(cat $SYSFS_LOGICAL_BLOCK_SIZE)
- test $ACTUAL_LOGICAL_BLOCK_SIZE = $1
- fi
+ SYSFS_LOGICAL_BLOCK_SIZE="/sys/block/$(basename $(< SCSI_DEBUG_DEV))/queue/logical_block_size"
+ test -f "$SYSFS_LOGICAL_BLOCK_SIZE" || return 0
+ test "$(< $SYSFS_LOGICAL_BLOCK_SIZE)" -eq "$1" # ACTUAL_LOGICAL_BLOCK_SIZE
}
check_optimal_io_size() {
- local DEV_=$(cat SCSI_DEBUG_DEV)
# Verify optimal_io_size
- SYSFS_OPTIMAL_IO_SIZE=$(echo /sys/block/$(basename $DEV_)/queue/optimal_io_size)
- if [ -f "$SYSFS_OPTIMAL_IO_SIZE" ] ; then
- ACTUAL_OPTIMAL_IO_SIZE=$(cat $SYSFS_OPTIMAL_IO_SIZE)
- test $ACTUAL_OPTIMAL_IO_SIZE = $1
- fi
+ SYSFS_OPTIMAL_IO_SIZE="/sys/block/$(basename $(< SCSI_DEBUG_DEV))/queue/optimal_io_size"
+ test -f "$SYSFS_OPTIMAL_IO_SIZE" || return 0
+ test "$(< $SYSFS_OPTIMAL_IO_SIZE)" -eq "$1" # ACTUAL_OPTIMAL_IO_SIZE
}
lvdev_() {
@@ -64,7 +58,7 @@ DEV_SIZE=$(($NUM_DEVS*$PER_DEV_SIZE))
# Test that kernel supports topology
aux prepare_scsi_debug_dev $DEV_SIZE || skip
-if [ ! -e /sys/block/$(basename $(cat SCSI_DEBUG_DEV))/alignment_offset ] ; then
+if [ ! -e /sys/block/$(basename $(< SCSI_DEBUG_DEV))/alignment_offset ] ; then
aux cleanup_scsi_debug_dev
skip
fi
@@ -79,7 +73,9 @@ aux prepare_scsi_debug_dev $DEV_SIZE \
check_logical_block_size $LOGICAL_BLOCK_SIZE
aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE
-vgcreate $vg $(cat DEVICES)
+get_devs
+
+vgcreate $vg "${DEVICES[@]}"
test_snapshot_mount
vgremove $vg
@@ -94,7 +90,7 @@ aux prepare_scsi_debug_dev $DEV_SIZE \
check_logical_block_size $LOGICAL_BLOCK_SIZE
aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE
-vgcreate $vg $(cat DEVICES)
+vgcreate $vg "${DEVICES[@]}"
test_snapshot_mount
vgremove $vg
@@ -109,7 +105,7 @@ aux prepare_scsi_debug_dev $DEV_SIZE \
check_logical_block_size $LOGICAL_BLOCK_SIZE
aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE
-vgcreate $vg $(cat DEVICES)
+vgcreate $vg "${DEVICES[@]}"
test_snapshot_mount
vgremove $vg
@@ -126,6 +122,6 @@ check_logical_block_size $LOGICAL_BLOCK_SIZE
check_optimal_io_size 786432
aux prepare_pvs 1 $PER_DEV_SIZE
-check pv_field $(cat DEVICES) pe_start 768.00k
+check pv_field "${DEVICES[@]}" pe_start 768.00k
aux cleanup_scsi_debug_dev
9 years, 9 months