diff options
author | Alasdair G Kergon <agk@redhat.com> | 2014-09-15 21:33:53 +0100 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2014-09-15 21:33:53 +0100 |
commit | 2360ce3551f2989f1cc2af06c3d3a0a0f1429bce (patch) | |
tree | a151ec9c456d6cbcd629ea7bae73bf43bade492f /tools | |
parent | 10a448eb2fdc795d144f13ba4a7d83351eb8c9df (diff) | |
download | lvm2-2360ce3551f2989f1cc2af06c3d3a0a0f1429bce.tar.gz |
cleanup: Use lv_is_ macros.
Use lv_is_* macros throughout the code base, introducing
lv_is_pvmove, lv_is_locked, lv_is_converting and lv_is_merging.
lv_is_mirror_type no longer includes pvmove.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lvchange.c | 20 | ||||
-rw-r--r-- | tools/lvconvert.c | 40 | ||||
-rw-r--r-- | tools/lvrename.c | 4 | ||||
-rw-r--r-- | tools/pvmove.c | 15 | ||||
-rw-r--r-- | tools/toollib.c | 10 | ||||
-rw-r--r-- | tools/vgchange.c | 6 | ||||
-rw-r--r-- | tools/vgreduce.c | 4 | ||||
-rw-r--r-- | tools/vgsplit.c | 4 |
8 files changed, 51 insertions, 52 deletions
diff --git a/tools/lvchange.c b/tools/lvchange.c index bbb030ff0..c3d0b6a08 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -41,7 +41,7 @@ static int lvchange_permission(struct cmd_context *cmd, return 0; } - if ((lv->status & MIRRORED) && (vg_is_clustered(lv->vg)) && + if (lv_is_mirrored(lv) && vg_is_clustered(lv->vg) && lv_info(cmd, lv, 0, &info, 0, 0) && info.exists) { log_error("Cannot change permissions of mirror \"%s\" " "while active.", lv->name); @@ -49,9 +49,9 @@ static int lvchange_permission(struct cmd_context *cmd, } /* Not allowed to change permissions on RAID sub-LVs directly */ - if ((lv->status & RAID_META) || (lv->status & RAID_IMAGE)) { + if (lv_is_raid_metadata(lv) || lv_is_raid_image(lv)) { log_error("Cannot change permissions of RAID %s \"%s\"", - (lv->status & RAID_IMAGE) ? "image" : + lv_is_raid_image(lv) ? "image" : "metadata area", lv->name); return 0; } @@ -137,7 +137,7 @@ static int lvchange_monitoring(struct cmd_context *cmd, } /* do not monitor pvmove lv's */ - if (lv->status & PVMOVE) + if (lv_is_pvmove(lv)) return 1; if ((dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) && @@ -287,18 +287,18 @@ static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv) dm_list_init(&device_list); - if (!(lv->status & MIRRORED) && !seg_is_raid(seg)) { + if (lv_is_mirrored(lv) && !seg_is_raid(seg)) { log_error("Unable to resync %s. It is not RAID or mirrored.", lv->name); return 0; } - if (lv->status & PVMOVE) { + if (lv_is_pvmove(lv)) { log_error("Unable to resync pvmove volume %s", lv->name); return 0; } - if (lv->status & LOCKED) { + if (lv_is_locked(lv)) { log_error("Unable to resync locked volume %s", lv->name); return 0; } @@ -859,19 +859,19 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv, return ECMD_FAILED; } - if (lv->status & PVMOVE) { + if (lv_is_pvmove(lv)) { log_error("Unable to change pvmove LV %s", lv->name); if (arg_count(cmd, activate_ARG)) log_error("Use 'pvmove --abort' to abandon a pvmove"); return ECMD_FAILED; } - if (lv->status & MIRROR_LOG) { + if (lv_is_mirror_log(lv)) { log_error("Unable to change mirror log LV %s directly", lv->name); return ECMD_FAILED; } - if (lv->status & MIRROR_IMAGE) { + if (lv_is_mirror_image(lv)) { log_error("Unable to change mirror image LV %s directly", lv->name); return ECMD_FAILED; diff --git a/tools/lvconvert.c b/tools/lvconvert.c index a04a7fca0..c2527453f 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -677,7 +677,7 @@ static int _finish_lvconvert_mirror(struct cmd_context *cmd, struct logical_volume *lv, struct dm_list *lvs_changed __attribute__((unused))) { - if (!(lv->status & CONVERTING)) + if (!lv_is_converting(lv)) return 1; if (!collapse_mirrored_lv(lv)) { @@ -968,7 +968,7 @@ static int _failed_logs_count(struct logical_volume *lv) unsigned s; struct logical_volume *log_lv = first_seg(lv)->log_lv; if (log_lv && (log_lv->status & PARTIAL_LV)) { - if (log_lv->status & MIRRORED) + if (lv_is_mirrored(log_lv)) ret += _failed_mirrors_count(log_lv); else ret += 1; @@ -1109,7 +1109,7 @@ static int _lv_update_mirrored_log(struct logical_volume *lv, return 1; log_lv = first_seg(_original_lv(lv))->log_lv; - if (!log_lv || !(log_lv->status & MIRRORED)) + if (!log_lv || !lv_is_mirrored(log_lv)) return 1; old_log_count = _get_log_count(lv); @@ -1252,7 +1252,7 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd, *new_mimage_count = *old_mimage_count; *new_log_count = *old_log_count; - if (find_temporary_mirror(lv) || (lv->status & CONVERTING)) + if (find_temporary_mirror(lv) || lv_is_converting(lv)) lp->need_polling = 1; return 1; } @@ -1337,7 +1337,7 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd, /* * Region size must not change on existing mirrors */ - if (arg_count(cmd, regionsize_ARG) && (lv->status & MIRRORED) && + if (arg_count(cmd, regionsize_ARG) && lv_is_mirrored(lv) && (lp->region_size != first_seg(lv)->region_size)) { log_error("Mirror log region size cannot be changed on " "an existing mirror."); @@ -1348,7 +1348,7 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd, * For the most part, we cannot handle multi-segment mirrors. Bail out * early if we have encountered one. */ - if ((lv->status & MIRRORED) && dm_list_size(&lv->segments) != 1) { + if (lv_is_mirrored(lv) && dm_list_size(&lv->segments) != 1) { log_error("Logical volume %s has multiple " "mirror segments.", lv->name); return 0; @@ -1378,7 +1378,7 @@ static int _lvconvert_mirrors_aux(struct cmd_context *cmd, uint32_t old_mimage_count = lv_mirror_count(lv); uint32_t old_log_count = _get_log_count(lv); - if ((lp->mirrors == 1) && !(lv->status & MIRRORED)) { + if ((lp->mirrors == 1) && !lv_is_mirrored(lv)) { log_warn("Logical volume %s is already not mirrored.", lv->name); return 1; @@ -1396,7 +1396,7 @@ static int _lvconvert_mirrors_aux(struct cmd_context *cmd, /* * Up-convert from linear to mirror */ - if (!(lv->status & MIRRORED)) { + if (!lv_is_mirrored(lv)) { /* FIXME Share code with lvcreate */ /* @@ -1442,7 +1442,7 @@ static int _lvconvert_mirrors_aux(struct cmd_context *cmd, * Is there already a convert in progress? We do not * currently allow more than one. */ - if (find_temporary_mirror(lv) || (lv->status & CONVERTING)) { + if (find_temporary_mirror(lv) || lv_is_converting(lv)) { log_error("%s is already being converted. Unable to start another conversion.", lv->name); return 0; @@ -1523,7 +1523,7 @@ out: /* * Converting the log type */ - if ((lv->status & MIRRORED) && (old_log_count != new_log_count)) { + if (lv_is_mirrored(lv) && (old_log_count != new_log_count)) { if (!_lv_update_log_type(cmd, lp, lv, operable_pvs, new_log_count)) return_0; @@ -1959,7 +1959,7 @@ static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volu if (!vg_check_status(vg, LVM_WRITE)) return_ECMD_FAILED; - if (lv_is_mirror_type(cow) || lv_is_raid_type(cow) || lv_is_thin_type(cow)) { + if (lv_is_pvmove(cow) || lv_is_mirror_type(cow) || lv_is_raid_type(cow) || lv_is_thin_type(cow)) { log_error("LV %s/%s type is unsupported with --splitsnapshot.", vg->name, cow->name); return ECMD_FAILED; } @@ -2000,7 +2000,7 @@ static int _lvconvert_snapshot(struct cmd_context *cmd, { struct logical_volume *org; - if (lv->status & MIRRORED) { + if (lv_is_mirrored(lv)) { log_error("Unable to convert mirrored LV \"%s\" into a snapshot.", lv->name); return 0; } @@ -2025,11 +2025,11 @@ static int _lvconvert_snapshot(struct cmd_context *cmd, if (!cow_has_min_chunks(lv->vg, lv->le_count, lp->chunk_size)) return_0; - if (org->status & (LOCKED|PVMOVE|MIRRORED) || lv_is_cow(org)) { + if (lv_is_locked(org) || lv_is_pvmove(org) || lv_is_mirrored(org) || lv_is_cow(org)) { log_error("Unable to convert an LV into a snapshot of a %s LV.", - org->status & LOCKED ? "locked" : - org->status & PVMOVE ? "pvmove" : - org->status & MIRRORED ? "mirrored" : + lv_is_locked(org) ? "locked" : + lv_is_pvmove(org) ? "pvmove" : + lv_is_mirrored(org) ? "mirrored" : "snapshot"); return 0; } @@ -2665,7 +2665,7 @@ static int _lvconvert_pool(struct cmd_context *cmd, log_error("Try \"raid1\" segment type instead."); return 0; } - if (metadata_lv->status & LOCKED) { + if (lv_is_locked(metadata_lv)) { log_error("Can't convert locked LV %s.", display_lvname(metadata_lv)); return 0; @@ -3031,7 +3031,7 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv, struct lvconvert_params *lp = handle; struct dm_list *failed_pvs; - if (lv->status & LOCKED) { + if (lv_is_locked(lv)) { log_error("Cannot convert locked LV %s", lv->name); return ECMD_FAILED; } @@ -3042,7 +3042,7 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv, return ECMD_FAILED; } - if (lv->status & PVMOVE) { + if (lv_is_pvmove(lv)) { log_error("Unable to convert pvmove LV %s", lv->name); return ECMD_FAILED; } @@ -3112,7 +3112,7 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv, _remove_missing_empty_pv(lv->vg, failed_pvs); } else if (arg_count(cmd, mirrors_ARG) || arg_count(cmd, splitmirrors_ARG) || - (lv->status & MIRRORED)) { + lv_is_mirrored(lv)) { if (!archive(lv->vg)) return_ECMD_FAILED; diff --git a/tools/lvrename.c b/tools/lvrename.c index 3bf479384..eeff76da2 100644 --- a/tools/lvrename.c +++ b/tools/lvrename.c @@ -111,9 +111,9 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv) goto bad; } - if (lvl->lv->status & (RAID_IMAGE | RAID_META)) { + if (lv_is_raid_image(lvl->lv) || lv_is_raid_metadata(lvl->lv)) { log_error("Cannot rename a RAID %s directly", - (lvl->lv->status & RAID_IMAGE) ? "image" : + lv_is_raid_image(lvl->lv) ? "image" : "metadata area"); goto bad; } diff --git a/tools/pvmove.c b/tools/pvmove.c index 3448af416..5b458b1ea 100644 --- a/tools/pvmove.c +++ b/tools/pvmove.c @@ -322,19 +322,18 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd, * RAID, thin and snapshot-related LVs are not * processed in a cluster, so we don't have to * worry about avoiding certain PVs in that context. + * + * Allow clustered mirror, but not raid mirror. */ - if (vg_is_clustered(lv->vg)) { - /* Allow clustered mirror, but not raid mirror. */ - if (!lv_is_mirror_type(lv) || lv_is_raid(lv)) - continue; - } + if (vg_is_clustered(lv->vg) && (!lv_is_mirror_type(lv) || lv_is_raid(lv))) + continue; if (!lv_is_on_pvs(lv, source_pvl)) continue; - if (lv->status & (CONVERTING | MERGING)) { + if (lv_is_converting(lv) || lv_is_merging(lv)) { log_error("Unable to pvmove when %s volumes are present", - (lv->status & CONVERTING) ? + lv_is_converting(lv) ? "converting" : "merging"); return NULL; } @@ -423,7 +422,7 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd, continue; } - if (lv->status & LOCKED) { + if (lv_is_locked(lv)) { lv_skipped = 1; log_print_unless_silent("Skipping locked LV %s", lv->name); continue; diff --git a/tools/toollib.c b/tools/toollib.c index b160ead5a..7be5b5aee 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1440,7 +1440,7 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv, if (background_polling() && is_change_activating(activate) && - (lv->status & (PVMOVE|CONVERTING|MERGING))) + (lv_is_pvmove(lv) || lv_is_converting(lv) || lv_is_merging(lv))) lv_spawn_background_polling(cmd, lv); return r; @@ -1509,19 +1509,19 @@ void lv_spawn_background_polling(struct cmd_context *cmd, { const char *pvname; - if ((lv->status & PVMOVE) && + if (lv_is_pvmove(lv) && (pvname = get_pvmove_pvname_from_lv_mirr(lv))) { log_verbose("Spawning background pvmove process for %s", pvname); pvmove_poll(cmd, pvname, 1); - } else if ((lv->status & LOCKED) && - (pvname = get_pvmove_pvname_from_lv(lv))) { + } else if (lv_is_locked(lv) && + (pvname = get_pvmove_pvname_from_lv(lv))) { log_verbose("Spawning background pvmove process for %s", pvname); pvmove_poll(cmd, pvname, 1); } - if (lv->status & (CONVERTING|MERGING)) { + if (lv_is_converting(lv) || lv_is_merging(lv)) { log_verbose("Spawning background lvconvert process for %s", lv->name); lvconvert_poll(cmd, lv, 1); diff --git a/tools/vgchange.c b/tools/vgchange.c index 88dc18079..29e2d8a74 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -36,7 +36,7 @@ static int _monitor_lvs_in_vg(struct cmd_context *cmd, /* * FIXME: Need to consider all cases... PVMOVE, etc */ - if (lv->status & PVMOVE) + if (lv_is_pvmove(lv)) continue; if (!monitor_dev_for_events(cmd, lv, 0, reg)) { @@ -67,7 +67,7 @@ static int _poll_lvs_in_vg(struct cmd_context *cmd, lv_active = info.exists; if (lv_active && - (lv->status & (PVMOVE|CONVERTING|MERGING))) { + (lv_is_pvmove(lv) || lv_is_converting(lv) || lv_is_merging(lv))) { lv_spawn_background_polling(cmd, lv); count++; } @@ -121,7 +121,7 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg, /* Can't deactivate a pvmove LV */ /* FIXME There needs to be a controlled way of doing this */ - if ((lv->status & PVMOVE) && !is_change_activating(activate)) + if (lv_is_pvmove(lv) && !is_change_activating(activate)) continue; if (lv_activation_skip(lv, activate, arg_count(cmd, ignoreactivationskip_ARG))) diff --git a/tools/vgreduce.c b/tools/vgreduce.c index 0ade4fad1..62162af23 100644 --- a/tools/vgreduce.c +++ b/tools/vgreduce.c @@ -95,13 +95,13 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg) goto restart; } - if (lv->status & MIRRORED) { + if (lv_is_mirrored(lv)) { if (!mirror_remove_missing(cmd, lv, 1)) return_0; goto restart; } - if (arg_count(cmd, mirrorsonly_ARG) &&!(lv->status & MIRRORED)) { + if (arg_count(cmd, mirrorsonly_ARG) && !lv_is_mirrored(lv)) { log_error("Non-mirror-image LV %s found: can't remove.", lv->name); continue; } diff --git a/tools/vgsplit.c b/tools/vgsplit.c index 1a8e2379a..ad2eb48de 100644 --- a/tools/vgsplit.c +++ b/tools/vgsplit.c @@ -71,7 +71,7 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to) if (lv_is_raid(lv)) continue; - if ((lv->status & MIRRORED)) + if (lv_is_mirrored(lv)) continue; if (lv_is_thin_pool(lv) || @@ -192,7 +192,7 @@ static int _move_mirrors(struct volume_group *vg_from, if (lv_is_raid(lv)) continue; - if (!(lv->status & MIRRORED)) + if (!lv_is_mirrored(lv)) continue; seg = first_seg(lv); |