From 2c44337bd5ff7aa217a39003460cba4742a1b867 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Mon, 3 Nov 2008 22:14:30 +0000 Subject: Right, a simple build (without options) is working again. --- tools/Makefile.in | 6 +-- tools/lvconvert.c | 10 ++-- tools/lvcreate.c | 6 +-- tools/lvmcmdline.c | 2 +- tools/lvresize.c | 10 ++-- tools/lvscan.c | 2 +- tools/polldaemon.c | 4 +- tools/polldaemon.h | 4 +- tools/pvchange.c | 10 ++-- tools/pvcreate.c | 4 +- tools/pvmove.c | 46 +++++++++--------- tools/pvremove.c | 6 +-- tools/pvresize.c | 8 ++-- tools/pvscan.c | 10 ++-- tools/reporter.c | 6 +-- tools/toollib.c | 134 ++++++++++++++++++++++++++--------------------------- tools/toollib.h | 10 ++-- tools/vgchange.c | 8 ++-- tools/vgconvert.c | 10 ++-- tools/vgexport.c | 2 +- tools/vgimport.c | 2 +- tools/vgmerge.c | 24 +++++----- tools/vgreduce.c | 50 ++++++++++---------- tools/vgrename.c | 6 +-- tools/vgsplit.c | 34 +++++++------- 25 files changed, 207 insertions(+), 207 deletions(-) (limited to 'tools') diff --git a/tools/Makefile.in b/tools/Makefile.in index 2bb046d3..fea1dbb5 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -80,7 +80,7 @@ LVMLIBS = -llvm CLEAN_TARGETS = liblvm2cmd.so liblvm2cmd.a liblvm2cmd-static.a lvm lvm.o \ lvm2cmd.o lvm2cmd-static.o lvm2cmdlib.o lvm.static \ lvm.cflow lvm.xref lvm.tree lvm.rxref lvm.rtree \ - lvmcmdlib.o lvm-static.o + lvmcmdlib.o lvm-static.o dmsetup.o ifeq ("@CMDLIB@", "yes") TARGETS += liblvm2cmd.so @@ -99,9 +99,9 @@ include $(top_srcdir)/make.tmpl device-mapper: dmsetup -dmsetup: dmsetup.o $(interfacedir)/libdevmapper.$(LIB_SUFFIX) +dmsetup: dmsetup.o $(top_srcdir)/libdm/libdevmapper.$(LIB_SUFFIX) $(CC) -o $@ dmsetup.o $(CFLAGS) $(LDFLAGS) \ - -L$(interfacedir) -L$(DESTDIR)/lib -ldevmapper $(LIBS) + -L$(top_srcdir)/libdm -L$(DESTDIR)/lib -ldevmapper $(LIBS) dmsetup.static: dmsetup.o $(interfacedir)/libdevmapper.a $(CC) -o $@ dmsetup.o $(CFLAGS) $(LDFLAGS) -static \ diff --git a/tools/lvconvert.c b/tools/lvconvert.c index d533bfc1..d1260f51 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -39,7 +39,7 @@ struct lvconvert_params { int pv_count; char **pvs; - struct list *pvh; + struct dm_list *pvh; }; static int _lvconvert_name_params(struct lvconvert_params *lp, @@ -257,7 +257,7 @@ static struct logical_volume *_get_lvconvert_lv(struct cmd_context *cmd __attrib static int _update_lvconvert_mirror(struct cmd_context *cmd __attribute((unused)), struct volume_group *vg __attribute((unused)), struct logical_volume *lv __attribute((unused)), - struct list *lvs_changed __attribute((unused)), + struct dm_list *lvs_changed __attribute((unused)), unsigned flags __attribute((unused))) { /* lvconvert mirror doesn't require periodical metadata update */ @@ -267,7 +267,7 @@ static int _update_lvconvert_mirror(struct cmd_context *cmd __attribute((unused) static int _finish_lvconvert_mirror(struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv, - struct list *lvs_changed __attribute((unused))) + struct dm_list *lvs_changed __attribute((unused))) { if (!collapse_mirrored_lv(lv)) { log_error("Failed to remove temporary sync layer."); @@ -477,7 +477,7 @@ static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * l /* FIXME Share code with lvcreate */ /* FIXME Why is this restriction here? Fix it! */ - list_iterate_items(seg, &lv->segments) { + dm_list_iterate_items(seg, &lv->segments) { if (seg_is_striped(seg) && seg->area_count > 1) { log_error("Mirrors of striped volumes are not yet supported."); return 0; @@ -501,7 +501,7 @@ static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * l * Converting from mirror to mirror with different leg count, * or different log type. */ - if (list_size(&lv->segments) != 1) { + if (dm_list_size(&lv->segments) != 1) { log_error("Logical volume %s has multiple " "mirror segments.", lv->name); return 0; diff --git a/tools/lvcreate.c b/tools/lvcreate.c index dfd9b875..f17f8760 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -518,7 +518,7 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg, uint32_t status = 0; uint64_t tmp_size; struct logical_volume *lv, *org = NULL; - struct list *pvh; + struct dm_list *pvh; const char *tag = NULL; int origin_active = 0; char lv_name_buf[128]; @@ -690,10 +690,10 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg, return 0; } - if (lp->stripes > list_size(pvh) && lp->alloc != ALLOC_ANYWHERE) { + if (lp->stripes > dm_list_size(pvh) && lp->alloc != ALLOC_ANYWHERE) { log_error("Number of stripes (%u) must not exceed " "number of physical volumes (%d)", lp->stripes, - list_size(pvh)); + dm_list_size(pvh)); return 0; } diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 98ff7e70..25cbfef6 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -120,7 +120,7 @@ int metadatatype_arg(struct cmd_context *cmd, struct arg *a) format = a->value; - list_iterate_items(fmt, &cmd->formats) { + dm_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 0a8bf7da..fa44ffeb 100644 --- a/tools/lvresize.c +++ b/tools/lvresize.c @@ -267,7 +267,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg, struct lv_segment *seg; uint32_t seg_extents; uint32_t sz, str; - struct list *pvh = NULL; + struct dm_list *pvh = NULL; char size_buf[SIZE_BUF]; char lv_path[PATH_MAX]; @@ -381,7 +381,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg, seg_size = lp->extents - lv->le_count; /* Use segment type of last segment */ - list_iterate_items(seg, &lv->segments) { + dm_list_iterate_items(seg, &lv->segments) { lp->segtype = seg->segtype; } @@ -394,7 +394,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg, /* If extending, find stripes, stripesize & size of last segment */ if ((lp->extents > lv->le_count) && !(lp->stripes == 1 || (lp->stripes > 1 && lp->stripe_size))) { - list_iterate_items(seg, &lv->segments) { + dm_list_iterate_items(seg, &lv->segments) { if (!seg_is_striped(seg)) continue; @@ -434,7 +434,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg, /* If extending, find mirrors of last segment */ if ((lp->extents > lv->le_count)) { - list_iterate_back_items(seg, &lv->segments) { + dm_list_iterate_back_items(seg, &lv->segments) { if (seg_is_mirrored(seg)) seg_mirrors = lv_mirror_count(seg->lv); else @@ -461,7 +461,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg, log_error("Ignoring stripes, stripesize and mirrors " "arguments when reducing"); - list_iterate_items(seg, &lv->segments) { + dm_list_iterate_items(seg, &lv->segments) { seg_extents = seg->len; if (seg_is_striped(seg)) { diff --git a/tools/lvscan.c b/tools/lvscan.c index f63d05ff..a286fe17 100644 --- a/tools/lvscan.c +++ b/tools/lvscan.c @@ -32,7 +32,7 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv, inkernel = lv_info(cmd, lv, &info, 1, 0) && info.exists; if (lv_is_origin(lv)) { - list_iterate_items_gen(snap_seg, &lv->snapshot_segs, + dm_list_iterate_items_gen(snap_seg, &lv->snapshot_segs, origin_list) { if (inkernel && (snap_active = lv_snapshot_percent(snap_seg->cow, diff --git a/tools/polldaemon.c b/tools/polldaemon.c index 7635088a..b545eafa 100644 --- a/tools/polldaemon.c +++ b/tools/polldaemon.c @@ -68,7 +68,7 @@ static int _check_mirror_status(struct cmd_context *cmd, const char *name, struct daemon_parms *parms, int *finished) { - struct list *lvs_changed; + struct dm_list *lvs_changed; float segment_percent = 0.0, overall_percent = 0.0; uint32_t event_nr = 0; @@ -196,7 +196,7 @@ static int _poll_vg(struct cmd_context *cmd, const char *vgname, if (!vg_check_status(vg, EXPORTED_VG)) return ECMD_FAILED; - list_iterate_items(lvl, &vg->lvs) { + dm_list_iterate_items(lvl, &vg->lvs) { lv_mirr = lvl->lv; if (!(lv_mirr->status & parms->lv_type)) continue; diff --git a/tools/polldaemon.h b/tools/polldaemon.h index 1c18bf6d..169313f5 100644 --- a/tools/polldaemon.h +++ b/tools/polldaemon.h @@ -29,11 +29,11 @@ struct poll_functions { int (*update_metadata) (struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv_mirr, - struct list *lvs_changed, unsigned flags); + struct dm_list *lvs_changed, unsigned flags); int (*finish_copy) (struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv_mirr, - struct list *lvs_changed); + struct dm_list *lvs_changed); }; struct daemon_parms { diff --git a/tools/pvchange.c b/tools/pvchange.c index 4ab0d250..d1f7fd08 100644 --- a/tools/pvchange.c +++ b/tools/pvchange.c @@ -226,8 +226,8 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv) char *pv_name; struct pv_list *pvl; - struct list *pvslist; - struct list mdas; + struct dm_list *pvslist; + struct dm_list mdas; if (arg_count(cmd, allocatable_ARG) + arg_count(cmd, addtag_ARG) + arg_count(cmd, deltag_ARG) + arg_count(cmd, uuid_ARG) != 1) { @@ -250,7 +250,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv) log_verbose("Using physical volume(s) on command line"); for (; opt < argc; opt++) { pv_name = argv[opt]; - list_init(&mdas); + dm_list_init(&mdas); if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1))) { log_error("Failed to read physical volume %s", pv_name); @@ -263,7 +263,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv) * means checking every VG by scanning every * PV on the system. */ - if (is_orphan(pv) && !list_size(&mdas)) { + if (is_orphan(pv) && !dm_list_size(&mdas)) { if (!scan_vgs_for_pvs(cmd)) { log_error("Rescan for PVs without " "metadata areas failed."); @@ -287,7 +287,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv) return ECMD_FAILED; } - list_iterate_items(pvl, pvslist) { + dm_list_iterate_items(pvl, pvslist) { total++; done += _pvchange_single(cmd, pvl->pv, NULL); } diff --git a/tools/pvcreate.c b/tools/pvcreate.c index b8af0e7b..db1a0e2f 100644 --- a/tools/pvcreate.c +++ b/tools/pvcreate.c @@ -148,7 +148,7 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name, struct pvcreate_params *pp = (struct pvcreate_params *) handle; void *pv; struct device *dev; - struct list mdas; + struct dm_list mdas; if (pp->idp) { if ((dev = device_from_pvid(cmd, pp->idp)) && @@ -176,7 +176,7 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name, goto error; } - list_init(&mdas); + dm_list_init(&mdas); if (!(pv = pv_create(cmd, dev, pp->idp, pp->size, pp->pe_start, pp->extent_count, pp->extent_size, pp->pvmetadatacopies, diff --git a/tools/pvmove.c b/tools/pvmove.c index 0a1ead91..58e1305c 100644 --- a/tools/pvmove.c +++ b/tools/pvmove.c @@ -102,12 +102,12 @@ static struct volume_group *_get_vg(struct cmd_context *cmd, const char *vgname) } /* Create list of PVs for allocation of replacement extents */ -static struct list *_get_allocatable_pvs(struct cmd_context *cmd, int argc, +static struct dm_list *_get_allocatable_pvs(struct cmd_context *cmd, int argc, char **argv, struct volume_group *vg, struct physical_volume *pv, alloc_policy_t alloc) { - struct list *allocatable_pvs, *pvht, *pvh; + struct dm_list *allocatable_pvs, *pvht, *pvh; struct pv_list *pvl; if (argc) @@ -118,21 +118,21 @@ static struct list *_get_allocatable_pvs(struct cmd_context *cmd, int argc, if (!allocatable_pvs) return_NULL; - list_iterate_safe(pvh, pvht, allocatable_pvs) { - pvl = list_item(pvh, struct pv_list); + dm_list_iterate_safe(pvh, pvht, allocatable_pvs) { + pvl = dm_list_item(pvh, struct pv_list); /* Don't allocate onto the PV we're clearing! */ if ((alloc != ALLOC_ANYWHERE) && (pvl->pv->dev == pv_dev(pv))) { - list_del(&pvl->list); + dm_list_del(&pvl->list); continue; } /* Remove PV if full */ if ((pvl->pv->pe_count == pvl->pv->pe_alloc_count)) - list_del(&pvl->list); + dm_list_del(&pvl->list); } - if (list_empty(allocatable_pvs)) { + if (dm_list_empty(allocatable_pvs)) { log_error("No extents available for allocation"); return NULL; } @@ -146,16 +146,16 @@ static struct list *_get_allocatable_pvs(struct cmd_context *cmd, int argc, */ static int _insert_pvmove_mirrors(struct cmd_context *cmd, struct logical_volume *lv_mirr, - struct list *source_pvl, + struct dm_list *source_pvl, struct logical_volume *lv, - struct list *lvs_changed) + struct dm_list *lvs_changed) { struct pv_list *pvl; uint32_t prev_le_count; /* Only 1 PV may feature in source_pvl */ - pvl = list_item(source_pvl->n, struct pv_list); + pvl = dm_list_item(source_pvl->n, struct pv_list); prev_le_count = lv_mirr->le_count; if (!insert_layer_for_segments_on_pv(cmd, lv, lv_mirr, PVMOVE, @@ -177,11 +177,11 @@ static int _insert_pvmove_mirrors(struct cmd_context *cmd, /* Create new LV with mirror segments for the required copies */ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd, struct volume_group *vg, - struct list *source_pvl, + struct dm_list *source_pvl, const char *lv_name, - struct list *allocatable_pvs, + struct dm_list *allocatable_pvs, alloc_policy_t alloc, - struct list **lvs_changed) + struct dm_list **lvs_changed) { struct logical_volume *lv_mirr, *lv; struct lv_list *lvl; @@ -203,10 +203,10 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd, return NULL; } - list_init(*lvs_changed); + dm_list_init(*lvs_changed); /* Find segments to be moved and set up mirrors */ - list_iterate_items(lvl, &vg->lvs) { + dm_list_iterate_items(lvl, &vg->lvs) { lv = lvl->lv; if ((lv == lv_mirr)) continue; @@ -276,7 +276,7 @@ static int _activate_lv(struct cmd_context *cmd, struct logical_volume *lv_mirr, static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv_mirr, - struct list *lvs_changed, unsigned flags) + struct dm_list *lvs_changed, unsigned flags) { unsigned exclusive = _pvmove_is_exclusive(cmd, vg); unsigned first_time = (flags & PVMOVE_FIRST_TIME) ? 1 : 0; @@ -347,10 +347,10 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name, const char *lv_name = NULL; char *pv_name_arg; struct volume_group *vg; - struct list *source_pvl; - struct list *allocatable_pvs; + struct dm_list *source_pvl; + struct dm_list *allocatable_pvs; alloc_policy_t alloc; - struct list *lvs_changed; + struct dm_list *lvs_changed; struct physical_volume *pv; struct logical_volume *lv_mirr; unsigned first_time = 1; @@ -474,14 +474,14 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name, static int _finish_pvmove(struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv_mirr, - struct list *lvs_changed) + struct dm_list *lvs_changed) { int r = 1; - struct list lvs_completed; + struct dm_list lvs_completed; struct lv_list *lvl; /* Update metadata to remove mirror segments and break dependencies */ - list_init(&lvs_completed); + dm_list_init(&lvs_completed); if (!lv_remove_mirrors(cmd, lv_mirr, 1, 0, NULL, PVMOVE) || !remove_layers_for_segments_all(cmd, lv_mirr, PVMOVE, &lvs_completed)) { @@ -489,7 +489,7 @@ static int _finish_pvmove(struct cmd_context *cmd, struct volume_group *vg, return 0; } - list_iterate_items(lvl, &lvs_completed) + dm_list_iterate_items(lvl, &lvs_completed) /* FIXME Assumes only one pvmove at a time! */ lvl->lv->status &= ~LOCKED; diff --git a/tools/pvremove.c b/tools/pvremove.c index acf598d6..9912711c 100644 --- a/tools/pvremove.c +++ b/tools/pvremove.c @@ -25,9 +25,9 @@ const char _really_wipe[] = static int pvremove_check(struct cmd_context *cmd, const char *name) { struct physical_volume *pv; - struct list mdas; + struct dm_list mdas; - list_init(&mdas); + dm_list_init(&mdas); /* FIXME Check partition type is LVM unless --force is given */ @@ -47,7 +47,7 @@ static int pvremove_check(struct cmd_context *cmd, const char *name) * means checking every VG by scanning every * PV on the system. */ - if (is_orphan(pv) && !list_size(&mdas)) { + if (is_orphan(pv) && !dm_list_size(&mdas)) { if (!scan_vgs_for_pvs(cmd)) { log_error("Rescan for PVs without metadata areas " "failed."); diff --git a/tools/pvresize.c b/tools/pvresize.c index 4f38ca3d..c9665b2b 100644 --- a/tools/pvresize.c +++ b/tools/pvresize.c @@ -32,13 +32,13 @@ static int _pv_resize_single(struct cmd_context *cmd, int consistent = 1; uint64_t size = 0; uint32_t new_pe_count = 0; - struct list mdas; + struct dm_list mdas; const char *pv_name = pv_dev_name(pv); const char *vg_name; struct lvmcache_info *info; int mda_count = 0; - list_init(&mdas); + dm_list_init(&mdas); if (is_orphan_vg(pv_vg_name(pv))) { vg_name = VG_ORPHANS; @@ -53,7 +53,7 @@ static int _pv_resize_single(struct cmd_context *cmd, return 0; } - mda_count = list_size(&mdas); + mda_count = dm_list_size(&mdas); } else { vg_name = pv_vg_name(pv); @@ -90,7 +90,7 @@ static int _pv_resize_single(struct cmd_context *cmd, return 0; } - mda_count = list_size(&info->mdas); + mda_count = dm_list_size(&info->mdas); if (!archive(vg)) return 0; diff --git a/tools/pvscan.c b/tools/pvscan.c index 519720fc..494af3d9 100644 --- a/tools/pvscan.c +++ b/tools/pvscan.c @@ -103,7 +103,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)), int new_pvs_found = 0; int pvs_found = 0; - struct list *pvslist; + struct dm_list *pvslist; struct pv_list *pvl; struct physical_volume *pv; @@ -139,13 +139,13 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)), } /* eliminate exported/new if required */ - list_iterate_items(pvl, pvslist) { + dm_list_iterate_items(pvl, pvslist) { pv = pvl->pv; if ((arg_count(cmd, exported_ARG) && !(pv_status(pv) & EXPORTED_VG)) || (arg_count(cmd, novolumegroup_ARG) && (!is_orphan(pv)))) { - list_del(&pvl->list); + dm_list_del(&pvl->list); continue; } @@ -171,7 +171,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)), /* find maximum pv name length */ pv_max_name_len = vg_max_name_len = 0; - list_iterate_items(pvl, pvslist) { + dm_list_iterate_items(pvl, pvslist) { pv = pvl->pv; len = strlen(pv_dev_name(pv)); if (pv_max_name_len < len) @@ -183,7 +183,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)), pv_max_name_len += 2; vg_max_name_len += 2; - list_iterate_items(pvl, pvslist) + dm_list_iterate_items(pvl, pvslist) _pvscan_display_single(cmd, pvl->pv, NULL); if (!pvs_found) { diff --git a/tools/reporter.c b/tools/reporter.c index 5c35a0cb..e95ed5e8 100644 --- a/tools/reporter.c +++ b/tools/reporter.c @@ -88,9 +88,9 @@ static int _pvsegs_sub_single(struct cmd_context *cmd __attribute((unused)), _free_lv_segment.segtype = get_segtype_from_string(cmd, "free"); _free_lv_segment.len = pvseg->len; - list_init(&_free_logical_volume.tags); - list_init(&_free_logical_volume.segments); - list_init(&_free_logical_volume.segs_using_this_lv); + dm_list_init(&_free_logical_volume.tags); + dm_list_init(&_free_logical_volume.segments); + dm_list_init(&_free_logical_volume.segs_using_this_lv); if (!report_object(handle, vg, seg ? seg->lv : &_free_logical_volume, pvseg->pv, seg ? : &_free_lv_segment, pvseg)) diff --git a/tools/toollib.c b/tools/toollib.c index 4d11b9be..ef4ee0e8 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -140,8 +140,8 @@ char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name, */ int process_each_lv_in_vg(struct cmd_context *cmd, const struct volume_group *vg, - const struct list *arg_lvnames, - const struct list *tags, + const struct dm_list *arg_lvnames, + const struct dm_list *tags, void *handle, process_single_lv_fn_t process_single) { @@ -158,10 +158,10 @@ int process_each_lv_in_vg(struct cmd_context *cmd, if (!vg_check_status(vg, EXPORTED_VG)) return ECMD_FAILED; - if (tags && !list_empty(tags)) + if (tags && !dm_list_empty(tags)) tags_supplied = 1; - if (arg_lvnames && !list_empty(arg_lvnames)) + if (arg_lvnames && !dm_list_empty(arg_lvnames)) lvargs_supplied = 1; /* Process all LVs in this VG if no restrictions given */ @@ -174,7 +174,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, process_all = 1; } - list_iterate_items(lvl, &vg->lvs) { + dm_list_iterate_items(lvl, &vg->lvs) { if (lvl->lv->status & SNAPSHOT) continue; @@ -207,7 +207,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, return ret_max; } - if (lvargs_supplied && lvargs_matched != list_size(arg_lvnames)) { + if (lvargs_supplied && lvargs_matched != dm_list_size(arg_lvnames)) { log_error("One or more specified logical volume(s) not found."); if (ret_max < ECMD_FAILED) ret_max = ECMD_FAILED; @@ -227,25 +227,25 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, int ret = 0; int consistent; - struct list *tags_arg; - struct list *vgnames; /* VGs to process */ + struct dm_list *tags_arg; + struct dm_list *vgnames; /* VGs to process */ struct str_list *sll, *strl; struct volume_group *vg; - struct list tags, lvnames; - struct list arg_lvnames; /* Cmdline vgname or vgname/lvname */ + struct dm_list tags, lvnames; + struct dm_list arg_lvnames; /* Cmdline vgname or vgname/lvname */ char *vglv; size_t vglv_sz; const char *vgname; - list_init(&tags); - list_init(&arg_lvnames); + dm_list_init(&tags); + dm_list_init(&arg_lvnames); if (argc) { - struct list arg_vgnames; + struct dm_list arg_vgnames; log_verbose("Using logical volume(s) on command line"); - list_init(&arg_vgnames); + dm_list_init(&arg_vgnames); for (; opt < argc; opt++) { const char *lv_name = argv[opt]; @@ -327,15 +327,15 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, vgnames = &arg_vgnames; } - if (!argc || !list_empty(&tags)) { + if (!argc || !dm_list_empty(&tags)) { log_verbose("Finding all logical volumes"); - if (!(vgnames = get_vgs(cmd, 0)) || list_empty(vgnames)) { + if (!(vgnames = get_vgs(cmd, 0)) || dm_list_empty(vgnames)) { log_error("No volume groups found"); return ret_max; } } - list_iterate_items(strl, vgnames) { + dm_list_iterate_items(strl, vgnames) { vgname = strl->str; if (is_orphan_vg(vgname)) continue; /* FIXME Unnecessary? */ @@ -377,15 +377,15 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, } tags_arg = &tags; - list_init(&lvnames); /* LVs to be processed in this VG */ - list_iterate_items(sll, &arg_lvnames) { + dm_list_init(&lvnames); /* LVs to be processed in this VG */ + dm_list_iterate_items(sll, &arg_lvnames) { const char *vg_name = sll->str; const char *lv_name = strchr(vg_name, '/'); if ((!lv_name && !strcmp(vg_name, vgname))) { /* Process all LVs in this VG */ tags_arg = NULL; - list_init(&lvnames); + dm_list_init(&lvnames); break; } else if (!strncmp(vg_name, vgname, strlen(vgname)) && strlen(vgname) == (size_t) (lv_name - vg_name)) { @@ -434,7 +434,7 @@ int process_each_segment_in_pv(struct cmd_context *cmd, } } - list_iterate_items(pvseg, &pv->segments) { + dm_list_iterate_items(pvseg, &pv->segments) { ret = process_single(cmd, vg, pvseg, handle); if (ret > ret_max) ret_max = ret; @@ -459,7 +459,7 @@ int process_each_segment_in_lv(struct cmd_context *cmd, int ret_max = ECMD_PROCESSED; int ret; - list_iterate_items(seg, &lv->segments) { + dm_list_iterate_items(seg, &lv->segments) { ret = process_single(cmd, seg, handle); if (ret > ret_max) ret_max = ret; @@ -472,7 +472,7 @@ int process_each_segment_in_lv(struct cmd_context *cmd, static int _process_one_vg(struct cmd_context *cmd, const char *vg_name, const char *vgid, - struct list *tags, struct list *arg_vgnames, + struct dm_list *tags, struct dm_list *arg_vgnames, uint32_t lock_type, int consistent, void *handle, int ret_max, int (*process_single) (struct cmd_context * cmd, @@ -500,7 +500,7 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name, return ECMD_FAILED; } - if (!list_empty(tags)) { + if (!dm_list_empty(tags)) { /* Only process if a tag matches or it's on arg_vgnames */ if (!str_list_match_item(arg_vgnames, vg_name) && !str_list_match_list(tags, &vg->tags)) { @@ -530,13 +530,13 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, int ret_max = ECMD_PROCESSED; struct str_list *sl; - struct list *vgnames, *vgids; - struct list arg_vgnames, tags; + struct dm_list *vgnames, *vgids; + struct dm_list arg_vgnames, tags; const char *vg_name, *vgid; - list_init(&tags); - list_init(&arg_vgnames); + dm_list_init(&tags); + dm_list_init(&arg_vgnames); if (argc) { log_verbose("Using volume group(s) on command line"); @@ -574,13 +574,13 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, vgnames = &arg_vgnames; } - if (!argc || !list_empty(&tags)) { + if (!argc || !dm_list_empty(&tags)) { log_verbose("Finding all volume groups"); - if (!(vgids = get_vgids(cmd, 0)) || list_empty(vgids)) { + if (!(vgids = get_vgids(cmd, 0)) || dm_list_empty(vgids)) { log_error("No volume groups found"); return ret_max; } - list_iterate_items(sl, vgids) { + dm_list_iterate_items(sl, vgids) { vgid = sl->str; if (!vgid || !(vg_name = vgname_from_vgid(cmd->mem, vgid)) || is_orphan_vg(vg_name)) @@ -593,7 +593,7 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, return ret_max; } } else { - list_iterate_items(sl, vgnames) { + dm_list_iterate_items(sl, vgnames) { vg_name = sl->str; if (is_orphan_vg(vg_name)) continue; /* FIXME Unnecessary? */ @@ -610,15 +610,15 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, } int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg, - const struct list *tags, void *handle, + const struct dm_list *tags, void *handle, process_single_pv_fn_t process_single) { int ret_max = ECMD_PROCESSED; int ret = 0; struct pv_list *pvl; - list_iterate_items(pvl, &vg->pvs) { - if (tags && !list_empty(tags) && + dm_list_iterate_items(pvl, &vg->pvs) { + if (tags && !dm_list_empty(tags) && !str_list_match_list(tags, &pvl->pv->tags)) { continue; } @@ -658,8 +658,8 @@ static int _process_all_devs(struct cmd_context *cmd, void *handle, while ((dev = dev_iter_get(iter))) { if (!(pv = pv_read(cmd, dev_name(dev), NULL, NULL, 0))) { memset(&pv_dummy, 0, sizeof(pv_dummy)); - list_init(&pv_dummy.tags); - list_init(&pv_dummy.segments); + dm_list_init(&pv_dummy.tags); + dm_list_init(&pv_dummy.segments); pv_dummy.dev = dev; pv_dummy.fmt = NULL; pv = &pv_dummy; @@ -689,14 +689,14 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv, struct pv_list *pvl; struct physical_volume *pv; - struct list *pvslist, *vgnames; - struct list tags; + struct dm_list *pvslist, *vgnames; + struct dm_list tags; struct str_list *sll; char *tagname; int consistent = 1; int scanned = 0; - list_init(&tags); + dm_list_init(&tags); if (argc) { log_verbose("Using physical volume(s) on command line"); @@ -769,9 +769,9 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv, if (sigint_caught()) return ret_max; } - if (!list_empty(&tags) && (vgnames = get_vgs(cmd, 0)) && - !list_empty(vgnames)) { - list_iterate_items(sll, vgnames) { + if (!dm_list_empty(&tags) && (vgnames = get_vgs(cmd, 0)) && + !dm_list_empty(vgnames)) { + dm_list_iterate_items(sll, vgnames) { if (!lock_vol(cmd, sll->str, lock_type)) { log_error("Can't lock %s: skipping", sll->str); continue; @@ -825,7 +825,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv, if (!(pvslist = get_pvs(cmd))) return ECMD_FAILED; - list_iterate_items(pvl, pvslist) { + dm_list_iterate_items(pvl, pvslist) { ret = process_single(cmd, NULL, pvl->pv, handle); if (ret > ret_max) @@ -927,7 +927,7 @@ char *default_vgname(struct cmd_context *cmd) * Process physical extent range specifiers */ static int _add_pe_range(struct dm_pool *mem, const char *pvname, - struct list *pe_ranges, uint32_t start, uint32_t count) + struct dm_list *pe_ranges, uint32_t start, uint32_t count) { struct pe_range *per; @@ -935,7 +935,7 @@ static int _add_pe_range(struct dm_pool *mem, const char *pvname, " on %s", start, count, pvname); /* Ensure no overlap with existing areas */ - list_iterate_items(per, pe_ranges) { + dm_list_iterate_items(per, pe_ranges) { if (((start < per->start) && (start + count - 1 >= per->start)) || ((start >= per->start) && (per->start + per->count - 1) >= start)) { @@ -955,7 +955,7 @@ static int _add_pe_range(struct dm_pool *mem, const char *pvname, per->start = start; per->count = count; - list_add(pe_ranges, &per->list); + dm_list_add(pe_ranges, &per->list); return 1; } @@ -972,7 +972,7 @@ static int xstrtouint32(const char *s, char **p, int base, uint32_t *result) return 0; } -static int _parse_pes(struct dm_pool *mem, char *c, struct list *pe_ranges, +static int _parse_pes(struct dm_pool *mem, char *c, struct dm_list *pe_ranges, const char *pvname, uint32_t size) { char *endptr; @@ -1039,11 +1039,11 @@ static int _parse_pes(struct dm_pool *mem, char *c, struct list *pe_ranges, } static int _create_pv_entry(struct dm_pool *mem, struct pv_list *pvl, - char *colon, int allocatable_only, struct list *r) + char *colon, int allocatable_only, struct dm_list *r) { const char *pvname; struct pv_list *new_pvl = NULL, *pvl2; - struct list *pe_ranges; + struct dm_list *pe_ranges; pvname = pv_dev_name(pvl->pv); if (allocatable_only && !(pvl->pv->status & ALLOCATABLE_PV)) { @@ -1057,7 +1057,7 @@ static int _create_pv_entry(struct dm_pool *mem, struct pv_list *pvl, return 1; } - list_iterate_items(pvl2, r) + dm_list_iterate_items(pvl2, r) if (pvl->pv->dev == pvl2->pv->dev) { new_pvl = pvl2; break; @@ -1075,9 +1075,9 @@ static int _create_pv_entry(struct dm_pool *mem, struct pv_list *pvl, log_error("Allocation of pe_ranges list failed"); return 0; } - list_init(pe_ranges); + dm_list_init(pe_ranges); new_pvl->pe_ranges = pe_ranges; - list_add(r, &new_pvl->list); + dm_list_add(r, &new_pvl->list); } /* Determine selected physical extents */ @@ -1088,12 +1088,12 @@ static int _create_pv_entry(struct dm_pool *mem, struct pv_list *pvl, return 1; } -struct list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc, +struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc, char **argv, int allocatable_only) { - struct list *r; + struct dm_list *r; struct pv_list *pvl; - struct list tags, arg_pvnames; + struct dm_list tags, arg_pvnames; const char *pvname = NULL; char *colon, *tagname; int i; @@ -1103,10 +1103,10 @@ struct list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int ar log_error("Allocation of list failed"); return NULL; } - list_init(r); + dm_list_init(r); - list_init(&tags); - list_init(&arg_pvnames); + dm_list_init(&tags); + dm_list_init(&arg_pvnames); for (i = 0; i < argc; i++) { if (*argv[i] == '@') { @@ -1115,7 +1115,7 @@ struct list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int ar log_error("Skipping invalid tag %s", tagname); continue; } - list_iterate_items(pvl, &vg->pvs) { + dm_list_iterate_items(pvl, &vg->pvs) { if (str_list_match_item(&pvl->pv->tags, tagname)) { if (!_create_pv_entry(mem, pvl, NULL, @@ -1147,15 +1147,15 @@ struct list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int ar return_NULL; } - if (list_empty(r)) + if (dm_list_empty(r)) log_error("No specified PVs have space available"); - return list_empty(r) ? NULL : r; + return dm_list_empty(r) ? NULL : r; } -struct list *clone_pv_list(struct dm_pool *mem, struct list *pvsl) +struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvsl) { - struct list *r; + struct dm_list *r; struct pv_list *pvl, *new_pvl; /* Build up list of PVs */ @@ -1163,16 +1163,16 @@ struct list *clone_pv_list(struct dm_pool *mem, struct list *pvsl) log_error("Allocation of list failed"); return NULL; } - list_init(r); + dm_list_init(r); - list_iterate_items(pvl, pvsl) { + dm_list_iterate_items(pvl, pvsl) { if (!(new_pvl = dm_pool_zalloc(mem, sizeof(*new_pvl)))) { log_error("Unable to allocate physical volume list."); return NULL; } memcpy(new_pvl, pvl, sizeof(*new_pvl)); - list_add(r, &new_pvl->list); + dm_list_add(r, &new_pvl->list); } return r; diff --git a/tools/toollib.h b/tools/toollib.h index ef2b9db7..f002d603 100644 --- a/tools/toollib.h +++ b/tools/toollib.h @@ -66,7 +66,7 @@ typedef int (*process_single_pv_fn_t) (struct cmd_context *cmd, void *handle); int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg, - const struct list *tags, void *handle, + const struct dm_list *tags, void *handle, process_single_pv_fn_t process_single); typedef int (*process_single_lv_fn_t) (struct cmd_context *cmd, @@ -75,8 +75,8 @@ typedef int (*process_single_lv_fn_t) (struct cmd_context *cmd, int process_each_lv_in_vg(struct cmd_context *cmd, const struct volume_group *vg, - const struct list *arg_lvnames, - const struct list *tags, + const struct dm_list *arg_lvnames, + const struct dm_list *tags, void *handle, process_single_lv_fn_t process_single); @@ -89,10 +89,10 @@ char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name, * Builds a list of pv's from the names in argv. Used in * lvcreate/extend. */ -struct list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc, +struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc, char **argv, int allocatable_only); -struct list *clone_pv_list(struct dm_pool *mem, struct list *pvs); +struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvs); int apply_lvname_restrictions(const char *name); int is_reserved_lvname(const char *name); diff --git a/tools/vgchange.c b/tools/vgchange.c index 17cd0c8f..f2df8364 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -24,7 +24,7 @@ static int _monitor_lvs_in_vg(struct cmd_context *cmd, int lv_active; int count = 0; - list_iterate_items(lvl, &vg->lvs) { + dm_list_iterate_items(lvl, &vg->lvs) { lv = lvl->lv; if (!lv_info(cmd, lv, &info, 0, 0)) @@ -59,7 +59,7 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, const char *pvname; int count = 0; - list_iterate_items(lvl, &vg->lvs) { + dm_list_iterate_items(lvl, &vg->lvs) { lv = lvl->lv; /* Only request activation of snapshot origin devices */ @@ -260,7 +260,7 @@ static int _vgchange_clustered(struct cmd_context *cmd, } if (clustered) { - list_iterate_items(lvl, &vg->lvs) { + dm_list_iterate_items(lvl, &vg->lvs) { if (lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) { log_error("Volume group %s contains snapshots " "that are not yet supported.", @@ -496,7 +496,7 @@ static int _vgchange_uuid(struct cmd_context *cmd __attribute((unused)), return ECMD_FAILED; } - list_iterate_items(lvl, &vg->lvs) { + dm_list_iterate_items(lvl, &vg->lvs) { memcpy(&lvl->lv->lvid, &vg->id, sizeof(vg->id)); } diff --git a/tools/vgconvert.c b/tools/vgconvert.c index 9cc5406c..dc9d0237 100644 --- a/tools/vgconvert.c +++ b/tools/vgconvert.c @@ -23,7 +23,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name, struct logical_volume *lv; struct lv_list *lvl; uint64_t size = 0; - struct list mdas; + struct dm_list mdas; int pvmetadatacopies = 0; uint64_t pvmetadatasize = 0; uint64_t pe_end = 0, pe_start = 0; @@ -93,7 +93,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name, /* If converting to restricted lvid, check if lvid is compatible */ if (!(vg->fid->fmt->features & FMT_RESTRICTED_LVIDS) && cmd->fmt->features & FMT_RESTRICTED_LVIDS) - list_iterate_items(lvl, &vg->lvs) + dm_list_iterate_items(lvl, &vg->lvs) if (!lvid_in_restricted_range(&lvl->lv->lvid)) { log_error("Logical volume %s lvid format is" " incompatible with requested" @@ -103,7 +103,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name, /* Attempt to change any LVIDs that are too big */ if (cmd->fmt->features & FMT_RESTRICTED_LVIDS) { - list_iterate_items(lvl, &vg->lvs) { + dm_list_iterate_items(lvl, &vg->lvs) { lv = lvl->lv; if (lv->status & SNAPSHOT) continue; @@ -124,14 +124,14 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name, if (active) return ECMD_FAILED; - list_iterate_items(pvl, &vg->pvs) { + dm_list_iterate_items(pvl, &vg->pvs) { existing_pv = pvl->pv; pe_start = pv_pe_start(existing_pv); pe_end = pv_pe_count(existing_pv) * pv_pe_size(existing_pv) + pe_start - 1; - list_init(&mdas); + dm_list_init(&mdas); if (!(pv = pv_create(cmd, pv_dev(existing_pv), &existing_pv->id, size, pe_start, pv_pe_count(existing_pv), diff --git a/tools/vgexport.c b/tools/vgexport.c index a2aee936..9b0734c7 100644 --- a/tools/vgexport.c +++ b/tools/vgexport.c @@ -48,7 +48,7 @@ static int vgexport_single(struct cmd_context *cmd __attribute((unused)), vg->status |= EXPORTED_VG; - list_iterate_items(pvl, &vg->pvs) { + dm_list_iterate_items(pvl, &vg->pvs) { pv = pvl->pv; pv->status |= EXPORTED_VG; } diff --git a/tools/vgimport.c b/tools/vgimport.c index 8896c008..25ab0359 100644 --- a/tools/vgimport.c +++ b/tools/vgimport.c @@ -44,7 +44,7 @@ static int vgimport_single(struct cmd_context *cmd __attribute((unused)), vg->status &= ~EXPORTED_VG; - list_iterate_items(pvl, &vg->pvs) { + dm_list_iterate_items(pvl, &vg->pvs) { pv = pvl->pv; pv->status &= ~EXPORTED_VG; } diff --git a/tools/vgmerge.c b/tools/vgmerge.c index 064389d4..c48fe0b6 100644 --- a/tools/vgmerge.c +++ b/tools/vgmerge.c @@ -52,23 +52,23 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, drop_cached_metadata(vg_from); /* Merge volume groups */ - while (!list_empty(&vg_from->pvs)) { - struct list *pvh = vg_from->pvs.n; + while (!dm_list_empty(&vg_from->pvs)) { + struct dm_list *pvh = vg_from->pvs.n; struct physical_volume *pv; - list_move(&vg_to->pvs, pvh); + dm_list_move(&vg_to->pvs, pvh); - pv = list_item(pvh, struct pv_list)->pv; + pv = dm_list_item(pvh, struct pv_list)->pv; pv->vg_name = dm_pool_strdup(cmd->mem, vg_to->name); } vg_to->pv_count += vg_from->pv_count; /* Fix up LVIDs */ - list_iterate_items(lvl1, &vg_to->lvs) { + dm_list_iterate_items(lvl1, &vg_to->lvs) { union lvid *lvid1 = &lvl1->lv->lvid; char uuid[64] __attribute((aligned(8))); - list_iterate_items(lvl2, &vg_from->lvs) { + dm_list_iterate_items(lvl2, &vg_from->lvs) { union lvid *lvid2 = &lvl2->lv->lvid; if (id_equal(&lvid1->id[1], &lvid2->id[1])) { @@ -88,16 +88,16 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, } } - while (!list_empty(&vg_from->lvs)) { - struct list *lvh = vg_from->lvs.n; + while (!dm_list_empty(&vg_from->lvs)) { + struct dm_list *lvh = vg_from->lvs.n; - list_move(&vg_to->lvs, lvh); + dm_list_move(&vg_to->lvs, lvh); } - while (!list_empty(&vg_from->fid->metadata_areas)) { - struct list *mdah = vg_from->fid->metadata_areas.n; + while (!dm_list_empty(&vg_from->fid->metadata_areas)) { + struct dm_list *mdah = vg_from->fid->metadata_areas.n; - list_move(&vg_to->fid->metadata_areas, mdah); + dm_list_move(&vg_to->fid->metadata_areas, mdah); } vg_to->lv_count += vg_from->lv_count; diff --git a/tools/vgreduce.c b/tools/vgreduce.c index 2842a0d7..9449b60d 100644 --- a/tools/vgreduce.c +++ b/tools/vgreduce.c @@ -41,16 +41,16 @@ static int _remove_pv(struct volume_group *vg, struct pv_list *pvl, int silent) vg->extent_count -= pvl->pv->pe_count; vg->pv_count--; - list_del(&pvl->list); + dm_list_del(&pvl->list); return 1; } static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv, - int *list_unsafe, struct list *lvs_changed) + int *list_unsafe, struct dm_list *lvs_changed) { struct lv_segment *snap_seg; - struct list *snh, *snht; + struct dm_list *snh, *snht; struct logical_volume *cow; struct lv_list *lvl; struct lvinfo info; @@ -77,8 +77,8 @@ static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv, } /* Remove snapshot dependencies */ - list_iterate_safe(snh, snht, &lv->snapshot_segs) { - snap_seg = list_struct_base(snh, struct lv_segment, + dm_list_iterate_safe(snh, snht, &lv->snapshot_segs) { + snap_seg = dm_list_struct_base(snh, struct lv_segment, origin_list); cow = snap_seg->cow; @@ -120,7 +120,7 @@ static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv, return 0; } lvl->lv = lv; - list_add(lvs_changed, &lvl->list); + dm_list_add(lvs_changed, &lvl->list); } else { /* Remove LV immediately. */ log_verbose("Removing LV %s from VG %s", lv->name, lv->vg->name); @@ -137,7 +137,7 @@ static int _consolidate_vg(struct cmd_context *cmd, struct volume_group *vg) struct lv_list *lvl; int r = 1; - list_iterate_items(lvl, &vg->lvs) + dm_list_iterate_items(lvl, &vg->lvs) if (lvl->lv->status & PARTIAL_LV) { log_warn("WARNING: Partial LV %s needs to be repaired " "or removed. ", lvl->lv->name); @@ -151,7 +151,7 @@ static int _consolidate_vg(struct cmd_context *cmd, struct volume_group *vg) log_warn("Proceeding to remove empty missing PVs."); } - list_iterate_items(pvl, &vg->pvs) { + dm_list_iterate_items(pvl, &vg->pvs) { if (pvl->pv->dev && !(pvl->pv->status & MISSING_PV)) continue; if (r && !_remove_pv(vg, pvl, 0)) @@ -163,8 +163,8 @@ static int _consolidate_vg(struct cmd_context *cmd, struct volume_group *vg) static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg) { - struct list *pvh, *pvht; - struct list *lvh, *lvht; + struct dm_list *pvh, *pvht; + struct dm_list *lvh, *lvht; struct pv_list *pvl; struct lv_list *lvl, *lvl2, *lvlt; struct logical_volume *lv; @@ -173,18 +173,18 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg) unsigned s; uint32_t mimages, remove_log; int list_unsafe, only_mirror_images_found; - LIST_INIT(lvs_changed); + DM_LIST_INIT(lvs_changed); only_mirror_images_found = 1; /* Deactivate & remove necessary LVs */ restart_loop: list_unsafe = 0; /* Set if we delete a different list-member */ - list_iterate_safe(lvh, lvht, &vg->lvs) { - lv = list_item(lvh, struct lv_list)->lv; + dm_list_iterate_safe(lvh, lvht, &vg->lvs) { + lv = dm_list_item(lvh, struct lv_list)->lv; /* Are any segments of this LV on missing PVs? */ - list_iterate_items(seg, &lv->segments) { + dm_list_iterate_items(seg, &lv->segments) { for (s = 0; s < seg->area_count; s++) { if (seg_type(seg, s) != AREA_PV) continue; @@ -222,8 +222,8 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg) * up *after* the PVs are removed. All this should be gradually * superseded by lvconvert --repair. */ - list_iterate_safe(pvh, pvht, &vg->pvs) { - pvl = list_item(pvh, struct pv_list); + dm_list_iterate_safe(pvh, pvht, &vg->pvs) { + pvl = dm_list_item(pvh, struct pv_list); if (pvl->pv->dev) continue; if (!_remove_pv(vg, pvl, 0)) @@ -232,7 +232,7 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg) /* FIXME Recovery. For now people must clean up by hand. */ - if (!list_empty(&lvs_changed)) { + if (!dm_list_empty(&lvs_changed)) { if (!vg_write(vg)) { log_error("Failed to write out a consistent VG for %s", vg->name); @@ -264,7 +264,7 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg) lvs_changed_altered: /* Remove lost mirror images from mirrors */ - list_iterate_items(lvl, &vg->lvs) { + dm_list_iterate_items(lvl, &vg->lvs) { mirrored_seg_altered: mirrored_seg = first_seg(lvl->lv); if (!seg_is_mirrored(mirrored_seg)) @@ -274,11 +274,11 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg) remove_log = 0; for (s = 0; s < mirrored_seg->area_count; s++) { - list_iterate_items_safe(lvl2, lvlt, &lvs_changed) { + dm_list_iterate_items_safe(lvl2, lvlt, &lvs_changed) { if (seg_type(mirrored_seg, s) != AREA_LV || lvl2->lv != seg_lv(mirrored_seg, s)) continue; - list_del(&lvl2->list); + dm_list_del(&lvl2->list); if (!shift_mirror_images(mirrored_seg, s)) return_0; mimages--; /* FIXME Assumes uniqueness */ @@ -286,7 +286,7 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg) } if (mirrored_seg->log_lv) { - list_iterate_items(seg, &mirrored_seg->log_lv->segments) { + dm_list_iterate_items(seg, &mirrored_seg->log_lv->segments) { /* FIXME: The second test shouldn't be required */ if ((seg->segtype == get_segtype_from_string(vg->cmd, "error"))) { @@ -343,7 +343,7 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg) /* Deactivate error LVs */ if (!test_mode()) { - list_iterate_items_safe(lvl, lvlt, &lvs_changed) { + dm_list_iterate_items_safe(lvl, lvlt, &lvs_changed) { log_verbose("Deactivating (if active) logical volume %s", lvl->lv->name); @@ -356,13 +356,13 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg) * Don't try to lv_remove it. * Continue work on others. */ - list_del(&lvl->list); + dm_list_del(&lvl->list); } } } /* Remove remaining LVs */ - list_iterate_items(lvl, &lvs_changed) { + dm_list_iterate_items(lvl, &lvs_changed) { log_verbose("Removing LV %s from VG %s", lvl->lv->name, lvl->lv->vg->name); /* Skip LVs already removed by mirror code */ @@ -411,7 +411,7 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg, log_verbose("Removing \"%s\" from volume group \"%s\"", name, vg->name); if (pvl) - list_del(&pvl->list); + dm_list_del(&pvl->list); pv->vg_name = vg->fid->fmt->orphan_vg_name; pv->status = ALLOCATABLE_PV; diff --git a/tools/vgrename.c b/tools/vgrename.c index 4cbbff1e..0d880f3d 100644 --- a/tools/vgrename.c +++ b/tools/vgrename.c @@ -23,7 +23,7 @@ static int vg_rename_path(struct cmd_context *cmd, const char *old_vg_path, int consistent = 1; int match = 0; int found_id = 0; - struct list *vgids; + struct dm_list *vgids; struct str_list *sl; char *vg_name_new; const char *vgid = NULL, *vg_name, *vg_name_old; @@ -41,12 +41,12 @@ static int vg_rename_path(struct cmd_context *cmd, const char *old_vg_path, log_verbose("Checking for existing volume group \"%s\"", vg_name_old); /* Avoid duplicates */ - if (!(vgids = get_vgids(cmd, 0)) || list_empty(vgids)) { + if (!(vgids = get_vgids(cmd, 0)) || dm_list_empty(vgids)) { log_error("No complete volume groups found"); return 0; } - list_iterate_items(sl, vgids) { + dm_list_iterate_items(sl, vgids) { vgid = sl->str; if (!vgid || !(vg_name = vgname_from_vgid(NULL, vgid)) || is_orphan_vg(vg_name)) diff --git a/tools/vgsplit.c b/tools/vgsplit.c index 50999281..d360a4f4 100644 --- a/tools/vgsplit.c +++ b/tools/vgsplit.c @@ -28,7 +28,7 @@ static int _move_pv(struct volume_group *vg_from, struct volume_group *vg_to, return 0; } - list_move(&vg_to->pvs, &pvl->list); + dm_list_move(&vg_to->pvs, &pvl->list); vg_from->pv_count--; vg_to->pv_count++; @@ -60,7 +60,7 @@ static int _move_pvs_used_by_lv(struct volume_group *vg_from, return 0; } - list_iterate_items(lvseg, &lvl->lv->segments) { + dm_list_iterate_items(lvseg, &lvl->lv->segments) { if (lvseg->log_lv) if (!_move_pvs_used_by_lv(vg_from, vg_to, lvseg->log_lv->name)) @@ -86,7 +86,7 @@ static int _lv_is_in_vg(struct volume_group *vg, struct logical_volume *lv) { struct lv_list *lvl; - list_iterate_items(lvl, &vg->lvs) + dm_list_iterate_items(lvl, &vg->lvs) if (lv == lvl->lv) return 1; @@ -95,11 +95,11 @@ static int _lv_is_in_vg(struct volume_group *vg, struct logical_volume *lv) static int _move_one_lv(struct volume_group *vg_from, struct volume_group *vg_to, - struct list *lvh) + struct dm_list *lvh) { - struct logical_volume *lv = list_item(lvh, struct lv_list)->lv; + struct logical_volume *lv = dm_list_item(lvh, struct lv_list)->lv; - list_move(&vg_to->lvs, lvh); + dm_list_move(&vg_to->lvs, lvh); if (lv_is_active(lv)) { log_error("Logical volume \"%s\" must be inactive", lv->name); @@ -118,15 +118,15 @@ static int _move_one_lv(struct volume_group *vg_from, static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to) { - struct list *lvh, *lvht; + struct dm_list *lvh, *lvht; struct logical_volume *lv; struct lv_segment *seg; struct physical_volume *pv; struct volume_group *vg_with; unsigned s; - list_iterate_safe(lvh, lvht, &vg_from->lvs) { - lv = list_item(lvh, struct lv_list)->lv; + dm_list_iterate_safe(lvh, lvht, &vg_from->lvs) { + lv = dm_list_item(lvh, struct lv_list)->lv; if ((lv->status & SNAPSHOT)) continue; @@ -137,7 +137,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_items(seg, &lv->segments) { + dm_list_iterate_items(seg, &lv->segments) { for (s = 0; s < seg->area_count; s++) { /* FIXME Check AREA_LV too */ if (seg_type(seg, s) != AREA_PV) @@ -189,19 +189,19 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to) static int _move_snapshots(struct volume_group *vg_from, struct volume_group *vg_to) { - struct list *lvh, *lvht; + struct dm_list *lvh, *lvht; struct logical_volume *lv; struct lv_segment *seg; int cow_from = 0; int origin_from = 0; - list_iterate_safe(lvh, lvht, &vg_from->lvs) { - lv = list_item(lvh, struct lv_list)->lv; + dm_list_iterate_safe(lvh, lvht, &vg_from->lvs) { + lv = dm_list_item(lvh, struct lv_list)->lv; if (!(lv->status & SNAPSHOT)) continue; - list_iterate_items(seg, &lv->segments) { + dm_list_iterate_items(seg, &lv->segments) { cow_from = _lv_is_in_vg(vg_from, seg->cow); origin_from = _lv_is_in_vg(vg_from, seg->origin); @@ -233,13 +233,13 @@ static int _move_snapshots(struct volume_group *vg_from, static int _move_mirrors(struct volume_group *vg_from, struct volume_group *vg_to) { - struct list *lvh, *lvht; + struct dm_list *lvh, *lvht; struct logical_volume *lv; struct lv_segment *seg; unsigned s, seg_in, log_in; - list_iterate_safe(lvh, lvht, &vg_from->lvs) { - lv = list_item(lvh, struct lv_list)->lv; + dm_list_iterate_safe(lvh, lvht, &vg_from->lvs) { + lv = dm_list_item(lvh, struct lv_list)->lv; if (!(lv->status & MIRRORED)) continue; -- cgit