summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2003-10-15 20:02:46 +0000
committerAlasdair Kergon <agk@redhat.com>2003-10-15 20:02:46 +0000
commitf2b7349e2f4e6a68678e834301d6fa2182c45505 (patch)
treefce06332c18bfa5a0a666087b1d7fe34340a1855 /tools
parent13057fe53fe2f0dedb2d70e71d9bea36eb4839b5 (diff)
downloadlvm2-f2b7349e2f4e6a68678e834301d6fa2182c45505.tar.gz
lvm2-f2b7349e2f4e6a68678e834301d6fa2182c45505.tar.xz
lvm2-f2b7349e2f4e6a68678e834301d6fa2182c45505.zip
macro changes
Diffstat (limited to 'tools')
-rw-r--r--tools/archive.c14
-rw-r--r--tools/lvm.c5
-rw-r--r--tools/lvresize.c19
-rw-r--r--tools/pvchange.c10
-rw-r--r--tools/pvmove.c12
-rw-r--r--tools/pvscan.c13
-rw-r--r--tools/toollib.c40
-rw-r--r--tools/vgchange.c6
-rw-r--r--tools/vgconvert.c6
-rw-r--r--tools/vgmerge.c13
-rw-r--r--tools/vgreduce.c11
-rw-r--r--tools/vgremove.c6
-rw-r--r--tools/vgsplit.c12
13 files changed, 66 insertions, 101 deletions
diff --git a/tools/archive.c b/tools/archive.c
index aa1c8a26..e11b4b6f 100644
--- a/tools/archive.c
+++ b/tools/archive.c
@@ -213,7 +213,6 @@ struct volume_group *backup_read_vg(struct cmd_context *cmd,
{
struct volume_group *vg = NULL;
struct format_instance *tf;
- struct list *mdah;
struct metadata_area *mda;
void *context;
@@ -225,8 +224,7 @@ struct volume_group *backup_read_vg(struct cmd_context *cmd,
return NULL;
}
- list_iterate(mdah, &tf->metadata_areas) {
- mda = list_item(mdah, struct metadata_area);
+ list_iterate_items(mda, &tf->metadata_areas) {
if (!(vg = mda->ops->vg_read(tf, vg_name, mda)))
stack;
break;
@@ -239,7 +237,7 @@ struct volume_group *backup_read_vg(struct cmd_context *cmd,
/* ORPHAN and VG locks held before calling this */
int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)
{
- struct list *pvh;
+ struct pv_list *pvl;
struct physical_volume *pv;
struct lvmcache_info *info;
@@ -256,8 +254,8 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)
}
/* Add any metadata areas on the PVs */
- list_iterate(pvh, &vg->pvs) {
- pv = list_item(pvh, struct pv_list)->pv;
+ list_iterate_items(pvl, &vg->pvs) {
+ pv = pvl->pv;
if (!(info = info_from_pvid(pv->dev->pvid))) {
log_error("PV %s missing from cache",
dev_name(pv->dev));
@@ -319,7 +317,6 @@ int backup_to_file(const char *file, const char *desc, struct volume_group *vg)
{
int r = 0;
struct format_instance *tf;
- struct list *mdah;
struct metadata_area *mda;
void *context;
struct cmd_context *cmd;
@@ -334,8 +331,7 @@ int backup_to_file(const char *file, const char *desc, struct volume_group *vg)
}
/* Write and commit the metadata area */
- list_iterate(mdah, &tf->metadata_areas) {
- mda = list_item(mdah, struct metadata_area);
+ list_iterate_items(mda, &tf->metadata_areas) {
if (!(r = mda->ops->vg_write(tf, vg, mda))) {
stack;
continue;
diff --git a/tools/lvm.c b/tools/lvm.c
index 474fb9be..3460386f 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -77,14 +77,11 @@ int yes_no_arg(struct cmd_context *cmd, struct arg *a)
int metadatatype_arg(struct cmd_context *cmd, struct arg *a)
{
struct format_type *fmt;
- struct list *fmth;
-
char *format;
format = a->value;
- list_iterate(fmth, &cmd->formats) {
- fmt = list_item(fmth, struct format_type);
+ list_iterate_items(fmt, &cmd->formats) {
if (!strcasecmp(fmt->name, format) ||
!strcasecmp(fmt->name + 3, format) ||
(fmt->alias && !strcasecmp(fmt->alias, format))) {
diff --git a/tools/lvresize.c b/tools/lvresize.c
index 50f8aecf..1b60597a 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -37,10 +37,13 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
const char *vg_name;
char *st, *lock_lvid;
const char *cmd_name;
- struct list *pvh, *segh;
+ struct list *pvh;
struct lv_list *lvl;
int opt = 0;
int consistent = 1;
+ struct lv_segment *seg;
+ uint32_t seg_extents;
+ uint32_t sz, str;
enum {
LV_ANY = 0,
@@ -197,12 +200,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
/* If extending, find stripes, stripesize & size of last segment */
if (extents > lv->le_count && !(stripes == 1 || (stripes > 1 && ssize))) {
- list_iterate(segh, &lv->segments) {
- struct lv_segment *seg;
- uint32_t sz, str;
-
- seg = list_item(segh, struct lv_segment);
-
+ list_iterate_items(seg, &lv->segments) {
if (seg->type != SEG_STRIPED)
continue;
@@ -248,12 +246,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
log_error("Ignoring stripes and stripesize arguments "
"when reducing");
- list_iterate(segh, &lv->segments) {
- struct lv_segment *seg;
- uint32_t seg_extents;
-
- seg = list_item(segh, struct lv_segment);
-
+ list_iterate_items(seg, &lv->segments) {
seg_extents = seg->len;
if (seg->type == SEG_STRIPED) {
diff --git a/tools/pvchange.c b/tools/pvchange.c
index 5bdfc285..122cf62e 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -154,7 +154,8 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
struct physical_volume *pv;
char *pv_name;
- struct list *pvh, *pvslist;
+ struct pv_list *pvl;
+ struct list *pvslist;
struct list mdas;
list_init(&mdas);
@@ -194,12 +195,9 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
- list_iterate(pvh, pvslist) {
+ list_iterate_items(pvl, pvslist) {
total++;
- done += _pvchange_single(cmd,
- list_item(pvh,
- struct pv_list)->pv,
- NULL);
+ done += _pvchange_single(cmd, pvl->pv, NULL);
}
}
diff --git a/tools/pvmove.c b/tools/pvmove.c
index cc80cea0..b8bec136 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -202,7 +202,7 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
struct list **lvs_changed)
{
struct logical_volume *lv_mirr, *lv;
- struct list *lvh;
+ struct lv_list *lvl;
/* FIXME Cope with non-contiguous => splitting existing segments */
if (!(lv_mirr = lv_create_empty(vg->fid, NULL, "pvmove%d",
@@ -222,8 +222,8 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
list_init(*lvs_changed);
/* Find segments to be moved and set up mirrors */
- list_iterate(lvh, &vg->lvs) {
- lv = list_item(lvh, struct lv_list)->lv;
+ list_iterate_items(lvl, &vg->lvs) {
+ lv = lvl->lv;
if ((lv == lv_mirr) || (lv_name && strcmp(lv->name, lv_name)))
continue;
if (lv_is_origin(lv) || lv_is_cow(lv)) {
@@ -576,7 +576,7 @@ static int _poll_pvmove_vgs(struct cmd_context *cmd, const char *vgname,
void *handle)
{
struct pvmove_parms *parms = (struct pvmove_parms *) handle;
- struct list *lvh;
+ struct lv_list *lvl;
struct logical_volume *lv_mirr;
struct physical_volume *pv;
int finished;
@@ -597,8 +597,8 @@ static int _poll_pvmove_vgs(struct cmd_context *cmd, const char *vgname,
return ECMD_FAILED;
}
- list_iterate(lvh, &vg->lvs) {
- lv_mirr = list_item(lvh, struct lv_list)->lv;
+ list_iterate_items(lvl, &vg->lvs) {
+ lv_mirr = lvl->lv;
if (!(lv_mirr->status & PVMOVE))
continue;
if (!(pv = get_pvmove_pv_from_lv_mirr(lv_mirr)))
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 0ea4b875..e6f704d9 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -109,7 +109,6 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
int pvs_found = 0;
struct list *pvslist;
- struct list *pvh;
struct pv_list *pvl;
struct physical_volume *pv;
@@ -141,8 +140,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
/* eliminate exported/new if required */
- list_iterate(pvh, pvslist) {
- pvl = list_item(pvh, struct pv_list);
+ list_iterate_items(pvl, pvslist) {
pv = pvl->pv;
if ((arg_count(cmd, exported_ARG)
@@ -175,8 +173,8 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
/* find maximum pv name length */
pv_max_name_len = vg_max_name_len = 0;
- list_iterate(pvh, pvslist) {
- pv = list_item(pvh, struct pv_list)->pv;
+ list_iterate_items(pvl, pvslist) {
+ pv = pvl->pv;
len = strlen(dev_name(pv->dev));
if (pv_max_name_len < len)
pv_max_name_len = len;
@@ -187,9 +185,8 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
pv_max_name_len += 2;
vg_max_name_len += 2;
- list_iterate(pvh, pvslist)
- _pvscan_display_single(cmd, list_item(pvh, struct pv_list)->pv,
- NULL);
+ list_iterate_items(pvl, pvslist)
+ _pvscan_display_single(cmd, pvl->pv, NULL);
if (!pvs_found) {
log_print("No matching physical volumes found");
diff --git a/tools/toollib.c b/tools/toollib.c
index 15bb6890..195bd4f3 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -17,17 +17,15 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
int ret_max = 0;
int ret = 0;
- struct list *lvh;
- struct logical_volume *lv;
+ struct lv_list *lvl;
if (vg->status & EXPORTED_VG) {
log_error("Volume group \"%s\" is exported", vg->name);
return ECMD_FAILED;
}
- list_iterate(lvh, &vg->lvs) {
- lv = list_item(lvh, struct lv_list)->lv;
- ret = process_single(cmd, lv, handle);
+ list_iterate_items(lvl, &vg->lvs) {
+ ret = process_single(cmd, lvl->lv, handle);
if (ret > ret_max)
ret_max = ret;
}
@@ -233,13 +231,11 @@ int process_each_segment_in_lv(struct cmd_context *cmd,
struct lv_segment * seg,
void *handle))
{
- struct list *segh;
struct lv_segment *seg;
int ret_max = 0;
int ret;
- list_iterate(segh, &lv->segments) {
- seg = list_item(segh, struct lv_segment);
+ list_iterate_items(seg, &lv->segments) {
ret = process_single(cmd, seg, handle);
if (ret > ret_max)
ret_max = ret;
@@ -328,15 +324,11 @@ int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
{
int ret_max = 0;
int ret = 0;
- struct list *pvh;
- struct physical_volume *pv;
-
- list_iterate(pvh, &vg->pvs) {
- pv = list_item(pvh, struct pv_list)->pv;
+ struct pv_list *pvl;
- if ((ret = process_single(cmd, vg, pv, handle)) > ret_max)
+ list_iterate_items(pvl, &vg->pvs)
+ if ((ret = process_single(cmd, vg, pvl->pv, handle)) > ret_max)
ret_max = ret;
- }
return ret_max;
}
@@ -354,7 +346,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
struct pv_list *pvl;
struct physical_volume *pv;
- struct list *pvslist, *pvh;
+ struct list *pvslist;
if (argc) {
log_verbose("Using physical volume(s) on command line");
@@ -390,9 +382,9 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
if (!(pvslist = get_pvs(cmd)))
return ECMD_FAILED;
- list_iterate(pvh, pvslist) {
- pv = list_item(pvh, struct pv_list)->pv;
- ret = process_single(cmd, NULL, pv, handle);
+ list_iterate_items(pvl, pvslist) {
+ ret = process_single(cmd, NULL, pvl->pv,
+ handle);
if (ret > ret_max)
ret_max = ret;
}
@@ -492,14 +484,12 @@ static int _add_alloc_area(struct pool *mem, struct list *alloc_areas,
uint32_t start, uint32_t count)
{
struct alloc_area *aa;
- struct list *aah;
log_debug("Adding alloc area: start PE %" PRIu32 " length %" PRIu32,
start, count);
/* Ensure no overlap with existing areas */
- list_iterate(aah, alloc_areas) {
- aa = list_item(aah, struct alloc_area);
+ list_iterate_items(aa, alloc_areas) {
if (((start < aa->start) && (start + count - 1 >= aa->start)) ||
((start >= aa->start) &&
(aa->start + aa->count - 1) >= start)) {
@@ -666,7 +656,7 @@ struct list *create_pv_list(struct pool *mem,
struct list *clone_pv_list(struct pool *mem, struct list *pvsl)
{
- struct list *r, *pvh;
+ struct list *r;
struct pv_list *pvl, *new_pvl;
/* Build up list of PVs */
@@ -676,9 +666,7 @@ struct list *clone_pv_list(struct pool *mem, struct list *pvsl)
}
list_init(r);
- list_iterate(pvh, pvsl) {
- pvl = list_item(pvh, struct pv_list);
-
+ list_iterate_items(pvl, pvsl) {
if (!(new_pvl = pool_zalloc(mem, sizeof(*new_pvl)))) {
log_error("Unable to allocate physical volume list.");
return NULL;
diff --git a/tools/vgchange.c b/tools/vgchange.c
index b85fe9be..5121c234 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -23,13 +23,13 @@
static int _activate_lvs_in_vg(struct cmd_context *cmd,
struct volume_group *vg, int lock)
{
- struct list *lvh;
+ struct lv_list *lvl;
struct logical_volume *lv;
struct physical_volume *pv;
int count = 0;
- list_iterate(lvh, &vg->lvs) {
- lv = list_item(lvh, struct lv_list)->lv;
+ list_iterate_items(lvl, &vg->lvs) {
+ lv = lvl->lv;
/* Only request activation of snapshot origin devices */
if (lv_is_cow(lv))
diff --git a/tools/vgconvert.c b/tools/vgconvert.c
index 6e3454a5..a1412802 100644
--- a/tools/vgconvert.c
+++ b/tools/vgconvert.c
@@ -30,7 +30,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
int pvmetadatacopies = 0;
uint64_t pvmetadatasize = 0;
uint64_t pe_end = 0, pe_start = 0;
- struct list *pvh;
+ struct pv_list *pvl;
int change_made = 0;
if (!vg) {
@@ -88,8 +88,8 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED;
}
- list_iterate(pvh, &vg->pvs) {
- existing_pv = list_item(pvh, struct pv_list)->pv;
+ list_iterate_items(pvl, &vg->pvs) {
+ existing_pv = pvl->pv;
pe_start = existing_pv->pe_start;
pe_end = existing_pv->pe_count * existing_pv->pe_size
diff --git a/tools/vgmerge.c b/tools/vgmerge.c
index 58c980e9..a99bf04d 100644
--- a/tools/vgmerge.c
+++ b/tools/vgmerge.c
@@ -24,7 +24,7 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
const char *vg_name_from)
{
struct volume_group *vg_to, *vg_from;
- struct list *lvh1, *lvh2;
+ struct lv_list *lvl1, *lvl2;
int active;
int consistent = 1;
@@ -109,13 +109,12 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
}
/* Check no conflicts with LV names */
- list_iterate(lvh1, &vg_to->lvs) {
- list_iterate(lvh2, &vg_from->lvs) {
- char *name1 = list_item(lvh1,
- struct lv_list)->lv->name;
+ list_iterate_items(lvl1, &vg_to->lvs) {
+ char *name1 = lvl1->lv->name;
+
+ list_iterate_items(lvl2, &vg_from->lvs) {
+ char *name2 = lvl2->lv->name;
- char *name2 = list_item(lvh2,
- struct lv_list)->lv->name;
if (!strcmp(name1, name2)) {
log_error("Duplicate logical volume "
"name \"%s\" "
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index 0d39d4bb..c45c9756 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -55,7 +55,8 @@ static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv,
int *list_unsafe)
{
struct snapshot *snap;
- struct list *snaplist, *snh;
+ struct snapshot_list *snl;
+ struct list *snaplist;
log_verbose("%s/%s has missing extents: removing (including "
"dependencies)", lv->vg->name, lv->name);
@@ -91,9 +92,9 @@ static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
/* List may be empty */
- list_iterate(snh, snaplist) {
+ list_iterate_items(snl, snaplist) {
*list_unsafe = 1; /* May remove caller's lvht! */
- snap = list_item(snh, struct snapshot_list)->snapshot;
+ snap = snl->snapshot;
if (!vg_remove_snapshot(lv->vg, snap->cow)) {
stack;
return 0;
@@ -126,7 +127,6 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
struct lv_segment *seg;
unsigned int s;
int list_unsafe;
- struct list *segh;
/* Deactivate & remove necessary LVs */
restart_loop:
@@ -136,8 +136,7 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
lv = list_item(lvh, struct lv_list)->lv;
/* Are any segments of this LV on missing PVs? */
- list_iterate(segh, &lv->segments) {
- seg = list_item(segh, struct lv_segment);
+ list_iterate_items(seg, &lv->segments) {
for (s = 0; s < seg->area_count; s++) {
if (seg->area[s].type != AREA_PV)
continue;
diff --git a/tools/vgremove.c b/tools/vgremove.c
index 1d2d2a9f..a5bde93d 100644
--- a/tools/vgremove.c
+++ b/tools/vgremove.c
@@ -25,7 +25,7 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
void *handle)
{
struct physical_volume *pv;
- struct list *pvh;
+ struct pv_list *pvl;
int ret = 0;
if (!vg || !consistent) {
@@ -59,8 +59,8 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
}
/* init physical volumes */
- list_iterate(pvh, &vg->pvs) {
- pv = list_item(pvh, struct pv_list)->pv;
+ list_iterate_items(pvl, &vg->pvs) {
+ pv = pvl->pv;
log_verbose("Removing physical volume \"%s\" from "
"volume group \"%s\"", dev_name(pv->dev), vg_name);
pv->vg_name = ORPHAN;
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 1d8ca0f0..8f96fa4d 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -51,7 +51,7 @@ static int _move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
{
- struct list *lvh, *lvht, *segh;
+ struct list *lvh, *lvht;
struct logical_volume *lv;
struct lv_segment *seg;
struct physical_volume *pv;
@@ -64,8 +64,7 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
/* Ensure all the PVs used by this LV remain in the same */
/* VG as each other */
vg_with = NULL;
- list_iterate(segh, &lv->segments) {
- seg = list_item(segh, struct lv_segment);
+ list_iterate_items(seg, &lv->segments) {
for (s = 0; s < seg->area_count; s++) {
/* FIXME Check AREA_LV too */
if (seg->area[s].type != AREA_PV)
@@ -115,12 +114,11 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
static int _lv_is_in_vg(struct volume_group *vg, struct logical_volume *lv)
{
- struct list *lvh;
+ struct lv_list *lvl;
- list_iterate(lvh, &vg->lvs) {
- if (lv == list_item(lvh, struct lv_list)->lv)
+ list_iterate_items(lvl, &vg->lvs)
+ if (lv == lvl->lv)
return 1;
- }
return 0;
}