master - tests: check stacked cache dataLV of thin-pool
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=888dd33148563e95b2b...
Commit: 888dd33148563e95b2b3faac98f6c6dd5f00a60a
Parent: df3ff32fc012b1e881dd492c1e34a7d1020747b1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 23 11:51:51 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 23 12:01:16 2017 +0200
tests: check stacked cache dataLV of thin-pool
---
test/shell/lvcreate-thin-cache.sh | 48 +++++++++++++++++++++++++++++++++++++
test/shell/lvextend-thin-cache.sh | 36 +++++++++++++++++++++++++++
2 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvcreate-thin-cache.sh b/test/shell/lvcreate-thin-cache.sh
new file mode 100644
index 0000000..0b9f3c8
--- /dev/null
+++ b/test/shell/lvcreate-thin-cache.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2017 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# Exercise caching thin-pool's data LV
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
+
+. lib/inittest
+
+#
+# Main
+#
+aux have_thin 1 0 0 || skip
+aux have_cache 1 3 0 || skip
+
+which mkfs.ext4 || skip
+
+aux prepare_pvs 2 64
+get_devs
+
+vgcreate -s 64K "$vg" "${DEVICES[@]}"
+
+lvcreate -L10M -V10M -T $vg/pool --name $lv1
+
+lvcreate -H -L10 $vg/pool
+
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+
+lvconvert --uncache $vg/pool
+fsck -n "$DM_DEV_DIR/$vg/$lv1"
+
+lvcreate -H -L10 $vg/pool_tdata
+fsck -n "$DM_DEV_DIR/$vg/$lv1"
+lvconvert --uncache $vg/pool_tdata
+
+vgremove -ff $vg
diff --git a/test/shell/lvextend-thin-cache.sh b/test/shell/lvextend-thin-cache.sh
new file mode 100644
index 0000000..8983b7d
--- /dev/null
+++ b/test/shell/lvextend-thin-cache.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2017 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# Exercise resize of cached thin pool data volumes
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
+
+. lib/inittest
+
+aux have_thin 1 0 0 || skip
+aux have_cache 1 3 0 || skip
+
+aux prepare_vg 2
+
+lvcreate -l2 -T $vg/pool
+# Caching of thin-pool's dataLV
+lvcreate -H -L10 $vg/pool
+
+# Resize is unsupported
+not lvextend -l+2 $vg/pool 2>&1 | tee out
+
+grep "Unable to resize" out
+
+vgremove -ff $vg
6 years, 5 months
master - lvextend: detect stacked cache lv used for thinpool
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d6fcab900b5b33c55c7...
Commit: d6fcab900b5b33c55c7894c3f4a7cdd1dbb81c1a
Parent: de58df390b6bd3f46841fdacb9a75defccf9f3e2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 23 11:20:32 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 23 12:00:43 2017 +0200
lvextend: detect stacked cache lv used for thinpool
Ensure, that cacheLV is not tried to be resize until full support is
added.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2644d37..2f08468 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.176 -
===================================
+ Avoid internal error when resizing cache type _tdata LV (not yet supported).
Show original converted names when lvconverting LV to pool volume.
Move lib code used only by liblvm into metadata-liblvm.c.
Distinguish between device not found and excluded by filter.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index c0e9a99..b03f9cf 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4797,7 +4797,8 @@ static int _lvresize_check(struct logical_volume *lv,
return 0;
}
- if (lv_is_cache_type(lv)) {
+ if (lv_is_cache_type(lv) ||
+ (lv_is_thin_pool(lv) && lv_is_cache_type(seg_lv(first_seg(lv), 0)))) {
log_error("Unable to resize logical volumes of cache type.");
return 0;
}
6 years, 5 months
master - lvcreate: skip checking for name restriction for caching
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=df3ff32fc012b1e881d...
Commit: df3ff32fc012b1e881dd492c1e34a7d1020747b1
Parent: d6fcab900b5b33c55c7894c3f4a7cdd1dbb81c1a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 23 11:36:51 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 23 12:01:15 2017 +0200
lvcreate: skip checking for name restriction for caching
lvcreate supports a 'conversion' when caching LV.
This normally worked fine, however in case passed LV was
thin-pool's data LV with suffix _tdata we have failed to early.
As the easiest fix looks dropping validation of name when
caching type is select - such name check will happen later
once the VG is opened again and properly detect if the LV
with protected name already exists and can be converted,
or will be rejected as ambigiuous operation requiring user
to specify --type cache | --type cache-pool.
---
WHATS_NEW | 1 +
tools/lvcreate.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2f08468..d91900b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.176 -
===================================
+ Allow lvcreate to be used for caching of _tdata LV.
Avoid internal error when resizing cache type _tdata LV (not yet supported).
Show original converted names when lvconverting LV to pool volume.
Move lib code used only by liblvm into metadata-liblvm.c.
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 8aa16f2..ff57baf 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1425,7 +1425,7 @@ static int _check_pool_parameters(struct cmd_context *cmd,
if (lp->create_pool) {
/* Given pool name needs to follow restrictions for created LV */
if (lp->pool_name) {
- if (!apply_lvname_restrictions(lp->pool_name))
+ if (!seg_is_cache(lp) && !apply_lvname_restrictions(lp->pool_name))
return_0;
/* We could check existance only when we have vg */
if (vg && find_lv(vg, lp->pool_name)) {
6 years, 5 months
master - lvconvert: preserve names of converted LV
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=de58df390b6bd3f4684...
Commit: de58df390b6bd3f46841fdacb9a75defccf9f3e2
Parent: d6f4563103a626bbe6a9e768a090233541ecd24c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 23 10:56:44 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 23 11:58:27 2017 +0200
lvconvert: preserve names of converted LV
When prompting and warning for conversion, remember initial LV names,
so after conversion is finished, correct original names are printed.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 22 +++++++++++-----------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8ee5b0c..2644d37 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.176 -
===================================
+ Show original converted names when lvconverting LV to pool volume.
Move lib code used only by liblvm into metadata-liblvm.c.
Distinguish between device not found and excluded by filter.
Monitor external origin LVs.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 28909dd..02c649c 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2864,6 +2864,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
const char *pool_name; /* name of original lv arg */
char meta_name[NAME_LEN]; /* generated sub lv name */
char data_name[NAME_LEN]; /* generated sub lv name */
+ char converted_names[3*NAME_LEN]; /* preserve names of converted lv */
struct segment_type *pool_segtype; /* thinpool or cachepool */
struct lv_segment *seg;
unsigned int target_attr = ~0;
@@ -3052,14 +3053,16 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
log_verbose("Pool metadata extents %u chunk_size %u", meta_extents, chunk_size);
+ (void) dm_snprintf(converted_names, sizeof(converted_names), "%s%s%s",
+ display_lvname(lv),
+ metadata_lv ? " and " : "",
+ metadata_lv ? display_lvname(metadata_lv) : "");
+
/*
* Verify that user wants to use these LVs.
*/
-
- log_warn("WARNING: Converting logical volume %s%s%s to %s pool's data%s %s metadata wiping.",
- display_lvname(lv),
- metadata_lv ? " and " : "",
- metadata_lv ? display_lvname(metadata_lv) : "",
+ log_warn("WARNING: Converting %s to %s pool's data%s %s metadata wiping.",
+ converted_names,
to_cachepool ? "cache" : "thin",
metadata_lv ? " and metadata volumes" : " volume",
zero_metadata ? "with" : "WITHOUT");
@@ -3070,10 +3073,8 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
log_warn("WARNING: Using mismatched cache pool metadata MAY DESTROY YOUR DATA!");
if (!arg_count(cmd, yes_ARG) &&
- yes_no_prompt("Do you really want to convert %s%s%s? [y/n]: ",
- display_lvname(lv),
- metadata_lv ? " and " : "",
- metadata_lv ? display_lvname(metadata_lv) : "") == 'n') {
+ yes_no_prompt("Do you really want to convert %s? [y/n]: ",
+ converted_names) == 'n') {
log_error("Conversion aborted.");
goto bad;
}
@@ -3289,8 +3290,7 @@ out:
if (r)
log_print_unless_silent("Converted %s to %s pool.",
- display_lvname(lv),
- to_cachepool ? "cache" : "thin");
+ converted_names, to_cachepool ? "cache" : "thin");
/*
* Unlock and free the locks from existing LVs that became pool data
6 years, 5 months
master - test: remove 'should's from test to test target status race fix
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d6f4563103a626bbe6a...
Commit: d6f4563103a626bbe6a9e768a090233541ecd24c
Parent: f3ae99dcc0b73f5551c08a3e0af8a17b4448ac50
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Oct 19 17:41:44 2017 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Oct 19 17:41:44 2017 +0200
test: remove 'should's from test to test target status race fix
---
test/shell/lvconvert-raid-status-validation.sh | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/test/shell/lvconvert-raid-status-validation.sh b/test/shell/lvconvert-raid-status-validation.sh
index cee3bfe..51c7048 100644
--- a/test/shell/lvconvert-raid-status-validation.sh
+++ b/test/shell/lvconvert-raid-status-validation.sh
@@ -76,9 +76,8 @@ while true; do
# Before starting sync thread: "Aa X/X recover"
# from the valid case,
# Just finished sync thread: "Aa X/X recover"
- # We'll just put "should" for now
- should [ "${a[5]}" = "AA" ]
- should [ "${a[7]}" = "idle" ]
+ [ "${a[5]}" = "AA" ]
+ [ "${a[7]}" = "idle" ]
break
fi
sleep .1
@@ -105,9 +104,8 @@ while true; do
# Before starting sync thread: "Aa X/X recover"
# from the valid case,
# Just finished sync thread: "Aa X/X recover"
- # We'll just put "should" for now
- should [ "${a[5]}" = "AAA" ]
- should [ "${a[7]}" = "idle" ]
+ [ "${a[5]}" = "AAA" ]
+ [ "${a[7]}" = "idle" ]
break
fi
sleep .1
@@ -129,8 +127,8 @@ while true; do
[ "${a[5]}" = "aa" ]
[ "${a[7]}" = "resync" ]
else
- should [ "${a[5]}" = "AA" ]
- should [ "${a[7]}" = "idle" ]
+ [ "${a[5]}" = "AA" ]
+ [ "${a[7]}" = "idle" ]
break
fi
sleep .1
6 years, 6 months
master - liblvm: Move lib code used exclusively into metadata-liblvm.c
by Alasdair Kergon
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f3ae99dcc0b73f5551c...
Commit: f3ae99dcc0b73f5551c08a3e0af8a17b4448ac50
Parent: f1cc5b12fd80c3c62247fccfb2e5537aef27533d
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Oct 18 19:29:32 2017 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Oct 18 19:29:32 2017 +0100
liblvm: Move lib code used exclusively into metadata-liblvm.c
Also remove some redundant function definitions from metadata.h.
---
WHATS_NEW | 1 +
lib/Makefile.in | 1 +
lib/metadata/metadata-exported.h | 6 +-
lib/metadata/metadata-liblvm.c | 701 ++++++++++++++++++++++++++++++++++++++
lib/metadata/metadata.c | 494 +--------------------------
lib/metadata/metadata.h | 17 +-
lib/metadata/pv_manip.c | 176 ----------
liblvm/lvm_lv.c | 2 +-
liblvm/lvm_pv.c | 2 +-
9 files changed, 727 insertions(+), 673 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 665517b..8ee5b0c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.176 -
===================================
+ Move lib code used only by liblvm into metadata-liblvm.c.
Distinguish between device not found and excluded by filter.
Monitor external origin LVs.
Remove the replicator code, including configure --with-replicators.
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 7e9fa91..1fdaca8 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -96,6 +96,7 @@ SOURCES =\
metadata/lv_manip.c \
metadata/merge.c \
metadata/metadata.c \
+ metadata/metadata-liblvm.c \
metadata/mirror.c \
metadata/pool_manip.c \
metadata/pv.c \
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index cd6e92a..85e5838 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -688,9 +688,9 @@ uint32_t vg_read_error(struct volume_group *vg_handle);
struct physical_volume *pv_create(const struct cmd_context *cmd,
struct device *dev, struct pv_create_args *pva);
-int pvremove_single(struct cmd_context *cmd, const char *pv_name,
- void *handle __attribute__((unused)), unsigned force_count,
- unsigned prompt, struct dm_list *pvslist);
+struct physical_volume *pvcreate_vol(struct cmd_context *cmd, const char *pv_name,
+ struct pvcreate_params *pp, int write_now);
+
int pvremove_many(struct cmd_context *cmd, struct dm_list *pv_names,
unsigned force_count, unsigned prompt);
diff --git a/lib/metadata/metadata-liblvm.c b/lib/metadata/metadata-liblvm.c
new file mode 100644
index 0000000..f37008d
--- /dev/null
+++ b/lib/metadata/metadata-liblvm.c
@@ -0,0 +1,701 @@
+/*
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * This file contains functions now used only by liblvm.
+ * Ideally this file should be empty as liblvm and toollib should be doing identical things.
+ * FIXME Merge all the code into different parts of the tree.
+ */
+#include "lib.h"
+#include "toolcontext.h"
+#include "lvm-string.h"
+#include "metadata.h"
+#include "label.h"
+#include "lvm-signal.h"
+#include "lvmcache.h"
+#include "lvmetad.h"
+
+int vg_reduce(struct volume_group *vg, const char *pv_name)
+{
+ struct physical_volume *pv;
+ struct pv_list *pvl;
+
+ if (!(pvl = find_pv_in_vg(vg, pv_name))) {
+ log_error("Physical volume %s not in volume group %s.",
+ pv_name, vg->name);
+ return 0;
+ }
+
+ pv = pvl->pv;
+
+ if (vgreduce_single(vg->cmd, vg, pv, 0)) {
+ dm_list_add(&vg->removed_pvs, &pvl->list);
+ return 1;
+ }
+
+ log_error("Unable to remove physical volume '%s' from "
+ "volume group '%s'.", pv_name, vg->name);
+
+ return 0;
+}
+
+static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_write *pvw)
+{
+ struct physical_volume *pv = pvw->pv;
+ struct device *dev = pv->dev;
+ const char *pv_name = dev_name(dev);
+
+ if (pvw->new_pv) {
+ /* Wipe existing label first */
+ if (!label_remove(pv_dev(pv))) {
+ log_error("Failed to wipe existing label on %s", pv_name);
+ return 0;
+ }
+
+ if (pvw->pp->zero) {
+ log_verbose("Zeroing start of device %s", pv_name);
+ if (!dev_open_quiet(dev)) {
+ log_error("%s not opened: device not zeroed", pv_name);
+ return 0;
+ }
+
+ if (!dev_set(dev, UINT64_C(0), (size_t) 2048, 0)) {
+ log_error("%s not wiped: aborting", pv_name);
+ if (!dev_close(dev))
+ stack;
+ return 0;
+ }
+ if (!dev_close(dev))
+ stack;
+ }
+ }
+
+ log_verbose("Writing physical volume data to disk \"%s\"",
+ pv_name);
+
+ if (!(pv_write(cmd, pv, 1))) {
+ log_error("Failed to write physical volume \"%s\"", pv_name);
+ return 0;
+ }
+
+ if (pvw->new_pv)
+ log_print_unless_silent("Physical volume \"%s\" successfully created", pv_name);
+ else
+ log_verbose("Physical volume \"%s\" successfully written", pv_name);
+
+ return 1;
+}
+
+static int _verify_pv_create_params(struct pvcreate_params *pp)
+{
+ /*
+ * FIXME: Some of these checks are duplicates in pvcreate_params_validate.
+ */
+ if (pp->pva.pvmetadatacopies > 2) {
+ log_error("Metadatacopies may only be 0, 1 or 2");
+ return 0;
+ }
+
+ if (pp->pva.data_alignment > UINT32_MAX) {
+ log_error("Physical volume data alignment is too big.");
+ return 0;
+ }
+
+ if (pp->pva.data_alignment_offset > UINT32_MAX) {
+ log_error("Physical volume data alignment offset is too big.");
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * See if we may pvcreate on this device.
+ * 0 indicates we may not.
+ */
+static int _pvcreate_check(struct cmd_context *cmd, const char *name,
+ struct pvcreate_params *pp, int *wiped)
+{
+ static const char really_init_msg[] = "Really INITIALIZE physical volume";
+ static const char not_init_msg[] = "physical volume not initialized";
+ struct physical_volume *pv;
+ struct device *dev;
+ int r = 0;
+ int scan_needed = 0;
+ int filter_refresh_needed = 0;
+ int used;
+
+ /* FIXME Check partition type is LVM unless --force is given */
+
+ *wiped = 0;
+
+ /* Is there a pv here already? */
+ pv = find_pv_by_name(cmd, name, 1, 1);
+
+ /* Allow partial & exported VGs to be destroyed. */
+ /* We must have -ff to overwrite a non orphan */
+ if (pv) {
+ if (!is_orphan(pv) && pp->force != DONT_PROMPT_OVERRIDE) {
+ log_error("Can't initialize physical volume \"%s\" of "
+ "volume group \"%s\" without -ff.", name, pv_vg_name(pv));
+ goto out;
+ }
+
+ if ((used = is_used_pv(pv)) < 0)
+ goto_out;
+
+ if (used && pp->force != DONT_PROMPT_OVERRIDE) {
+ log_error("PV %s is used by a VG but its metadata is missing.", name);
+ log_error("Can't initialize PV '%s' without -ff.", name);
+ goto out;
+ }
+ }
+
+ /* prompt */
+ if (pv && !pp->yes) {
+ if (is_orphan(pv)) {
+ if (used) {
+ if (yes_no_prompt("%s \"%s\" that is marked as belonging to a VG [y/n]? ",
+ really_init_msg, name) == 'n') {
+ log_error("%s: %s", name, not_init_msg);
+ goto out;
+ }
+ }
+ } else {
+ if (yes_no_prompt("%s \"%s\" of volume group \"%s\" [y/n]? ",
+ really_init_msg, name, pv_vg_name(pv)) == 'n') {
+ log_error("%s: %s", name, not_init_msg);
+ goto out;
+ }
+ }
+ }
+
+ if (sigint_caught())
+ goto_out;
+
+ dev = dev_cache_get(name, cmd->full_filter);
+
+ /*
+ * Refresh+rescan at the end is needed if:
+ * - we don't obtain device list from udev,
+ * hence persistent cache file is used
+ * and we need to trash it and reevaluate
+ * for any changes done outside - adding
+ * any new foreign signature which may affect
+ * filtering - before we do pvcreate, we
+ * need to be sure that we have up-to-date
+ * view for filters
+ *
+ * - we have wiped existing foreign signatures
+ * from dev as this may affect what's filtered
+ * as well
+ *
+ *
+ * Only rescan at the end is needed if:
+ * - we've just checked whether dev is fileterd
+ * by MD filter. We do the refresh in-situ,
+ * so no need to require the refresh at the
+ * end of this fn. This is to allow for
+ * wiping MD signature during pvcreate for
+ * the dev - the dev would normally be
+ * filtered because of MD filter.
+ * This is an exception.
+ */
+
+ /* Is there an md superblock here? */
+ if (!dev && md_filtering()) {
+ if (!refresh_filters(cmd))
+ goto_out;
+
+ init_md_filtering(0);
+ dev = dev_cache_get(name, cmd->full_filter);
+ init_md_filtering(1);
+
+ scan_needed = 1;
+ } else if (!obtain_device_list_from_udev())
+ filter_refresh_needed = scan_needed = 1;
+
+ if (!dev) {
+ log_error("Device %s not found (or ignored by filtering).", name);
+ goto out;
+ }
+
+ /*
+ * This test will fail if the device belongs to an MD array.
+ */
+ if (!dev_test_excl(dev)) {
+ /* FIXME Detect whether device-mapper itself is still using it */
+ log_error("Can't open %s exclusively. Mounted filesystem?",
+ name);
+ goto out;
+ }
+
+ if (!wipe_known_signatures(cmd, dev, name,
+ TYPE_LVM1_MEMBER | TYPE_LVM2_MEMBER,
+ 0, pp->yes, pp->force, wiped)) {
+ log_error("Aborting pvcreate on %s.", name);
+ goto out;
+ }
+
+ if (*wiped)
+ filter_refresh_needed = scan_needed = 1;
+
+ if (sigint_caught())
+ goto_out;
+
+ if (pv && !is_orphan(pv) && pp->force)
+ log_warn("WARNING: Forcing physical volume creation on "
+ "%s%s%s%s", name,
+ !is_orphan(pv) ? " of volume group \"" : "",
+ pv_vg_name(pv),
+ !is_orphan(pv) ? "\"" : "");
+
+ r = 1;
+
+out:
+ if (filter_refresh_needed)
+ if (!refresh_filters(cmd)) {
+ stack;
+ r = 0;
+ }
+
+ if (scan_needed) {
+ lvmcache_force_next_label_scan();
+ if (!lvmcache_label_scan(cmd)) {
+ stack;
+ r = 0;
+ }
+ }
+
+ free_pv_fid(pv);
+ return r;
+}
+
+/*
+ * pvcreate_vol() - initialize a device with PV label and metadata area
+ *
+ * Parameters:
+ * - pv_name: device path to initialize
+ * - pp: parameters to pass to pv_create; if NULL, use default values
+ *
+ * Returns:
+ * NULL: error
+ * struct physical_volume * (non-NULL): handle to physical volume created
+ */
+struct physical_volume *pvcreate_vol(struct cmd_context *cmd, const char *pv_name,
+ struct pvcreate_params *pp, int write_now)
+{
+ struct physical_volume *pv = NULL;
+ struct device *dev;
+ int wiped = 0;
+ struct dm_list mdas;
+ struct pvcreate_params default_pp;
+ char buffer[64] __attribute__((aligned(8)));
+ dev_ext_t dev_ext_src;
+
+ pvcreate_params_set_defaults(&default_pp);
+ if (!pp)
+ pp = &default_pp;
+
+ if (!_verify_pv_create_params(pp)) {
+ goto bad;
+ }
+
+ if (pp->pva.idp) {
+ if ((dev = lvmcache_device_from_pvid(cmd, pp->pva.idp, NULL, NULL)) &&
+ (dev != dev_cache_get(pv_name, cmd->full_filter))) {
+ if (!id_write_format((const struct id*)&pp->pva.idp->uuid,
+ buffer, sizeof(buffer)))
+ goto_bad;
+ log_error("uuid %s already in use on \"%s\"", buffer,
+ dev_name(dev));
+ goto bad;
+ }
+ }
+
+ if (!_pvcreate_check(cmd, pv_name, pp, &wiped))
+ goto_bad;
+
+ if (sigint_caught())
+ goto_bad;
+
+ /*
+ * wipe_known_signatures called in _pvcreate_check fires
+ * WATCH event to update udev database. But at the moment,
+ * we have no way to synchronize with such event - we may
+ * end up still seeing the old info in udev db and pvcreate
+ * can fail to proceed because of the device still being
+ * filtered (because of the stale info in udev db).
+ * Disable udev dev-ext source temporarily here for
+ * this reason and rescan with DEV_EXT_NONE dev-ext
+ * source (so filters use DEV_EXT_NONE source).
+ */
+ dev_ext_src = external_device_info_source();
+ if (wiped && (dev_ext_src == DEV_EXT_UDEV))
+ init_external_device_info_source(DEV_EXT_NONE);
+
+ dev = dev_cache_get(pv_name, cmd->full_filter);
+
+ init_external_device_info_source(dev_ext_src);
+
+ if (!dev) {
+ log_error("%s: Couldn't find device. Check your filters?",
+ pv_name);
+ goto bad;
+ }
+
+ dm_list_init(&mdas);
+
+ if (!(pv = pv_create(cmd, dev, &pp->pva))) {
+ log_error("Failed to setup physical volume \"%s\"", pv_name);
+ goto bad;
+ }
+
+ log_verbose("Set up physical volume for \"%s\" with %" PRIu64
+ " available sectors", pv_name, pv_size(pv));
+
+ pv->status |= UNLABELLED_PV;
+ if (write_now) {
+ struct pv_to_write pvw;
+ pvw.pp = pp;
+ pvw.pv = pv;
+ pvw.new_pv = 1;
+ if (!_pvcreate_write(cmd, &pvw))
+ goto bad;
+ }
+
+ return pv;
+
+bad:
+ return NULL;
+}
+
+/*
+ * Extend a VG by a single PV / device path
+ *
+ * Parameters:
+ * - vg: handle of volume group to extend by 'pv_name'
+ * - pv_name: device path of PV to add to VG
+ * - pp: parameters to pass to implicit pvcreate; if NULL, do not pvcreate
+ * - max_phys_block_size: largest physical block size found amongst PVs in a VG
+ *
+ */
+static int _vg_extend_single_pv(struct volume_group *vg, char *pv_name,
+ struct pvcreate_params *pp,
+ unsigned int *max_phys_block_size)
+{
+ struct physical_volume *pv;
+ struct pv_to_write *pvw;
+ int new_pv = 0;
+
+ pv = find_pv_by_name(vg->cmd, pv_name, 1, 1);
+
+ if (!pv && !pp) {
+ log_error("%s not identified as an existing "
+ "physical volume", pv_name);
+ return 0;
+ }
+
+ if (!pv && pp) {
+ if (!(pv = pvcreate_vol(vg->cmd, pv_name, pp, 0)))
+ return_0;
+ new_pv = 1;
+ }
+
+ if (!(check_dev_block_size_for_vg(pv->dev, (const struct volume_group *) vg,
+ max_phys_block_size)))
+ goto_bad;
+
+ if (!add_pv_to_vg(vg, pv_name, pv, new_pv))
+ goto_bad;
+
+ if ((pv->fmt->features & FMT_PV_FLAGS) ||
+ (pv->status & UNLABELLED_PV)) {
+ if (!(pvw = dm_pool_zalloc(vg->vgmem, sizeof(*pvw)))) {
+ log_error("pv_to_write allocation for '%s' failed", pv_name);
+ return 0;
+ }
+ pvw->pv = pv;
+ pvw->pp = new_pv ? pp : NULL;
+ pvw->new_pv = new_pv;
+ dm_list_add(&vg->pvs_to_write, &pvw->list);
+ }
+
+ return 1;
+bad:
+ free_pv_fid(pv);
+ return 0;
+}
+
+/*
+ * Extend a VG by a single PV / device path
+ *
+ * Parameters:
+ * - vg: handle of volume group to extend by 'pv_name'
+ * - pv_count: count of device paths of PVs
+ * - pv_names: device paths of PVs to add to VG
+ * - pp: parameters to pass to implicit pvcreate; if NULL, do not pvcreate
+ *
+ */
+int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names,
+ struct pvcreate_params *pp)
+{
+ int i;
+ char *pv_name;
+ unsigned int max_phys_block_size = 0;
+
+ if (vg_bad_status_bits(vg, RESIZEABLE_VG))
+ return_0;
+
+ /* attach each pv */
+ for (i = 0; i < pv_count; i++) {
+ if (!(pv_name = dm_strdup(pv_names[i]))) {
+ log_error("Failed to duplicate pv name %s.", pv_names[i]);
+ return 0;
+ }
+ dm_unescape_colons_and_at_signs(pv_name, NULL, NULL);
+ if (!_vg_extend_single_pv(vg, pv_name, pp, &max_phys_block_size)) {
+ log_error("Unable to add physical volume '%s' to "
+ "volume group '%s'.", pv_name, vg->name);
+ dm_free(pv_name);
+ return 0;
+ }
+ dm_free(pv_name);
+ }
+
+ (void) check_pv_dev_sizes(vg);
+
+/* FIXME Decide whether to initialise and add new mdahs to format instance */
+
+ return 1;
+}
+
+/*
+ * Decide whether it is "safe" to wipe the labels on this device.
+ * 0 indicates we may not.
+ */
+static int _pvremove_check(struct cmd_context *cmd, const char *name,
+ unsigned force_count, unsigned prompt, struct dm_list *pvslist)
+{
+ static const char really_wipe_msg[] = "Really WIPE LABELS from physical volume";
+ struct device *dev;
+ struct label *label;
+ struct pv_list *pvl;
+ struct physical_volume *pv = NULL;
+ int used;
+ int r = 0;
+
+ /* FIXME Check partition type is LVM unless --force is given */
+
+ if (!(dev = dev_cache_get(name, cmd->filter))) {
+ log_error("Device %s not found.", name);
+ return 0;
+ }
+
+ /* Is there a pv here already? */
+ /* If not, this is an error unless you used -f. */
+ if (!label_read(dev, &label, 0)) {
+ if (force_count)
+ return 1;
+ log_error("No PV label found on %s.", name);
+ return 0;
+ }
+
+ dm_list_iterate_items(pvl, pvslist)
+ if (pvl->pv->dev == dev)
+ pv = pvl->pv;
+
+ if (!pv) {
+ log_error(INTERNAL_ERROR "Physical Volume %s has a label, "
+ "but is neither in a VG nor orphan.", name);
+ goto out; /* better safe than sorry */
+ }
+
+ if (is_orphan(pv)) {
+ if ((used = is_used_pv(pv)) < 0)
+ goto_out;
+
+ if (used) {
+ log_warn("WARNING: PV %s is used by a VG but its metadata is missing.", name);
+
+ if (force_count < 2)
+ goto_bad;
+
+ if (!prompt &&
+ yes_no_prompt("%s \"%s\" that is marked as belonging to a VG [y/n]? ",
+ really_wipe_msg, name) == 'n')
+ goto_bad;
+ }
+ } else {
+ log_warn("WARNING: PV %s is used by VG %s (consider using vgreduce).", name, pv_vg_name(pv));
+
+ if (force_count < 2)
+ goto_bad;
+
+ if (!prompt &&
+ yes_no_prompt("%s \"%s\" of volume group \"%s\" [y/n]? ",
+ really_wipe_msg, name, pv_vg_name(pv)) == 'n')
+ goto_bad;
+ }
+
+ if (force_count)
+ log_warn("WARNING: Wiping physical volume label from "
+ "%s%s%s%s", name,
+ !is_orphan(pv) ? " of volume group \"" : "",
+ pv_vg_name(pv),
+ !is_orphan(pv) ? "\"" : "");
+
+ r = 1;
+bad:
+ if (!r) {
+ log_error("%s: physical volume label not removed.", name);
+
+ if (force_count < 2) /* Show hint as log_error() */
+ log_error("(If you are certain you need pvremove, "
+ "then confirm by using --force twice.)");
+ }
+out:
+ return r;
+}
+
+static int _pvremove_single(struct cmd_context *cmd, const char *pv_name,
+ void *handle __attribute__((unused)), unsigned force_count,
+ unsigned prompt, struct dm_list *pvslist)
+{
+ struct device *dev;
+ struct lvmcache_info *info;
+ int r = 0;
+
+ if (!_pvremove_check(cmd, pv_name, force_count, prompt, pvslist))
+ goto out;
+
+ if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
+ log_error("%s: Couldn't find device. Check your filters?",
+ pv_name);
+ goto out;
+ }
+
+ info = lvmcache_info_from_pvid(dev->pvid, dev, 0);
+
+ if (!dev_test_excl(dev)) {
+ /* FIXME Detect whether device-mapper is still using the device */
+ log_error("Can't open %s exclusively - not removing. "
+ "Mounted filesystem?", dev_name(dev));
+ goto out;
+ }
+
+ /* Wipe existing label(s) */
+ if (!label_remove(dev)) {
+ log_error("Failed to wipe existing label(s) on %s", pv_name);
+ goto out;
+ }
+
+ if (info)
+ lvmcache_del(info);
+
+ if (!lvmetad_pv_gone_by_dev(dev))
+ goto_out;
+
+ log_print_unless_silent("Labels on physical volume \"%s\" successfully wiped",
+ pv_name);
+
+ r = 1;
+
+out:
+ return r;
+}
+
+int pvremove_many(struct cmd_context *cmd, struct dm_list *pv_names,
+ unsigned force_count, unsigned prompt)
+{
+ int ret = 1;
+ struct dm_list *pvslist = NULL;
+ struct pv_list *pvl;
+ const struct dm_str_list *pv_name;
+
+ if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
+ log_error("Can't get lock for orphan PVs");
+ return 0;
+ }
+
+ lvmcache_seed_infos_from_lvmetad(cmd);
+
+ if (!(pvslist = get_pvs(cmd))) {
+ ret = 0;
+ goto_out;
+ }
+
+ dm_list_iterate_items(pv_name, pv_names) {
+ if (!_pvremove_single(cmd, pv_name->str, NULL, force_count, prompt, pvslist)) {
+ stack;
+ ret = 0;
+ }
+ if (sigint_caught()) {
+ ret = 0;
+ goto_out;
+ }
+ }
+
+out:
+ unlock_vg(cmd, NULL, VG_ORPHANS);
+
+ if (pvslist)
+ dm_list_iterate_items(pvl, pvslist)
+ free_pv_fid(pvl->pv);
+
+ return ret;
+}
+
+/* FIXME: liblvm todo - make into function that returns handle */
+struct physical_volume *find_pv_by_name(struct cmd_context *cmd,
+ const char *pv_name,
+ int allow_orphan, int allow_unformatted)
+{
+ struct device *dev;
+ struct pv_list *pvl;
+ struct dm_list *pvslist;
+ struct physical_volume *pv = NULL;
+
+ lvmcache_seed_infos_from_lvmetad(cmd);
+
+ if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
+ if (!allow_unformatted)
+ log_error("Physical volume %s not found", pv_name);
+ return_NULL;
+ }
+
+ if (!(pvslist = get_pvs(cmd)))
+ return_NULL;
+
+ dm_list_iterate_items(pvl, pvslist)
+ if (pvl->pv->dev == dev)
+ pv = pvl->pv;
+ else
+ free_pv_fid(pvl->pv);
+
+ if (!pv && !allow_unformatted)
+ log_error("Physical volume %s not found", pv_name);
+
+ if (pv && !allow_orphan && is_orphan_vg(pv->vg_name)) {
+ log_error("Physical volume %s not in a volume group", pv_name);
+ goto bad;
+ }
+
+ return pv;
+
+bad:
+ free_pv_fid(pv);
+ return NULL;
+}
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 15e08e6..bcc23bc 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -44,9 +44,6 @@ static struct physical_volume *_pv_read(struct cmd_context *cmd,
struct format_instance *fid,
uint32_t warn_flags, int scan_label_only);
-static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
- uint64_t status);
-
static int _alignment_overrides_default(unsigned long data_alignment,
unsigned long default_pe_align)
{
@@ -177,8 +174,8 @@ void del_pvl_from_vgs(struct volume_group *vg, struct pv_list *pvl)
* 1 - success
* FIXME: remove pv_name - obtain safely from pv
*/
-static int _add_pv_to_vg(struct volume_group *vg, const char *pv_name,
- struct physical_volume *pv, int new_pv)
+int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
+ struct physical_volume *pv, int new_pv)
{
struct pv_list *pvl;
struct format_instance *fid = vg->fid;
@@ -387,8 +384,8 @@ static int _move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
return 0;
}
- if (_vg_bad_status_bits(vg_from, RESIZEABLE_VG) ||
- _vg_bad_status_bits(vg_to, RESIZEABLE_VG))
+ if (vg_bad_status_bits(vg_from, RESIZEABLE_VG) ||
+ vg_bad_status_bits(vg_to, RESIZEABLE_VG))
return 0;
del_pvl_from_vgs(vg_from, pvl);
@@ -427,8 +424,8 @@ int move_pvs_used_by_lv(struct volume_group *vg_from,
return 0;
}
- if (_vg_bad_status_bits(vg_from, RESIZEABLE_VG) ||
- _vg_bad_status_bits(vg_to, RESIZEABLE_VG))
+ if (vg_bad_status_bits(vg_from, RESIZEABLE_VG) ||
+ vg_bad_status_bits(vg_to, RESIZEABLE_VG))
return 0;
dm_list_iterate_items(lvseg, &lvl->lv->segments) {
@@ -675,7 +672,7 @@ int vg_check_pv_dev_block_sizes(const struct volume_group *vg)
return 1;
}
-static int _check_pv_dev_sizes(struct volume_group *vg)
+int check_pv_dev_sizes(struct volume_group *vg)
{
struct pv_list *pvl;
uint64_t dev_size, size;
@@ -711,124 +708,15 @@ static int _check_pv_dev_sizes(struct volume_group *vg)
}
/*
- * Extend a VG by a single PV / device path
- *
- * Parameters:
- * - vg: handle of volume group to extend by 'pv_name'
- * - pv_name: device path of PV to add to VG
- * - pp: parameters to pass to implicit pvcreate; if NULL, do not pvcreate
- * - max_phys_block_size: largest physical block size found amongst PVs in a VG
- *
- */
-static int _vg_extend_single_pv(struct volume_group *vg, char *pv_name,
- struct pvcreate_params *pp,
- unsigned int *max_phys_block_size)
-{
- struct physical_volume *pv;
- struct pv_to_write *pvw;
- int new_pv = 0;
-
- pv = find_pv_by_name(vg->cmd, pv_name, 1, 1);
-
- if (!pv && !pp) {
- log_error("%s not identified as an existing "
- "physical volume", pv_name);
- return 0;
- }
-
- if (!pv && pp) {
- if (!(pv = pvcreate_vol(vg->cmd, pv_name, pp, 0)))
- return_0;
- new_pv = 1;
- }
-
- if (!(check_dev_block_size_for_vg(pv->dev, (const struct volume_group *) vg,
- max_phys_block_size)))
- goto_bad;
-
- if (!_add_pv_to_vg(vg, pv_name, pv, new_pv))
- goto_bad;
-
- if ((pv->fmt->features & FMT_PV_FLAGS) ||
- (pv->status & UNLABELLED_PV)) {
- if (!(pvw = dm_pool_zalloc(vg->vgmem, sizeof(*pvw)))) {
- log_error("pv_to_write allocation for '%s' failed", pv_name);
- return 0;
- }
- pvw->pv = pv;
- pvw->pp = new_pv ? pp : NULL;
- pvw->new_pv = new_pv;
- dm_list_add(&vg->pvs_to_write, &pvw->list);
- }
-
- return 1;
-bad:
- free_pv_fid(pv);
- return 0;
-}
-
-/*
* FIXME: commands shifting to common code in toollib have left a large
* amount of code only used by liblvm. Either remove this by shifting
* liblvm to use toollib, or isolate all this code into a liblvm-specific
* source file. All the following and more are only used by liblvm:
*
- * . vg_extend()
- * . _vg_extend_single_pv()
- * . pvcreate_vol()
- * . _pvcreate_check()
- * . _pvcreate_write()
- * . pvremove_many()
- * . pvremove_single()
- * . find_pv_by_name()
* . get_pvs()
* . the vg->pvs_to_write list and pv_to_write struct
- * . vg_reduce()
*/
-/*
- * Extend a VG by a single PV / device path
- *
- * Parameters:
- * - vg: handle of volume group to extend by 'pv_name'
- * - pv_count: count of device paths of PVs
- * - pv_names: device paths of PVs to add to VG
- * - pp: parameters to pass to implicit pvcreate; if NULL, do not pvcreate
- *
- */
-int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names,
- struct pvcreate_params *pp)
-{
- int i;
- char *pv_name;
- unsigned int max_phys_block_size = 0;
-
- if (_vg_bad_status_bits(vg, RESIZEABLE_VG))
- return_0;
-
- /* attach each pv */
- for (i = 0; i < pv_count; i++) {
- if (!(pv_name = dm_strdup(pv_names[i]))) {
- log_error("Failed to duplicate pv name %s.", pv_names[i]);
- return 0;
- }
- dm_unescape_colons_and_at_signs(pv_name, NULL, NULL);
- if (!_vg_extend_single_pv(vg, pv_name, pp, &max_phys_block_size)) {
- log_error("Unable to add physical volume '%s' to "
- "volume group '%s'.", pv_name, vg->name);
- dm_free(pv_name);
- return 0;
- }
- dm_free(pv_name);
- }
-
- (void) _check_pv_dev_sizes(vg);
-
-/* FIXME Decide whether to initialise and add new mdahs to format instance */
-
- return 1;
-}
-
int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_params *pp)
{
struct pv_list *pvl;
@@ -836,7 +724,7 @@ int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_params *pp)
log_debug_metadata("Adding PVs to VG %s.", vg->name);
- if (_vg_bad_status_bits(vg, RESIZEABLE_VG))
+ if (vg_bad_status_bits(vg, RESIZEABLE_VG))
return_0;
dm_list_iterate_items(pvl, &pp->pvs) {
@@ -849,44 +737,20 @@ int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_params *pp)
return 0;
}
- if (!_add_pv_to_vg(vg, pv_dev_name(pvl->pv), pvl->pv, 0)) {
+ if (!add_pv_to_vg(vg, pv_dev_name(pvl->pv), pvl->pv, 0)) {
log_error("PV %s cannot be added to VG %s.",
pv_dev_name(pvl->pv), vg->name);
return 0;
}
}
- (void) _check_pv_dev_sizes(vg);
+ (void) check_pv_dev_sizes(vg);
dm_list_splice(&vg->pv_write_list, &pp->pvs);
return 1;
}
-int vg_reduce(struct volume_group *vg, const char *pv_name)
-{
- struct physical_volume *pv;
- struct pv_list *pvl;
-
- if (!(pvl = find_pv_in_vg(vg, pv_name))) {
- log_error("Physical volume %s not in volume group %s.",
- pv_name, vg->name);
- return 0;
- }
-
- pv = pvl->pv;
-
- if (vgreduce_single(vg->cmd, vg, pv, 0)) {
- dm_list_add(&vg->removed_pvs, &pvl->list);
- return 1;
- }
-
- log_error("Unable to remove physical volume '%s' from "
- "volume group '%s'.", pv_name, vg->name);
-
- return 0;
-}
-
int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag)
{
char *tag_new;
@@ -1573,168 +1437,6 @@ void pvcreate_params_set_defaults(struct pvcreate_params *pp)
dm_list_init(&pp->pvs);
}
-/*
- * See if we may pvcreate on this device.
- * 0 indicates we may not.
- */
-static int _pvcreate_check(struct cmd_context *cmd, const char *name,
- struct pvcreate_params *pp, int *wiped)
-{
- static const char really_init_msg[] = "Really INITIALIZE physical volume";
- static const char not_init_msg[] = "physical volume not initialized";
- struct physical_volume *pv;
- struct device *dev;
- int r = 0;
- int scan_needed = 0;
- int filter_refresh_needed = 0;
- int used;
-
- /* FIXME Check partition type is LVM unless --force is given */
-
- *wiped = 0;
-
- /* Is there a pv here already? */
- pv = find_pv_by_name(cmd, name, 1, 1);
-
- /* Allow partial & exported VGs to be destroyed. */
- /* We must have -ff to overwrite a non orphan */
- if (pv) {
- if (!is_orphan(pv) && pp->force != DONT_PROMPT_OVERRIDE) {
- log_error("Can't initialize physical volume \"%s\" of "
- "volume group \"%s\" without -ff.", name, pv_vg_name(pv));
- goto out;
- }
-
- if ((used = is_used_pv(pv)) < 0)
- goto_out;
-
- if (used && pp->force != DONT_PROMPT_OVERRIDE) {
- log_error("PV %s is used by a VG but its metadata is missing.", name);
- log_error("Can't initialize PV '%s' without -ff.", name);
- goto out;
- }
- }
-
- /* prompt */
- if (pv && !pp->yes) {
- if (is_orphan(pv)) {
- if (used) {
- if (yes_no_prompt("%s \"%s\" that is marked as belonging to a VG [y/n]? ",
- really_init_msg, name) == 'n') {
- log_error("%s: %s", name, not_init_msg);
- goto out;
- }
- }
- } else {
- if (yes_no_prompt("%s \"%s\" of volume group \"%s\" [y/n]? ",
- really_init_msg, name, pv_vg_name(pv)) == 'n') {
- log_error("%s: %s", name, not_init_msg);
- goto out;
- }
- }
- }
-
- if (sigint_caught())
- goto_out;
-
- dev = dev_cache_get(name, cmd->full_filter);
-
- /*
- * Refresh+rescan at the end is needed if:
- * - we don't obtain device list from udev,
- * hence persistent cache file is used
- * and we need to trash it and reevaluate
- * for any changes done outside - adding
- * any new foreign signature which may affect
- * filtering - before we do pvcreate, we
- * need to be sure that we have up-to-date
- * view for filters
- *
- * - we have wiped existing foreign signatures
- * from dev as this may affect what's filtered
- * as well
- *
- *
- * Only rescan at the end is needed if:
- * - we've just checked whether dev is fileterd
- * by MD filter. We do the refresh in-situ,
- * so no need to require the refresh at the
- * end of this fn. This is to allow for
- * wiping MD signature during pvcreate for
- * the dev - the dev would normally be
- * filtered because of MD filter.
- * This is an exception.
- */
-
- /* Is there an md superblock here? */
- if (!dev && md_filtering()) {
- if (!refresh_filters(cmd))
- goto_out;
-
- init_md_filtering(0);
- dev = dev_cache_get(name, cmd->full_filter);
- init_md_filtering(1);
-
- scan_needed = 1;
- } else if (!obtain_device_list_from_udev())
- filter_refresh_needed = scan_needed = 1;
-
- if (!dev) {
- log_error("Device %s not found (or ignored by filtering).", name);
- goto out;
- }
-
- /*
- * This test will fail if the device belongs to an MD array.
- */
- if (!dev_test_excl(dev)) {
- /* FIXME Detect whether device-mapper itself is still using it */
- log_error("Can't open %s exclusively. Mounted filesystem?",
- name);
- goto out;
- }
-
- if (!wipe_known_signatures(cmd, dev, name,
- TYPE_LVM1_MEMBER | TYPE_LVM2_MEMBER,
- 0, pp->yes, pp->force, wiped)) {
- log_error("Aborting pvcreate on %s.", name);
- goto out;
- }
-
- if (*wiped)
- filter_refresh_needed = scan_needed = 1;
-
- if (sigint_caught())
- goto_out;
-
- if (pv && !is_orphan(pv) && pp->force)
- log_warn("WARNING: Forcing physical volume creation on "
- "%s%s%s%s", name,
- !is_orphan(pv) ? " of volume group \"" : "",
- pv_vg_name(pv),
- !is_orphan(pv) ? "\"" : "");
-
- r = 1;
-
-out:
- if (filter_refresh_needed)
- if (!refresh_filters(cmd)) {
- stack;
- r = 0;
- }
-
- if (scan_needed) {
- lvmcache_force_next_label_scan();
- if (!lvmcache_label_scan(cmd)) {
- stack;
- r = 0;
- }
- }
-
- free_pv_fid(pv);
- return r;
-}
-
static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_write *pvw)
{
struct physical_volume *pv = pvw->pv;
@@ -1782,129 +1484,6 @@ static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_write *pvw)
return 1;
}
-static int _verify_pv_create_params(struct pvcreate_params *pp)
-{
- /*
- * FIXME: Some of these checks are duplicates in pvcreate_params_validate.
- */
- if (pp->pva.pvmetadatacopies > 2) {
- log_error("Metadatacopies may only be 0, 1 or 2");
- return 0;
- }
-
- if (pp->pva.data_alignment > UINT32_MAX) {
- log_error("Physical volume data alignment is too big.");
- return 0;
- }
-
- if (pp->pva.data_alignment_offset > UINT32_MAX) {
- log_error("Physical volume data alignment offset is too big.");
- return 0;
- }
-
- return 1;
-}
-
-
-/*
- * pvcreate_vol() - initialize a device with PV label and metadata area
- *
- * Parameters:
- * - pv_name: device path to initialize
- * - pp: parameters to pass to pv_create; if NULL, use default values
- *
- * Returns:
- * NULL: error
- * struct physical_volume * (non-NULL): handle to physical volume created
- */
-struct physical_volume *pvcreate_vol(struct cmd_context *cmd, const char *pv_name,
- struct pvcreate_params *pp, int write_now)
-{
- struct physical_volume *pv = NULL;
- struct device *dev;
- int wiped = 0;
- struct dm_list mdas;
- struct pvcreate_params default_pp;
- char buffer[64] __attribute__((aligned(8)));
- dev_ext_t dev_ext_src;
-
- pvcreate_params_set_defaults(&default_pp);
- if (!pp)
- pp = &default_pp;
-
- if (!_verify_pv_create_params(pp)) {
- goto bad;
- }
-
- if (pp->pva.idp) {
- if ((dev = lvmcache_device_from_pvid(cmd, pp->pva.idp, NULL, NULL)) &&
- (dev != dev_cache_get(pv_name, cmd->full_filter))) {
- if (!id_write_format((const struct id*)&pp->pva.idp->uuid,
- buffer, sizeof(buffer)))
- goto_bad;
- log_error("uuid %s already in use on \"%s\"", buffer,
- dev_name(dev));
- goto bad;
- }
- }
-
- if (!_pvcreate_check(cmd, pv_name, pp, &wiped))
- goto_bad;
-
- if (sigint_caught())
- goto_bad;
-
- /*
- * wipe_known_signatures called in _pvcreate_check fires
- * WATCH event to update udev database. But at the moment,
- * we have no way to synchronize with such event - we may
- * end up still seeing the old info in udev db and pvcreate
- * can fail to proceed because of the device still being
- * filtered (because of the stale info in udev db).
- * Disable udev dev-ext source temporarily here for
- * this reason and rescan with DEV_EXT_NONE dev-ext
- * source (so filters use DEV_EXT_NONE source).
- */
- dev_ext_src = external_device_info_source();
- if (wiped && (dev_ext_src == DEV_EXT_UDEV))
- init_external_device_info_source(DEV_EXT_NONE);
-
- dev = dev_cache_get(pv_name, cmd->full_filter);
-
- init_external_device_info_source(dev_ext_src);
-
- if (!dev) {
- log_error("%s: Couldn't find device. Check your filters?",
- pv_name);
- goto bad;
- }
-
- dm_list_init(&mdas);
-
- if (!(pv = pv_create(cmd, dev, &pp->pva))) {
- log_error("Failed to setup physical volume \"%s\"", pv_name);
- goto bad;
- }
-
- log_verbose("Set up physical volume for \"%s\" with %" PRIu64
- " available sectors", pv_name, pv_size(pv));
-
- pv->status |= UNLABELLED_PV;
- if (write_now) {
- struct pv_to_write pvw;
- pvw.pp = pp;
- pvw.pv = pv;
- pvw.new_pv = 1;
- if (!_pvcreate_write(cmd, &pvw))
- goto bad;
- }
-
- return pv;
-
-bad:
- return NULL;
-}
-
static struct physical_volume *_alloc_pv(struct dm_pool *mem, struct device *dev)
{
struct physical_volume *pv;
@@ -2203,48 +1782,6 @@ struct physical_volume *find_pv(struct volume_group *vg, struct device *dev)
return NULL;
}
-/* FIXME: liblvm todo - make into function that returns handle */
-struct physical_volume *find_pv_by_name(struct cmd_context *cmd,
- const char *pv_name,
- int allow_orphan, int allow_unformatted)
-{
- struct device *dev;
- struct pv_list *pvl;
- struct dm_list *pvslist;
- struct physical_volume *pv = NULL;
-
- lvmcache_seed_infos_from_lvmetad(cmd);
-
- if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
- if (!allow_unformatted)
- log_error("Physical volume %s not found", pv_name);
- return_NULL;
- }
-
- if (!(pvslist = get_pvs(cmd)))
- return_NULL;
-
- dm_list_iterate_items(pvl, pvslist)
- if (pvl->pv->dev == dev)
- pv = pvl->pv;
- else
- free_pv_fid(pvl->pv);
-
- if (!pv && !allow_unformatted)
- log_error("Physical volume %s not found", pv_name);
-
- if (pv && !allow_orphan && is_orphan_vg(pv->vg_name)) {
- log_error("Physical volume %s not in a volume group", pv_name);
- goto bad;
- }
-
- return pv;
-
-bad:
- free_pv_fid(pv);
- return NULL;
-}
-
/* Find segment at a given logical extent in an LV */
struct lv_segment *find_seg_by_le(const struct logical_volume *lv, uint32_t le)
{
@@ -4899,7 +4436,7 @@ struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgnam
if (!(vg = _vg_read(cmd, vgname, vgid, warn_flags, consistent, 0)))
goto_out;
- if (!_check_pv_dev_sizes(vg))
+ if (!check_pv_dev_sizes(vg))
log_warn("One or more devices used as PVs in VG %s "
"have changed sizes.", vg->name);
@@ -5573,8 +5110,7 @@ static int _access_vg_clustered(struct cmd_context *cmd, const struct volume_gro
*
* FIXME Remove the unnecessary duplicate definitions and return bits directly.
*/
-static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
- uint64_t status)
+uint32_t vg_bad_status_bits(const struct volume_group *vg, uint64_t status)
{
uint32_t failure = 0;
@@ -5610,7 +5146,7 @@ static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
*/
int vg_check_status(const struct volume_group *vg, uint64_t status)
{
- return !_vg_bad_status_bits(vg, status);
+ return !vg_bad_status_bits(vg, status);
}
/*
@@ -5830,7 +5366,7 @@ static int _access_vg_systemid(struct cmd_context *cmd, struct volume_group *vg)
}
/*
- * FIXME: move _vg_bad_status_bits() checks in here.
+ * FIXME: move vg_bad_status_bits() checks in here.
*/
static int _vg_access_permitted(struct cmd_context *cmd, struct volume_group *vg,
uint32_t lockd_state, uint32_t *failure)
@@ -5966,7 +5502,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
goto bad;
}
- failure |= _vg_bad_status_bits(vg, status_flags);
+ failure |= vg_bad_status_bits(vg, status_flags);
if (failure)
goto_bad;
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index f3b1c95..0de9ed8 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -353,16 +353,13 @@ unsigned long set_pe_align_offset(struct physical_volume *pv,
int pv_write_orphan(struct cmd_context *cmd, struct physical_volume *pv);
-struct physical_volume *pvcreate_vol(struct cmd_context *cmd, const char *pv_name,
- struct pvcreate_params *pp, int write_now);
-
int check_dev_block_size_for_vg(struct device *dev, const struct volume_group *vg,
unsigned int *max_phys_block_size_found);
+int check_pv_dev_sizes(struct volume_group *vg);
+uint32_t vg_bad_status_bits(const struct volume_group *vg, uint64_t status);
+int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
+ struct physical_volume *pv, int new_pv);
-/* Manipulate PV structures */
-int pv_add(struct volume_group *vg, struct physical_volume *pv);
-int pv_remove(struct volume_group *vg, struct physical_volume *pv);
-struct physical_volume *pv_find(struct volume_group *vg, const char *pv_name);
/* Find a PV within a given VG */
int get_pv_from_vg_by_id(const struct format_type *fmt, const char *vg_name,
@@ -375,10 +372,6 @@ struct logical_volume *find_lv_in_vg_by_lvid(struct volume_group *vg,
struct lv_list *find_lv_in_lv_list(const struct dm_list *ll,
const struct logical_volume *lv);
-/* Return the VG that contains a given LV (based on path given in lv_name) */
-/* or environment var */
-struct volume_group *find_vg_with_lv(const char *lv_name);
-
/* Find LV with given lvid (used during activation) */
struct logical_volume *lv_from_lvid(struct cmd_context *cmd,
const char *lvid_s,
@@ -466,8 +459,6 @@ void lv_calculate_readahead(const struct logical_volume *lv, uint32_t *read_ahea
*/
size_t export_vg_to_buffer(struct volume_group *vg, char **buf);
struct dm_config_tree *export_vg_to_config_tree(struct volume_group *vg);
-struct volume_group *import_vg_from_buffer(const char *buf,
- struct format_instance *fid);
struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft,
struct format_instance *fid);
struct volume_group *import_vg_from_lvmetad_config_tree(const struct dm_config_tree *cft,
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index 2a1754d..d68561c 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -705,179 +705,3 @@ out:
"to repair from archived metadata.");
return r;
}
-
-/*
- * Decide whether it is "safe" to wipe the labels on this device.
- * 0 indicates we may not.
- */
-static int _pvremove_check(struct cmd_context *cmd, const char *name,
- unsigned force_count, unsigned prompt, struct dm_list *pvslist)
-{
- static const char really_wipe_msg[] = "Really WIPE LABELS from physical volume";
- struct device *dev;
- struct label *label;
- struct pv_list *pvl;
- struct physical_volume *pv = NULL;
- int used;
- int r = 0;
-
- /* FIXME Check partition type is LVM unless --force is given */
-
- if (!(dev = dev_cache_get(name, cmd->filter))) {
- log_error("Device %s not found.", name);
- return 0;
- }
-
- /* Is there a pv here already? */
- /* If not, this is an error unless you used -f. */
- if (!label_read(dev, &label, 0)) {
- if (force_count)
- return 1;
- log_error("No PV label found on %s.", name);
- return 0;
- }
-
- dm_list_iterate_items(pvl, pvslist)
- if (pvl->pv->dev == dev)
- pv = pvl->pv;
-
- if (!pv) {
- log_error(INTERNAL_ERROR "Physical Volume %s has a label, "
- "but is neither in a VG nor orphan.", name);
- goto out; /* better safe than sorry */
- }
-
- if (is_orphan(pv)) {
- if ((used = is_used_pv(pv)) < 0)
- goto_out;
-
- if (used) {
- log_warn("WARNING: PV %s is used by a VG but its metadata is missing.", name);
-
- if (force_count < 2)
- goto_bad;
-
- if (!prompt &&
- yes_no_prompt("%s \"%s\" that is marked as belonging to a VG [y/n]? ",
- really_wipe_msg, name) == 'n')
- goto_bad;
- }
- } else {
- log_warn("WARNING: PV %s is used by VG %s (consider using vgreduce).", name, pv_vg_name(pv));
-
- if (force_count < 2)
- goto_bad;
-
- if (!prompt &&
- yes_no_prompt("%s \"%s\" of volume group \"%s\" [y/n]? ",
- really_wipe_msg, name, pv_vg_name(pv)) == 'n')
- goto_bad;
- }
-
- if (force_count)
- log_warn("WARNING: Wiping physical volume label from "
- "%s%s%s%s", name,
- !is_orphan(pv) ? " of volume group \"" : "",
- pv_vg_name(pv),
- !is_orphan(pv) ? "\"" : "");
-
- r = 1;
-bad:
- if (!r) {
- log_error("%s: physical volume label not removed.", name);
-
- if (force_count < 2) /* Show hint as log_error() */
- log_error("(If you are certain you need pvremove, "
- "then confirm by using --force twice.)");
- }
-out:
- return r;
-}
-
-int pvremove_single(struct cmd_context *cmd, const char *pv_name,
- void *handle __attribute__((unused)), unsigned force_count,
- unsigned prompt, struct dm_list *pvslist)
-{
- struct device *dev;
- struct lvmcache_info *info;
- int r = 0;
-
- if (!_pvremove_check(cmd, pv_name, force_count, prompt, pvslist))
- goto out;
-
- if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
- log_error("%s: Couldn't find device. Check your filters?",
- pv_name);
- goto out;
- }
-
- info = lvmcache_info_from_pvid(dev->pvid, dev, 0);
-
- if (!dev_test_excl(dev)) {
- /* FIXME Detect whether device-mapper is still using the device */
- log_error("Can't open %s exclusively - not removing. "
- "Mounted filesystem?", dev_name(dev));
- goto out;
- }
-
- /* Wipe existing label(s) */
- if (!label_remove(dev)) {
- log_error("Failed to wipe existing label(s) on %s", pv_name);
- goto out;
- }
-
- if (info)
- lvmcache_del(info);
-
- if (!lvmetad_pv_gone_by_dev(dev))
- goto_out;
-
- log_print_unless_silent("Labels on physical volume \"%s\" successfully wiped",
- pv_name);
-
- r = 1;
-
-out:
- return r;
-}
-
-int pvremove_many(struct cmd_context *cmd, struct dm_list *pv_names,
- unsigned force_count, unsigned prompt)
-{
- int ret = 1;
- struct dm_list *pvslist = NULL;
- struct pv_list *pvl;
- const struct dm_str_list *pv_name;
-
- if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
- log_error("Can't get lock for orphan PVs");
- return 0;
- }
-
- lvmcache_seed_infos_from_lvmetad(cmd);
-
- if (!(pvslist = get_pvs(cmd))) {
- ret = 0;
- goto_out;
- }
-
- dm_list_iterate_items(pv_name, pv_names) {
- if (!pvremove_single(cmd, pv_name->str, NULL, force_count, prompt, pvslist)) {
- stack;
- ret = 0;
- }
- if (sigint_caught()) {
- ret = 0;
- goto_out;
- }
- }
-
-out:
- unlock_vg(cmd, NULL, VG_ORPHANS);
-
- if (pvslist)
- dm_list_iterate_items(pvl, pvslist)
- free_pv_fid(pvl->pv);
-
- return ret;
-}
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index 580e942..20ceda3 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -13,7 +13,7 @@
*/
#include "lib.h"
-#include "metadata.h"
+#include "metadata-exported.h"
#include "lvm-string.h"
#include "defaults.h"
#include "segtype.h"
diff --git a/liblvm/lvm_pv.c b/liblvm/lvm_pv.c
index 26e3cf1..143545b 100644
--- a/liblvm/lvm_pv.c
+++ b/liblvm/lvm_pv.c
@@ -14,7 +14,7 @@
#include <stddef.h>
#include "lib.h"
-#include "metadata.h"
+#include "metadata-exported.h"
#include "lvm-string.h"
#include "str_list.h"
#include "lvm_misc.h"
6 years, 6 months
master - tidy: Add missing underscores to statics.
by Alasdair Kergon
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f1cc5b12fd80c3c6224...
Commit: f1cc5b12fd80c3c62247fccfb2e5537aef27533d
Parent: 327d9d59be6f7179b2e0a756deaa0f9a196e0651
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Oct 18 15:57:46 2017 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Oct 18 15:58:13 2017 +0100
tidy: Add missing underscores to statics.
---
lib/cache/lvmetad.c | 6 +-
lib/commands/toolcontext.c | 10 +-
lib/device/dev-md.c | 13 +-
lib/device/dev-swap.c | 3 +-
lib/locking/cluster_locking.c | 6 +-
lib/metadata/lv_manip.c | 4 +-
lib/metadata/metadata.c | 18 +-
lib/metadata/pv_manip.c | 22 +--
lib/metadata/raid_manip.c | 10 +-
lib/mm/memlock.c | 6 +-
lib/report/report.c | 15 +-
lib/report/values.h | 4 +-
libdaemon/client/config-util.c | 4 +-
libdaemon/server/daemon-log.c | 8 +-
libdaemon/server/daemon-server.c | 4 +-
libdm/ioctl/libdm-iface.c | 4 +-
libdm/libdm-config.c | 6 +-
libdm/mm/pool-fast.c | 8 +-
libdm/mm/pool.c | 6 +-
tools/command.c | 397 +++++++++++++++++++-------------------
tools/dmsetup.c | 12 +-
tools/lvchange.c | 8 +-
tools/lvmcmdline.c | 18 +-
tools/lvpoll.c | 4 +-
tools/lvscan.c | 6 +-
tools/polldaemon.c | 22 +-
tools/pvcreate.c | 12 +-
tools/pvmove.c | 12 +-
tools/toollib.c | 10 +-
tools/vgcfgbackup.c | 8 +-
tools/vgchange.c | 8 +-
tools/vgconvert.c | 8 +-
tools/vgdisplay.c | 8 +-
tools/vgimport.c | 10 +-
tools/vgremove.c | 8 +-
tools/vgscan.c | 8 +-
tools/vgsplit.c | 4 +-
37 files changed, 358 insertions(+), 362 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 1ba844f..1fd9091 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -39,7 +39,7 @@ static int64_t _lvmetad_update_timeout;
static int _found_lvm1_metadata = 0;
-static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct volume_group *vg);
+static struct volume_group *_lvmetad_pvscan_vg(struct cmd_context *cmd, struct volume_group *vg);
static uint64_t _monotonic_seconds(void)
{
@@ -1090,7 +1090,7 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
* invalidated the cached vg.
*/
if (rescan) {
- if (!(vg2 = lvmetad_pvscan_vg(cmd, vg))) {
+ if (!(vg2 = _lvmetad_pvscan_vg(cmd, vg))) {
log_debug_lvmetad("VG %s from lvmetad not found during rescan.", vgname);
fid = NULL;
release_vg(vg);
@@ -1787,7 +1787,7 @@ static int _lvmetad_pvscan_single(struct metadata_area *mda, void *baton)
* the VG, and that PV may have been reused for another VG.
*/
-static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct volume_group *vg)
+static struct volume_group *_lvmetad_pvscan_vg(struct cmd_context *cmd, struct volume_group *vg)
{
char pvid_s[ID_LEN + 1] __attribute__((aligned(8)));
char uuid[64] __attribute__((aligned(8)));
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 3cb3cf8..e742df5 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -54,7 +54,7 @@
# include <malloc.h>
#endif
-static const size_t linebuffer_size = 4096;
+static const size_t _linebuffer_size = 4096;
/*
* Copy the input string, removing invalid characters.
@@ -1873,7 +1873,7 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
/* Set in/out stream buffering before glibc */
if (set_buffering) {
/* Allocate 2 buffers */
- if (!(cmd->linebuffer = dm_malloc(2 * linebuffer_size))) {
+ if (!(cmd->linebuffer = dm_malloc(2 * _linebuffer_size))) {
log_error("Failed to allocate line buffer.");
goto out;
}
@@ -1884,7 +1884,7 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
(flags & O_ACCMODE) != O_WRONLY) {
if (!reopen_standard_stream(&stdin, "r"))
goto_out;
- if (setvbuf(stdin, cmd->linebuffer, _IOLBF, linebuffer_size)) {
+ if (setvbuf(stdin, cmd->linebuffer, _IOLBF, _linebuffer_size)) {
log_sys_error("setvbuf", "");
goto out;
}
@@ -1895,8 +1895,8 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
(flags & O_ACCMODE) != O_RDONLY) {
if (!reopen_standard_stream(&stdout, "w"))
goto_out;
- if (setvbuf(stdout, cmd->linebuffer + linebuffer_size,
- _IOLBF, linebuffer_size)) {
+ if (setvbuf(stdout, cmd->linebuffer + _linebuffer_size,
+ _IOLBF, _linebuffer_size)) {
log_sys_error("setvbuf", "");
goto out;
}
diff --git a/lib/device/dev-md.c b/lib/device/dev-md.c
index d0e69a1..6e0a312 100644
--- a/lib/device/dev-md.c
+++ b/lib/device/dev-md.c
@@ -261,8 +261,7 @@ out:
/*
* Retrieve chunk size from md device using sysfs.
*/
-static unsigned long dev_md_chunk_size(struct dev_types *dt,
- struct device *dev)
+static unsigned long _dev_md_chunk_size(struct dev_types *dt, struct device *dev)
{
const char *attribute = "chunk_size";
unsigned long chunk_size_bytes = 0UL;
@@ -280,7 +279,7 @@ static unsigned long dev_md_chunk_size(struct dev_types *dt,
/*
* Retrieve level from md device using sysfs.
*/
-static int dev_md_level(struct dev_types *dt, struct device *dev)
+static int _dev_md_level(struct dev_types *dt, struct device *dev)
{
char level_string[MD_MAX_SYSFS_SIZE];
const char *attribute = "level";
@@ -303,7 +302,7 @@ static int dev_md_level(struct dev_types *dt, struct device *dev)
/*
* Retrieve raid_disks from md device using sysfs.
*/
-static int dev_md_raid_disks(struct dev_types *dt, struct device *dev)
+static int _dev_md_raid_disks(struct dev_types *dt, struct device *dev)
{
const char *attribute = "raid_disks";
int raid_disks = 0;
@@ -327,15 +326,15 @@ unsigned long dev_md_stripe_width(struct dev_types *dt, struct device *dev)
unsigned long stripe_width_sectors = 0UL;
int level, raid_disks, data_disks;
- chunk_size_sectors = dev_md_chunk_size(dt, dev);
+ chunk_size_sectors = _dev_md_chunk_size(dt, dev);
if (!chunk_size_sectors)
return 0;
- level = dev_md_level(dt, dev);
+ level = _dev_md_level(dt, dev);
if (level < 0)
return 0;
- raid_disks = dev_md_raid_disks(dt, dev);
+ raid_disks = _dev_md_raid_disks(dt, dev);
if (!raid_disks)
return 0;
diff --git a/lib/device/dev-swap.c b/lib/device/dev-swap.c
index 6bce535..7d16dd1 100644
--- a/lib/device/dev-swap.c
+++ b/lib/device/dev-swap.c
@@ -20,8 +20,7 @@
#define MAX_PAGESIZE (64 * 1024)
#define SIGNATURE_SIZE 10
-static int
-_swap_detect_signature(const char *buf)
+static int _swap_detect_signature(const char *buf)
{
if (memcmp(buf, "SWAP-SPACE", 10) == 0 ||
memcmp(buf, "SWAPSPACE2", 10) == 0)
diff --git a/lib/locking/cluster_locking.c b/lib/locking/cluster_locking.c
index a04d9c7..e2f8123 100644
--- a/lib/locking/cluster_locking.c
+++ b/lib/locking/cluster_locking.c
@@ -515,7 +515,7 @@ static int _lock_resource(struct cmd_context *cmd, const char *resource,
return _lock_for_cluster(cmd, clvmd_cmd, flags, lockname);
}
-static int decode_lock_type(const char *response)
+static int _decode_lock_type(const char *response)
{
if (!response)
return LCK_NULL;
@@ -566,8 +566,8 @@ int query_resource(const char *resource, const char *node, int *mode)
* If two nodes report different locks,
* something is broken - just return more important mode.
*/
- if (decode_lock_type(response[i].response) > *mode)
- *mode = decode_lock_type(response[i].response);
+ if (_decode_lock_type(response[i].response) > *mode)
+ *mode = _decode_lock_type(response[i].response);
log_debug_locking("Lock held for %s, node %s : %s", resource,
response[i].node, response[i].response);
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index e71e2eb..c0e9a99 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4719,7 +4719,7 @@ static int _lvresize_adjust_policy(const struct logical_volume *lv,
return 1;
}
-static uint32_t lvseg_get_stripes(struct lv_segment *seg, uint32_t *stripesize)
+static uint32_t _lvseg_get_stripes(struct lv_segment *seg, uint32_t *stripesize)
{
uint32_t s;
struct lv_segment *seg_mirr;
@@ -5165,7 +5165,7 @@ static int _lvresize_adjust_extents(struct logical_volume *lv,
seg_physical_extents = seg->area_len * seg->area_count; /* FIXME Also metadata, cow etc. */
/* Check for underlying stripe sizes */
- seg_stripes = lvseg_get_stripes(seg, &seg_stripesize);
+ seg_stripes = _lvseg_get_stripes(seg, &seg_stripesize);
if (seg_is_mirrored(seg))
seg_mirrors = lv_mirror_count(seg->lv);
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 496dbee..15e08e6 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -177,8 +177,8 @@ void del_pvl_from_vgs(struct volume_group *vg, struct pv_list *pvl)
* 1 - success
* FIXME: remove pv_name - obtain safely from pv
*/
-static int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
- struct physical_volume *pv, int new_pv)
+static int _add_pv_to_vg(struct volume_group *vg, const char *pv_name,
+ struct physical_volume *pv, int new_pv)
{
struct pv_list *pvl;
struct format_instance *fid = vg->fid;
@@ -720,9 +720,9 @@ static int _check_pv_dev_sizes(struct volume_group *vg)
* - max_phys_block_size: largest physical block size found amongst PVs in a VG
*
*/
-static int vg_extend_single_pv(struct volume_group *vg, char *pv_name,
- struct pvcreate_params *pp,
- unsigned int *max_phys_block_size)
+static int _vg_extend_single_pv(struct volume_group *vg, char *pv_name,
+ struct pvcreate_params *pp,
+ unsigned int *max_phys_block_size)
{
struct physical_volume *pv;
struct pv_to_write *pvw;
@@ -746,7 +746,7 @@ static int vg_extend_single_pv(struct volume_group *vg, char *pv_name,
max_phys_block_size)))
goto_bad;
- if (!add_pv_to_vg(vg, pv_name, pv, new_pv))
+ if (!_add_pv_to_vg(vg, pv_name, pv, new_pv))
goto_bad;
if ((pv->fmt->features & FMT_PV_FLAGS) ||
@@ -774,7 +774,7 @@ bad:
* source file. All the following and more are only used by liblvm:
*
* . vg_extend()
- * . vg_extend_single_pv()
+ * . _vg_extend_single_pv()
* . pvcreate_vol()
* . _pvcreate_check()
* . _pvcreate_write()
@@ -813,7 +813,7 @@ int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names
return 0;
}
dm_unescape_colons_and_at_signs(pv_name, NULL, NULL);
- if (!vg_extend_single_pv(vg, pv_name, pp, &max_phys_block_size)) {
+ if (!_vg_extend_single_pv(vg, pv_name, pp, &max_phys_block_size)) {
log_error("Unable to add physical volume '%s' to "
"volume group '%s'.", pv_name, vg->name);
dm_free(pv_name);
@@ -849,7 +849,7 @@ int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_params *pp)
return 0;
}
- if (!add_pv_to_vg(vg, pv_dev_name(pvl->pv), pvl->pv, 0)) {
+ if (!_add_pv_to_vg(vg, pv_dev_name(pvl->pv), pvl->pv, 0)) {
log_error("PV %s cannot be added to VG %s.",
pv_dev_name(pvl->pv), vg->name);
return 0;
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index f37bc4c..2a1754d 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -84,8 +84,8 @@ int peg_dup(struct dm_pool *mem, struct dm_list *peg_new, struct dm_list *peg_ol
}
/* Find segment at a given physical extent in a PV */
-static struct pv_segment *find_peg_by_pe(const struct physical_volume *pv,
- uint32_t pe)
+static struct pv_segment *_find_peg_by_pe(const struct physical_volume *pv,
+ uint32_t pe)
{
struct pv_segment *pvseg;
@@ -137,7 +137,7 @@ int pv_split_segment(struct dm_pool *mem,
if (pe == pv->pe_count)
goto out;
- if (!(pvseg = find_peg_by_pe(pv, pe))) {
+ if (!(pvseg = _find_peg_by_pe(pv, pe))) {
log_error("Segment with extent %" PRIu32 " in PV %s not found",
pe, pv_dev_name(pv));
return 0;
@@ -158,7 +158,7 @@ out:
return 1;
}
-static struct pv_segment null_pv_segment = {
+static struct pv_segment _null_pv_segment = {
.pv = NULL,
.pe = 0,
};
@@ -172,7 +172,7 @@ struct pv_segment *assign_peg_to_lvseg(struct physical_volume *pv,
/* Missing format1 PV */
if (!pv)
- return &null_pv_segment;
+ return &_null_pv_segment;
if (!pv_split_segment(seg->lv->vg->vgmem, pv, pe, &peg) ||
!pv_split_segment(seg->lv->vg->vgmem, pv, pe + area_len, NULL))
@@ -556,9 +556,7 @@ static int _extend_pv(struct physical_volume *pv, struct volume_group *vg,
* Resize a PV in a VG, adding or removing segments as needed.
* New size must fit within pv->size.
*/
-static int pv_resize(struct physical_volume *pv,
- struct volume_group *vg,
- uint64_t size)
+static int _pv_resize(struct physical_volume *pv, struct volume_group *vg, uint64_t size)
{
uint32_t old_pe_count, new_pe_count = 0;
@@ -674,7 +672,7 @@ int pv_resize_single(struct cmd_context *cmd,
log_verbose("Resizing volume \"%s\" to %" PRIu64 " sectors.",
pv_name, size);
- if (!pv_resize(pv, vg, size))
+ if (!_pv_resize(pv, vg, size))
goto_out;
log_verbose("Updating physical volume \"%s\"", pv_name);
@@ -712,8 +710,8 @@ out:
* Decide whether it is "safe" to wipe the labels on this device.
* 0 indicates we may not.
*/
-static int pvremove_check(struct cmd_context *cmd, const char *name,
- unsigned force_count, unsigned prompt, struct dm_list *pvslist)
+static int _pvremove_check(struct cmd_context *cmd, const char *name,
+ unsigned force_count, unsigned prompt, struct dm_list *pvslist)
{
static const char really_wipe_msg[] = "Really WIPE LABELS from physical volume";
struct device *dev;
@@ -804,7 +802,7 @@ int pvremove_single(struct cmd_context *cmd, const char *pv_name,
struct lvmcache_info *info;
int r = 0;
- if (!pvremove_check(cmd, pv_name, force_count, prompt, pvslist))
+ if (!_pvremove_check(cmd, pv_name, force_count, prompt, pvslist))
goto out;
if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 691ff58..f065a4c 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1321,7 +1321,7 @@ static int _cmp_level(const struct segment_type *t1, const struct segment_type *
*
* Return 1 if same, else != 1
*/
-static int is_same_level(const struct segment_type *t1, const struct segment_type *t2)
+static int _is_same_level(const struct segment_type *t1, const struct segment_type *t2)
{
return _cmp_level(t1, t2);
}
@@ -2331,7 +2331,7 @@ static int _raid_reshape(struct logical_volume *lv,
if (!seg_is_reshapable_raid(seg))
return_0;
- if (!is_same_level(seg->segtype, new_segtype))
+ if (!_is_same_level(seg->segtype, new_segtype))
return_0;
if (!(old_image_count = seg->area_count))
@@ -2510,7 +2510,7 @@ static int _reshape_requested(const struct logical_volume *lv, const struct segm
return 0;
/* Switching raid levels is a takeover, no reshape */
- if (!is_same_level(seg->segtype, segtype))
+ if (!_is_same_level(seg->segtype, segtype))
return 0;
/* Possible takeover in case #data_copies == #stripes */
@@ -6042,7 +6042,7 @@ static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_fr
const struct segment_type *segtype_sav = *segtype;
/* Bail out if same RAID level is requested. */
- if (is_same_level(seg_from->segtype, *segtype))
+ if (_is_same_level(seg_from->segtype, *segtype))
return 1;
log_debug("Checking LV %s requested %s segment type for convenience",
@@ -6296,7 +6296,7 @@ static int _conversion_options_allowed(const struct lv_segment *seg_from,
if (r &&
!yes &&
strcmp((*segtype_to)->name, SEG_TYPE_NAME_MIRROR) && /* "mirror" is prompted for later */
- !is_same_level(seg_from->segtype, *segtype_to)) { /* Prompt here for takeover */
+ !_is_same_level(seg_from->segtype, *segtype_to)) { /* Prompt here for takeover */
const char *basic_fmt = "Are you sure you want to convert %s LV %s";
const char *type_fmt = " to %s type";
const char *question_fmt = "? [y/n]: ";
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index da90144..389e213 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -396,7 +396,7 @@ static int _memlock_maps(struct cmd_context *cmd, lvmlock_t lock, size_t *mstats
#define _GNU_SOURCE
#endif
#include <dlfcn.h>
-static const unsigned char INSTRUCTION_HLT = 0x94;
+static const unsigned char _instruction_hlt = 0x94;
static char _mmap_orig;
static unsigned char *_mmap_addr;
#ifdef __i386__
@@ -429,8 +429,8 @@ static int _disable_mmap(void)
}
_mmap_orig = *_mmap_addr;
}
- log_debug_mem("Remapping mmap entry %02x to %02x.", _mmap_orig, INSTRUCTION_HLT);
- *_mmap_addr = INSTRUCTION_HLT;
+ log_debug_mem("Remapping mmap entry %02x to %02x.", _mmap_orig, _instruction_hlt);
+ *_mmap_addr = _instruction_hlt;
#ifdef __i386__
if (!_mmap64_addr) {
diff --git a/lib/report/report.c b/lib/report/report.c
index c32df71..6d6289e 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -38,8 +38,7 @@ struct lvm_report_object {
struct label *label;
};
-static uint32_t log_seqnum = 1;
-
+static uint32_t _log_seqnum = 1;
/*
* Enum for field_num index to use in per-field reserved value definition.
@@ -1091,10 +1090,10 @@ static void *_lv_time_handler_get_dynamic_value(struct dm_report *rh,
return result;
}
-static int lv_time_handler(struct dm_report *rh, struct dm_pool *mem,
- uint32_t field_num,
- dm_report_reserved_action_t action,
- const void *data_in, const void **data_out)
+static int _lv_time_handler(struct dm_report *rh, struct dm_pool *mem,
+ uint32_t field_num,
+ dm_report_reserved_action_t action,
+ const void *data_in, const void **data_out)
{
*data_out = NULL;
if (!data_in)
@@ -4128,7 +4127,7 @@ int report_cmdlog(void *handle, const char *type, const char *context,
const char *object_group_id, const char *msg,
int current_errno, int ret_code)
{
- struct cmd_log_item log_item = {log_seqnum++, type, context, object_type_name,
+ struct cmd_log_item log_item = {_log_seqnum++, type, context, object_type_name,
object_name ? : "", object_id ? : "",
object_group ? : "", object_group_id ? : "",
msg ? : "", current_errno, ret_code};
@@ -4141,7 +4140,7 @@ int report_cmdlog(void *handle, const char *type, const char *context,
void report_reset_cmdlog_seqnum(void)
{
- log_seqnum = 1;
+ _log_seqnum = 1;
}
int report_current_object_cmdlog(const char *type, const char *msg, int32_t ret_code)
diff --git a/lib/report/values.h b/lib/report/values.h
index 652689b..7c53651 100644
--- a/lib/report/values.h
+++ b/lib/report/values.h
@@ -90,8 +90,8 @@ FIELD_RESERVED_VALUE(NOFLAG, lv_read_ahead, lv_read_ahead_auto, "", &_siz_max, "
FIELD_RESERVED_VALUE(NAMED, lv_when_full, lv_when_full_error, "", "error", "error", "error when full", "error if no space")
FIELD_RESERVED_VALUE(NAMED, lv_when_full, lv_when_full_queue, "", "queue", "queue", "queue when full", "queue if no space")
FIELD_RESERVED_VALUE(NOFLAG, lv_when_full, lv_when_full_undef, "", "", "", "undefined")
-FIELD_RESERVED_VALUE(NAMED | RANGE | FUZZY | DYNAMIC, lv_time, lv_time_fuzzy, "", lv_time_handler, NULL)
-FIELD_RESERVED_VALUE(NAMED | RANGE | FUZZY | DYNAMIC, lv_time_removed, lv_time_removed_fuzzy, "", lv_time_handler, NULL)
+FIELD_RESERVED_VALUE(NAMED | RANGE | FUZZY | DYNAMIC, lv_time, lv_time_fuzzy, "", _lv_time_handler, NULL)
+FIELD_RESERVED_VALUE(NAMED | RANGE | FUZZY | DYNAMIC, lv_time_removed, lv_time_removed_fuzzy, "", _lv_time_handler, NULL)
/* Reserved values for SEG fields */
FIELD_RESERVED_VALUE(NOFLAG, cache_policy, cache_policy_undef, "", "", "", "undefined")
diff --git a/libdaemon/client/config-util.c b/libdaemon/client/config-util.c
index 5b6cfb8..32f36f6 100644
--- a/libdaemon/client/config-util.c
+++ b/libdaemon/client/config-util.c
@@ -304,7 +304,7 @@ struct dm_config_node *config_make_nodes(struct dm_config_tree *cft,
}
/* Test if the doubles are close enough to be considered equal */
-static int close_enough(double d1, double d2)
+static int _close_enough(double d1, double d2)
{
return fabs(d1 - d2) < DBL_EPSILON;
}
@@ -320,7 +320,7 @@ int compare_value(struct dm_config_value *a, struct dm_config_value *b)
switch (a->type) {
case DM_CFG_STRING: r = strcmp(a->v.str, b->v.str); break;
- case DM_CFG_FLOAT: r = close_enough(a->v.f, b->v.f) ? 0 : (a->v.f > b->v.f) ? 1 : -1; break;
+ case DM_CFG_FLOAT: r = _close_enough(a->v.f, b->v.f) ? 0 : (a->v.f > b->v.f) ? 1 : -1; break;
case DM_CFG_INT: r = (a->v.i == b->v.i) ? 0 : (a->v.i > b->v.i) ? 1 : -1; break;
case DM_CFG_EMPTY_ARRAY: return 0;
}
diff --git a/libdaemon/server/daemon-log.c b/libdaemon/server/daemon-log.c
index e0fe188..3be5573 100644
--- a/libdaemon/server/daemon-log.c
+++ b/libdaemon/server/daemon-log.c
@@ -24,7 +24,7 @@ struct backend {
void (*log)(log_state *s, void **state, int type, const char *message);
};
-static void log_syslog(log_state *s, void **state, int type, const char *message)
+static void _log_syslog(log_state *s, void **state, int type, const char *message)
{
int prio;
@@ -44,7 +44,7 @@ static void log_syslog(log_state *s, void **state, int type, const char *message
syslog(prio, "%s", message);
}
-static void log_stderr(log_state *s, void **state, int type, const char *message)
+static void _log_stderr(log_state *s, void **state, int type, const char *message)
{
const char *prefix;
@@ -60,8 +60,8 @@ static void log_stderr(log_state *s, void **state, int type, const char *message
}
struct backend backend[] = {
- { DAEMON_LOG_OUTLET_SYSLOG, log_syslog },
- { DAEMON_LOG_OUTLET_STDERR, log_stderr },
+ { DAEMON_LOG_OUTLET_SYSLOG, _log_syslog },
+ { DAEMON_LOG_OUTLET_STDERR, _log_stderr },
{ 0, 0 }
};
diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c
index 2ffdf40..3b19883 100644
--- a/libdaemon/server/daemon-server.c
+++ b/libdaemon/server/daemon-server.c
@@ -498,7 +498,7 @@ fail:
return NULL;
}
-static int handle_connect(daemon_state s)
+static int _handle_connect(daemon_state s)
{
thread_state *ts;
struct sockaddr_un sockaddr;
@@ -651,7 +651,7 @@ void daemon_start(daemon_state s)
perror("select error");
if (FD_ISSET(s.socket_fd, &in)) {
timeout_count = 0;
- handle_connect(s);
+ _handle_connect(s);
}
_reap(s, 0);
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index 100d0cc..8bee24b 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -594,7 +594,7 @@ int dm_cookie_supported(void)
_dm_version_minor >= 15);
}
-static int dm_inactive_supported(void)
+static int _dm_inactive_supported(void)
{
int inactive_supported = 0;
@@ -1231,7 +1231,7 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
dmi->flags |= DM_SECURE_DATA_FLAG;
}
if (dmt->query_inactive_table) {
- if (!dm_inactive_supported())
+ if (!_dm_inactive_supported())
log_warn("WARNING: Inactive table query unsupported "
"by kernel. It will use live table.");
dmi->flags |= DM_QUERY_INACTIVE_TABLE_FLAG;
diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c
index d85effb..e1ca210 100644
--- a/libdm/libdm-config.c
+++ b/libdm/libdm-config.c
@@ -72,7 +72,7 @@ static struct dm_config_node *_create_node(struct dm_pool *mem);
static char *_dup_tok(struct parser *p);
static char *_dup_token(struct dm_pool *mem, const char *b, const char *e);
-static const int sep = '/';
+static const int _sep = '/';
#define MAX_INDENT 32
@@ -530,11 +530,11 @@ static struct dm_config_node *_find_or_make_node(struct dm_pool *mem,
while (cn || mem) {
/* trim any leading slashes */
- while (*path && (*path == sep))
+ while (*path && (*path == _sep))
path++;
/* find the end of this segment */
- for (e = path; *e && (*e != sep); e++) ;
+ for (e = path; *e && (*e != _sep); e++) ;
/* hunt for the node */
cn_found = NULL;
diff --git a/libdm/mm/pool-fast.c b/libdm/mm/pool-fast.c
index 65ca856..614e903 100644
--- a/libdm/mm/pool-fast.c
+++ b/libdm/mm/pool-fast.c
@@ -269,16 +269,16 @@ static struct chunk *_new_chunk(struct dm_pool *p, size_t s)
p->spare_chunk = 0;
} else {
#ifdef DEBUG_ENFORCE_POOL_LOCKING
- if (!pagesize) {
- pagesize = getpagesize(); /* lvm_pagesize(); */
- pagesize_mask = pagesize - 1;
+ if (!_pagesize) {
+ _pagesize = getpagesize(); /* lvm_pagesize(); */
+ _pagesize_mask = _pagesize - 1;
}
/*
* Allocate page aligned size so malloc could work.
* Otherwise page fault would happen from pool unrelated
* memory writes of internal malloc pointers.
*/
-# define aligned_malloc(s) (posix_memalign((void**)&c, pagesize, \
+# define aligned_malloc(s) (posix_memalign((void**)&c, _pagesize, \
ALIGN_ON_PAGE(s)) == 0)
#else
# define aligned_malloc(s) (c = dm_malloc(s))
diff --git a/libdm/mm/pool.c b/libdm/mm/pool.c
index c1cb61e..1321cc7 100644
--- a/libdm/mm/pool.c
+++ b/libdm/mm/pool.c
@@ -35,9 +35,9 @@ void dm_pools_check_leaks(void);
* - Only pool-fast is properly handled for now.
* - Checksum is slower compared to mprotect.
*/
-static size_t pagesize = 0;
-static size_t pagesize_mask = 0;
-#define ALIGN_ON_PAGE(size) (((size) + (pagesize_mask)) & ~(pagesize_mask))
+static size_t _pagesize = 0;
+static size_t _pagesize_mask = 0;
+#define ALIGN_ON_PAGE(size) (((size) + (_pagesize_mask)) & ~(_pagesize_mask))
#endif
#ifdef DEBUG_POOL
diff --git a/tools/command.c b/tools/command.c
index 52a3766..17b5eb4 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -83,7 +83,7 @@ static void *dm_pool_alloc(void *p, size_t size)
struct cmd_context;
struct arg_values;
-/* needed to include args.h */
+/* needed to include vals.h */
static inline int yes_no_arg(struct cmd_context *cmd, struct arg_values *av) { return 0; }
static inline int activation_arg(struct cmd_context *cmd, struct arg_values *av) { return 0; }
static inline int cachemetadataformat_arg(struct cmd_context *cmd, struct arg_values *av) { return 0; }
@@ -273,14 +273,14 @@ struct command lvm_all;
/* saves OO_FOO lines (groups of optional options) to include in multiple defs */
-static int oo_line_count;
+static int _oo_line_count;
#define MAX_OO_LINES 256
struct oo_line {
char *name;
char *line;
};
-static struct oo_line oo_lines[MAX_OO_LINES];
+static struct oo_line _oo_lines[MAX_OO_LINES];
#define REQUIRED 1 /* required option */
#define OPTIONAL 0 /* optional option */
@@ -297,14 +297,14 @@ static struct oo_line oo_lines[MAX_OO_LINES];
*/
#include "command-lines-input.h"
-static void add_optional_opt_line(struct cmd_context *cmdtool, struct command *cmd, int argc, char *argv[]);
+static void __add_optional_opt_line(struct cmd_context *cmdtool, struct command *cmd, int argc, char *argv[]);
/*
* modifies buf, replacing the sep characters with \0
* argv pointers point to positions in buf
*/
-static char *split_line(char *buf, int *argc, char **argv, char sep)
+static char *_split_line(char *buf, int *argc, char **argv, char sep)
{
char *p = buf, *rp = NULL;
int i;
@@ -331,7 +331,7 @@ static char *split_line(char *buf, int *argc, char **argv, char sep)
/* convert value string, e.g. Number, to foo_VAL enum */
-static int val_str_to_num(char *str)
+static int _val_str_to_num(char *str)
{
char name[32];
char *new;
@@ -357,7 +357,7 @@ static int val_str_to_num(char *str)
#define MAX_LONG_OPT_NAME_LEN 32
-static int opt_str_to_num(struct command *cmd, char *str)
+static int _opt_str_to_num(struct command *cmd, char *str)
{
char long_name[MAX_LONG_OPT_NAME_LEN];
char *p;
@@ -432,7 +432,7 @@ int command_id_to_enum(const char *str)
/* "lv_is_prop" to is_prop_LVP */
-static int lvp_name_to_enum(struct command *cmd, char *str)
+static int _lvp_name_to_enum(struct command *cmd, char *str)
{
int i;
@@ -448,7 +448,7 @@ static int lvp_name_to_enum(struct command *cmd, char *str)
/* "type" to type_LVT */
-static int lvt_name_to_enum(struct command *cmd, char *str)
+static int _lvt_name_to_enum(struct command *cmd, char *str)
{
int i;
@@ -464,9 +464,9 @@ static int lvt_name_to_enum(struct command *cmd, char *str)
/* LV_<type> to <type>_LVT */
-static int lv_to_enum(struct command *cmd, char *name)
+static int _lv_to_enum(struct command *cmd, char *name)
{
- return lvt_name_to_enum(cmd, name + 3);
+ return _lvt_name_to_enum(cmd, name + 3);
}
/*
@@ -480,7 +480,7 @@ static int lv_to_enum(struct command *cmd, char *name)
#define LVTYPE_LEN 64
-static uint64_t lv_to_bits(struct command *cmd, char *name)
+static uint64_t _lv_to_bits(struct command *cmd, char *name)
{
char buf[LVTYPE_LEN];
char *argv[MAX_LINE_ARGC];
@@ -492,20 +492,20 @@ static uint64_t lv_to_bits(struct command *cmd, char *name)
memset(buf, 0, sizeof(buf));
strncpy(buf, name, LVTYPE_LEN-1);
- split_line(buf, &argc, argv, '_');
+ _split_line(buf, &argc, argv, '_');
/* 0 is "LV" */
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "new"))
continue;
- lvt_enum = lvt_name_to_enum(cmd, argv[i]);
+ lvt_enum = _lvt_name_to_enum(cmd, argv[i]);
lvt_bits |= lvt_enum_to_bit(lvt_enum);
}
return lvt_bits;
}
-static struct command_name *find_command_name(const char *name)
+static struct command_name *_find_command_name(const char *name)
{
int i;
@@ -522,17 +522,17 @@ static struct command_name *find_command_name(const char *name)
return NULL;
}
-static const char *is_command_name(char *str)
+static const char *_is_command_name(char *str)
{
const struct command_name *c;
- if ((c = find_command_name(str)))
+ if ((c = _find_command_name(str)))
return c->name;
return NULL;
}
-static int is_opt_name(char *str)
+static int _is_opt_name(char *str)
{
if ((str[0] == '-') && (str[1] == '-'))
return 1;
@@ -548,7 +548,7 @@ static int is_opt_name(char *str)
* can be empty if the --select option is used.
*/
-static int is_pos_name(char *str)
+static int _is_pos_name(char *str)
{
switch (str[0]) {
case 'V': return (str[1] == 'G'); /* VG */
@@ -562,56 +562,56 @@ static int is_pos_name(char *str)
return 0;
}
-static int is_oo_definition(char *str)
+static int _is_oo_definition(char *str)
{
if (!strncmp(str, "OO_", 3) && strchr(str, ':'))
return 1;
return 0;
}
-static int is_oo_line(char *str)
+static int _is_oo_line(char *str)
{
if (!strncmp(str, "OO:", 3))
return 1;
return 0;
}
-static int is_io_line(char *str)
+static int _is_io_line(char *str)
{
if (!strncmp(str, "IO:", 3))
return 1;
return 0;
}
-static int is_op_line(char *str)
+static int _is_op_line(char *str)
{
if (!strncmp(str, "OP:", 3))
return 1;
return 0;
}
-static int is_desc_line(char *str)
+static int _is_desc_line(char *str)
{
if (!strncmp(str, "DESC:", 5))
return 1;
return 0;
}
-static int is_flags_line(char *str)
+static int _is_flags_line(char *str)
{
if (!strncmp(str, "FLAGS:", 6))
return 1;
return 0;
}
-static int is_rule_line(char *str)
+static int _is_rule_line(char *str)
{
if (!strncmp(str, "RULE:", 5))
return 1;
return 0;
}
-static int is_id_line(char *str)
+static int _is_id_line(char *str)
{
if (!strncmp(str, "ID:", 3))
return 1;
@@ -624,7 +624,7 @@ static int is_id_line(char *str)
* like VG, VG|LV, VG|LV_linear|LV_striped, etc.
*/
-static void set_pos_def(struct command *cmd, char *str, struct arg_def *def)
+static void _set_pos_def(struct command *cmd, char *str, struct arg_def *def)
{
char *argv[MAX_LINE_ARGC];
int argc;
@@ -632,12 +632,12 @@ static void set_pos_def(struct command *cmd, char *str, struct arg_def *def)
int val_enum;
int i;
- split_line(str, &argc, argv, '|');
+ _split_line(str, &argc, argv, '|');
for (i = 0; i < argc; i++) {
name = argv[i];
- val_enum = val_str_to_num(name);
+ val_enum = _val_str_to_num(name);
if (!val_enum) {
log_error("Parsing command defs: unknown pos arg: %s.", name);
@@ -648,7 +648,7 @@ static void set_pos_def(struct command *cmd, char *str, struct arg_def *def)
def->val_bits |= val_enum_to_bit(val_enum);
if ((val_enum == lv_VAL) && strchr(name, '_'))
- def->lvt_bits = lv_to_bits(cmd, name);
+ def->lvt_bits = _lv_to_bits(cmd, name);
if (strstr(name, "_new")) {
if (val_enum == lv_VAL)
@@ -664,7 +664,7 @@ static void set_pos_def(struct command *cmd, char *str, struct arg_def *def)
* Parse str for anything that can follow --option.
*/
-static void set_opt_def(struct cmd_context *cmdtool, struct command *cmd, char *str, struct arg_def *def)
+static void _set_opt_def(struct cmd_context *cmdtool, struct command *cmd, char *str, struct arg_def *def)
{
char *argv[MAX_LINE_ARGC];
int argc;
@@ -672,12 +672,12 @@ static void set_opt_def(struct cmd_context *cmdtool, struct command *cmd, char *
int val_enum;
int i;
- split_line(str, &argc, argv, '|');
+ _split_line(str, &argc, argv, '|');
for (i = 0; i < argc; i++) {
name = argv[i];
- val_enum = val_str_to_num(name);
+ val_enum = _val_str_to_num(name);
if (!val_enum) {
/* a literal number or string */
@@ -713,7 +713,7 @@ static void set_opt_def(struct cmd_context *cmdtool, struct command *cmd, char *
if (val_enum == lv_VAL) {
if (strchr(name, '_'))
- def->lvt_bits = lv_to_bits(cmd, name);
+ def->lvt_bits = _lv_to_bits(cmd, name);
}
if (strstr(name, "_new")) {
@@ -736,13 +736,13 @@ static void set_opt_def(struct cmd_context *cmdtool, struct command *cmd, char *
* oo->line = "--opt1 ...";
*/
-static void add_oo_definition_line(const char *name, const char *line)
+static void _add_oo_definition_line(const char *name, const char *line)
{
struct oo_line *oo;
char *colon;
char *start;
- oo = &oo_lines[oo_line_count++];
+ oo = &_oo_lines[_oo_line_count++];
if (!(oo->name = dm_strdup(name))) {
log_error("Failer to duplicate name %s.", name);
@@ -765,14 +765,14 @@ static void add_oo_definition_line(const char *name, const char *line)
/* Support OO_FOO: continuing on multiple lines. */
-static void append_oo_definition_line(const char *new_line)
+static void _append_oo_definition_line(const char *new_line)
{
struct oo_line *oo;
char *old_line;
char *line;
int len;
- oo = &oo_lines[oo_line_count-1];
+ oo = &_oo_lines[_oo_line_count - 1];
old_line = oo->line;
@@ -793,7 +793,7 @@ static void append_oo_definition_line(const char *new_line)
#define OO_NAME_LEN 64
-static char *get_oo_line(const char *str)
+static char *_get_oo_line(const char *str)
{
char *name;
char *end;
@@ -806,10 +806,10 @@ static char *get_oo_line(const char *str)
if ((end = strchr(str2, ',')))
*end = '\0';
- for (i = 0; i < oo_line_count; i++) {
- name = oo_lines[i].name;
+ for (i = 0; i < _oo_line_count; i++) {
+ name = _oo_lines[i].name;
if (!strcmp(name, str2))
- return oo_lines[i].line;
+ return _oo_lines[i].line;
}
return NULL;
}
@@ -819,14 +819,14 @@ static char *get_oo_line(const char *str)
* i.e. include common options from an OO_FOO definition.
*/
-static void include_optional_opt_args(struct cmd_context *cmdtool, struct command *cmd, const char *str)
+static void _include_optional_opt_args(struct cmd_context *cmdtool, struct command *cmd, const char *str)
{
char *oo_line;
char *line;
char *line_argv[MAX_LINE_ARGC];
int line_argc;
- if (!(oo_line = get_oo_line(str))) {
+ if (!(oo_line = _get_oo_line(str))) {
log_error("Parsing command defs: no OO line found for %s.", str);
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
@@ -837,8 +837,8 @@ static void include_optional_opt_args(struct cmd_context *cmdtool, struct comman
return;
}
- split_line(line, &line_argc, line_argv, ' ');
- add_optional_opt_line(cmdtool, cmd, line_argc, line_argv);
+ _split_line(line, &line_argc, line_argv, ' ');
+ __add_optional_opt_line(cmdtool, cmd, line_argc, line_argv);
dm_free(line);
}
@@ -847,7 +847,7 @@ static void include_optional_opt_args(struct cmd_context *cmdtool, struct comman
* This function sets the opt_args.opt value for it.
*/
-static void add_opt_arg(struct command *cmd, char *str,
+static void _add_opt_arg(struct command *cmd, char *str,
int *takes_arg, int *already, int required)
{
char *comma;
@@ -855,7 +855,7 @@ static void add_opt_arg(struct command *cmd, char *str,
int i;
/* opt_arg.opt set here */
- /* opt_arg.def will be set in update_prev_opt_arg() if needed */
+ /* opt_arg.def will be set in _update_prev_opt_arg() if needed */
if ((comma = strchr(str, ',')))
*comma = '\0';
@@ -870,7 +870,7 @@ static void add_opt_arg(struct command *cmd, char *str,
goto skip;
}
- opt = opt_str_to_num(cmd, str);
+ opt = _opt_str_to_num(cmd, str);
/* If the binary-search finds uuidstr_ARG switch to uuid_ARG */
if (opt == uuidstr_ARG)
@@ -903,7 +903,7 @@ skip:
* for the value that appears after --option.
*/
-static void update_prev_opt_arg(struct cmd_context *cmdtool, struct command *cmd, char *str, int required)
+static void _update_prev_opt_arg(struct cmd_context *cmdtool, struct command *cmd, char *str, int required)
{
struct arg_def def = { 0 };
char *comma;
@@ -915,12 +915,12 @@ static void update_prev_opt_arg(struct cmd_context *cmdtool, struct command *cmd
}
/* opt_arg.def set here */
- /* opt_arg.opt was previously set in add_opt_arg() when --foo was read */
+ /* opt_arg.opt was previously set in _add_opt_arg() when --foo was read */
if ((comma = strchr(str, ',')))
*comma = '\0';
- set_opt_def(cmdtool, cmd, str, &def);
+ _set_opt_def(cmdtool, cmd, str, &def);
if (required > 0)
cmd->required_opt_args[cmd->ro_count-1].def = def;
@@ -935,13 +935,13 @@ static void update_prev_opt_arg(struct cmd_context *cmdtool, struct command *cmd
* This function sets the pos_args.pos and pos_args.def.
*/
-static void add_pos_arg(struct command *cmd, char *str, int required)
+static void _add_pos_arg(struct command *cmd, char *str, int required)
{
struct arg_def def = { 0 };
/* pos_arg.pos and pos_arg.def are set here */
- set_pos_def(cmd, str, &def);
+ _set_pos_def(cmd, str, &def);
if (required) {
cmd->required_pos_args[cmd->rp_count].pos = cmd->pos_count++;
@@ -956,7 +956,7 @@ static void add_pos_arg(struct command *cmd, char *str, int required)
/* Process something that follows a pos arg, which is not a new pos arg. */
-static void update_prev_pos_arg(struct command *cmd, char *str, int required)
+static void _update_prev_pos_arg(struct command *cmd, char *str, int required)
{
struct arg_def *def;
@@ -978,7 +978,7 @@ static void update_prev_pos_arg(struct command *cmd, char *str, int required)
/* Process what follows OO:, which are the optional opt args for the cmd def. */
-static void add_optional_opt_line(struct cmd_context *cmdtool, struct command *cmd, int argc, char *argv[])
+static void __add_optional_opt_line(struct cmd_context *cmdtool, struct command *cmd, int argc, char *argv[])
{
int takes_arg = 0;
int already;
@@ -990,12 +990,12 @@ static void add_optional_opt_line(struct cmd_context *cmdtool, struct command *c
already = 0;
- if (is_opt_name(argv[i]))
- add_opt_arg(cmd, argv[i], &takes_arg, &already, OPTIONAL);
+ if (_is_opt_name(argv[i]))
+ _add_opt_arg(cmd, argv[i], &takes_arg, &already, OPTIONAL);
else if (!strncmp(argv[i], "OO_", 3))
- include_optional_opt_args(cmdtool, cmd, argv[i]);
+ _include_optional_opt_args(cmdtool, cmd, argv[i]);
else if (takes_arg)
- update_prev_opt_arg(cmdtool, cmd, argv[i], OPTIONAL);
+ _update_prev_opt_arg(cmdtool, cmd, argv[i], OPTIONAL);
else {
log_error("Parsing command defs: can't parse argc %d argv %s prev %s.",
i, argv[i], argv[i-1]);
@@ -1010,7 +1010,7 @@ static void add_optional_opt_line(struct cmd_context *cmdtool, struct command *c
/* Process what follows IO:, which are the ignore options for the cmd def. */
-static void add_ignore_opt_line(struct cmd_context *cmdtool, struct command *cmd, int argc, char *argv[])
+static void _add_ignore_opt_line(struct cmd_context *cmdtool, struct command *cmd, int argc, char *argv[])
{
int takes_arg = 0;
int i;
@@ -1018,10 +1018,10 @@ static void add_ignore_opt_line(struct cmd_context *cmdtool, struct command *cmd
for (i = 0; i < argc; i++) {
if (!i && !strncmp(argv[i], "IO:", 3))
continue;
- if (is_opt_name(argv[i]))
- add_opt_arg(cmd, argv[i], &takes_arg, NULL, IGNORE);
+ if (_is_opt_name(argv[i]))
+ _add_opt_arg(cmd, argv[i], &takes_arg, NULL, IGNORE);
else if (takes_arg)
- update_prev_opt_arg(cmdtool, cmd, argv[i], IGNORE);
+ _update_prev_opt_arg(cmdtool, cmd, argv[i], IGNORE);
else {
log_error("Parsing command defs: can't parse argc %d argv %s prev %s.",
i, argv[i], argv[i-1]);
@@ -1033,30 +1033,30 @@ static void add_ignore_opt_line(struct cmd_context *cmdtool, struct command *cmd
/* Process what follows OP:, which are optional pos args for the cmd def. */
-static void add_optional_pos_line(struct command *cmd, int argc, char *argv[])
+static void _add_optional_pos_line(struct command *cmd, int argc, char *argv[])
{
int i;
for (i = 0; i < argc; i++) {
if (!i && !strncmp(argv[i], "OP:", 3))
continue;
- if (is_pos_name(argv[i]))
- add_pos_arg(cmd, argv[i], OPTIONAL);
+ if (_is_pos_name(argv[i]))
+ _add_pos_arg(cmd, argv[i], OPTIONAL);
else
- update_prev_pos_arg(cmd, argv[i], OPTIONAL);
+ _update_prev_pos_arg(cmd, argv[i], OPTIONAL);
}
}
-static void add_required_opt_line(struct cmd_context *cmdtool, struct command *cmd, int argc, char *argv[])
+static void _add_required_opt_line(struct cmd_context *cmdtool, struct command *cmd, int argc, char *argv[])
{
int takes_arg = 0;
int i;
for (i = 0; i < argc; i++) {
- if (is_opt_name(argv[i]))
- add_opt_arg(cmd, argv[i], &takes_arg, NULL, REQUIRED);
+ if (_is_opt_name(argv[i]))
+ _add_opt_arg(cmd, argv[i], &takes_arg, NULL, REQUIRED);
else if (takes_arg)
- update_prev_opt_arg(cmdtool, cmd, argv[i], REQUIRED);
+ _update_prev_opt_arg(cmdtool, cmd, argv[i], REQUIRED);
else {
log_error("Parsing command defs: can't parse argc %d argv %s prev %s.",
i, argv[i], argv[i-1]);
@@ -1075,14 +1075,14 @@ static void add_required_opt_line(struct cmd_context *cmdtool, struct command *c
* this special case.
*/
-static void include_required_opt_args(struct cmd_context *cmdtool, struct command *cmd, char *str)
+static void _include_required_opt_args(struct cmd_context *cmdtool, struct command *cmd, char *str)
{
char *oo_line;
char *line;
char *line_argv[MAX_LINE_ARGC];
int line_argc;
- if (!(oo_line = get_oo_line(str))) {
+ if (!(oo_line = _get_oo_line(str))) {
log_error("Parsing command defs: no OO line found for %s.", str);
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
@@ -1093,14 +1093,14 @@ static void include_required_opt_args(struct cmd_context *cmdtool, struct comman
return;
}
- split_line(line, &line_argc, line_argv, ' ');
- add_required_opt_line(cmdtool, cmd, line_argc, line_argv);
+ _split_line(line, &line_argc, line_argv, ' ');
+ _add_required_opt_line(cmdtool, cmd, line_argc, line_argv);
dm_free(line);
}
/* Process what follows command_name, which are required opt/pos args. */
-static void add_required_line(struct cmd_context *cmdtool, struct command *cmd, int argc, char *argv[])
+static void _add_required_line(struct cmd_context *cmdtool, struct command *cmd, int argc, char *argv[])
{
int i;
int takes_arg;
@@ -1110,32 +1110,32 @@ static void add_required_line(struct cmd_context *cmdtool, struct command *cmd,
for (i = 1; i < argc; i++) {
- if (is_opt_name(argv[i])) {
+ if (_is_opt_name(argv[i])) {
/* add new required_opt_arg */
- add_opt_arg(cmd, argv[i], &takes_arg, NULL, REQUIRED);
+ _add_opt_arg(cmd, argv[i], &takes_arg, NULL, REQUIRED);
prev_was_opt = 1;
prev_was_pos = 0;
} else if (prev_was_opt && takes_arg) {
/* set value for previous required_opt_arg */
- update_prev_opt_arg(cmdtool, cmd, argv[i], REQUIRED);
+ _update_prev_opt_arg(cmdtool, cmd, argv[i], REQUIRED);
prev_was_opt = 0;
prev_was_pos = 0;
- } else if (is_pos_name(argv[i])) {
+ } else if (_is_pos_name(argv[i])) {
/* add new required_pos_arg */
- add_pos_arg(cmd, argv[i], REQUIRED);
+ _add_pos_arg(cmd, argv[i], REQUIRED);
prev_was_opt = 0;
prev_was_pos = 1;
} else if (!strncmp(argv[i], "OO_", 3)) {
/* one required_opt_arg is required, special case lv/vgchange */
cmd->cmd_flags |= CMD_FLAG_ONE_REQUIRED_OPT;
- include_required_opt_args(cmdtool, cmd, argv[i]);
+ _include_required_opt_args(cmdtool, cmd, argv[i]);
} else if (prev_was_pos) {
/* set property for previous required_pos_arg */
- update_prev_pos_arg(cmd, argv[i], REQUIRED);
+ _update_prev_pos_arg(cmd, argv[i], REQUIRED);
} else {
log_error("Parsing command defs: can't parse argc %d argv %s prev %s.",
i, argv[i], argv[i-1]);
@@ -1145,7 +1145,7 @@ static void add_required_line(struct cmd_context *cmdtool, struct command *cmd,
}
}
-static void add_flags(struct command *cmd, char *line)
+static void _add_flags(struct command *cmd, char *line)
{
if (strstr(line, "SECONDARY_SYNTAX"))
cmd->cmd_flags |= CMD_FLAG_SECONDARY_SYNTAX;
@@ -1155,7 +1155,7 @@ static void add_flags(struct command *cmd, char *line)
#define MAX_RULE_OPTS 64
-static void add_rule(struct cmd_context *cmdtool, struct command *cmd, char *line)
+static void _add_rule(struct cmd_context *cmdtool, struct command *cmd, char *line)
{
struct cmd_rule *rule;
char *line_argv[MAX_LINE_ARGC];
@@ -1172,7 +1172,7 @@ static void add_rule(struct cmd_context *cmdtool, struct command *cmd, char *lin
rule = &cmd->rules[cmd->rule_count++];
- split_line(line, &line_argc, line_argv, ' ');
+ _split_line(line, &line_argc, line_argv, ' ');
for (i = 0; i < line_argc; i++) {
arg = line_argv[i];
@@ -1212,13 +1212,13 @@ static void add_rule(struct cmd_context *cmdtool, struct command *cmd, char *lin
}
if (check)
- rule->check_opts[rule->check_opts_count++] = opt_str_to_num(cmd, arg);
+ rule->check_opts[rule->check_opts_count++] = _opt_str_to_num(cmd, arg);
else
- rule->opts[rule->opts_count++] = opt_str_to_num(cmd, arg);
+ rule->opts[rule->opts_count++] = _opt_str_to_num(cmd, arg);
}
else if (!strncmp(arg, "LV_", 3)) {
- lvt_enum = lv_to_enum(cmd, arg);
+ lvt_enum = _lv_to_enum(cmd, arg);
if (check)
rule->check_lvt_bits |= lvt_enum_to_bit(lvt_enum);
@@ -1227,7 +1227,7 @@ static void add_rule(struct cmd_context *cmdtool, struct command *cmd, char *lin
}
else if (!strncmp(arg, "lv_is_", 6)) {
- lvp_enum = lvp_name_to_enum(cmd, arg);
+ lvp_enum = _lvp_name_to_enum(cmd, arg);
if (check)
rule->check_lvp_bits |= lvp_enum_to_bit(lvp_enum);
@@ -1239,7 +1239,7 @@ static void add_rule(struct cmd_context *cmdtool, struct command *cmd, char *lin
/* The given option is common to all lvm commands (set in lvm_all). */
-static int is_lvm_all_opt(int opt)
+static int _is_lvm_all_opt(int opt)
{
int oo;
@@ -1335,26 +1335,27 @@ int command_has_alternate_extents(const char *name)
return 0;
}
-static int long_name_compare(const void *on1, const void *on2)
+static int _long_name_compare(const void *on1, const void *on2)
{
const struct opt_name * const *optname1 = on1;
const struct opt_name * const *optname2 = on2;
+
return strcmp((*optname1)->long_opt + 2, (*optname2)->long_opt + 2);
}
/* Create list of option names for printing alphabetically. */
-static void create_opt_names_alpha(void)
+static void _create_opt_names_alpha(void)
{
int i;
for (i = 0; i < ARG_COUNT; i++)
opt_names_alpha[i] = &opt_names[i];
- qsort(opt_names_alpha, ARG_COUNT, sizeof(long), long_name_compare);
+ qsort(opt_names_alpha, ARG_COUNT, sizeof(long), _long_name_compare);
}
-static int copy_line(char *line, int max_line, int *position)
+static int _copy_line(char *line, int max_line, int *position)
{
int p = *position;
int i = 0;
@@ -1398,11 +1399,11 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
if (run_name && !strcmp(run_name, "help"))
run_name = NULL;
- create_opt_names_alpha();
+ _create_opt_names_alpha();
/* Process each line of command-lines-input.h (from command-lines.in) */
- while (copy_line(line, MAX_LINE, ©_pos)) {
+ while (_copy_line(line, MAX_LINE, ©_pos)) {
if (line[0] == '\n')
break;
@@ -1410,13 +1411,13 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
*n = '\0';
memcpy(line_orig, line, sizeof(line));
- split_line(line, &line_argc, line_argv, ' ');
+ _split_line(line, &line_argc, line_argv, ' ');
if (!line_argc)
continue;
/* New cmd def begins: command_name <required opt/pos args> */
- if ((name = is_command_name(line_argv[0]))) {
+ if ((name = _is_command_name(line_argv[0]))) {
if (cmd_count >= COMMAND_COUNT) {
return 0;
}
@@ -1448,10 +1449,10 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
skip = 0;
cmd->pos_count = 1;
- add_required_line(cmdtool, cmd, line_argc, line_argv);
+ _add_required_line(cmdtool, cmd, line_argc, line_argv);
/* Every cmd gets the OO_ALL options */
- include_optional_opt_args(cmdtool, cmd, "OO_ALL:");
+ _include_optional_opt_args(cmdtool, cmd, "OO_ALL:");
continue;
}
@@ -1460,7 +1461,7 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
* context of the existing command[].
*/
- if (is_desc_line(line_argv[0]) && !skip && cmd) {
+ if (_is_desc_line(line_argv[0]) && !skip && cmd) {
char *desc = dm_pool_strdup(cmdtool->libmem, line_orig);
if (cmd->desc) {
int newlen = strlen(cmd->desc) + strlen(desc) + 2;
@@ -1479,17 +1480,17 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
continue;
}
- if (is_flags_line(line_argv[0]) && !skip && cmd) {
- add_flags(cmd, line_orig);
+ if (_is_flags_line(line_argv[0]) && !skip && cmd) {
+ _add_flags(cmd, line_orig);
continue;
}
- if (is_rule_line(line_argv[0]) && !skip && cmd) {
- add_rule(cmdtool, cmd, line_orig);
+ if (_is_rule_line(line_argv[0]) && !skip && cmd) {
+ _add_rule(cmdtool, cmd, line_orig);
continue;
}
- if (is_id_line(line_argv[0]) && cmd) {
+ if (_is_id_line(line_argv[0]) && cmd) {
cmd->command_id = dm_pool_strdup(cmdtool->libmem, line_argv[1]);
if (!cmd->command_id) {
@@ -1501,8 +1502,8 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
}
/* OO_FOO: ... */
- if (is_oo_definition(line_argv[0])) {
- add_oo_definition_line(line_argv[0], line_orig);
+ if (_is_oo_definition(line_argv[0])) {
+ _add_oo_definition_line(line_argv[0], line_orig);
prev_was_oo_def = 1;
prev_was_oo = 0;
prev_was_op = 0;
@@ -1510,8 +1511,8 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
}
/* OO: ... */
- if (is_oo_line(line_argv[0]) && !skip && cmd) {
- add_optional_opt_line(cmdtool, cmd, line_argc, line_argv);
+ if (_is_oo_line(line_argv[0]) && !skip && cmd) {
+ __add_optional_opt_line(cmdtool, cmd, line_argc, line_argv);
prev_was_oo_def = 0;
prev_was_oo = 1;
prev_was_op = 0;
@@ -1519,8 +1520,8 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
}
/* OP: ... */
- if (is_op_line(line_argv[0]) && !skip && cmd) {
- add_optional_pos_line(cmd, line_argc, line_argv);
+ if (_is_op_line(line_argv[0]) && !skip && cmd) {
+ _add_optional_pos_line(cmd, line_argc, line_argv);
prev_was_oo_def = 0;
prev_was_oo = 0;
prev_was_op = 1;
@@ -1528,8 +1529,8 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
}
/* IO: ... */
- if (is_io_line(line_argv[0]) && !skip && cmd) {
- add_ignore_opt_line(cmdtool, cmd, line_argc, line_argv);
+ if (_is_io_line(line_argv[0]) && !skip && cmd) {
+ _add_ignore_opt_line(cmdtool, cmd, line_argc, line_argv);
prev_was_oo = 0;
prev_was_op = 0;
continue;
@@ -1538,17 +1539,17 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
/* handle OO_FOO:, OO:, OP: continuing on multiple lines */
if (prev_was_oo_def) {
- append_oo_definition_line(line_orig);
+ _append_oo_definition_line(line_orig);
continue;
}
if (prev_was_oo && cmd) {
- add_optional_opt_line(cmdtool, cmd, line_argc, line_argv);
+ __add_optional_opt_line(cmdtool, cmd, line_argc, line_argv);
continue;
}
if (prev_was_op && cmd) {
- add_optional_pos_line(cmd, line_argc, line_argv);
+ _add_optional_pos_line(cmd, line_argc, line_argv);
continue;
}
@@ -1561,15 +1562,15 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
return 0;
}
- include_optional_opt_args(cmdtool, &lvm_all, "OO_ALL");
+ _include_optional_opt_args(cmdtool, &lvm_all, "OO_ALL");
- for (i = 0; i < oo_line_count; i++) {
- struct oo_line *oo = &oo_lines[i];
+ for (i = 0; i < _oo_line_count; i++) {
+ struct oo_line *oo = &_oo_lines[i];
dm_free(oo->name);
dm_free(oo->line);
}
- memset(&oo_lines, 0, sizeof(oo_lines));
- oo_line_count = 0;
+ memset(&_oo_lines, 0, sizeof(_oo_lines));
+ _oo_line_count = 0;
return 1;
}
@@ -1665,7 +1666,7 @@ void configure_command_option_values(const char *name)
/* type_LVT to "type" */
-static const char *lvt_enum_to_name(int lvt_enum)
+static const char *_lvt_enum_to_name(int lvt_enum)
{
return lv_types[lvt_enum].name;
}
@@ -1706,7 +1707,7 @@ static void _print_usage_description(struct command *cmd)
}
}
-static void print_val_usage(struct command *cmd, int opt_enum, int val_enum)
+static void _print_val_usage(struct command *cmd, int opt_enum, int val_enum)
{
int is_relative_opt = (opt_enum == size_ARG) ||
(opt_enum == extents_ARG) ||
@@ -1732,7 +1733,7 @@ static void print_val_usage(struct command *cmd, int opt_enum, int val_enum)
printf("%s", val_names[val_enum].usage);
}
-static void print_usage_def(struct command *cmd, int opt_enum, struct arg_def *def)
+static void _print_usage_def(struct command *cmd, int opt_enum, struct arg_def *def)
{
int val_enum;
int lvt_enum;
@@ -1749,14 +1750,14 @@ static void print_usage_def(struct command *cmd, int opt_enum, struct arg_def *d
else {
if (sep) printf("|");
- print_val_usage(cmd, opt_enum, val_enum);
+ _print_val_usage(cmd, opt_enum, val_enum);
sep = 1;
}
if (val_enum == lv_VAL && def->lvt_bits) {
for (lvt_enum = 1; lvt_enum < LVT_COUNT; lvt_enum++) {
if (lvt_bit_is_set(def->lvt_bits, lvt_enum))
- printf("_%s", lvt_enum_to_name(lvt_enum));
+ printf("_%s", _lvt_enum_to_name(lvt_enum));
}
}
@@ -1773,7 +1774,7 @@ static void print_usage_def(struct command *cmd, int opt_enum, struct arg_def *d
void print_usage(struct command *cmd, int longhelp, int desc_first)
{
- struct command_name *cname = find_command_name(cmd->name);
+ struct command_name *cname = _find_command_name(cmd->name);
int onereq = (cmd->cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) ? 1 : 0;
int include_extents = 0;
int ro, rp, oo, op, opt_enum, first;
@@ -1813,7 +1814,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
if (cmd->required_opt_args[ro].def.val_bits) {
printf(" ");
- print_usage_def(cmd, opt_enum, &cmd->required_opt_args[ro].def);
+ _print_usage_def(cmd, opt_enum, &cmd->required_opt_args[ro].def);
}
}
@@ -1837,7 +1838,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
if (cmd->required_opt_args[ro].def.val_bits) {
printf(" ");
- print_usage_def(cmd, opt_enum, &cmd->required_opt_args[ro].def);
+ _print_usage_def(cmd, opt_enum, &cmd->required_opt_args[ro].def);
}
}
@@ -1858,7 +1859,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
if (cmd->required_opt_args[ro].def.val_bits) {
printf(" ");
- print_usage_def(cmd, opt_enum, &cmd->required_opt_args[ro].def);
+ _print_usage_def(cmd, opt_enum, &cmd->required_opt_args[ro].def);
}
}
}
@@ -1869,7 +1870,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
for (rp = 0; rp < cmd->rp_count; rp++) {
if (cmd->required_pos_args[rp].def.val_bits) {
printf(" ");
- print_usage_def(cmd, 0, &cmd->required_pos_args[rp].def);
+ _print_usage_def(cmd, 0, &cmd->required_pos_args[rp].def);
}
}
}
@@ -1883,7 +1884,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
if (cmd->oo_count) {
if (include_extents) {
printf("\n\t[ -l|--extents ");
- print_val_usage(cmd, extents_ARG, opt_names[extents_ARG].val_enum);
+ _print_val_usage(cmd, extents_ARG, opt_names[extents_ARG].val_enum);
printf(" ]");
}
@@ -1901,7 +1902,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
* see print_common_options_lvm()
*/
- if (is_lvm_all_opt(opt_enum))
+ if (_is_lvm_all_opt(opt_enum))
continue;
/*
@@ -1921,7 +1922,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
printf(" -%c|%s", opt_names[opt_enum].short_opt, opt_names[opt_enum].long_opt);
if (cmd->optional_opt_args[oo].def.val_bits) {
printf(" ");
- print_usage_def(cmd, opt_enum, &cmd->optional_opt_args[oo].def);
+ _print_usage_def(cmd, opt_enum, &cmd->optional_opt_args[oo].def);
}
printf(" ]");
@@ -1941,7 +1942,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
* see print_common_options_lvm()
*/
- if (is_lvm_all_opt(opt_enum))
+ if (_is_lvm_all_opt(opt_enum))
continue;
/*
@@ -1961,7 +1962,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
printf(" %s", opt_names[opt_enum].long_opt);
if (cmd->optional_opt_args[oo].def.val_bits) {
printf(" ");
- print_usage_def(cmd, opt_enum, &cmd->optional_opt_args[oo].def);
+ _print_usage_def(cmd, opt_enum, &cmd->optional_opt_args[oo].def);
}
printf(" ]");
@@ -1980,7 +1981,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
for (op = 0; op < cmd->op_count; op++) {
if (cmd->optional_pos_args[op].def.val_bits) {
printf(" ");
- print_usage_def(cmd, 0, &cmd->optional_pos_args[op].def);
+ _print_usage_def(cmd, 0, &cmd->optional_pos_args[op].def);
}
}
}
@@ -2014,7 +2015,7 @@ void print_usage_common_lvm(struct command_name *cname, struct command *cmd)
printf(" -%c|%s", opt_names[opt_enum].short_opt, opt_names[opt_enum].long_opt);
if (lvm_all.optional_opt_args[oo].def.val_bits) {
printf(" ");
- print_usage_def(cmd, opt_enum, &lvm_all.optional_opt_args[oo].def);
+ _print_usage_def(cmd, opt_enum, &lvm_all.optional_opt_args[oo].def);
}
printf(" ]");
}
@@ -2032,7 +2033,7 @@ void print_usage_common_lvm(struct command_name *cname, struct command *cmd)
printf(" %s", opt_names[opt_enum].long_opt);
if (lvm_all.optional_opt_args[oo].def.val_bits) {
printf(" ");
- print_usage_def(cmd, opt_enum, &lvm_all.optional_opt_args[oo].def);
+ _print_usage_def(cmd, opt_enum, &lvm_all.optional_opt_args[oo].def);
}
printf(" ]");
}
@@ -2060,7 +2061,7 @@ void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
if (!cname->common_options[opt_enum])
continue;
- if (is_lvm_all_opt(opt_enum))
+ if (_is_lvm_all_opt(opt_enum))
continue;
if (!opt_names[opt_enum].short_opt)
@@ -2075,7 +2076,7 @@ void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
printf(" -%c|%s", opt_names[opt_enum].short_opt, opt_names[opt_enum].long_opt);
if (cmd->optional_opt_args[oo].def.val_bits) {
printf(" ");
- print_usage_def(cmd, opt_enum, &cmd->optional_opt_args[oo].def);
+ _print_usage_def(cmd, opt_enum, &cmd->optional_opt_args[oo].def);
}
break;
}
@@ -2088,7 +2089,7 @@ void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
if (!cname->common_options[opt_enum])
continue;
- if (is_lvm_all_opt(opt_enum))
+ if (_is_lvm_all_opt(opt_enum))
continue;
if (opt_names[opt_enum].short_opt)
@@ -2103,7 +2104,7 @@ void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
printf(" %s", opt_names[opt_enum].long_opt);
if (cmd->optional_opt_args[oo].def.val_bits) {
printf(" ");
- print_usage_def(cmd, opt_enum, &cmd->optional_opt_args[oo].def);
+ _print_usage_def(cmd, opt_enum, &cmd->optional_opt_args[oo].def);
}
break;
}
@@ -2185,7 +2186,7 @@ void print_usage_notes(struct command_name *cname)
* Otherwise, this function has to be updated in
* sync with any string changes in vals.h
*/
-static void print_val_man(struct command_name *cname, int opt_enum, int val_enum)
+static void _print_val_man(struct command_name *cname, int opt_enum, int val_enum)
{
const char *str;
char *line;
@@ -2296,7 +2297,7 @@ static void print_val_man(struct command_name *cname, int opt_enum, int val_enum
if (strchr(str, '|')) {
line = dm_strdup(str);
- split_line(line, &line_argc, line_argv, '|');
+ _split_line(line, &line_argc, line_argv, '|');
for (i = 0; i < line_argc; i++) {
if (i)
printf("|");
@@ -2312,7 +2313,7 @@ static void print_val_man(struct command_name *cname, int opt_enum, int val_enum
printf("\\fB%s\\fP", str);
}
-static void print_def_man(struct command_name *cname, int opt_enum, struct arg_def *def, int usage)
+static void _print_def_man(struct command_name *cname, int opt_enum, struct arg_def *def, int usage)
{
int val_enum;
int lvt_enum;
@@ -2333,7 +2334,7 @@ static void print_def_man(struct command_name *cname, int opt_enum, struct arg_d
if (!usage || !val_names[val_enum].usage)
printf("\\fI%s\\fP", val_names[val_enum].name);
else
- print_val_man(cname, opt_enum, val_enum);
+ _print_val_man(cname, opt_enum, val_enum);
sep = 1;
}
@@ -2342,7 +2343,7 @@ static void print_def_man(struct command_name *cname, int opt_enum, struct arg_d
printf("\\fI");
for (lvt_enum = 1; lvt_enum < LVT_COUNT; lvt_enum++) {
if (lvt_bit_is_set(def->lvt_bits, lvt_enum))
- printf("_%s", lvt_enum_to_name(lvt_enum));
+ printf("_%s", _lvt_enum_to_name(lvt_enum));
}
printf("\\fP");
}
@@ -2358,7 +2359,7 @@ static void print_def_man(struct command_name *cname, int opt_enum, struct arg_d
}
#define LONG_OPT_NAME_LEN 64
-static const char *man_long_opt_name(const char *cmdname, int opt_enum)
+static const char *_man_long_opt_name(const char *cmdname, int opt_enum)
{
static char long_opt_name[LONG_OPT_NAME_LEN];
const char *long_opt;
@@ -2409,7 +2410,7 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
int need_ro_indent_end = 0;
int include_extents = 0;
- if (!(cname = find_command_name(cmd->name)))
+ if (!(cname = _find_command_name(cmd->name)))
return;
printf("\\fB%s\\fP", lvmname);
@@ -2453,15 +2454,15 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
if (opt_names[opt_enum].short_opt) {
printf(" \\fB-%c\\fP|\\fB%s\\fP",
opt_names[opt_enum].short_opt,
- man_long_opt_name(cmd->name, opt_enum));
+ _man_long_opt_name(cmd->name, opt_enum));
} else {
printf(" ");
- printf(" \\fB%s\\fP", man_long_opt_name(cmd->name, opt_enum));
+ printf(" \\fB%s\\fP", _man_long_opt_name(cmd->name, opt_enum));
}
if (cmd->required_opt_args[ro].def.val_bits) {
printf(" ");
- print_def_man(cname, opt_enum, &cmd->required_opt_args[ro].def, 1);
+ _print_def_man(cname, opt_enum, &cmd->required_opt_args[ro].def, 1);
}
sep++;
@@ -2484,11 +2485,11 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
printf(".ad l\n");
printf(" ");
- printf(" \\fB%s\\fP", man_long_opt_name(cmd->name, opt_enum));
+ printf(" \\fB%s\\fP", _man_long_opt_name(cmd->name, opt_enum));
if (cmd->required_opt_args[ro].def.val_bits) {
printf(" ");
- print_def_man(cname, opt_enum, &cmd->required_opt_args[ro].def, 1);
+ _print_def_man(cname, opt_enum, &cmd->required_opt_args[ro].def, 1);
}
sep++;
@@ -2504,7 +2505,7 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
for (rp = 0; rp < cmd->rp_count; rp++) {
if (cmd->required_pos_args[rp].def.val_bits) {
printf(" ");
- print_def_man(cname, 0, &cmd->required_pos_args[rp].def, 1);
+ _print_def_man(cname, 0, &cmd->required_pos_args[rp].def, 1);
}
}
@@ -2543,13 +2544,13 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
if (opt_names[opt_enum].short_opt) {
printf(" \\fB-%c\\fP|\\fB%s\\fP",
opt_names[opt_enum].short_opt,
- man_long_opt_name(cmd->name, opt_enum));
+ _man_long_opt_name(cmd->name, opt_enum));
} else
printf(" \\fB%s\\fP", opt_names[cmd->required_opt_args[ro].opt].long_opt);
if (cmd->required_opt_args[ro].def.val_bits) {
printf(" ");
- print_def_man(cname, opt_enum, &cmd->required_opt_args[ro].def, 1);
+ _print_def_man(cname, opt_enum, &cmd->required_opt_args[ro].def, 1);
}
sep++;
@@ -2561,7 +2562,7 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
for (rp = 0; rp < cmd->rp_count; rp++) {
if (cmd->required_pos_args[rp].def.val_bits) {
printf(" ");
- print_def_man(cname, 0, &cmd->required_pos_args[rp].def, 1);
+ _print_def_man(cname, 0, &cmd->required_pos_args[rp].def, 1);
}
}
@@ -2592,7 +2593,7 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
*/
printf(".ad l\n");
printf("[ \\fB-l\\fP|\\fB--extents\\fP ");
- print_val_man(cname, extents_ARG, opt_names[extents_ARG].val_enum);
+ _print_val_man(cname, extents_ARG, opt_names[extents_ARG].val_enum);
printf(" ]\n");
printf(".ad b\n");
sep = 1;
@@ -2606,7 +2607,7 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
if (!opt_names[opt_enum].short_opt)
continue;
- if (is_lvm_all_opt(opt_enum))
+ if (_is_lvm_all_opt(opt_enum))
continue;
if ((cname->variants > 1) && cname->common_options[opt_enum])
@@ -2618,11 +2619,11 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
printf("[ \\fB-%c\\fP|\\fB%s\\fP",
opt_names[opt_enum].short_opt,
- man_long_opt_name(cmd->name, opt_enum));
+ _man_long_opt_name(cmd->name, opt_enum));
if (cmd->optional_opt_args[oo].def.val_bits) {
printf(" ");
- print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1);
+ _print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1);
}
printf(" ]\n");
printf(".ad b\n");
@@ -2637,7 +2638,7 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
if (opt_names[opt_enum].short_opt)
continue;
- if (is_lvm_all_opt(opt_enum))
+ if (_is_lvm_all_opt(opt_enum))
continue;
if ((cname->variants > 1) && cname->common_options[opt_enum])
@@ -2650,11 +2651,11 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
/* space alignment without short opt */
printf("[ ");
- printf(" \\fB%s\\fP", man_long_opt_name(cmd->name, opt_enum));
+ printf(" \\fB%s\\fP", _man_long_opt_name(cmd->name, opt_enum));
if (cmd->optional_opt_args[oo].def.val_bits) {
printf(" ");
- print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1);
+ _print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1);
}
printf(" ]\n");
printf(".ad b\n");
@@ -2682,7 +2683,7 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
for (op = 0; op < cmd->op_count; op++) {
if (cmd->optional_pos_args[op].def.val_bits) {
printf(" ");
- print_def_man(cname, 0, &cmd->optional_pos_args[op].def, 1);
+ _print_def_man(cname, 0, &cmd->optional_pos_args[op].def, 1);
}
}
}
@@ -2696,7 +2697,7 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
*
* For commands with only one variant, this is only
* the options which are common to all lvm commands
- * (in lvm_all, see is_lvm_all_opt).
+ * (in lvm_all, see _is_lvm_all_opt).
*
* For commands with more than one variant, this
* is the set of options common to all variants
@@ -2713,7 +2714,7 @@ static void _print_man_usage_common_lvm(struct command *cmd)
struct command_name *cname;
int i, sep, oo, opt_enum;
- if (!(cname = find_command_name(cmd->name)))
+ if (!(cname = _find_command_name(cmd->name)))
return;
printf("Common options for lvm:\n");
@@ -2730,7 +2731,7 @@ static void _print_man_usage_common_lvm(struct command *cmd)
if (!opt_names[opt_enum].short_opt)
continue;
- if (!is_lvm_all_opt(opt_enum))
+ if (!_is_lvm_all_opt(opt_enum))
continue;
if (sep)
@@ -2743,11 +2744,11 @@ static void _print_man_usage_common_lvm(struct command *cmd)
printf("[ \\fB-%c\\fP|\\fB%s\\fP",
opt_names[opt_enum].short_opt,
- man_long_opt_name(cmd->name, opt_enum));
+ _man_long_opt_name(cmd->name, opt_enum));
if (cmd->optional_opt_args[oo].def.val_bits) {
printf(" ");
- print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1);
+ _print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1);
}
printf(" ]\n");
printf(".ad b\n");
@@ -2764,7 +2765,7 @@ static void _print_man_usage_common_lvm(struct command *cmd)
if (opt_names[opt_enum].short_opt)
continue;
- if (!is_lvm_all_opt(opt_enum))
+ if (!_is_lvm_all_opt(opt_enum))
continue;
if (sep)
@@ -2778,11 +2779,11 @@ static void _print_man_usage_common_lvm(struct command *cmd)
/* space alignment without short opt */
printf("[ ");
- printf(" \\fB%s\\fP", man_long_opt_name(cmd->name, opt_enum));
+ printf(" \\fB%s\\fP", _man_long_opt_name(cmd->name, opt_enum));
if (cmd->optional_opt_args[oo].def.val_bits) {
printf(" ");
- print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1);
+ _print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1);
}
printf(" ]\n");
printf(".ad b\n");
@@ -2800,7 +2801,7 @@ static void _print_man_usage_common_cmd(struct command *cmd)
struct command_name *cname;
int i, sep, oo, opt_enum;
- if (!(cname = find_command_name(cmd->name)))
+ if (!(cname = _find_command_name(cmd->name)))
return;
if (cname->variants < 2)
@@ -2827,7 +2828,7 @@ static void _print_man_usage_common_cmd(struct command *cmd)
if (cname->variants < 2)
continue;
- if (is_lvm_all_opt(opt_enum))
+ if (_is_lvm_all_opt(opt_enum))
continue;
if (sep)
@@ -2840,11 +2841,11 @@ static void _print_man_usage_common_cmd(struct command *cmd)
printf("[ \\fB-%c\\fP|\\fB%s\\fP",
opt_names[opt_enum].short_opt,
- man_long_opt_name(cmd->name, opt_enum));
+ _man_long_opt_name(cmd->name, opt_enum));
if (cmd->optional_opt_args[oo].def.val_bits) {
printf(" ");
- print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1);
+ _print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1);
}
printf(" ]\n");
printf(".ad b\n");
@@ -2868,7 +2869,7 @@ static void _print_man_usage_common_cmd(struct command *cmd)
if (cname->variants < 2)
continue;
- if (is_lvm_all_opt(opt_enum))
+ if (_is_lvm_all_opt(opt_enum))
continue;
if (sep)
@@ -2882,11 +2883,11 @@ static void _print_man_usage_common_cmd(struct command *cmd)
/* space alignment without short opt */
printf("[ ");
- printf(" \\fB%s\\fP", man_long_opt_name(cmd->name, opt_enum));
+ printf(" \\fB%s\\fP", _man_long_opt_name(cmd->name, opt_enum));
if (cmd->optional_opt_args[oo].def.val_bits) {
printf(" ");
- print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1);
+ _print_def_man(cname, opt_enum, &cmd->optional_opt_args[oo].def, 1);
}
printf(" ]\n");
printf(".ad b\n");
@@ -3003,10 +3004,10 @@ static void _print_man_all_options_list(struct command_name *cname)
if (opt_names[opt_enum].short_opt) {
printf(" \\fB-%c\\fP|\\fB%s\\fP",
opt_names[opt_enum].short_opt,
- man_long_opt_name(cname->name, opt_enum));
+ _man_long_opt_name(cname->name, opt_enum));
} else {
/* spaces for alignment without short opt */
- printf(" \\fB%s\\fP", man_long_opt_name(cname->name, opt_enum));
+ printf(" \\fB%s\\fP", _man_long_opt_name(cname->name, opt_enum));
}
val_enum = opt_names[opt_enum].val_enum;
@@ -3020,7 +3021,7 @@ static void _print_man_all_options_list(struct command_name *cname)
printf("\\fP");
} else {
printf(" ");
- print_val_man(cname, opt_enum, val_enum);
+ _print_val_man(cname, opt_enum, val_enum);
}
printf("\n.ad b\n");
@@ -3051,9 +3052,9 @@ static void _print_man_all_options_desc(struct command_name *cname)
if (opt_names[opt_enum].short_opt) {
printf("\\fB-%c\\fP|\\fB%s\\fP",
opt_names[opt_enum].short_opt,
- man_long_opt_name(cname->name, opt_enum));
+ _man_long_opt_name(cname->name, opt_enum));
} else {
- printf("\\fB%s\\fP", man_long_opt_name(cname->name, opt_enum));
+ printf("\\fB%s\\fP", _man_long_opt_name(cname->name, opt_enum));
}
val_enum = opt_names[opt_enum].val_enum;
@@ -3067,7 +3068,7 @@ static void _print_man_all_options_desc(struct command_name *cname)
printf("\\fP");
} else {
printf(" ");
- print_val_man(cname, opt_enum, val_enum);
+ _print_val_man(cname, opt_enum, val_enum);
}
if (opt_names[opt_enum].flags & ARG_COUNTABLE)
@@ -3277,7 +3278,7 @@ static void _print_desc_man(const char *desc)
}
}
-static char *upper_command_name(char *str)
+static const char *_upper_command_name(char *str)
{
static char str_upper[32];
int i = 0;
@@ -3292,7 +3293,7 @@ static char *upper_command_name(char *str)
#define MAX_MAN_DESC (1024 * 1024)
-static int include_description_file(char *name, char *des_file)
+static int _include_description_file(char *name, char *des_file)
{
char *buf;
int fd, r = 0;
@@ -3348,10 +3349,10 @@ static int _print_man(char *name, char *des_file, int secondary)
name += 4;
}
- cname = find_command_name(name);
+ cname = _find_command_name(name);
printf(".TH %s 8 \"LVM TOOLS #VERSION#\" \"Red Hat, Inc.\"\n",
- upper_command_name(lvmname));
+ _upper_command_name(lvmname));
for (i = 0; i < COMMAND_COUNT; i++) {
@@ -3389,7 +3390,7 @@ static int _print_man(char *name, char *des_file, int secondary)
printf(".SH SYNOPSIS\n");
prev_cmd = cmd;
- if (!(cname = find_command_name(cmd->name)))
+ if (!(cname = _find_command_name(cmd->name)))
return 0;
if (cname->variant_has_ro && cname->variant_has_rp)
@@ -3419,7 +3420,7 @@ static int _print_man(char *name, char *des_file, int secondary)
_print_man_all_options_list(cname);
}
- if (des_file && !include_description_file(lvmname, des_file))
+ if (des_file && !_include_description_file(lvmname, des_file))
return 0;
printf(".SH USAGE\n");
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 5a9f006..661910f 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -4625,8 +4625,8 @@ FIELD_F(STATS_META, STR, "ObjType", 7, dm_stats_object_type, "obj_type", "Type o
#undef NUM
#undef SIZ
-static const char *default_report_options = "name,major,minor,attr,open,segments,events,uuid";
-static const char *splitname_report_options = "vg_name,lv_name,lv_layer";
+static const char *_default_report_options = "name,major,minor,attr,open,segments,events,uuid";
+static const char *_splitname_report_options = "vg_name,lv_name,lv_layer";
/* Stats counters & derived metrics. */
#define RD_COUNTERS "read_count,reads_merged_count,read_sector_count,read_time,read_ticks"
@@ -4661,7 +4661,7 @@ static const char *_stats_hist_relative_options = STATS_HIST ",hist_percent_boun
static int _report_init(const struct command *cmd, const char *subcommand)
{
- char *options = (char *) default_report_options;
+ char *options = (char *) _default_report_options;
char *opt_fields = NULL; /* optional fields from command line */
const char *keys = "";
const char *separator = " ";
@@ -4673,7 +4673,7 @@ static int _report_init(const struct command *cmd, const char *subcommand)
int r = 0;
if (cmd && !strcmp(cmd->name, "splitname")) {
- options = (char *) splitname_report_options;
+ options = (char *) _splitname_report_options;
_report_type |= DR_NAME;
}
@@ -6490,7 +6490,7 @@ static int _process_tree_options(const char *options)
return 1;
}
-static char *parse_loop_device_name(const char *dev, const char *dev_dir)
+static char *_parse_loop_device_name(const char *dev, const char *dev_dir)
{
char *buf;
char *device = NULL;
@@ -6657,7 +6657,7 @@ static int _process_losetup_switches(const char *base, int *argcp, char ***argvp
return 0;
}
- if (!(device_name = parse_loop_device_name((*argvp)[0], dev_dir))) {
+ if (!(device_name = _parse_loop_device_name((*argvp)[0], dev_dir))) {
fprintf(stderr, "%s: Could not parse loop_device %s\n",
base, (*argvp)[0]);
_usage(stderr);
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 92161e2..83dbf97 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -241,7 +241,7 @@ static int _lvchange_activate(struct cmd_context *cmd, struct logical_volume *lv
return 1;
}
-static int detach_metadata_devices(struct lv_segment *seg, struct dm_list *list)
+static int _detach_metadata_devices(struct lv_segment *seg, struct dm_list *list)
{
uint32_t s;
uint32_t num_meta_lvs;
@@ -274,7 +274,7 @@ static int detach_metadata_devices(struct lv_segment *seg, struct dm_list *list)
return 1;
}
-static int attach_metadata_devices(struct lv_segment *seg, struct dm_list *list)
+static int _attach_metadata_devices(struct lv_segment *seg, struct dm_list *list)
{
struct lv_list *lvl;
@@ -407,7 +407,7 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
lv->status &= ~LV_NOTSYNCED;
/* Separate mirror log or metadata devices so we can clear them */
- if (!detach_metadata_devices(seg, &device_list)) {
+ if (!_detach_metadata_devices(seg, &device_list)) {
log_error("Failed to clear %s %s for %s.",
lvseg_name(seg), seg_is_raid(seg) ?
"metadata area" : "mirror log", display_lvname(lv));
@@ -458,7 +458,7 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
}
/* Put metadata sub-LVs back in place */
- if (!attach_metadata_devices(seg, &device_list)) {
+ if (!_attach_metadata_devices(seg, &device_list)) {
log_error("Failed to reattach %s device after clearing.",
(seg_is_raid(seg)) ? "metadata" : "log");
return 0;
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index fc4b3bb..f2e208c 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -91,7 +91,7 @@ static struct cmdline_context _cmdline;
* to use these functions instead of the old per-command-name function.
* For now, any command id not included here uses the old command fn.
*/
-static const struct command_function command_functions[CMD_COUNT] = {
+static const struct command_function _command_functions[CMD_COUNT] = {
{ lvmconfig_general_CMD, lvmconfig },
{ lvchange_properties_CMD, lvchange_properties_cmd },
{ lvchange_resync_CMD, lvchange_resync_cmd },
@@ -1234,7 +1234,7 @@ static void _set_valid_args_for_command_name(int ci)
command_names[ci].num_args = num_args;
}
-static struct command_name *find_command_name(const char *name)
+static struct command_name *_find_command_name(const char *name)
{
int i;
@@ -1255,8 +1255,8 @@ static const struct command_function *_find_command_id_function(int command_enum
return NULL;
for (i = 0; i < CMD_COUNT; i++) {
- if (command_functions[i].command_enum == command_enum)
- return &command_functions[i];
+ if (_command_functions[i].command_enum == command_enum)
+ return &_command_functions[i];
}
return NULL;
}
@@ -1307,7 +1307,7 @@ int lvm_register_commands(struct cmd_context *cmd, const char *run_name)
/* old style */
if (!commands[i].functions) {
- struct command_name *cname = find_command_name(commands[i].name);
+ struct command_name *cname = _find_command_name(commands[i].name);
if (cname)
commands[i].fn = cname->fn;
}
@@ -1877,7 +1877,7 @@ static void _short_usage(const char *name)
static int _usage(const char *name, int longhelp, int skip_notes)
{
- struct command_name *cname = find_command_name(name);
+ struct command_name *cname = _find_command_name(name);
struct command *cmd = NULL;
int show_full = longhelp;
int i;
@@ -2041,7 +2041,7 @@ static int _find_arg(const char *cmd_name, int goval)
int arg_enum;
int i;
- if (!(cname = find_command_name(cmd_name)))
+ if (!(cname = _find_command_name(cmd_name)))
return -1;
for (i = 0; i < cname->num_args; i++) {
@@ -2768,7 +2768,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
return_ECMD_FAILED;
/* Look up command - will be NULL if not recognised */
- if (!(cmd->cname = find_command_name(cmd->name)))
+ if (!(cmd->cname = _find_command_name(cmd->name)))
return ENO_SUCH_CMD;
if (!_process_command_line(cmd, &argc, &argv)) {
@@ -3512,7 +3512,7 @@ int lvm2_main(int argc, char **argv)
*/
if (!run_name)
run_shell = 1;
- else if (!find_command_name(run_name))
+ else if (!_find_command_name(run_name))
run_script = 1;
else
run_command_name = run_name;
diff --git a/tools/lvpoll.c b/tools/lvpoll.c
index fe237d9..8b4580f 100644
--- a/tools/lvpoll.c
+++ b/tools/lvpoll.c
@@ -72,7 +72,7 @@ static int _set_daemon_parms(struct cmd_context *cmd, struct daemon_parms *parms
return 1;
}
-static int poll_lv(struct cmd_context *cmd, const char *lv_name)
+static int _poll_lv(struct cmd_context *cmd, const char *lv_name)
{
struct daemon_parms parms = { 0 };
struct poll_operation_id id = {
@@ -110,5 +110,5 @@ int lvpoll(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- return poll_lv(cmd, argv[0]);
+ return _poll_lv(cmd, argv[0]);
}
diff --git a/tools/lvscan.c b/tools/lvscan.c
index ab3238b..c38208a 100644
--- a/tools/lvscan.c
+++ b/tools/lvscan.c
@@ -45,8 +45,8 @@ static int _lvscan_single_lvmetad(struct cmd_context *cmd, struct logical_volume
return ECMD_PROCESSED;
}
-static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
- struct processing_handle *handle __attribute__((unused)))
+static int _lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
+ struct processing_handle *handle __attribute__((unused)))
{
struct lvinfo info;
int inkernel, snap_active = 1;
@@ -119,5 +119,5 @@ int lvscan(struct cmd_context *cmd, int argc, char **argv)
*/
}
- return process_each_lv(cmd, argc, argv, NULL, NULL, 0, NULL, NULL, &lvscan_single);
+ return process_each_lv(cmd, argc, argv, NULL, NULL, 0, NULL, NULL, &_lvscan_single);
}
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index a4df22e..d69284d 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -237,13 +237,13 @@ struct poll_id_list {
struct poll_operation_id *id;
};
-static struct poll_operation_id *copy_poll_operation_id(struct dm_pool *mem,
+static struct poll_operation_id *_copy_poll_operation_id(struct dm_pool *mem,
const struct poll_operation_id *id)
{
struct poll_operation_id *copy;
if (!id || !id->vg_name || !id->lv_name || !id->display_name || !id->uuid) {
- log_error(INTERNAL_ERROR "Wrong params for copy_poll_operation_id.");
+ log_error(INTERNAL_ERROR "Wrong params for _copy_poll_operation_id.");
return NULL;
}
@@ -264,8 +264,8 @@ static struct poll_operation_id *copy_poll_operation_id(struct dm_pool *mem,
return copy;
}
-static struct poll_id_list* poll_id_list_create(struct dm_pool *mem,
- const struct poll_operation_id *id)
+static struct poll_id_list* _poll_id_list_create(struct dm_pool *mem,
+ const struct poll_operation_id *id)
{
struct poll_id_list *idl = (struct poll_id_list *) dm_pool_alloc(mem, sizeof(struct poll_id_list));
@@ -274,7 +274,7 @@ static struct poll_id_list* poll_id_list_create(struct dm_pool *mem,
return NULL;
}
- if (!(idl->id = copy_poll_operation_id(mem, id))) {
+ if (!(idl->id = _copy_poll_operation_id(mem, id))) {
dm_pool_free(mem, idl);
return NULL;
}
@@ -329,7 +329,7 @@ static int _poll_vg(struct cmd_context *cmd, const char *vgname,
id.vg_name = vg->name;
id.uuid = lv->lvid.s;
- idl = poll_id_list_create(cmd->mem, &id);
+ idl = _poll_id_list_create(cmd->mem, &id);
if (!idl) {
log_error("Failed to create poll_id_list.");
goto err;
@@ -379,8 +379,8 @@ typedef struct {
struct dm_list idls;
} lvmpolld_parms_t;
-static int report_progress(struct cmd_context *cmd, struct poll_operation_id *id,
- struct daemon_parms *parms)
+static int _report_progress(struct cmd_context *cmd, struct poll_operation_id *id,
+ struct daemon_parms *parms)
{
struct volume_group *vg;
struct logical_volume *lv;
@@ -482,7 +482,7 @@ static int _lvmpolld_init_poll_vg(struct cmd_context *cmd, const char *vgname,
r = lvmpolld_poll_init(cmd, &id, lpdp->parms);
if (r && !lpdp->parms->background) {
- if (!(idl = poll_id_list_create(cmd->mem, &id)))
+ if (!(idl = _poll_id_list_create(cmd->mem, &id)))
return ECMD_FAILED;
dm_list_add(&lpdp->idls, &idl->list);
@@ -519,7 +519,7 @@ static void _lvmpolld_poll_for_all_vgs(struct cmd_context *cmd,
if (!r || finished)
dm_list_del(&idl->list);
else if (!parms->aborting)
- report_progress(cmd, idl->id, lpdp.parms);
+ _report_progress(cmd, idl->id, lpdp.parms);
}
if (lpdp.parms->interval)
@@ -548,7 +548,7 @@ static int _lvmpoll_daemon(struct cmd_context *cmd, struct poll_operation_id *id
while (1) {
if (!(r = lvmpolld_request_info(id, parms, &finished)) ||
finished ||
- (!parms->aborting && !(r = report_progress(cmd, id, parms))))
+ (!parms->aborting && !(r = _report_progress(cmd, id, parms))))
break;
if (parms->interval)
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 9dc50e4..73605a8 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -22,8 +22,8 @@
* Output arguments:
* pp: structure allocated by caller, fields written / validated here
*/
-static int pvcreate_restore_params_from_args(struct cmd_context *cmd, int argc,
- struct pvcreate_params *pp)
+static int _pvcreate_restore_params_from_args(struct cmd_context *cmd, int argc,
+ struct pvcreate_params *pp)
{
pp->restorefile = arg_str_value(cmd, restorefile_ARG, NULL);
@@ -63,7 +63,7 @@ static int pvcreate_restore_params_from_args(struct cmd_context *cmd, int argc,
return 1;
}
-static int pvcreate_restore_params_from_backup(struct cmd_context *cmd,
+static int _pvcreate_restore_params_from_backup(struct cmd_context *cmd,
struct pvcreate_params *pp)
{
struct volume_group *vg;
@@ -110,7 +110,7 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
/*
* Device info needs to be available for reading the VG backup file in
- * pvcreate_restore_params_from_backup.
+ * _pvcreate_restore_params_from_backup.
*/
lvmcache_seed_infos_from_lvmetad(cmd);
@@ -126,10 +126,10 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
pvcreate_params_set_defaults(&pp);
- if (!pvcreate_restore_params_from_args(cmd, argc, &pp))
+ if (!_pvcreate_restore_params_from_args(cmd, argc, &pp))
return EINVALID_CMD_LINE;
- if (!pvcreate_restore_params_from_backup(cmd, &pp))
+ if (!_pvcreate_restore_params_from_backup(cmd, &pp))
return EINVALID_CMD_LINE;
if (!pvcreate_params_from_args(cmd, &pp))
diff --git a/tools/pvmove.c b/tools/pvmove.c
index 305647e..09ce54b 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -293,7 +293,7 @@ static int _insert_pvmove_mirrors(struct cmd_context *cmd,
*
* Returns: 1 if true, 0 otherwise
*/
-static int sub_lv_of(struct logical_volume *lv, const char *lv_name)
+static int _sub_lv_of(struct logical_volume *lv, const char *lv_name)
{
struct lv_segment *seg;
@@ -308,7 +308,7 @@ static int sub_lv_of(struct logical_volume *lv, const char *lv_name)
return 1;
/* Continue up the tree */
- return sub_lv_of(seg->lv, lv_name);
+ return _sub_lv_of(seg->lv, lv_name);
}
/*
@@ -319,7 +319,7 @@ static int sub_lv_of(struct logical_volume *lv, const char *lv_name)
*
* If this LV is below a cache LV (at any depth), return 1.
*/
-static int parent_lv_is_cache_type(struct logical_volume *lv)
+static int _parent_lv_is_cache_type(struct logical_volume *lv)
{
struct lv_segment *seg;
@@ -334,7 +334,7 @@ static int parent_lv_is_cache_type(struct logical_volume *lv)
return 1;
/* Continue up the tree */
- return parent_lv_is_cache_type(seg->lv);
+ return _parent_lv_is_cache_type(seg->lv);
}
/* Create new LV with mirror segments for the required copies */
@@ -451,7 +451,7 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
continue;
if (lv_name) {
- if (strcmp(lv->name, lv_name) && !sub_lv_of(lv, lv_name))
+ if (strcmp(lv->name, lv_name) && !_sub_lv_of(lv, lv_name))
continue;
lv_found = 1;
}
@@ -469,7 +469,7 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
continue;
}
- if (parent_lv_is_cache_type(lv)) {
+ if (_parent_lv_is_cache_type(lv)) {
log_print_unless_silent("Skipping %s because a parent"
" is of cache type", lv->name);
lv_skipped = 1;
diff --git a/tools/toollib.c b/tools/toollib.c
index fc615f3..79829f4 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2375,7 +2375,7 @@ void opt_array_to_str(struct cmd_context *cmd, int *opts, int count,
buf[len - 1] = '\0';
}
-static void lvp_bits_to_str(uint64_t bits, char *buf, int len)
+static void _lvp_bits_to_str(uint64_t bits, char *buf, int len)
{
struct lv_prop *prop;
int lvp_enum;
@@ -2396,7 +2396,7 @@ static void lvp_bits_to_str(uint64_t bits, char *buf, int len)
buf[len - 1] = '\0';
}
-static void lvt_bits_to_str(uint64_t bits, char *buf, int len)
+static void _lvt_bits_to_str(uint64_t bits, char *buf, int len)
{
struct lv_type *type;
int lvt_enum;
@@ -2850,7 +2850,7 @@ static int _check_lv_rules(struct cmd_context *cmd, struct logical_volume *lv)
if (rule->check_lvt_bits && (rule->rule == RULE_REQUIRE) && !lv_types_match_bits) {
memset(buf, 0, sizeof(buf));
- lvt_bits_to_str(rule->check_lvt_bits, buf, sizeof(buf));
+ _lvt_bits_to_str(rule->check_lvt_bits, buf, sizeof(buf));
if (rule->opts_count)
log_warn("Command on LV %s uses options that require LV types %s.",
display_lvname(lv), buf);
@@ -2864,7 +2864,7 @@ static int _check_lv_rules(struct cmd_context *cmd, struct logical_volume *lv)
if (rule->check_lvp_bits && (rule->rule == RULE_INVALID) && lv_props_match_bits) {
memset(buf, 0, sizeof(buf));
- lvp_bits_to_str(lv_props_match_bits, buf, sizeof(buf));
+ _lvp_bits_to_str(lv_props_match_bits, buf, sizeof(buf));
if (rule->opts_count)
log_warn("Command on LV %s uses options that are invalid with LV properties: %s.",
display_lvname(lv), buf);
@@ -2878,7 +2878,7 @@ static int _check_lv_rules(struct cmd_context *cmd, struct logical_volume *lv)
if (rule->check_lvp_bits && (rule->rule == RULE_REQUIRE) && lv_props_unmatch_bits) {
memset(buf, 0, sizeof(buf));
- lvp_bits_to_str(lv_props_unmatch_bits, buf, sizeof(buf));
+ _lvp_bits_to_str(lv_props_unmatch_bits, buf, sizeof(buf));
if (rule->opts_count)
log_warn("Command on LV %s uses options that require LV properties: %s.",
display_lvname(lv), buf);
diff --git a/tools/vgcfgbackup.c b/tools/vgcfgbackup.c
index a04c3ab..5d21131 100644
--- a/tools/vgcfgbackup.c
+++ b/tools/vgcfgbackup.c
@@ -47,9 +47,9 @@ static char *_expand_filename(const char *template, const char *vg_name,
return filename;
}
-static int vg_backup_single(struct cmd_context *cmd, const char *vg_name,
- struct volume_group *vg,
- struct processing_handle *handle)
+static int _vg_backup_single(struct cmd_context *cmd, const char *vg_name,
+ struct volume_group *vg,
+ struct processing_handle *handle)
{
char **last_filename = (char **)handle->custom_handle;
char *filename;
@@ -95,7 +95,7 @@ int vgcfgbackup(struct cmd_context *cmd, int argc, char **argv)
init_pvmove(1);
ret = process_each_vg(cmd, argc, argv, NULL, NULL, READ_ALLOW_INCONSISTENT, 0,
- handle, &vg_backup_single);
+ handle, &_vg_backup_single);
dm_free(last_filename);
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 3de635d..ae97a4a 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -680,9 +680,9 @@ static int _vgchange_lock_stop(struct cmd_context *cmd, struct volume_group *vg)
return lockd_stop_vg(cmd, vg);
}
-static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
- struct volume_group *vg,
- struct processing_handle *handle)
+static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
+ struct volume_group *vg,
+ struct processing_handle *handle)
{
int ret = ECMD_PROCESSED;
unsigned i;
@@ -927,7 +927,7 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
- ret = process_each_vg(cmd, argc, argv, NULL, NULL, flags, 0, handle, &vgchange_single);
+ ret = process_each_vg(cmd, argc, argv, NULL, NULL, flags, 0, handle, &_vgchange_single);
destroy_processing_handle(cmd, handle);
return ret;
diff --git a/tools/vgconvert.c b/tools/vgconvert.c
index 9f98048..8bdf8be 100644
--- a/tools/vgconvert.c
+++ b/tools/vgconvert.c
@@ -15,9 +15,9 @@
#include "tools.h"
-static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
- struct volume_group *vg,
- struct processing_handle *handle __attribute__((unused)))
+static int _vgconvert_single(struct cmd_context *cmd, const char *vg_name,
+ struct volume_group *vg,
+ struct processing_handle *handle __attribute__((unused)))
{
struct pv_create_args pva = { 0 };
struct logical_volume *lv;
@@ -170,5 +170,5 @@ int vgconvert(struct cmd_context *cmd, int argc, char **argv)
}
return process_each_vg(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE, 0, NULL,
- &vgconvert_single);
+ &_vgconvert_single);
}
diff --git a/tools/vgdisplay.c b/tools/vgdisplay.c
index f4b0b6f..e9d0842 100644
--- a/tools/vgdisplay.c
+++ b/tools/vgdisplay.c
@@ -15,9 +15,9 @@
#include "tools.h"
-static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
- struct volume_group *vg,
- struct processing_handle *handle __attribute__((unused)))
+static int _vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
+ struct volume_group *vg,
+ struct processing_handle *handle __attribute__((unused)))
{
if (arg_is_set(cmd, activevolumegroups_ARG) && !lvs_in_vg_activated(vg))
return ECMD_PROCESSED;
@@ -93,7 +93,7 @@ int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
**********/
return process_each_vg(cmd, argc, argv, NULL, NULL, 0, 0, NULL,
- vgdisplay_single);
+ _vgdisplay_single);
/******** FIXME Need to count number processed
Add this to process_each_vg if arg_is_set(cmd,activevolumegroups_ARG) ?
diff --git a/tools/vgimport.c b/tools/vgimport.c
index 53eeca5..ea50198 100644
--- a/tools/vgimport.c
+++ b/tools/vgimport.c
@@ -15,10 +15,10 @@
#include "tools.h"
-static int vgimport_single(struct cmd_context *cmd,
- const char *vg_name,
- struct volume_group *vg,
- struct processing_handle *handle __attribute__((unused)))
+static int _vgimport_single(struct cmd_context *cmd,
+ const char *vg_name,
+ struct volume_group *vg,
+ struct processing_handle *handle __attribute__((unused)))
{
struct pv_list *pvl;
struct physical_volume *pv;
@@ -110,5 +110,5 @@ int vgimport(struct cmd_context *cmd, int argc, char **argv)
return process_each_vg(cmd, argc, argv, NULL, NULL,
READ_FOR_UPDATE | READ_ALLOW_EXPORTED,
0, NULL,
- &vgimport_single);
+ &_vgimport_single);
}
diff --git a/tools/vgremove.c b/tools/vgremove.c
index d105fc6..8bf3841 100644
--- a/tools/vgremove.c
+++ b/tools/vgremove.c
@@ -15,9 +15,9 @@
#include "tools.h"
-static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
- struct volume_group *vg,
- struct processing_handle *handle __attribute__((unused)))
+static int _vgremove_single(struct cmd_context *cmd, const char *vg_name,
+ struct volume_group *vg,
+ struct processing_handle *handle __attribute__((unused)))
{
/*
* Though vgremove operates per VG by definition, internally, it
@@ -111,7 +111,7 @@ int vgremove(struct cmd_context *cmd, int argc, char **argv)
cmd->handles_missing_pvs = 1;
ret = process_each_vg(cmd, argc, argv, NULL, NULL,
READ_FOR_UPDATE, 0,
- NULL, &vgremove_single);
+ NULL, &_vgremove_single);
return ret;
}
diff --git a/tools/vgscan.c b/tools/vgscan.c
index 4deab73..1ec9083 100644
--- a/tools/vgscan.c
+++ b/tools/vgscan.c
@@ -15,9 +15,9 @@
#include "tools.h"
-static int vgscan_single(struct cmd_context *cmd, const char *vg_name,
- struct volume_group *vg,
- struct processing_handle *handle __attribute__((unused)))
+static int _vgscan_single(struct cmd_context *cmd, const char *vg_name,
+ struct volume_group *vg,
+ struct processing_handle *handle __attribute__((unused)))
{
log_print_unless_silent("Found %svolume group \"%s\" using metadata type %s",
vg_is_exported(vg) ? "exported " : "", vg_name,
@@ -117,7 +117,7 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
else
log_print_unless_silent("Reading volume groups from cache.");
- maxret = process_each_vg(cmd, argc, argv, NULL, NULL, 0, 0, NULL, &vgscan_single);
+ maxret = process_each_vg(cmd, argc, argv, NULL, NULL, 0, 0, NULL, &_vgscan_single);
if (arg_is_set(cmd, mknodes_ARG)) {
ret = vgmknodes(cmd, argc, argv);
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 843738b..46c8911 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -529,7 +529,7 @@ static struct volume_group *_vgsplit_from(struct cmd_context *cmd,
/*
* Has the user given an option related to a new vg as the split destination?
*/
-static int new_vg_option_specified(struct cmd_context *cmd)
+static int _new_vg_option_specified(struct cmd_context *cmd)
{
return(arg_is_set(cmd, clustered_ARG) ||
arg_is_set(cmd, alloc_ARG) ||
@@ -616,7 +616,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
}
if (existing_vg) {
- if (new_vg_option_specified(cmd)) {
+ if (_new_vg_option_specified(cmd)) {
log_error("Volume group \"%s\" exists, but new VG "
"option specified", vg_name_to);
goto bad;
6 years, 6 months
master - libdm: fix typo in libdevmapper.pc
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=327d9d59be6f7179b2e...
Commit: 327d9d59be6f7179b2e0a756deaa0f9a196e0651
Parent: 1b319f39d6692a6770493d5f751ebbb9062164fc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 18 00:03:08 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 18 00:04:06 2017 +0200
libdm: fix typo in libdevmapper.pc
Fixing name for RT libraries and using RT_LIBS.
---
WHATS_NEW_DM | 1 +
libdm/libdevmapper.pc.in | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index a5d24dd..b0dd01b 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.145 -
===================================
+ Fix RT_LIBS reference in generated libdevmapper.pc for pkg-config
Version 1.02.144 - 6th October 2017
===================================
diff --git a/libdm/libdevmapper.pc.in b/libdm/libdevmapper.pc.in
index f29f920..a325aeb 100644
--- a/libdm/libdevmapper.pc.in
+++ b/libdm/libdevmapper.pc.in
@@ -9,4 +9,4 @@ Version: @DM_LIB_PATCHLEVEL@
Cflags: -I${includedir}
Libs: -L${libdir} -ldevmapper
Requires.private: @SELINUX_PC@ @UDEV_PC@
-Libs.private: -lm @RT_LIB@
+Libs.private: -lm @RT_LIBS@
6 years, 6 months
master - lvmlockd: check error for sanlock access to lvmlock LV
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1b319f39d6692a67704...
Commit: 1b319f39d6692a6770493d5f751ebbb9062164fc
Parent: 146745ad88abc0512650b5b40d00ca587784ca36
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Oct 17 13:45:53 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Oct 17 13:45:53 2017 -0500
lvmlockd: check error for sanlock access to lvmlock LV
When the sanlock daemon does not have permission to access
the lvmlock LV, make the error messages more helpful.
---
daemons/lvmlockd/lvmlockd-client.h | 1 +
daemons/lvmlockd/lvmlockd-sanlock.c | 19 +++++++++++++------
lib/locking/lvmlockd.c | 4 ++++
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-client.h b/daemons/lvmlockd/lvmlockd-client.h
index 67fcbe3..1d42338 100644
--- a/daemons/lvmlockd/lvmlockd-client.h
+++ b/daemons/lvmlockd/lvmlockd-client.h
@@ -48,5 +48,6 @@ static inline void lvmlockd_close(daemon_handle h)
#define EVGKILLED 217 /* sanlock lost access to leases and VG is killed. */
#define ELOCKIO 218 /* sanlock io errors during lock op, may be transient. */
#define EREMOVED 219
+#define EDEVOPEN 220 /* sanlock failed to open lvmlock LV */
#endif /* _LVM_LVMLOCKD_CLIENT_H */
diff --git a/daemons/lvmlockd/lvmlockd-sanlock.c b/daemons/lvmlockd/lvmlockd-sanlock.c
index a10d02f..0e81915 100644
--- a/daemons/lvmlockd/lvmlockd-sanlock.c
+++ b/daemons/lvmlockd/lvmlockd-sanlock.c
@@ -356,12 +356,19 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
log_debug("sanlock daemon version %08x proto %08x",
daemon_version, daemon_proto);
- align_size = sanlock_align(&disk);
- if (align_size <= 0) {
- log_error("S %s init_vg_san bad disk align size %d %s",
- ls_name, align_size, disk.path);
- return -EARGS;
- }
+ rv = sanlock_align(&disk);
+ if (rv <= 0) {
+ if (rv == -EACCES) {
+ log_error("S %s init_vg_san sanlock error -EACCES: no permission to access %s",
+ ls_name, disk.path);
+ return -EDEVOPEN;
+ } else {
+ log_error("S %s init_vg_san sanlock error %d trying to get align size of %s",
+ ls_name, rv, disk.path);
+ return -EARGS;
+ }
+ } else
+ align_size = rv;
strncpy(ss.name, ls_name, SANLK_NAME_LEN);
memcpy(ss.host_id_disk.path, disk.path, SANLK_PATH_LEN);
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 0f2b160..cf2c3d5 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -667,6 +667,10 @@ static int _init_vg_sanlock(struct cmd_context *cmd, struct volume_group *vg, in
case -EARGS:
log_error("VG %s init failed: invalid parameters for sanlock", vg->name);
break;
+ case -EDEVOPEN:
+ log_error("VG %s init failed: sanlock cannot open device /dev/mapper/%s-%s", vg->name, vg->name, LOCKD_SANLOCK_LV_NAME);
+ log_error("Check that sanlock has permission to access disks.");
+ break;
case -EMANAGER:
log_error("VG %s init failed: lock manager sanlock is not running", vg->name);
break;
6 years, 6 months
master - device: Separate errors for dev not found and filtered.
by Alasdair Kergon
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=146745ad88abc051265...
Commit: 146745ad88abc0512650b5b40d00ca587784ca36
Parent: 1f359f7558b5ae7750fa629575426ae110781566
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Oct 17 02:12:41 2017 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Oct 17 02:12:41 2017 +0100
device: Separate errors for dev not found and filtered.
Replaced the confusing device error message "not found (or ignored by
filtering)" by either "not found" or "excluded by a filter".
(Later we should be able to say which filter.)
Left the the liblvm code paths alone.
---
WHATS_NEW | 1 +
lib/device/dev-cache.c | 13 +++++++++++++
lib/device/dev-cache.h | 1 +
lib/metadata/metadata.c | 3 +--
tools/toollib.c | 4 ++--
5 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4ad6b1f..665517b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.176 -
===================================
+ Distinguish between device not found and excluded by filter.
Monitor external origin LVs.
Remove the replicator code, including configure --with-replicators.
Allow lvcreate --type mirror to work with 100%FREE.
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 7802e45..83c2b12 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1370,6 +1370,19 @@ const char *dev_name_confirmed(struct device *dev, int quiet)
return dev_name(dev);
}
+/* Provide a custom reason when a device is ignored */
+const char *dev_cache_filtered_reason(const char *name)
+{
+ const char *reason = "not found";
+ struct device *d = (struct device *) dm_hash_lookup(_cache.names, name);
+
+ if (d)
+ /* FIXME Record which filter caused the exclusion */
+ reason = "excluded by a filter";
+
+ return reason;
+}
+
struct device *dev_cache_get(const char *name, struct dev_filter *f)
{
struct stat buf;
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
index 0406970..546b1fe 100644
--- a/lib/device/dev-cache.h
+++ b/lib/device/dev-cache.h
@@ -55,6 +55,7 @@ int dev_cache_add_dir(const char *path);
int dev_cache_add_loopfile(const char *path);
__attribute__((nonnull(1)))
struct device *dev_cache_get(const char *name, struct dev_filter *f);
+const char *dev_cache_filtered_reason(const char *name);
// TODO
struct device *dev_cache_get_by_devt(dev_t device, struct dev_filter *f);
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 1606b39..496dbee 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -5488,8 +5488,7 @@ int pv_analyze(struct cmd_context *cmd, const char *pv_name,
dev = dev_cache_get(pv_name, cmd->filter);
if (!dev) {
- log_error("Device %s not found (or ignored by filtering).",
- pv_name);
+ log_error("Device %s %s.", pv_name, dev_cache_filtered_reason(pv_name));
return 0;
}
diff --git a/tools/toollib.c b/tools/toollib.c
index b28167b..fc615f3 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -5532,7 +5532,7 @@ int pvcreate_each_device(struct cmd_context *cmd,
* Check if all arg_devices were found by process_each_pv.
*/
dm_list_iterate_items(pd, &pp->arg_devices)
- log_error("Device %s not found (or ignored by filtering).", pd->name);
+ log_error("Device %s %s.", pd->name, dev_cache_filtered_reason(pd->name));
/*
* Can the command continue if some specified devices were not found?
@@ -5652,7 +5652,7 @@ int pvcreate_each_device(struct cmd_context *cmd,
process_each_pv(cmd, 0, NULL, NULL, 1, 0, handle, _pv_confirm_single);
dm_list_iterate_items(pd, &pp->arg_confirm)
- log_error("Device %s not found (or ignored by filtering).", pd->name);
+ log_error("Device %s %s.", pd->name, dev_cache_filtered_reason(pd->name));
/* Some devices were not found during the second check. */
if (!dm_list_empty(&pp->arg_confirm) && must_use_all)
6 years, 6 months