master - makefiles: use configure vars
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fc0e49297d6a68...
Commit: fc0e49297d6a6818b82169d1059084770c29b9d6
Parent: 3350eb67cc66dcd2c6ee6456a3524bc723aa4e38
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 14 09:48:24 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 14 10:24:56 2017 +0100
makefiles: use configure vars
Use binaries found in configure.
---
make.tmpl.in | 9 +++++++--
test/Makefile.in | 4 ++--
tools/Makefile.in | 9 ++-------
udev/Makefile.in | 2 +-
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/make.tmpl.in b/make.tmpl.in
index d418cfb..2e7c1ba 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -40,6 +40,11 @@ SED = @SED@
CFLOW_CMD = @CFLOW_CMD@
AWK = @AWK@
CHMOD = @CHMOD@
+EGREP = @EGREP@
+GREP = @GREP@
+SORT = @SORT@
+WC = @WC@
+
PYTHON2 = @PYTHON2@
PYTHON3 = @PYTHON3@
PYCOMPILE = $(top_srcdir)/autoconf/py-compile
@@ -512,9 +517,9 @@ ifeq (,$(firstword $(EXPORTED_SYMBOLS)))
) > $@
else
set -e;\
- R=$$(sort $^ | uniq -u);\
+ R=$$($(SORT) $^ | uniq -u);\
test -z "$$R" || { echo "Mismatch between symbols in shared library and lists in .exported_symbols.* files: $$R"; false; } ;\
- ( for i in $$(echo $(EXPORTED_SYMBOLS) | tr ' ' '\n' | sort -rnt_ -k5 ); do\
+ ( for i in $$(echo $(EXPORTED_SYMBOLS) | tr ' ' '\n' | $(SORT) -rnt_ -k5 ); do\
echo "$${i##*.} {"; echo " global:";\
$(SED) "s/^/ /;s/$$/;/" $$i;\
echo "};";\
diff --git a/test/Makefile.in b/test/Makefile.in
index f152868..3cb0f18 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -39,7 +39,7 @@ S ?= @ # never match anything by default
VERBOSE ?= 0
ALL := $(shell find -L $(srcdir) \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) | sort)
comma = ,
-RUN := $(shell find -L $(srcdir) -regextype posix-egrep \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) -and -regex "$(srcdir)/.*($(subst $(comma),|,$(T))).*" -and -not -regex "$(srcdir)/.*($(subst $(comma),|,$(S))).*" | sort)
+RUN := $(shell find -L $(srcdir) -regextype posix-egrep \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) -and -regex "$(srcdir)/.*($(subst $(comma),|,$(T))).*" -and -not -regex "$(srcdir)/.*($(subst $(comma),|,$(S))).*" | ($SORT))
RUN_BASE = $(subst $(srcdir)/,,$(RUN))
ifeq ("@BUILD_LVMETAD@", "yes")
@@ -267,7 +267,7 @@ lib/%: lib/%.o .lib-dir-stamp
lib/%: $(srcdir)/lib/%.sh .lib-dir-stamp
cp $< $@
- chmod +x $@
+ $(CHMOD) +x $@
lib/flavour-%: $(srcdir)/lib/flavour-%.sh .lib-dir-stamp
cp $< $@
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 5aaba2f..ed359ea 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -173,15 +173,10 @@ liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION): liblvm2cmd.$(LIB_SUFFIX)
.commands: $(srcdir)/commands.h $(srcdir)/cmdnames.h Makefile
$(CC) -E -P $(srcdir)/cmdnames.h 2> /dev/null | \
- egrep -v '^ *(|#.*|config|devtypes|dumpconfig|formats|fullreport|help|lastlog|lvpoll|pvdata|segtypes|systemid|tags|version) *$$' > .commands
+ $(EGREP) -v '^ *(|#.*|config|devtypes|dumpconfig|formats|fullreport|help|lastlog|lvpoll|pvdata|segtypes|systemid|tags|version) *$$' > .commands
.DELETE_ON_ERROR:
-# move properly to configure
-WC = /usr/bin/wc
-GREP = /bin/grep
-SORT = /bin/sort
-
command-count.h: $(srcdir)/command-lines.in Makefile
set -o pipefail && \
( cat $(top_srcdir)/doc/license.txt && \
@@ -204,7 +199,7 @@ command-lines-input.h: $(srcdir)/command-lines.in Makefile
( cat $(top_srcdir)/doc/license.txt && \
echo "/* Do not edit. This file is generated by the Makefile. */" && \
echo -en "const char _command_input[] =\n\n\"" && \
- $(GREP) -Ev '^#|\-\-\-|^$$' $(srcdir)/command-lines.in | $(AWK) 'BEGIN {ORS = "\\n\"\n\""} //' && \
+ $(EGREP) -v '^#|\-\-\-|^$$' $(srcdir)/command-lines.in | $(AWK) 'BEGIN {ORS = "\\n\"\n\""} //' && \
echo "\\n\";" \
) > $@
diff --git a/udev/Makefile.in b/udev/Makefile.in
index cb968df..c498aa8 100644
--- a/udev/Makefile.in
+++ b/udev/Makefile.in
@@ -23,7 +23,7 @@ ifeq ("@BUILD_LVMETAD@", "yes")
LVM_RULES+=69-dm-lvm-metad.rules
endif
-DM_DIR=$(shell grep "\#define DM_DIR" $(top_srcdir)/libdm/misc/dm-ioctl.h | awk '{print $$3}')
+DM_DIR=$(shell $(GREP) "\#define DM_DIR" $(top_srcdir)/libdm/misc/dm-ioctl.h | $(AWK) '{print $$3}')
ifeq ("@UDEV_RULE_EXEC_DETECTION@", "yes")
SBIN=\$$env{DM_SBIN_PATH}
7 years, 3 months
master - libdm: move code for _stats_resize_group
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3350eb67cc66dc...
Commit: 3350eb67cc66dcd2c6ee6456a3524bc723aa4e38
Parent: 6118b0fb93502e1ba06e5a4a696a264c0e4af0ed
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 14 09:53:13 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 14 10:24:56 2017 +0100
libdm: move code for _stats_resize_group
Code is only needed when "fiemap.h" so keep it under single #ifdef.
---
libdm/libdm-stats.c | 62 +++++++++++++++++++++++++-------------------------
1 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 587c748..3f6730e 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -3868,37 +3868,6 @@ static int _extent_start_compare(const void *p1, const void *p2)
return 1;
}
-/*
- * Resize the group bitmap corresponding to group_id so that it can
- * contain at least num_regions members.
- */
-static int _stats_resize_group(struct dm_stats_group *group, int num_regions)
-{
- int last_bit = dm_bit_get_last(group->regions);
- dm_bitset_t new, old;
-
- if (last_bit >= num_regions) {
- log_error("Cannot resize group bitmap to %d with bit %d set.",
- num_regions, last_bit);
- return 0;
- }
-
- log_very_verbose("Resizing group bitmap from %d to %d (last_bit: %d).",
- group->regions[0], num_regions, last_bit);
-
- new = dm_bitset_create(NULL, num_regions);
- if (!new) {
- log_error("Could not allocate memory for new group bitmap.");
- return 0;
- }
-
- old = group->regions;
- dm_bit_copy(new, old);
- group->regions = new;
- dm_bitset_destroy(old);
- return 1;
-}
-
static int _stats_create_group(struct dm_stats *dms, dm_bitset_t regions,
const char *alias, uint64_t *group_id)
{
@@ -4203,6 +4172,37 @@ int dm_stats_get_group_descriptor(const struct dm_stats *dms,
#ifdef HAVE_LINUX_FIEMAP_H
/*
+ * Resize the group bitmap corresponding to group_id so that it can
+ * contain at least num_regions members.
+ */
+static int _stats_resize_group(struct dm_stats_group *group, int num_regions)
+{
+ int last_bit = dm_bit_get_last(group->regions);
+ dm_bitset_t new, old;
+
+ if (last_bit >= num_regions) {
+ log_error("Cannot resize group bitmap to %d with bit %d set.",
+ num_regions, last_bit);
+ return 0;
+ }
+
+ log_very_verbose("Resizing group bitmap from %d to %d (last_bit: %d).",
+ group->regions[0], num_regions, last_bit);
+
+ new = dm_bitset_create(NULL, num_regions);
+ if (!new) {
+ log_error("Could not allocate memory for new group bitmap.");
+ return 0;
+ }
+
+ old = group->regions;
+ dm_bit_copy(new, old);
+ group->regions = new;
+ dm_bitset_destroy(old);
+ return 1;
+}
+
+/*
* Group a table of region_ids corresponding to the extents of a file.
*/
static int _stats_group_file_regions(struct dm_stats *dms, uint64_t *region_ids,
7 years, 3 months
master - configure: update
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6118b0fb93502e...
Commit: 6118b0fb93502e1ba06e5a4a696a264c0e4af0ed
Parent: 65b82a80720b137e24077c29f9c52d6ad43f93a5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 13 22:55:30 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 14 00:05:04 2017 +0100
configure: update
---
configure | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 198 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index 1cb4b54..9b69964 100755
--- a/configure
+++ b/configure
@@ -821,6 +821,8 @@ HAVE_PIE
POW_LIB
LIBOBJS
ALLOCA
+SORT
+WC
CHMOD
CSCOPE_CMD
CFLOW_CMD
@@ -5234,6 +5236,202 @@ else
CHMOD="$ac_cv_path_CHMOD"
fi
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}wc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}wc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_WC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $WC in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_WC="$WC" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_WC="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+WC=$ac_cv_path_WC
+if test -n "$WC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WC" >&5
+$as_echo "$WC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_WC"; then
+ ac_pt_WC=$WC
+ # Extract the first word of "wc", so it can be a program name with args.
+set dummy wc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_WC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $ac_pt_WC in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_ac_pt_WC="$ac_pt_WC" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_ac_pt_WC="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+ac_pt_WC=$ac_cv_path_ac_pt_WC
+if test -n "$ac_pt_WC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_WC" >&5
+$as_echo "$ac_pt_WC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_pt_WC" = x; then
+ WC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ WC=$ac_pt_WC
+ fi
+else
+ WC="$ac_cv_path_WC"
+fi
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}sort", so it can be a program name with args.
+set dummy ${ac_tool_prefix}sort; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_SORT+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $SORT in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_SORT="$SORT" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_SORT="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+SORT=$ac_cv_path_SORT
+if test -n "$SORT"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SORT" >&5
+$as_echo "$SORT" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_SORT"; then
+ ac_pt_SORT=$SORT
+ # Extract the first word of "sort", so it can be a program name with args.
+set dummy sort; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_SORT+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $ac_pt_SORT in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_ac_pt_SORT="$ac_pt_SORT" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_ac_pt_SORT="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+ac_pt_SORT=$ac_cv_path_ac_pt_SORT
+if test -n "$ac_pt_SORT"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_SORT" >&5
+$as_echo "$ac_pt_SORT" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_pt_SORT" = x; then
+ SORT=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ SORT=$ac_pt_SORT
+ fi
+else
+ SORT="$ac_cv_path_SORT"
+fi
+
################################################################################
ac_header_dirent=no
7 years, 3 months
master - activation: trust 'pending' status reported by dmeventd
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=65b82a80720b13...
Commit: 65b82a80720b137e24077c29f9c52d6ad43f93a5
Parent: 05dd566a52e4311c0626eb1a1250042aba746fae
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 13 22:50:19 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 14 00:04:26 2017 +0100
activation: trust 'pending' status reported by dmeventd
Only usleep when dmeventd reports 'pending' otherwise trust reported
state.
---
lib/activate/activate.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 608611f..ea56735 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1948,16 +1948,13 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume
/* Check [un]monitor results */
/* Try a couple times if pending, but not forever... */
- for (i = 0; i < 40; i++) {
+ for (i = 0;; i++) {
pending = 0;
monitored = seg->segtype->ops->target_monitored(seg, &pending);
- if (pending ||
- (!monitored && monitor) ||
- (monitored && !monitor))
- log_very_verbose("%s %smonitoring still pending: waiting...",
- display_lvname(lv), monitor ? "" : "un");
- else
+ if (!pending || i >= 40)
break;
+ log_very_verbose("%s %smonitoring still pending: waiting...",
+ display_lvname(lv), monitor ? "" : "un");
usleep(10000 * i);
}
7 years, 3 months
master - dmeventd: unify error handling
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=05dd566a52e431...
Commit: 05dd566a52e4311c0626eb1a1250042aba746fae
Parent: 5a87d8667d0a8cadfea13f837cf01c91d86dad0c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 13 19:00:59 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 14 00:03:34 2017 +0100
dmeventd: unify error handling
Always make sure the 'status' is release on 'error' path (thin pluging missed)
Make code looking same across all plugins.
---
daemons/dmeventd/plugins/mirror/dmeventd_mirror.c | 11 +++++------
daemons/dmeventd/plugins/raid/dmeventd_raid.c | 7 ++++---
.../dmeventd/plugins/snapshot/dmeventd_snapshot.c | 7 ++++---
daemons/dmeventd/plugins/thin/dmeventd_thin.c | 7 ++++---
4 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
index 3d3a6de..4ec348f 100644
--- a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
+++ b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
@@ -184,16 +184,12 @@ int register_device(const char *device,
goto_bad;
if (!dmeventd_lvm2_command(state->mem, state->cmd_lvscan, sizeof(state->cmd_lvscan),
- "lvscan --cache", device)) {
- dmeventd_lvm2_exit_with_pool(state);
+ "lvscan --cache", device))
goto_bad;
- }
if (!dmeventd_lvm2_command(state->mem, state->cmd_lvconvert, sizeof(state->cmd_lvconvert),
- "lvconvert --repair --use-policies", device)) {
- dmeventd_lvm2_exit_with_pool(state);
+ "lvconvert --repair --use-policies", device))
goto_bad;
- }
*user = state;
@@ -203,6 +199,9 @@ int register_device(const char *device,
bad:
log_error("Failed to monitor mirror %s.", device);
+ if (state)
+ dmeventd_lvm2_exit_with_pool(state);
+
return 0;
}
diff --git a/daemons/dmeventd/plugins/raid/dmeventd_raid.c b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
index 911ae7a..ae3fc86 100644
--- a/daemons/dmeventd/plugins/raid/dmeventd_raid.c
+++ b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
@@ -140,10 +140,8 @@ int register_device(const char *device,
"lvscan --cache", device) ||
!dmeventd_lvm2_command(state->mem, state->cmd_lvconvert, sizeof(state->cmd_lvconvert),
"lvconvert --config devices{ignore_suspended_devices=1} "
- "--repair --use-policies", device)) {
- dmeventd_lvm2_exit_with_pool(state);
+ "--repair --use-policies", device))
goto_bad;
- }
*user = state;
@@ -153,6 +151,9 @@ int register_device(const char *device,
bad:
log_error("Failed to monitor RAID %s.", device);
+ if (state)
+ dmeventd_lvm2_exit_with_pool(state);
+
return 0;
}
diff --git a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
index a70d07c..bab7f0e 100644
--- a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
+++ b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
@@ -254,10 +254,8 @@ int register_device(const char *device,
if (!dmeventd_lvm2_command(state->mem, state->cmd_lvextend,
sizeof(state->cmd_lvextend),
- "lvextend --use-policies", device)) {
- dmeventd_lvm2_exit_with_pool(state);
+ "lvextend --use-policies", device))
goto_bad;
- }
state->percent_check = CHECK_MINIMUM;
*user = state;
@@ -268,6 +266,9 @@ int register_device(const char *device,
bad:
log_error("Failed to monitor snapshot %s.", device);
+ if (state)
+ dmeventd_lvm2_exit_with_pool(state);
+
return 0;
}
diff --git a/daemons/dmeventd/plugins/thin/dmeventd_thin.c b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
index e447ba2..e7d24c5 100644
--- a/daemons/dmeventd/plugins/thin/dmeventd_thin.c
+++ b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
@@ -359,10 +359,8 @@ int register_device(const char *device,
goto_bad;
if (!dmeventd_lvm2_command(state->mem, cmd_str, sizeof(cmd_str),
- "_dmeventd_thin_command", device)) {
- dmeventd_lvm2_exit_with_pool(state);
+ "_dmeventd_thin_command", device))
goto_bad;
- }
if (strncmp(cmd_str, "lvm ", 4) == 0) {
if (!(state->cmd_str = dm_pool_strdup(state->mem, cmd_str + 4))) {
@@ -401,6 +399,9 @@ inval:
bad:
log_error("Failed to monitor thin pool %s.", device);
+ if (state)
+ dmeventd_lvm2_exit_with_pool(state);
+
return 0;
}
7 years, 3 months
master - coverity cleanups for recent command defs commits
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5a87d8667d0a8c...
Commit: 5a87d8667d0a8cadfea13f837cf01c91d86dad0c
Parent: 5ab051df7a6f53ababb1c283af2ec4f8e1c7cac3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Feb 13 16:11:04 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Feb 13 16:11:04 2017 -0600
coverity cleanups for recent command defs commits
---
tools/command.c | 59 +++++++++++++++++++++++++++++++++------------------
tools/lvmcmdline.c | 5 ++-
2 files changed, 41 insertions(+), 23 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index 68566fa..0ff5cd7 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -348,9 +348,11 @@ static int val_str_to_num(char *str)
/* convert "--option" to foo_ARG enum */
+#define MAX_LONG_OPT_NAME_LEN 32
+
static int opt_str_to_num(char *str)
{
- char long_name[32];
+ char long_name[MAX_LONG_OPT_NAME_LEN];
char *p;
int i;
@@ -361,9 +363,10 @@ static int opt_str_to_num(char *str)
* short option.
*/
if (strstr(str, "_long")) {
- strcpy(long_name, str);
- p = strstr(long_name, "_long");
- *p = '\0';
+ memset(long_name, 0, sizeof(long_name));
+ strncpy(long_name, str, MAX_LONG_OPT_NAME_LEN-1);
+ if ((p = strstr(long_name, "_long")))
+ *p = '\0';
for (i = 0; i < ARG_COUNT; i++) {
if (!opt_names[i].long_opt)
@@ -451,16 +454,19 @@ static int lv_to_enum(char *name)
* lvt_bits |= lvt_enum_to_bit(lvt_enum)
*/
+#define LVTYPE_LEN 64
+
static uint64_t lv_to_bits(char *name)
{
- char buf[64];
+ char buf[LVTYPE_LEN];
char *argv[MAX_LINE_ARGC];
uint64_t lvt_bits = 0;
int lvt_enum;
int argc;
int i;
- strcpy(buf, name);
+ memset(buf, 0, sizeof(buf));
+ strncpy(buf, name, LVTYPE_LEN-1);
split_line(buf, &argc, argv, '_');
@@ -737,6 +743,10 @@ static void append_oo_definition_line(const char *new_line)
/* +2 = 1 space between old and new + 1 terminating \0 */
len = strlen(old_line) + strlen(new_line) + 2;
line = malloc(len);
+ if (!line) {
+ log_error("Parsing command defs: no memory");
+ exit(EXIT_FAILURE);
+ }
memset(line, 0, len);
strcat(line, old_line);
@@ -749,14 +759,17 @@ static void append_oo_definition_line(const char *new_line)
/* Find a saved OO_FOO definition. */
+#define OO_NAME_LEN 64
+
static char *get_oo_line(const char *str)
{
char *name;
char *end;
- char str2[64];
+ char str2[OO_NAME_LEN];
int i;
- strcpy(str2, str);
+ memset(str2, 0, sizeof(str2));
+ strncpy(str2, str, OO_NAME_LEN-1);
if ((end = strstr(str2, ":")))
*end = '\0';
if ((end = strstr(str2, ",")))
@@ -917,7 +930,7 @@ static void update_prev_pos_arg(struct command *cmd, char *str, int required)
static void add_optional_opt_line(struct command *cmd, int argc, char *argv[])
{
- int takes_arg;
+ int takes_arg = 0;
int i;
for (i = 0; i < argc; i++) {
@@ -941,7 +954,7 @@ static void add_optional_opt_line(struct command *cmd, int argc, char *argv[])
static void add_ignore_opt_line(struct command *cmd, int argc, char *argv[])
{
- int takes_arg;
+ int takes_arg = 0;
int i;
for (i = 0; i < argc; i++) {
@@ -977,7 +990,7 @@ static void add_optional_pos_line(struct command *cmd, int argc, char *argv[])
static void add_required_opt_line(struct command *cmd, int argc, char *argv[])
{
- int takes_arg;
+ int takes_arg = 0;
int i;
for (i = 0; i < argc; i++) {
@@ -1345,10 +1358,12 @@ int define_commands(void)
if (cmd->desc) {
int newlen = strlen(cmd->desc) + strlen(desc) + 2;
char *newdesc = malloc(newlen);
- memset(newdesc, 0, newlen);
- snprintf(newdesc, newlen, "%s %s", cmd->desc, desc);
- cmd->desc = newdesc;
- free(desc);
+ if (newdesc) {
+ memset(newdesc, 0, newlen);
+ snprintf(newdesc, newlen, "%s %s", cmd->desc, desc);
+ cmd->desc = newdesc;
+ free(desc);
+ }
} else
cmd->desc = desc;
continue;
@@ -1632,7 +1647,7 @@ void print_usage(struct command *cmd)
void print_usage_common(struct command_name *cname, struct command *cmd)
{
- int oo, opt_enum, first;
+ int oo, opt_enum, first = 1;
printf(" Common options:");
@@ -1644,8 +1659,6 @@ void print_usage_common(struct command_name *cname, struct command *cmd)
if (cname->variants < 2)
goto all;
- first = 1;
-
for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
if (!cname->common_options[opt_enum])
continue;
@@ -2527,9 +2540,11 @@ static char *upper_command_name(char *str)
return str_upper;
}
+#define MAX_MAN_DESC (1024 * 1024)
+
static void include_description_file(char *name, char *des_file)
{
- char buf[1024 * 1024];
+ char buf[MAX_MAN_DESC];
int fd;
memset(buf, 0, sizeof(buf));
@@ -2539,7 +2554,9 @@ static void include_description_file(char *name, char *des_file)
if (fd < 0)
return;
- read(fd, buf, sizeof(buf) - 1);
+ read(fd, buf, sizeof(buf));
+
+ buf[MAX_MAN_DESC-1] = '\0';
printf(".SH DESCRIPTION\n");
printf("%s\n", buf);
@@ -2586,7 +2603,7 @@ void print_man(char *name, char *des_file, int include_primary, int include_seco
if (!(cmd->cmd_flags & CMD_FLAG_SECONDARY_SYNTAX) && !include_primary)
continue;
- if (name && strcmp(name, cmd->name))
+ if (strcmp(name, cmd->name))
continue;
if (!prev_cmd || strcmp(prev_cmd->name, cmd->name)) {
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 40e1cf4..43278ff 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1155,7 +1155,8 @@ void lvm_register_commands(void)
/* old style */
if (!commands[i].functions) {
struct command_name *cname = find_command_name(commands[i].name);
- commands[i].fn = cname->fn;
+ if (cname)
+ commands[i].fn = cname->fn;
}
}
@@ -1365,7 +1366,7 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
char buf[64];
int match_required, match_ro, match_rp, match_type, match_unused, mismatch_required;
int best_i = 0, best_required = 0, best_type = 0, best_unused = 0;
- int close_i = 0, close_ro = 0, close_type;
+ int close_i = 0, close_ro = 0, close_type = 0;
int temp_unused_options[MAX_UNUSED_COUNT];
int temp_unused_count;
int best_unused_options[MAX_UNUSED_COUNT] = { 0 };
7 years, 3 months
master - WHATS_NEW: changes for recent command defs
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5ab051df7a6f53...
Commit: 5ab051df7a6f53ababb1c283af2ec4f8e1c7cac3
Parent: c816e8b6365f777a2e555824ae2425f85869c5c5
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Feb 13 15:36:17 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Feb 13 15:36:17 2017 -0600
WHATS_NEW: changes for recent command defs
---
WHATS_NEW | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3fbef6f..c8b7fdc 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,14 +1,16 @@
Version 2.02.169 -
=====================================
- Add lvconvert --swapmetadata for previous non-specific command.
- Add lvconvert --startpoll for previous non-specific command.
- Add lvconvert --mergethin for specific --merge case.
- Add lvconvert --mergemirrors for specific --merge case.
- Add lvconvert --mergesnapshot for specific --merge case.
+ Add lvconvert --swapmetadata, new specific way to swap pool metadata LVs.
+ Add lvconvert --startpoll, new specific way to start polling conversions.
+ Add lvconvert --mergethin, new specific way to merge thin snapshots.
+ Add lvconvert --mergemirrors, new specific way to merge split mirrors.
+ Add lvconvert --mergesnapshot, new specific way to combine cow LVs.
Split up lvconvert code based on command definitions.
Split up lvchange code based on command definitions.
Generate help output and man pages from command definitions.
- Add command definitions and match every command to one.
+ Verify all command line items against command definition.
+ Match every command run to one command definition.
+ Specify every allowed command definition/syntax in command-lines.in.
Add extra memory page when limiting pthread stack size in clvmd.
Support striped/raid0* <-> raid10_near conversions
Support shrinking of RaidLvs
7 years, 3 months
master - WHATS_NEW: items from command definitions patch set
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c816e8b6365f77...
Commit: c816e8b6365f777a2e555824ae2425f85869c5c5
Parent: 717363bb9427c02addeb22ef77396132cb30c782
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Feb 13 15:22:26 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Feb 13 15:22:26 2017 -0600
WHATS_NEW: items from command definitions patch set
---
WHATS_NEW | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index b497c7e..3fbef6f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,14 @@
Version 2.02.169 -
=====================================
+ Add lvconvert --swapmetadata for previous non-specific command.
+ Add lvconvert --startpoll for previous non-specific command.
+ Add lvconvert --mergethin for specific --merge case.
+ Add lvconvert --mergemirrors for specific --merge case.
+ Add lvconvert --mergesnapshot for specific --merge case.
+ Split up lvconvert code based on command definitions.
+ Split up lvchange code based on command definitions.
+ Generate help output and man pages from command definitions.
+ Add command definitions and match every command to one.
Add extra memory page when limiting pthread stack size in clvmd.
Support striped/raid0* <-> raid10_near conversions
Support shrinking of RaidLvs
7 years, 3 months
master - lvconvert: enable previous syntax to swap metadata
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=717363bb9427c0...
Commit: 717363bb9427c02addeb22ef77396132cb30c782
Parent: b2fd5b31d3cbe1267ab01c4d6af4785f800938f4
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Feb 13 14:40:53 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Feb 13 14:41:54 2017 -0600
lvconvert: enable previous syntax to swap metadata
---
tools/command-lines.in | 14 ++++++++++++++
tools/lvconvert.c | 2 --
tools/lvmcmdline.c | 2 ++
tools/tools.h | 1 +
4 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 1a9a796..2eddd41 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -508,6 +508,20 @@ OO: --chunksize SizeKB, OO_LVCONVERT
ID: lvconvert_swap_pool_metadata
DESC: Swap metadata LV in a thin pool or cache pool (for repair only).
+lvconvert --poolmetadata LV --thinpool LV_thinpool
+OO: --chunksize SizeKB, OO_LVCONVERT
+ID: lvconvert_swap_thinpool_metadata
+DESC: Swap metadata LV in a thin pool (for repair only).
+DESC: (variant, use --swapmetadata).
+FLAGS: SECONDARY_SYNTAX
+
+lvconvert --poolmetadata LV --cachepool LV_cachepool
+OO: --chunksize SizeKB, OO_LVCONVERT
+ID: lvconvert_swap_cachepool_metadata
+DESC: Swap metadata LV in a cache pool (for repair only).
+DESC: (variant, use --swapmetadata).
+FLAGS: SECONDARY_SYNTAX
+
---
# lvconvert --merge is an extremely ambiguous command.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 502d614..3897602 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -4040,7 +4040,6 @@ int lvconvert_swap_pool_metadata_cmd(struct cmd_context *cmd, int argc, char **a
NULL, NULL, &_lvconvert_swap_pool_metadata_single);
}
-#if 0
int lvconvert_swap_pool_metadata_noarg_cmd(struct cmd_context *cmd, int argc, char **argv)
{
struct command *new_command;
@@ -4072,7 +4071,6 @@ int lvconvert_swap_pool_metadata_noarg_cmd(struct cmd_context *cmd, int argc, ch
return lvconvert_swap_pool_metadata_cmd(cmd, argc, argv);
}
-#endif
static int _lvconvert_merge_thin_single(struct cmd_context *cmd,
struct logical_volume *lv,
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 44efc85..40e1cf4 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -141,6 +141,8 @@ struct command_function command_functions[CMD_COUNT] = {
{ lvconvert_to_thin_with_external_CMD, lvconvert_to_thin_with_external_cmd },
{ lvconvert_to_cache_vol_CMD, lvconvert_to_cache_vol_cmd },
{ lvconvert_swap_pool_metadata_CMD, lvconvert_swap_pool_metadata_cmd },
+ { lvconvert_swap_thinpool_metadata_CMD, lvconvert_swap_pool_metadata_noarg_cmd },
+ { lvconvert_swap_cachepool_metadata_CMD, lvconvert_swap_pool_metadata_noarg_cmd },
{ lvconvert_merge_thin_CMD, lvconvert_merge_thin_cmd },
{ lvconvert_split_and_keep_cachepool_CMD, lvconvert_split_cachepool_cmd },
{ lvconvert_split_and_remove_cachepool_CMD, lvconvert_split_cachepool_cmd },
diff --git a/tools/tools.h b/tools/tools.h
index b3858a0..2f2a0fd 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -278,6 +278,7 @@ int lvconvert_to_pool_noarg_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_to_cache_vol_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_to_thin_with_external_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_swap_pool_metadata_cmd(struct cmd_context *cmd, int argc, char **argv);
+int lvconvert_swap_pool_metadata_noarg_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_merge_thin_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_split_cachepool_cmd(struct cmd_context *cmd, int argc, char **argv);
7 years, 3 months
master - commands: suggest --help if command doesn't match
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b2fd5b31d3cbe1...
Commit: b2fd5b31d3cbe1267ab01c4d6af4785f800938f4
Parent: 698abdde165a3e747b81f18cf3405f2d4abb5bae
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Feb 13 13:46:17 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Feb 13 13:46:17 2017 -0600
commands: suggest --help if command doesn't match
---
tools/lvmcmdline.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 58d1a44..44efc85 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1542,6 +1542,7 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
if (!best_required) {
/* cmd did not have all the required opt/pos args of any command */
log_error("Failed to find a matching command definition.");
+ log_error("Run '%s --help' for more information.", name);
if (close_ro) {
log_warn("Closest command usage is:");
print_usage(&_cmdline.commands[close_i]);
7 years, 3 months