master - cleanup: properly align code lines
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d0f26440eed53f...
Commit: d0f26440eed53fd34faf2773a9a7faf6deaf7d66
Parent: d202f43fff6ff7d12540440ae6b16a0ec2c7de5e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jan 14 12:51:59 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jan 14 14:50:08 2015 +0100
cleanup: properly align code lines
Misaligned indetion in branches.
---
lib/activate/dev_manager.c | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 18092db..c134e1b 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -145,26 +145,26 @@ static int _get_segment_status_from_target_params(const char *target_name,
if (!dm_get_status_cache(seg_status->mem, params,
(struct dm_status_cache **) &seg_status->status))
return_0;
- seg_status->type = SEG_STATUS_CACHE;
+ seg_status->type = SEG_STATUS_CACHE;
} else if (!strcmp(segtype->name, "raid")) {
if (!dm_get_status_raid(seg_status->mem, params,
- (struct dm_status_raid **) &seg_status->status))
- return_0;
- seg_status->type = SEG_STATUS_RAID;
+ (struct dm_status_raid **) &seg_status->status))
+ return_0;
+ seg_status->type = SEG_STATUS_RAID;
} else if (!strcmp(segtype->name, "thin")) {
if (!dm_get_status_thin(seg_status->mem, params,
- (struct dm_status_thin **) &seg_status->status))
- return_0;
- seg_status->type = SEG_STATUS_THIN;
+ (struct dm_status_thin **) &seg_status->status))
+ return_0;
+ seg_status->type = SEG_STATUS_THIN;
} else if (!strcmp(segtype->name, "thin-pool")) {
if (!dm_get_status_thin_pool(seg_status->mem, params,
- (struct dm_status_thin_pool **) &seg_status->status))
- return_0;
- seg_status->type = SEG_STATUS_THIN_POOL;
+ (struct dm_status_thin_pool **) &seg_status->status))
+ return_0;
+ seg_status->type = SEG_STATUS_THIN_POOL;
} else if (!strcmp(segtype->name, "snapshot")) {
if (!dm_get_status_snapshot(seg_status->mem, params,
- (struct dm_status_snapshot **) &seg_status->status))
- return_0;
+ (struct dm_status_snapshot **) &seg_status->status))
+ return_0;
seg_status->type = SEG_STATUS_SNAPSHOT;
}
9 years, 3 months
master - cleanup: update API for segment reporting
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d202f43fff6ff7...
Commit: d202f43fff6ff7d12540440ae6b16a0ec2c7de5e
Parent: cdd17eee377013a569e2aeed0cbe865749323def
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jan 14 10:31:24 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jan 14 14:50:08 2015 +0100
cleanup: update API for segment reporting
API for seg reporting is breaking internal lvm coding - it cannot
use vgmem mem pool for allocation of reported value.
So use separate pool instead of 'vgmem' for non vg related allocations
Add consts for many function params - but still many other are left
for now as non-const - needs deeper level of change even on libdm side.
---
lib/activate/activate.c | 20 +++++----
lib/activate/activate.h | 18 ++++----
lib/report/report.c | 66 +++++++++++++++-------------
lib/report/report.h | 10 ++--
libdm/libdevmapper.h | 1 +
tools/reporter.c | 110 +++++++++++++++++++++++++----------------------
6 files changed, 121 insertions(+), 104 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index c63cbde..d1d1104 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -619,7 +619,8 @@ int target_present(struct cmd_context *cmd, const char *target_name,
static int _lv_info(struct cmd_context *cmd, const struct logical_volume *lv,
int use_layer, struct lvinfo *info,
- struct lv_segment *seg, struct lv_seg_status *seg_status,
+ const struct lv_segment *seg,
+ struct lv_seg_status *seg_status,
int with_open_count, int with_read_ahead)
{
struct dm_info dminfo;
@@ -698,7 +699,7 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
* Returns 1 if lv_seg_status structure populated,
* else 0 on failure or if device not active locally.
*/
-int lv_status(struct cmd_context *cmd, struct lv_segment *lv_seg,
+int lv_status(struct cmd_context *cmd, const struct lv_segment *lv_seg,
struct lv_seg_status *lv_seg_status)
{
if (!activation())
@@ -712,18 +713,18 @@ int lv_status(struct cmd_context *cmd, struct lv_segment *lv_seg,
* else 0 on failure or if device not active locally.
*
* This is the same as calling lv_info and lv_status,
- * but* it's done in one go with one ioctl if possible!
+ * but* it's done in one go with one ioctl if possible! ]
*/
int lv_info_with_seg_status(struct cmd_context *cmd, const struct logical_volume *lv,
- struct lv_segment *lv_seg, int use_layer,
- struct lvinfo *lvinfo, struct lv_seg_status *lv_seg_status,
- int with_open_count, int with_read_ahead)
+ const struct lv_segment *lv_seg, int use_layer,
+ struct lv_with_info_and_seg_status *status,
+ int with_open_count, int with_read_ahead)
{
if (!activation())
return 0;
if (lv == lv_seg->lv)
- return _lv_info(cmd, lv, use_layer, lvinfo, lv_seg, lv_seg_status,
+ return _lv_info(cmd, lv, use_layer, &status->info, lv_seg, &status->seg_status,
with_open_count, with_read_ahead);
/*
@@ -731,8 +732,9 @@ int lv_info_with_seg_status(struct cmd_context *cmd, const struct logical_volume
* status for segment that belong to another LV,
* we need to acquire info and status separately!
*/
- return _lv_info(cmd, lv, use_layer, lvinfo, NULL, NULL, with_open_count, with_read_ahead) &&
- _lv_info(cmd, lv_seg->lv, use_layer, NULL, lv_seg, lv_seg_status, 0, 0);
+ return _lv_info(cmd, lv, use_layer, &status->info, NULL, NULL, with_open_count, with_read_ahead) &&
+ _lv_info(cmd, lv_seg->lv, use_layer, NULL, lv_seg,
+ &status->seg_status, 0, 0);
}
#define OPEN_COUNT_CHECK_RETRIES 25
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index ef375bd..1376ce5 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -41,16 +41,16 @@ typedef enum {
struct lv_seg_status {
struct dm_pool *mem; /* input */
- struct lv_segment *seg; /* input */
+ const struct lv_segment *seg; /* input */
lv_seg_status_type_t type; /* output */
- void *status; /* struct dm_status_* */ /* output */
+ const void *status; /* struct dm_status_* */ /* output */
};
struct lv_with_info_and_seg_status {
- struct logical_volume *lv; /* input */
- struct lvinfo *info; /* output */
+ const struct logical_volume *lv; /* input */
+ struct lvinfo info; /* output */
int seg_part_of_lv; /* output */
- struct lv_seg_status *seg_status; /* input/output, see lv_seg_status */
+ struct lv_seg_status seg_status; /* input/output, see lv_seg_status */
};
struct lv_activate_opts {
@@ -123,19 +123,19 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
* Returns 1 if lv_seg_status structure has been populated,
* else 0 on failure or if device not active locally.
*/
-int lv_status(struct cmd_context *cmd, struct lv_segment *lv_seg,
+int lv_status(struct cmd_context *cmd, const struct lv_segment *lv_seg,
struct lv_seg_status *lv_seg_status);
/*
* Returns 1 if lv_info_and_seg_status structure has been populated,
* else 0 on failure or if device not active locally.
*
- * lv_info_with_seg_status is the same as calling lv_info and then lv_seg_status,
+ * lv_info_with_seg_status is the same as calling lv_info and then lv_status,
* but this fn tries to do that with one ioctl if possible.
*/
int lv_info_with_seg_status(struct cmd_context *cmd, const struct logical_volume *lv,
- struct lv_segment *lv_seg, int use_layer,
- struct lvinfo *lvinfo, struct lv_seg_status *lv_seg_status,
+ const struct lv_segment *lv_seg, int use_layer,
+ struct lv_with_info_and_seg_status *status,
int with_open_count, int with_read_ahead);
int lv_check_not_in_use(const struct logical_volume *lv);
diff --git a/lib/report/report.c b/lib/report/report.c
index d0351f7..be80e77 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -393,8 +393,8 @@ static int _lvkmaj_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(
{
const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data;
- if (lvdm->info && lvdm->info->exists && lvdm->info->major >= 0)
- return dm_report_field_int(rh, field, &lvdm->info->major);
+ if (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(num_undef_32));
}
@@ -405,8 +405,8 @@ static int _lvkmin_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(
{
const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data;
- if (lvdm->info && lvdm->info->exists && lvdm->info->minor >= 0)
- return dm_report_field_int(rh, field, &lvdm->info->minor);
+ if (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(num_undef_32));
}
@@ -746,10 +746,10 @@ 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)
+ if (!lvdm->info.exists)
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);
+ return _size32_disp(rh, mem, field, &lvdm->info.read_ahead, private);
}
static int _vgsize_disp(struct dm_report *rh, struct dm_pool *mem,
@@ -1533,9 +1533,9 @@ static int _lvpermissions_disp(struct dm_report *rh, struct dm_pool *mem,
if (!lv_is_pvmove(lvdm->lv)) {
if (lvdm->lv->status & LVM_WRITE) {
- if (!lvdm->info->exists)
+ if (!lvdm->info.exists)
perms = _str_unknown;
- else if (lvdm->info->read_only)
+ else if (lvdm->info.read_only)
perms = GET_FIRST_RESERVED_NAME(lv_permissions_r_override);
else
perms = GET_FIRST_RESERVED_NAME(lv_permissions_rw);
@@ -1702,8 +1702,8 @@ 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, GET_FIRST_RESERVED_NAME(lv_suspended_y), private);
+ if (lvdm->info.exists)
+ 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);
}
@@ -1714,8 +1714,8 @@ 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, GET_FIRST_RESERVED_NAME(lv_live_table_y), private);
+ if (lvdm->info.exists)
+ 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);
}
@@ -1726,8 +1726,8 @@ 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, GET_FIRST_RESERVED_NAME(lv_inactive_table_y), private);
+ if (lvdm->info.exists)
+ 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);
}
@@ -1738,8 +1738,8 @@ 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, GET_FIRST_RESERVED_NAME(lv_device_open_y), private);
+ if (lvdm->info.exists)
+ 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);
}
@@ -1801,9 +1801,9 @@ static int _cache_ ## cache_status_field_name ## _disp (struct dm_report *rh, \
void *private) \
{ \
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) \
+ if (lvdm->seg_status.type != SEG_STATUS_CACHE) \
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))); \
+ return dm_report_field_uint64(rh, field, (void *) ((char *) lvdm->seg_status.status + offsetof(struct dm_status_cache, cache_status_field_name))); \
}
GENERATE_CACHE_STATUS_DISP_FN(total_blocks)
@@ -1840,7 +1840,7 @@ static void *_obj_get_vg(void *obj)
static void *_obj_get_lv(void *obj)
{
- return ((struct lvm_report_object *)obj)->lvdm->lv;
+ return (struct logical_volume *)((struct lvm_report_object *)obj)->lvdm->lv;
}
static void *_obj_get_lv_with_info_and_seg_status(void *obj)
@@ -1973,24 +1973,30 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
/*
* Create a row of data for an object
*/
-int report_object(void *handle, struct volume_group *vg,
- struct logical_volume *lv, struct physical_volume *pv,
- struct lv_segment *seg, struct pv_segment *pvseg,
- struct lvinfo *lvinfo, struct lv_seg_status *lv_seg_status,
- struct label *label)
+int report_object(void *handle, const struct volume_group *vg,
+ const struct logical_volume *lv, const struct physical_volume *pv,
+ const struct lv_segment *seg, const struct pv_segment *pvseg,
+ const struct lvinfo *lvinfo, const struct lv_seg_status *lv_seg_status,
+ const struct label *label)
{
struct device dummy_device = { .dev = 0 };
struct label dummy_label = { .dev = &dummy_device };
- struct lv_with_info_and_seg_status lvdm = { .lv = lv, .info = lvinfo, .seg_status = lv_seg_status};
+ struct lv_with_info_and_seg_status lvdm = { .lv = lv };
struct lvm_report_object obj = {
- .vg = vg,
+ .vg = (struct volume_group *) vg,
.lvdm = &lvdm,
- .pv = pv,
- .seg = seg,
- .pvseg = pvseg,
- .label = label ? : (pv ? pv_label(pv) : NULL)
+ .pv = (struct physical_volume *) pv,
+ .seg = (struct lv_segment *) seg,
+ .pvseg = (struct pv_segment *) pvseg,
+ .label = (struct label *) (label ? : (pv ? pv_label(pv) : NULL))
};
+ if (lvinfo)
+ lvdm.info = *lvinfo;
+
+ if (lv_seg_status)
+ lvdm.seg_status = *lv_seg_status;
+
/* FIXME workaround for pv_label going through cache; remove once struct
* physical_volume gains a proper "label" pointer */
if (!obj.label) {
diff --git a/lib/report/report.h b/lib/report/report.h
index 20fb6bd..a8e7405 100644
--- a/lib/report/report.h
+++ b/lib/report/report.h
@@ -44,11 +44,11 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
int aligned, int buffered, int headings, int field_prefixes,
int quoted, int columns_as_rows, const char *selection);
void report_free(void *handle);
-int report_object(void *handle, struct volume_group *vg,
- struct logical_volume *lv, struct physical_volume *pv,
- struct lv_segment *seg, struct pv_segment *pvseg,
- struct lvinfo *lvinfo, struct lv_seg_status *lv_seg_status,
- struct label *label);
+int report_object(void *handle, const struct volume_group *vg,
+ const struct logical_volume *lv, const struct physical_volume *pv,
+ const struct lv_segment *seg, const struct pv_segment *pvseg,
+ const struct lvinfo *lvinfo, const struct lv_seg_status *lv_seg_status,
+ const struct label *label);
int report_devtypes(void *handle);
int report_output(void *handle);
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index f18fba9..48adf22 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1647,6 +1647,7 @@ struct dm_report_object_type {
uint32_t id; /* Powers of 2 */
const char *desc;
const char *prefix; /* field id string prefix (optional) */
+ /* FIXME: convert to proper usage of const pointers here */
void *(*data_fn)(void *object); /* callback from report_object() */
};
diff --git a/tools/reporter.c b/tools/reporter.c
index b312568..133ef39 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -39,7 +39,7 @@ static int _vgs_single(struct cmd_context *cmd __attribute__((unused)),
return ECMD_PROCESSED;
}
-static void _choose_lv_segment_for_status_report(struct logical_volume *lv, struct lv_segment **lv_seg)
+static void _choose_lv_segment_for_status_report(const struct logical_volume *lv, const struct lv_segment **lv_seg)
{
/*
* By default, take the first LV segment to report status for.
@@ -51,58 +51,61 @@ static void _choose_lv_segment_for_status_report(struct logical_volume *lv, stru
*lv_seg = first_seg(lv);
}
-static void _do_info_and_status(struct cmd_context *cmd,
- struct logical_volume *lv,
- struct lvinfo *lvinfo,
- struct lv_segment *lv_seg,
- struct lv_seg_status *lv_seg_status,
- int do_info, int do_status)
+static int _do_info_and_status(struct cmd_context *cmd,
+ const struct logical_volume *lv,
+ const struct lv_segment *lv_seg,
+ struct lv_with_info_and_seg_status *status,
+ int do_info, int do_status)
{
- if (lv_seg_status) {
- lv_seg_status->mem = lv->vg->vgmem;
- lv_seg_status->type = SEG_STATUS_NONE;
- lv_seg_status->status = NULL;
- }
+ status->seg_status.mem = NULL;
- if (do_info && !do_status) {
- /* info only */
- if (!lv_info(cmd, lv, 0, lvinfo, 1, 1))
- lvinfo->exists = 0;
- } else if (!do_info && do_status) {
- /* status only */
+ if (do_status) {
+ if (!(status->seg_status.mem = dm_pool_create("reporter_pool", 1024)))
+ return_0;
if (!lv_seg)
_choose_lv_segment_for_status_report(lv, &lv_seg);
- if (!lv_status(cmd, lv_seg, lv_seg_status))
- lvinfo->exists = 0;
- } else if (do_info && do_status) {
- /* both info and status */
- if (!lv_seg)
- _choose_lv_segment_for_status_report(lv, &lv_seg);
- if (!lv_info_with_seg_status(cmd, lv, lv_seg, 0, lvinfo, lv_seg_status, 1, 1))
- lvinfo->exists = 0;
+ if (do_info) {
+ /* both info and status */
+ if (!lv_info_with_seg_status(cmd, lv, lv_seg, 0, status, 1, 1))
+ status->info.exists = 0;
+ } else {
+ /* status only */
+ if (!lv_status(cmd, lv_seg, &status->seg_status))
+ status->info.exists = 0;
+ }
+ } else if (do_info) {
+ /* info only */
+ if (!lv_info(cmd, lv, 0, &status->info, 1, 1))
+ status->info.exists = 0;
}
+
+ return 1;
}
static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
- struct logical_volume *lv,
+ const struct logical_volume *lv,
int do_info, int do_status,
void *handle)
{
- struct lvinfo lvinfo;
- struct lv_seg_status lv_seg_status;
+ struct lv_with_info_and_seg_status status;
int r = ECMD_FAILED;
- _do_info_and_status(cmd, lv, &lvinfo, NULL, &lv_seg_status, do_info, do_status);
+ if (!_do_info_and_status(cmd, lv, NULL, &status, do_info, do_status)) {
+ stack;
+ return r;
+ }
+
if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL,
- do_info ? &lvinfo : NULL,
- do_status ? &lv_seg_status : NULL,
+ do_info ? &status.info : NULL,
+ do_status ? &status.seg_status : NULL,
NULL))
- goto out;
+ goto_out;
r = ECMD_PROCESSED;
out:
- if (lv_seg_status.status)
- dm_pool_free(lv_seg_status.mem, lv_seg_status.status);
+ if (status.seg_status.mem)
+ dm_pool_destroy(status.seg_status.mem);
+
return r;
}
@@ -131,25 +134,29 @@ static int _lvs_with_info_and_status_single(struct cmd_context *cmd, struct logi
}
static int _do_segs_with_info_and_status_single(struct cmd_context *cmd,
- struct lv_segment *seg,
+ const struct lv_segment *seg,
int do_info, int do_status,
void *handle)
{
- struct lvinfo lvinfo;
- struct lv_seg_status lv_seg_status;
+ struct lv_with_info_and_seg_status status;
int r = ECMD_FAILED;
- _do_info_and_status(cmd, seg->lv, &lvinfo, seg, &lv_seg_status, do_info, do_status);
+ if (!_do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status)) {
+ stack;
+ return r;
+ }
+
if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL,
- do_info ? &lvinfo : NULL,
- do_status ? &lv_seg_status : NULL,
+ do_info ? &status.info : NULL,
+ do_status ? &status.seg_status : NULL,
NULL))
- goto out;
+ goto_out;
r = ECMD_PROCESSED;
out:
- if (lv_seg_status.status)
- dm_pool_free(lv_seg_status.mem, lv_seg_status.status);
+ if (status.seg_status.mem)
+ dm_pool_destroy(status.seg_status.mem);
+
return r;
}
@@ -222,9 +229,9 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
{
int ret = ECMD_PROCESSED;
struct lv_segment *seg = pvseg->lvseg;
- struct lvinfo lvinfo = { .exists = 0 };
- struct lv_seg_status lv_seg_status = { .type = SEG_STATUS_NONE,
- .status = NULL };
+ struct lv_with_info_and_seg_status status = {
+ .seg_status.type = SEG_STATUS_NONE
+ };
struct segment_type _freeseg_type = {
.name = "free",
@@ -260,18 +267,19 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
};
if (seg)
- _do_info_and_status(cmd, seg->lv, &lvinfo, seg, &lv_seg_status, do_info, do_status);
+ _do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status);
if (!report_object(handle, vg, seg ? seg->lv : &_free_logical_volume, pvseg->pv,
- seg ? : &_free_lv_segment, pvseg, &lvinfo, &lv_seg_status,
+ seg ? : &_free_lv_segment, pvseg, &status.info, &status.seg_status,
pv_label(pvseg->pv))) {
ret = ECMD_FAILED;
goto_out;
}
out:
- if (seg && lv_seg_status.status)
- dm_pool_free(lv_seg_status.mem, lv_seg_status.status);
+ if (status.seg_status.mem)
+ dm_pool_destroy(status.seg_status.mem);
+
return ret;
}
9 years, 3 months
master - raid_manip: fix multi-segment misallocation on 'lvconvert --repair'
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cdd17eee377013...
Commit: cdd17eee377013a569e2aeed0cbe865749323def
Parent: 8804023825e9eb00df653a7c5116097d1ce49087
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed Jan 14 13:41:55 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jan 14 13:41:55 2015 +0100
raid_manip: fix multi-segment misallocation on 'lvconvert --repair'
An 'lvconvert --repair $RAID_LV" to replace a failed leg of a multi-segment
RAID10/4/5/6 logical volume can lead to allocation of (parts of) the replacement
image component pair on the physical volume of another image component
(e.g. image 0 allocated on the same PV as image 1 silently impeding resilience).
Patch fixes this severe resilince issue by prohibiting allocation on PVs
already holding other legs of the RAID set. It allows to allocate free space
on any operational PV already holding parts of the image component pair.
---
WHATS_NEW | 1 +
lib/metadata/raid_manip.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index e295e6c..bbb45c4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Fix lvconvert --repair to honour resilience requirement for segmented RAID LV.
Filter out partitioned device-mapper devices as unsuitable for use as PVs.
Also notify lvmetad about filtered device if using pvscan --cache DevicePath.
Use LVM's own selection instead of awk expressions in clvmd startup scripts.
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 6f951f4..cb0366f 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1545,6 +1545,28 @@ has_enough_space:
return 1;
}
+static int _avoid_pvs_of_lv(struct logical_volume *lv, void *data)
+{
+ struct dm_list *allocate_pvs = (struct dm_list *) data;
+ struct pv_list *pvl;
+
+ dm_list_iterate_items(pvl, allocate_pvs)
+ if (!(lv->status & PARTIAL_LV) &&
+ lv_is_on_pv(lv, pvl->pv))
+ pvl->pv->status &= ~ALLOCATABLE_PV;
+
+ return 1;
+ }
+
+/*
+ * Prevent any PVs holding other image components of @lv from being used for allocation,
+ * I.e. reset ALLOCATABLE_PV on respective PVs listed on @allocatable_pvs
+ */
+static void _avoid_pvs_with_other_images_of_lv(struct logical_volume *lv, struct dm_list *allocate_pvs)
+{
+ for_each_sub_lv(lv, _avoid_pvs_of_lv, allocate_pvs);
+}
+
/*
* lv_raid_replace
* @lv
@@ -1643,6 +1665,9 @@ int lv_raid_replace(struct logical_volume *lv,
}
}
+ /* Prevent any PVs holding image components from being used for allocation */
+ _avoid_pvs_with_other_images_of_lv(lv, allocate_pvs);
+
/*
* Allocate the new image components first
* - This makes it easy to avoid all currently used devs
9 years, 3 months
master - tests: pvscan --cache DevicePath does not fail if the device is just filtered
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8804023825e9eb...
Commit: 8804023825e9eb00df653a7c5116097d1ce49087
Parent: 99d895014d971395fe7a739838952e7405eb4dda
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jan 12 15:16:57 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jan 12 15:16:57 2015 +0100
tests: pvscan --cache DevicePath does not fail if the device is just filtered
It's not an error if the device is filtered out and hence cleared from
lvmetad cache - "pvscan --cache DevPath" has now the same behaviour in
this case as "pvscan --cache major:minor" (which is more consistent).
Before, the tests expected failure return code for "pvscan --cache DevicePath"
if the device was filtered (which is a different situation if the device
is missing in the system completely!).
---
test/shell/lvmetad-pvscan-filter.sh | 4 +++-
test/shell/lvmetad-pvscan-md.sh | 4 ++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvmetad-pvscan-filter.sh b/test/shell/lvmetad-pvscan-filter.sh
index a3af1b2..05666df 100644
--- a/test/shell/lvmetad-pvscan-filter.sh
+++ b/test/shell/lvmetad-pvscan-filter.sh
@@ -18,8 +18,10 @@ aux prepare_pvs 2
maj=$(($(stat -L --printf=0x%t "$dev2")))
min=$(($(stat -L --printf=0x%T "$dev2")))
+# Filter out device, pvscan should trigger
+# clearing of the device from lvmetad cache.
aux hide_dev "$dev2"
-not pvscan --cache "$dev2" 2>&1 | grep "not found"
+pvscan --cache "$dev2" 2>&1 | grep "not found"
# pvscan with --major/--minor does not fail: lvmetad needs to
# be notified about device removal on REMOVE uevent, hence
# this should not fail so udev does not grab a "failed" state
diff --git a/test/shell/lvmetad-pvscan-md.sh b/test/shell/lvmetad-pvscan-md.sh
index 449369d..653d18a 100644
--- a/test/shell/lvmetad-pvscan-md.sh
+++ b/test/shell/lvmetad-pvscan-md.sh
@@ -69,8 +69,8 @@ pvcreate $lvmdev
pvscan --cache "$lvmdev"
# ensure that lvmetad can only see the toplevel MD device
-not pvscan --cache "$dev1" 2>&1 | grep "not found"
-not pvscan --cache "$dev2" 2>&1 | grep "not found"
+pvscan --cache "$dev1" 2>&1 | grep "not found"
+pvscan --cache "$dev2" 2>&1 | grep "not found"
pvs | grep $lvmdev
pvs | not grep "$dev1"
9 years, 3 months
master - dev-type: filter out partitioned device-mapper devices as unsuitable for use as PVs
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=99d895014d9713...
Commit: 99d895014d971395fe7a739838952e7405eb4dda
Parent: 8dbe76734049a225a34bbbab383418b62acdcce1
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jan 12 14:02:57 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jan 12 14:10:44 2015 +0100
dev-type: filter out partitioned device-mapper devices as unsuitable for use as PVs
Normally, if there are partitions defined on top of device-mapper
device, there should be a device-mapper device created for each
partiton on top of the old one and once the underlying DM device
is used by another devices (partition mappings in this case),
it can't be used as a PV anymore.
However, sometimes, it may happen the partition mappings are
missing - either the partitioning tool is not creating them if
it does not contain full support for device-mapper devices or
the mappings were removed.
Better safe than sorry - check for partition header on DM devs
and filter them out as unsuitable for PVs in case the check is
positive. Whatever the user is doing, let's do our best to prevent
unwanted corruption (...by running pvcreate on top of such device
that would corrupt the partition header).
---
WHATS_NEW | 1 +
lib/device/dev-type.c | 3 +++
test/shell/test-partition.sh | 3 ++-
3 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 11611dd..e295e6c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Filter out partitioned device-mapper devices as unsuitable for use as PVs.
Also notify lvmetad about filtered device if using pvscan --cache DevicePath.
Use LVM's own selection instead of awk expressions in clvmd startup scripts.
Do not filter out snapshot origin LVs as unusable devices for an LVM stack.
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 001248d..a84f7e9 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -272,6 +272,9 @@ static int _is_partitionable(struct dev_types *dt, struct device *dev)
{
int parts = major_max_partitions(dt, MAJOR(dev->dev));
+ if (MAJOR(dev->dev) == dt->device_mapper_major)
+ return 1;
+
/* All MD devices are partitionable via blkext (as of 2.6.28) */
if (MAJOR(dev->dev) == dt->md_major)
return 1;
diff --git a/test/shell/test-partition.sh b/test/shell/test-partition.sh
index af04b4e..e79216e 100644
--- a/test/shell/test-partition.sh
+++ b/test/shell/test-partition.sh
@@ -28,4 +28,5 @@ pvs "$dev1"
# create small partition table
echo "1 2" | sfdisk "$dev1"
-pvs "$dev1"
+aux notify_lvmetad "$dev1"
+not pvs "$dev1"
9 years, 3 months
master - pvscan: notify lvmetad about device that is gone and pvscan is run with device path instead of major:minor pair
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8dbe76734049a2...
Commit: 8dbe76734049a225a34bbbab383418b62acdcce1
Parent: 1e4a4d48aeb1e56a8df19ba73425eb5f7632c9d2
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jan 12 13:50:11 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jan 12 13:59:51 2015 +0100
pvscan: notify lvmetad about device that is gone and pvscan is run with device path instead of major:minor pair
If pvscan is run with device path instead of major:minor pair and this
device still exists in the system and the device is not visible anymore
(due to a filter that is applied), notify lvmetad properly about this.
This makes it more consistent with respect to existing pvscan with
major:minor which already notifies lvmetad about device that is gone
due to filters.
However, if the device is not in the system anymore, we're not able
to translate the original device path into major:minor pair which
lvmetad needs for its action (lvmetad_pv_gone fn). So in this case,
we still need to use major:minor pair only, not device path. But at
least make "pvscan --cache DevicePath" as near as possible to "pvscan
--cahce <major>:<minor>" functionality.
Also add a note to pvscan man page about this difference when using
pvscan --cache with DevicePath and major:minor pair.
---
WHATS_NEW | 1 +
man/pvscan.8.in | 8 ++++++--
tools/pvscan.c | 13 +++++++++++--
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 242c17d..11611dd 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Also notify lvmetad about filtered device if using pvscan --cache DevicePath.
Use LVM's own selection instead of awk expressions in clvmd startup scripts.
Do not filter out snapshot origin LVs as unusable devices for an LVM stack.
Fix incorrect rimage names when converting from mirror to raid1 LV (2.02.112).
diff --git a/man/pvscan.8.in b/man/pvscan.8.in
index c1187ac..f976b40 100644
--- a/man/pvscan.8.in
+++ b/man/pvscan.8.in
@@ -69,8 +69,12 @@ If lvmetad has not yet cached any metadata or the filters have recently been
changed, then all devices may be scanned, effectively ignoring the rest of
the command line. Otherwise, if all the devices referenced on the command line
contain metadata in the default lvm2 format, other devices are not accessed.
-If metadata written using the obsolete GFS pool format is encountered, this is
-ignored and so lvmetad should not be used.
+If metadata written using the obsolete GFS pool or lvm1 format is encountered,
+this is ignored and so lvmetad should not be used.
+To notify lvmetad about a device that is not present in the system anymore,
+\fB\-\-major\fP and \fB\-\-minor\fP pair of that device must be always supplied,
+not \fBDevicePath\fP as pvscan is not able to translate the \fBDevicePath\fP
+into major and minor pair which lvmetad requires.
.SH SEE ALSO
.BR lvm (8),
.BR lvmetad (8),
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 3eaf0bb..4ab2ff7 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -239,8 +239,17 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
if (pv_name[0] == '/') {
/* device path */
if (!(dev = dev_cache_get(pv_name, cmd->lvmetad_filter))) {
- log_error("Physical Volume %s not found.", pv_name);
- ret = ECMD_FAILED;
+ if ((dev = dev_cache_get(pv_name, NULL))) {
+ if (!_clear_dev_from_lvmetad_cache(dev->dev, MAJOR(dev->dev), MINOR(dev->dev), handler)) {
+ stack;
+ ret = ECMD_FAILED;
+ break;
+ }
+ } else {
+ log_error("Physical Volume %s not found.", pv_name);
+ ret = ECMD_FAILED;
+ break;
+ }
continue;
}
}
9 years, 3 months
master - toollib: process_each_pv should match by device
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1e4a4d48aeb1e5...
Commit: 1e4a4d48aeb1e56a8df19ba73425eb5f7632c9d2
Parent: 6a77b6f43c7c9a90210bb90be55c4060e612106d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jan 7 14:04:12 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Jan 9 10:03:31 2015 -0600
toollib: process_each_pv should match by device
When processing PVs specified on the command line, the arg
name was being matched against pv_dev_name, which will not
always work:
- The PV specified on the command line could be an alias,
e.g. /dev/disk/by-id/...
- The PV specified on the command line could be any random
path to the device, e.g. /dev/../dev/sdb
To fix this, first resolve the named PV args to struct device's,
then iterate through the devices for processing.
---
tools/toollib.c | 96 +++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 72 insertions(+), 24 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 41e6f88..1b3883e 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2074,6 +2074,31 @@ static int _get_arg_pvnames(struct cmd_context *cmd,
return ret_max;
}
+static int _get_arg_devices(struct cmd_context *cmd,
+ struct dm_list *arg_pvnames,
+ struct dm_list *arg_devices)
+{
+ struct dm_str_list *sl;
+ struct device_list *devl;
+ int ret_max = ECMD_PROCESSED;
+
+ dm_list_iterate_items(sl, arg_pvnames) {
+ if (!(devl = dm_pool_alloc(cmd->mem, sizeof(*devl)))) {
+ log_error("device_list alloc failed.");
+ return ECMD_FAILED;
+ }
+
+ if (!(devl->dev = dev_cache_get(sl->str, cmd->filter))) {
+ log_error("Failed to find physical volume \"%s\".", sl->str);
+ ret_max = ECMD_FAILED;
+ } else {
+ dm_list_add(arg_devices, &devl->list);
+ }
+ }
+
+ return ret_max;
+}
+
static int _get_all_devices(struct cmd_context *cmd, struct dm_list *all_devices)
{
struct dev_iter *iter;
@@ -2118,6 +2143,18 @@ static int _device_list_remove(struct dm_list *all_devices, struct device *dev)
return 0;
}
+static int _device_list_match(struct dm_list *devices, struct device *dev)
+{
+ struct device_list *devl;
+
+ dm_list_iterate_items(devl, devices) {
+ if (devl->dev == dev)
+ return 1;
+ }
+
+ return 0;
+}
+
static int _process_device_list(struct cmd_context *cmd, struct dm_list *all_devices,
void *handle, process_single_pv_fn_t process_single_pv)
{
@@ -2155,7 +2192,7 @@ static int _process_device_list(struct cmd_context *cmd, struct dm_list *all_dev
static int _process_pvs_in_vg(struct cmd_context *cmd,
struct volume_group *vg,
struct dm_list *all_devices,
- struct dm_list *arg_pvnames,
+ struct dm_list *arg_devices,
struct dm_list *arg_tags,
int process_all,
int skip,
@@ -2179,11 +2216,12 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
process_pv = process_all;
- /* Remove each pvname as it is processed. */
- if (!process_pv && !dm_list_empty(arg_pvnames) &&
- str_list_match_item(arg_pvnames, pv_name)) {
+ /* Remove each arg_devices entry as it is processed. */
+
+ if (!process_pv && !dm_list_empty(arg_devices) &&
+ _device_list_match(arg_devices, pv->dev)) {
process_pv = 1;
- str_list_del(arg_pvnames, pv_name);
+ _device_list_remove(arg_devices, pv->dev);
}
if (!process_pv && !dm_list_empty(arg_tags) &&
@@ -2222,10 +2260,9 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
}
/*
- * When processing only specific PV names, we can quit
- * once they've all been found.
+ * When processing only specific PVs, we can quit once they've all been found.
*/
- if (!process_all && dm_list_empty(arg_tags) && dm_list_empty(arg_pvnames))
+ if (!process_all && dm_list_empty(arg_tags) && dm_list_empty(arg_devices))
break;
}
@@ -2234,19 +2271,19 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
/*
* Iterate through all PVs in each listed VG. Process a PV if
- * the name or tag matches arg_pvnames or arg_tags. If both
- * arg_pvnames and arg_tags are empty, then process all PVs.
+ * its dev or tag matches arg_devices or arg_tags. If both
+ * arg_devices and arg_tags are empty, then process all PVs.
* No PV should be processed more than once.
*
- * Each PV is removed from arg_pvnames and all_devices when it is
- * processed. Any names remaining in arg_pvnames were not found, and
+ * Each PV is removed from arg_devices and all_devices when it is
+ * processed. Any names remaining in arg_devices were not found, and
* should produce an error. Any devices remaining in all_devices were
* not found and should be processed by process_all_devices().
*/
static int _process_pvs_in_vgs(struct cmd_context *cmd, uint32_t flags,
struct dm_list *all_vgnameids,
struct dm_list *all_devices,
- struct dm_list *arg_pvnames,
+ struct dm_list *arg_devices,
struct dm_list *arg_tags,
int process_all,
void *handle,
@@ -2254,7 +2291,6 @@ static int _process_pvs_in_vgs(struct cmd_context *cmd, uint32_t flags,
{
struct volume_group *vg;
struct vgnameid_list *vgnl;
- struct dm_str_list *sl;
const char *vg_name;
const char *vg_uuid;
int ret_max = ECMD_PROCESSED;
@@ -2282,7 +2318,7 @@ static int _process_pvs_in_vgs(struct cmd_context *cmd, uint32_t flags,
* vg->pvs entries from devices list.
*/
- ret = _process_pvs_in_vg(cmd, vg, all_devices, arg_pvnames, arg_tags,
+ ret = _process_pvs_in_vg(cmd, vg, all_devices, arg_devices, arg_tags,
process_all, skip, handle, process_single_pv);
if (ret != ECMD_PROCESSED)
stack;
@@ -2295,16 +2331,10 @@ static int _process_pvs_in_vgs(struct cmd_context *cmd, uint32_t flags,
unlock_and_release_vg(cmd, vg, vg->name);
/* Quit early when possible. */
- if (!process_all && dm_list_empty(arg_tags) && dm_list_empty(arg_pvnames))
+ if (!process_all && dm_list_empty(arg_tags) && dm_list_empty(arg_devices))
return ret_max;
}
- /* Return an error if a pvname arg was not found. */
- dm_list_iterate_items(sl, arg_pvnames) {
- log_error("Failed to find physical volume \"%s\".", sl->str);
- ret_max = ECMD_FAILED;
- }
-
return ret_max;
}
@@ -2317,8 +2347,10 @@ int process_each_pv(struct cmd_context *cmd,
{
struct dm_list arg_tags; /* str_list */
struct dm_list arg_pvnames; /* str_list */
+ struct dm_list arg_devices; /* device_list */
struct dm_list all_vgnameids; /* vgnameid_list */
struct dm_list all_devices; /* device_list */
+ struct device_list *devl;
int process_all_pvs;
int process_all_devices;
int ret_max = ECMD_PROCESSED;
@@ -2326,6 +2358,7 @@ int process_each_pv(struct cmd_context *cmd,
dm_list_init(&arg_tags);
dm_list_init(&arg_pvnames);
+ dm_list_init(&arg_devices);
dm_list_init(&all_vgnameids);
dm_list_init(&all_devices);
@@ -2333,9 +2366,14 @@ int process_each_pv(struct cmd_context *cmd,
* Create two lists from argv:
* arg_pvnames: pvs explicitly named in argv
* arg_tags: tags explicitly named in argv
+ *
+ * Then convert arg_pvnames, which are free-form, user-specified,
+ * names/paths into arg_devices which can be used to match below.
*/
- if ((ret = _get_arg_pvnames(cmd, argc, argv, &arg_pvnames, &arg_tags)) != ECMD_PROCESSED)
+ if ((ret = _get_arg_pvnames(cmd, argc, argv, &arg_pvnames, &arg_tags)) != ECMD_PROCESSED) {
+ stack;
return ret;
+ }
process_all_pvs = dm_list_empty(&arg_pvnames) && dm_list_empty(&arg_tags);
@@ -2343,6 +2381,11 @@ int process_each_pv(struct cmd_context *cmd,
(cmd->command->flags & ENABLE_ALL_DEVS) &&
arg_count(cmd, all_ARG);
+ if ((ret = _get_arg_devices(cmd, &arg_pvnames, &arg_devices) != ECMD_PROCESSED)) {
+ /* get_arg_devices reports the error for any PV names not found. */
+ ret_max = ECMD_FAILED;
+ }
+
/*
* If the caller wants to process all devices (not just PVs), then all PVs
* from all VGs are processed first, removing them from all_devices. Then
@@ -2359,13 +2402,18 @@ int process_each_pv(struct cmd_context *cmd,
}
ret = _process_pvs_in_vgs(cmd, flags, &all_vgnameids, &all_devices,
- &arg_pvnames, &arg_tags, process_all_pvs,
+ &arg_devices, &arg_tags, process_all_pvs,
handle, process_single_pv);
if (ret != ECMD_PROCESSED)
stack;
if (ret > ret_max)
ret_max = ret;
+ dm_list_iterate_items(devl, &arg_devices) {
+ log_error("Failed to find physical volume \"%s\".", dev_name(devl->dev));
+ ret_max = ECMD_FAILED;
+ }
+
if (!process_all_devices)
goto out;
9 years, 3 months
master - scripts: clvmd: replace awk functionality with LVM's selection
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6a77b6f43c7c9a...
Commit: 6a77b6f43c7c9a90210bb90be55c4060e612106d
Parent: fb7e2ff49368e547d597baf263e8cb7cca8b63fb
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jan 9 16:34:16 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jan 9 16:41:07 2015 +0100
scripts: clvmd: replace awk functionality with LVM's selection
No need to use awk now to get appropriate VGs/LVs, use LVM's
own --select - it's quicker, it removes a need for external
dependency on awk and it's also more readable.
---
WHATS_NEW | 1 +
scripts/clvmd_init_red_hat.in | 13 ++++---------
scripts/lvm2_cluster_activation_red_hat.sh.in | 10 +---------
3 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 893c382..242c17d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Use LVM's own selection instead of awk expressions in clvmd startup scripts.
Do not filter out snapshot origin LVs as unusable devices for an LVM stack.
Fix incorrect rimage names when converting from mirror to raid1 LV (2.02.112).
Avoid excessive re-reading of metadata and related error messages in pvremove.
diff --git a/scripts/clvmd_init_red_hat.in b/scripts/clvmd_init_red_hat.in
index 8c46c06..d7f3392 100644
--- a/scripts/clvmd_init_red_hat.in
+++ b/scripts/clvmd_init_red_hat.in
@@ -24,9 +24,9 @@ exec_prefix=@exec_prefix@
sbindir=@sbindir@
lvm_vgchange=${sbindir}/vgchange
-lvm_vgdisplay=${sbindir}/vgdisplay
+lvm_vgs=${sbindir}/vgs
lvm_vgscan=${sbindir}/vgscan
-lvm_lvdisplay=${sbindir}/lvdisplay
+lvm_lvs=${sbindir}/lvs
CLVMDOPTS="-T30"
@@ -42,17 +42,12 @@ CLVMDOPTS="-T30"
LOCK_FILE="/var/lock/subsys/$DAEMON"
-# NOTE: replace this with vgs, once display filter per attr is implemented.
clustered_vgs() {
- ${lvm_vgdisplay} 2>/dev/null | \
- awk 'BEGIN {RS="VG Name"} {if (/Clustered/) print $1;}'
+ ${lvm_vgs} --noheadings -o vg_name -S 'vg_clustered=1' 2>/dev/null
}
clustered_active_lvs() {
- for i in $(clustered_vgs); do
- ${lvm_lvdisplay} $i 2>/dev/null | \
- awk 'BEGIN {RS="LV Name"} {if (/[^N^O^T] available/) print $1;}'
- done
+ ${lvm_lvs} --noheadings -o lv_name -S 'vg_clustered=1 && lv_active!=""' 2>/dev/null
}
rh_status() {
diff --git a/scripts/lvm2_cluster_activation_red_hat.sh.in b/scripts/lvm2_cluster_activation_red_hat.sh.in
index 0d4676c..abea026 100644
--- a/scripts/lvm2_cluster_activation_red_hat.sh.in
+++ b/scripts/lvm2_cluster_activation_red_hat.sh.in
@@ -7,16 +7,8 @@ lvm_vgscan=${sbindir}/vgscan
lvm_vgs=${sbindir}/vgs
lvm_lvm=${sbindir}/lvm
-parse_clustered_vgs() {
- while read -r name attrs;
- do
- test "${attrs:5:1}" == 'c' && echo -n "$name "
- done
-}
-
-# NOTE: replace this with vgs, once display filter per attr is implemented.
clustered_vgs() {
- ${lvm_vgs} -o vg_name,vg_attr --noheadings | parse_clustered_vgs
+ ${lvm_vgs} --noheadings -o vg_name -S 'vg_clustered=1' 2>/dev/null
}
activate() {
9 years, 3 months
master - metadata: add "Failed to write VG <vg_name>." on failed vg_write and revert previous patch
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fb7e2ff49368e5...
Commit: fb7e2ff49368e547d597baf263e8cb7cca8b63fb
Parent: db7351d3133e237db01361fed8efd6b0fac85c32
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jan 9 14:04:44 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jan 9 14:04:44 2015 +0100
metadata: add "Failed to write VG <vg_name>." on failed vg_write and revert previous patch
Better than previous patch which changed log_warn to log_error -
we can have multiple MDAs and if one of them fails to be written,
we can still continue with other MDAs if we're in a mode where
we can handle missing PVs - so keep the log_warn for single
failed MDA write as it was before.
However, add log_error with "Failed to write VG <vg_name>." in
case we're not handling missing PVs or no MDA was written at all
during VG write process. This also prevents an internal error in
which the vg_write fails and we're not issuing any other log_error
in vg_write caller or above, so we end up with:
"Internal error: Failed command did not use log_error".
---
lib/metadata/metadata.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 39bd325..465eb84 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2795,7 +2795,7 @@ int vg_write(struct volume_group *vg)
}
if (!mda->ops->vg_write(vg->fid, vg, mda)) {
if (vg->cmd->handles_missing_pvs) {
- log_error("Failed to write an MDA of VG %s.", vg->name);
+ log_warn("WARNING: Failed to write an MDA of VG %s.", vg->name);
mda->status |= MDA_FAILED;
} else {
stack;
@@ -2807,6 +2807,7 @@ int vg_write(struct volume_group *vg)
}
if (revert || !wrote) {
+ log_error("Failed to write VG %s.", vg->name);
dm_list_uniterate(mdah, &vg->fid->metadata_areas_in_use, &mda->list) {
mda = dm_list_item(mdah, struct metadata_area);
9 years, 3 months
master - metadata: log_error instead of log_warn on failed mda write
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=db7351d3133e23...
Commit: db7351d3133e237db01361fed8efd6b0fac85c32
Parent: 08ac12d5e7dd8375fda49dc44c4ee924dcf05b1b
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jan 9 12:00:03 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jan 9 12:00:03 2015 +0100
metadata: log_error instead of log_warn on failed mda write
---
lib/metadata/metadata.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 26e43b4..39bd325 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2795,7 +2795,7 @@ int vg_write(struct volume_group *vg)
}
if (!mda->ops->vg_write(vg->fid, vg, mda)) {
if (vg->cmd->handles_missing_pvs) {
- log_warn("WARNING: Failed to write an MDA of VG %s.", vg->name);
+ log_error("Failed to write an MDA of VG %s.", vg->name);
mda->status |= MDA_FAILED;
} else {
stack;
9 years, 3 months