master - dmeventd: Fix memory leak
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5ca54c4f0b2712...
Commit: 5ca54c4f0b27125bc385d55ea0b44853fc7744dd
Parent: 7db95d0d40c3608b7298cb19380430613fa9e532
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Jul 31 15:23:13 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Jul 31 15:23:13 2013 -0500
dmeventd: Fix memory leak
When creating a timeout thread for snapshots, the thread is not
tracked and thus never joined. This means that the exit status
of the timeout thread is held indefinitely. Saves a bit of
memory to set PTHREAD_CREATE_DETACHED when creating this thread.
I've also added pthread_attr_init|destroy to setup the creation
pthread_attr_t.
Reported-by: NeilBrown <neilb(a)suse.de>
Signed-off-by: Jonathan Brassow <jbrassow(a)redhat.com>
---
WHATS_NEW | 1 +
daemons/dmeventd/dmeventd.c | 41 +++++++++++++++++++++++++++++++++--------
2 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 69a8275..c76dc68 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.100 -
================================
+ Create dmeventd timeout threads as "detached" so exit status is freed.
Add initial support thin pool lvconvert --repair.
Add --with-thin-repair and --with-thin-dump configure options.
Add lvm.conf thin_repair/dump_executable and thin_repair_options.
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 92c93d9..9c7a6c6 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -264,16 +264,44 @@ static struct dso_data *_alloc_dso_data(struct message_data *data)
return ret;
}
-/* Create a device monitoring thread. */
+/*
+ * Create a device monitoring thread.
+ * N.B. Error codes returned are positive.
+ */
static int _pthread_create_smallstack(pthread_t *t, void *(*fun)(void *), void *arg)
{
+ int r;
+ pthread_t tmp;
pthread_attr_t attr;
pthread_attr_init(&attr);
+
+ /*
+ * From pthread_attr_init man page:
+ * POSIX.1-2001 documents an ENOMEM error for pthread_attr_init(); on
+ * Linux these functions always succeed (but portable and future-proof
+ * applications should nevertheless handle a possible error return).
+ */
+ if ((r = pthread_attr_init(&attr)) != 0)
+ return r;
+
/*
* We use a smaller stack since it gets preallocated in its entirety
*/
pthread_attr_setstacksize(&attr, THREAD_STACK_SIZE);
- return pthread_create(t, &attr, fun, arg);
+
+ /*
+ * If no-one will be waiting, we need to detach.
+ */
+ if (!t) {
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ t = &tmp;
+ }
+
+ r = pthread_create(t, &attr, fun, arg);
+
+ pthread_attr_destroy(&attr);
+
+ return r;
}
static void _free_dso_data(struct dso_data *data)
@@ -548,12 +576,9 @@ static int _register_for_timeout(struct thread_status *thread)
pthread_cond_signal(&_timeout_cond);
}
- if (!_timeout_running) {
- pthread_t timeout_id;
-
- if (!(ret = _pthread_create_smallstack(&timeout_id, _timeout_thread, NULL)))
- _timeout_running = 1;
- }
+ if (!_timeout_running &&
+ !(ret = _pthread_create_smallstack(NULL, _timeout_thread, NULL)))
+ _timeout_running = 1;
pthread_mutex_unlock(&_timeout_mutex);
10 years, 1 month
master - configure: autoreconf
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7db95d0d40c360...
Commit: 7db95d0d40c3608b7298cb19380430613fa9e532
Parent: de0cba0e2d588a327867f17015cecba516364591
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jul 31 15:59:05 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jul 31 15:59:05 2013 +0200
configure: autoreconf
---
configure | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/configure b/configure
index a9a2830..20a706a 100755
--- a/configure
+++ b/configure
@@ -7128,7 +7128,7 @@ fi
set dummy thin_dump; 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_THIN_DUMP_CMD+:} false; then :
+if test "${ac_cv_path_THIN_DUMP_CMD+set}" = set; then :
$as_echo_n "(cached) " >&6
else
case $THIN_DUMP_CMD in
@@ -7142,7 +7142,7 @@ 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
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_THIN_DUMP_CMD="$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
@@ -7180,7 +7180,7 @@ fi
set dummy thin_repair; 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_THIN_REPAIR_CMD+:} false; then :
+if test "${ac_cv_path_THIN_REPAIR_CMD+set}" = set; then :
$as_echo_n "(cached) " >&6
else
case $THIN_REPAIR_CMD in
@@ -7194,7 +7194,7 @@ 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
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_THIN_REPAIR_CMD="$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
10 years, 1 month
master - thin: initial --repair support for pools
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=de0cba0e2d588a...
Commit: de0cba0e2d588a327867f17015cecba516364591
Parent: 22fc80982aa08ef8a907fc858a29a30c2d9293a7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 24 15:25:34 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 31 15:32:36 2013 +0200
thin: initial --repair support for pools
Initial basic support for repair.
It currently takes pool metadata spare volume, which
is used for recovery. New spare is created if the volume
is successfuly repaired.
After the operation the previous _tmeta volume is moved
into _tmeta%d volume and if everything is ok, this volume
could be removed.
New _tmeta needs to be pvmoved to proper place and also
converted to i.e. mirror if it should be mirrored.
Later version will try to automate some steps here.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 196 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 197 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6d59265..69a8275 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.100 -
================================
+ Add initial support thin pool lvconvert --repair.
Add --with-thin-repair and --with-thin-dump configure options.
Add lvm.conf thin_repair/dump_executable and thin_repair_options.
Require 1.9 thin pool target version for online thin pool metadata resize.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index bd07497..88e0119 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1948,6 +1948,199 @@ out:
return r;
}
+static int _lvconvert_thinpool_repair(struct cmd_context *cmd,
+ struct logical_volume *pool_lv,
+ struct lvconvert_params *lp)
+{
+ const char *dmdir = dm_dir();
+ const char *thin_dump =
+ find_config_tree_str_allow_empty(cmd, global_thin_dump_executable_CFG, NULL);
+ const char *thin_repair =
+ find_config_tree_str_allow_empty(cmd, global_thin_repair_executable_CFG, NULL);
+ const struct dm_config_node *cn;
+ const struct dm_config_value *cv;
+ int ret = 0, status;
+ int args = 0;
+ const char *argv[19]; /* Max supported 10 args */
+ char *split, *dm_name, *trans_id_str;
+ char meta_path[PATH_MAX];
+ char pms_path[PATH_MAX];
+ uint64_t trans_id;
+ struct logical_volume *pmslv;
+ struct logical_volume *mlv = first_seg(pool_lv)->metadata_lv;
+ FILE *f;
+
+ if (!thin_repair[0]) {
+ log_error("Thin repair commnand is not configured. Repair is disabled.");
+ return 0; /* Checking disabled */
+ }
+
+ /* Check we have pool metadata spare LV */
+ if (!handle_pool_metadata_spare(pool_lv->vg, 0, NULL, 1))
+ return_0;
+
+ pmslv = pool_lv->vg->pool_metadata_spare_lv;
+
+ if (!(dm_name = dm_build_dm_name(cmd->mem, mlv->vg->name,
+ mlv->name, NULL)) ||
+ (dm_snprintf(meta_path, sizeof(meta_path), "%s/%s", dmdir, dm_name) < 0)) {
+ log_error("Failed to build thin metadata path.");
+ return 0;
+ }
+
+ if (!(dm_name = dm_build_dm_name(cmd->mem, pmslv->vg->name,
+ pmslv->name, NULL)) ||
+ (dm_snprintf(pms_path, sizeof(pms_path), "%s/%s", dmdir, dm_name) < 0)) {
+ log_error("Failed to build pool metadata spare path.");
+ return 0;
+ }
+
+ if ((cn = find_config_tree_node(cmd, global_thin_repair_options_CFG, NULL))) {
+ for (cv = cn->v; cv && args < 16; cv = cv->next) {
+ if (cv->type != DM_CFG_STRING) {
+ log_error("Invalid string in config file: "
+ "global/thin_repair_options");
+ return 0;
+ }
+ argv[++args] = cv->v.str;
+ }
+ } else {
+ /* Use default options (no support for options with spaces) */
+ if (!(split = dm_pool_strdup(cmd->mem, DEFAULT_THIN_REPAIR_OPTIONS))) {
+ log_error("Failed to duplicate thin repair string.");
+ return 0;
+ }
+ args = dm_split_words(split, 16, 0, (char**) argv + 1);
+ }
+
+ if (args == 10) {
+ log_error("Too many options for thin repair command.");
+ return 0;
+ }
+
+ argv[0] = thin_repair;
+ argv[++args] = "-i";
+ argv[++args] = meta_path;
+ argv[++args] = "-o";
+ argv[++args] = pms_path;
+ argv[++args] = NULL;
+
+ if (pool_is_active(pool_lv)) {
+ log_error("Only inactive pool can be repaired.");
+ return 0;
+ }
+
+ if (!activate_lv_local(cmd, pmslv)) {
+ log_error("Cannot activate pool metadata spare volume %s.",
+ pmslv->name);
+ return 0;
+ }
+
+ if (!activate_lv_local(cmd, mlv)) {
+ log_error("Cannot activate thin pool metadata volume %s.",
+ mlv->name);
+ goto deactivate_pmslv;
+ }
+
+ if (!(ret = exec_cmd(cmd, (const char * const *)argv, &status, 1))) {
+ log_error("Repair of thin metadata volume of thin pool %s/%s failed (status:%d). "
+ "Manual repair required!",
+ pool_lv->vg->name, pool_lv->name, status);
+ goto deactivate_mlv;
+ }
+
+ if (thin_dump[0]) {
+ if (dm_snprintf(meta_path, sizeof(meta_path), "%s %s", thin_dump, pms_path) < 0) {
+ log_error("Command cannot fit into buffer.");
+ goto deactivate_mlv;
+ }
+
+ if (!(f = popen(meta_path, "r")))
+ log_warn("WARNING: Cannot read output from %s.", meta_path);
+ else {
+ /*
+ * Scan only the 1st. line for transation id.
+ * Watch out, if the thin_dump format changes
+ */
+ if ((fgets(meta_path, sizeof(meta_path), f) > 0) &&
+ (trans_id_str = strstr(meta_path, "transaction=\"")) &&
+ (sscanf(trans_id_str + 13, "%" PRIu64, &trans_id) == 1) &&
+ (trans_id != first_seg(pool_lv)->transaction_id) &&
+ ((trans_id - 1) != first_seg(pool_lv)->transaction_id))
+ log_error("Transaction id %" PRIu64 " from pool \"%s/%s\" "
+ "does not match repaired transaction id "
+ "%" PRIu64 " from %s.",
+ first_seg(pool_lv)->transaction_id,
+ pool_lv->vg->name, pool_lv->name, trans_id,
+ pms_path);
+ if (pclose(f))
+ log_sys_error("popen", thin_dump);
+ }
+ }
+
+deactivate_mlv:
+ if (!deactivate_lv(cmd, mlv)) {
+ log_error("Cannot deactivate thin pool metadata volume %s.",
+ mlv->name);
+ return 0;
+ }
+
+deactivate_pmslv:
+ if (!deactivate_lv(cmd, pmslv)) {
+ log_error("Cannot deactivate thin pool metadata volume %s.",
+ mlv->name);
+ return 0;
+ }
+
+ if (!ret)
+ return 0;
+
+ if (pmslv == pool_lv->vg->pool_metadata_spare_lv) {
+ pool_lv->vg->pool_metadata_spare_lv = NULL;
+ pmslv->status &= ~POOL_METADATA_SPARE;
+ lv_set_visible(pmslv);
+ }
+
+ /* Try to allocate new pool metadata spare LV */
+ if (!handle_pool_metadata_spare(pool_lv->vg, 0, NULL, 1))
+ stack;
+
+ if (dm_snprintf(meta_path, sizeof(meta_path), "%s%%d", mlv->name) < 0) {
+ log_error("Can't prepare new name for %s.", mlv->name);
+ return 0;
+ }
+
+ if (!generate_lv_name(pool_lv->vg, meta_path, pms_path, sizeof(pms_path))) {
+ log_error("Can't generate new name for %s.", meta_path);
+ return 0;
+ }
+
+ if (!detach_pool_metadata_lv(first_seg(pool_lv), &mlv))
+ return_0;
+
+ if (!_swap_lv_identifiers(cmd, mlv, pmslv))
+ return_0;
+
+ /* Used _pmspare will become _tmeta */
+ if (!attach_pool_metadata_lv(first_seg(pool_lv), pmslv))
+ return_0;
+
+ /* Used _tmeta will become visible _tmeta%d */
+ if (!lv_rename_update(cmd, mlv, pms_path, 0))
+ return_0;
+
+ if (!vg_write(pool_lv->vg) || !vg_commit(pool_lv->vg))
+ return_0;
+
+ log_warn("WARNING: If everything works, remove \"%s/%s\".",
+ mlv->vg->name, mlv->name);
+
+ log_warn("WARNING: Use pvmove command to move \"%s/%s\" on the best fitting PV.",
+ mlv->vg->name, first_seg(pool_lv)->metadata_lv->name);
+
+ return 1;
+}
+
static int _lvconvert_thinpool_external(struct cmd_context *cmd,
struct logical_volume *pool_lv,
struct logical_volume *external_lv,
@@ -2326,6 +2519,9 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
return ECMD_FAILED;
}
+ if (arg_count(cmd, repair_ARG) && lv_is_thin_pool(lv))
+ return _lvconvert_thinpool_repair(cmd, lv, lp);
+
if (arg_count(cmd, repair_ARG) &&
!(lv->status & MIRRORED) && !(lv->status & RAID)) {
if (arg_count(cmd, use_policies_ARG))
10 years, 1 month
master - thin: add thin_repair and thin_dump options
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=22fc80982aa08e...
Commit: 22fc80982aa08ef8a907fc858a29a30c2d9293a7
Parent: ea605d1ec72960cf8076fb0260dd151a32750ff6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 31 14:38:10 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 31 15:30:47 2013 +0200
thin: add thin_repair and thin_dump options
Add new configure lvm.conf options for binaries thin_repair
and thin_dump.
Those are part of device-mapper-persistent-data package
and will be used for recovery of thin_pool.
---
WHATS_NEW | 2 +
conf/example.conf.in | 28 ++++++++--
configure | 124 ++++++++++++++++++++++++++++++++++++++++++
configure.in | 26 +++++++++
lib/config/config_settings.h | 3 +
lib/config/defaults.h | 1 +
lib/misc/configure.h.in | 6 ++
7 files changed, 186 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 71228c9..6d59265 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
Version 2.02.100 -
================================
+ Add --with-thin-repair and --with-thin-dump configure options.
+ Add lvm.conf thin_repair/dump_executable and thin_repair_options.
Require 1.9 thin pool target version for online thin pool metadata resize.
Ignore previous LV seg with alloc contiguous & cling when num stripes varies.
Fix segfault if devices/global_filter is not specified correctly.
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 2032a81..0e313c8 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -561,11 +561,29 @@ global {
# The thin tools are available as part of the device-mapper-persistent-data
# package from https://github.com/jthornber/thin-provisioning-tools.
#
- thin_check_executable = "@THIN_CHECK_CMD@"
+ # thin_check_executable = "@THIN_CHECK_CMD@"
- # String with options passed with thin_check command. By default,
- # option '-q' is for quiet output.
- thin_check_options = [ "-q" ]
+ # Array of string options passed with thin_check command. By default,
+ # option "-q" is for quiet output.
+ # With thin_check version 2.1 or newer you can add "--ignore-non-fatal-errors"
+ # to let it pass through ignoreable errors and fix them later.
+ #
+ # thin_check_options = [ "-q" ]
+
+ # Full path of the utility called to repair a thin metadata device
+ # is in a state that allows it to be used.
+ # Each time a thin pool needs repair this utility is executed.
+ # See thin_check_executable how to obtain binaries.
+ #
+ # thin_repair_executable = "@THIN_REPAIR_CMD@"
+
+ # Array of extra string options passed with thin_repair command.
+ # thin_repair_options = [ "" ]
+
+ # Full path of the utility called to dump thin metadata content.
+ # See thin_check_executable how to obtain binaries.
+ #
+ # thin_dump_executable = "@THIN_DUMP_CMD@"
# If set, given features are not used by thin driver.
# This can be helpful not just for testing, but i.e. allows to avoid
@@ -574,6 +592,8 @@ global {
# block_size
# discards
# discards_non_power_2
+ # external_origin
+ # metadata_resize
#
# thin_disabled_features = [ "discards", "block_size" ]
}
diff --git a/configure b/configure
index 12272d1..a9a2830 100755
--- a/configure
+++ b/configure
@@ -730,6 +730,8 @@ PKGCONFIGINIT_CFLAGS
PKG_CONFIG_LIBDIR
PKG_CONFIG_PATH
PKG_CONFIG
+THIN_REPAIR_CMD
+THIN_DUMP_CMD
THIN_CHECK_CMD
POW_LIB
LIBOBJS
@@ -826,6 +828,8 @@ with_raid
with_replicators
with_thin
with_thin_check
+with_thin_dump
+with_thin_repair
enable_readline
enable_realtime
enable_ocf
@@ -1598,6 +1602,8 @@ Optional Packages:
--with-thin=TYPE thin provisioning support: internal/shared/none
[[TYPE=none]]
--with-thin-check=PATH thin_check tool: [[autodetect]]
+ --with-thin-dump=PATH thin_dump tool: [[autodetect]]
+ --with-thin-repair=PATH thin_repair tool: [[autodetect]]
--with-ocfdir=DIR install OCF files in DIR
[[PREFIX/lib/ocf/resource.d/lvm2]]
--with-default-pid-dir=PID_DIR
@@ -7108,6 +7114,110 @@ fi
test -z "$THIN_CHECK_CMD" && as_fn_error $? "thin_check not found in path $PATH" "$LINENO" 5
fi
+
+# Check whether --with-thin-dump was given.
+if test "${with_thin_dump+set}" = set; then :
+ withval=$with_thin_dump; THIN_DUMP_CMD=$withval
+else
+ THIN_DUMP_CMD="autodetect"
+fi
+
+ # Empty means a config way to ignore thin checking
+ if test "$THIN_DUMP_CMD" = "autodetect"; then
+ # Extract the first word of "thin_dump", so it can be a program name with args.
+set dummy thin_dump; 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_THIN_DUMP_CMD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $THIN_DUMP_CMD in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_THIN_DUMP_CMD="$THIN_DUMP_CMD" # 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_THIN_DUMP_CMD="$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
+THIN_DUMP_CMD=$ac_cv_path_THIN_DUMP_CMD
+if test -n "$THIN_DUMP_CMD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THIN_DUMP_CMD" >&5
+$as_echo "$THIN_DUMP_CMD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -z "$THIN_DUMP_CMD" && as_fn_error $? "thin_dump not found in path $PATH" "$LINENO" 5
+ fi
+
+# Check whether --with-thin-repair was given.
+if test "${with_thin_repair+set}" = set; then :
+ withval=$with_thin_repair; THIN_REPAIR_CMD=$withval
+else
+ THIN_REPAIR_CMD="autodetect"
+fi
+
+ # Empty means a config way to ignore thin checking
+ if test "$THIN_REPAIR_CMD" = "autodetect"; then
+ # Extract the first word of "thin_repair", so it can be a program name with args.
+set dummy thin_repair; 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_THIN_REPAIR_CMD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $THIN_REPAIR_CMD in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_THIN_REPAIR_CMD="$THIN_REPAIR_CMD" # 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_THIN_REPAIR_CMD="$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
+THIN_REPAIR_CMD=$ac_cv_path_THIN_REPAIR_CMD
+if test -n "$THIN_REPAIR_CMD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THIN_REPAIR_CMD" >&5
+$as_echo "$THIN_REPAIR_CMD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -z "$THIN_REPAIR_CMD" && as_fn_error $? "thin_repair not found in path $PATH" "$LINENO" 5
+ fi
;;
esac
@@ -7118,6 +7228,18 @@ _ACEOF
+cat >>confdefs.h <<_ACEOF
+#define THIN_DUMP_CMD "$THIN_DUMP_CMD"
+_ACEOF
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define THIN_REPAIR_CMD "$THIN_REPAIR_CMD"
+_ACEOF
+
+
+
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable readline" >&5
$as_echo_n "checking whether to enable readline... " >&6; }
@@ -10809,6 +10931,8 @@ LVM_LIBAPI=`echo "$VER" | $AWK -F '[()]' '{print $2}'`
+
+
################################################################################
ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/lvmetad/Makefile conf/Makefile conf/example.conf conf/default.profile include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile python/Makefile python/setup.py scripts/blkdeactivate.sh scripts/blk_availability_
init_red_hat scripts/blk_availability_systemd_red_hat.service scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/dm_event_systemd_red_hat.socket scripts/dm_event_systemd_red_hat.service scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_tmpfiles_red_hat.conf scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile"
diff --git a/configure.in b/configure.in
index 97ddc1d..611ab37 100644
--- a/configure.in
+++ b/configure.in
@@ -424,12 +424,36 @@ case "$THIN" in
AC_PATH_PROG(THIN_CHECK_CMD, thin_check)
test -z "$THIN_CHECK_CMD" && AC_MSG_ERROR(thin_check not found in path $PATH)
fi
+ AC_ARG_WITH(thin-dump,
+ AC_HELP_STRING([--with-thin-dump=PATH],
+ [thin_dump tool: [[autodetect]]]),
+ THIN_DUMP_CMD=$withval, THIN_DUMP_CMD="autodetect")
+ # Empty means a config way to ignore thin checking
+ if test "$THIN_DUMP_CMD" = "autodetect"; then
+ AC_PATH_PROG(THIN_DUMP_CMD, thin_dump)
+ test -z "$THIN_DUMP_CMD" && AC_MSG_ERROR(thin_dump not found in path $PATH)
+ fi
+ AC_ARG_WITH(thin-repair,
+ AC_HELP_STRING([--with-thin-repair=PATH],
+ [thin_repair tool: [[autodetect]]]),
+ THIN_REPAIR_CMD=$withval, THIN_REPAIR_CMD="autodetect")
+ # Empty means a config way to ignore thin checking
+ if test "$THIN_REPAIR_CMD" = "autodetect"; then
+ AC_PATH_PROG(THIN_REPAIR_CMD, thin_repair)
+ test -z "$THIN_REPAIR_CMD" && AC_MSG_ERROR(thin_repair not found in path $PATH)
+ fi
;;
esac
AC_DEFINE_UNQUOTED([THIN_CHECK_CMD], ["$THIN_CHECK_CMD"],
[The path to 'thin_check', if available.])
+AC_DEFINE_UNQUOTED([THIN_DUMP_CMD], ["$THIN_DUMP_CMD"],
+ [The path to 'thin_dump', if available.])
+
+AC_DEFINE_UNQUOTED([THIN_REPAIR_CMD], ["$THIN_REPAIR_CMD"],
+ [The path to 'thin_repair', if available.])
+
################################################################################
dnl -- Disable readline
@@ -1598,6 +1622,8 @@ AC_SUBST(STATIC_LINK)
AC_SUBST(TESTING)
AC_SUBST(THIN)
AC_SUBST(THIN_CHECK_CMD)
+AC_SUBST(THIN_DUMP_CMD)
+AC_SUBST(THIN_REPAIR_CMD)
AC_SUBST(UDEV_LIBS)
AC_SUBST(UDEV_PC)
AC_SUBST(UDEV_RULES)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 16a9437..3992764 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -160,6 +160,9 @@ cfg(global_use_lvmetad_CFG, "use_lvmetad", global_CFG_SECTION, 0, CFG_TYPE_BOOL,
cfg(global_thin_check_executable_CFG, "thin_check_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, THIN_CHECK_CMD, vsn(2, 2, 94), NULL)
cfg_array(global_thin_check_options_CFG, "thin_check_options", global_CFG_SECTION, 0, CFG_TYPE_STRING, "#S" DEFAULT_THIN_CHECK_OPTIONS, vsn(2, 2, 96), NULL)
cfg_array(global_thin_disabled_features_CFG, "thin_disabled_features", global_CFG_SECTION, 0, CFG_TYPE_STRING, "#S", vsn(2, 2, 99), NULL)
+cfg(global_thin_dump_executable_CFG, "thin_dump_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, THIN_DUMP_CMD, vsn(2, 2, 100), NULL)
+cfg(global_thin_repair_executable_CFG, "thin_repair_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, THIN_REPAIR_CMD, vsn(2, 2, 100), NULL)
+cfg_array(global_thin_repair_options_CFG, "thin_repair_options", global_CFG_SECTION, 0, CFG_TYPE_STRING, "#S" DEFAULT_THIN_REPAIR_OPTIONS, vsn(2, 2, 100), NULL)
cfg(activation_checks_CFG, "checks", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_ACTIVATION_CHECKS, vsn(2, 2, 86), NULL)
cfg(activation_udev_sync_CFG, "udev_sync", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_UDEV_SYNC, vsn(2, 2, 51), NULL)
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 34ce2ea..5af0f00 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -66,6 +66,7 @@
#define DEFAULT_BACKGROUND_POLLING 1
#define DEFAULT_THIN_CHECK_OPTIONS "-q"
+#define DEFAULT_THIN_REPAIR_OPTIONS ""
#define DEFAULT_THIN_POOL_METADATA_REQUIRE_SEPARATE_PVS 0
#define DEFAULT_THIN_POOL_MAX_METADATA_SIZE (16 * 1024 * 1024) /* KB */
#define DEFAULT_THIN_POOL_MIN_METADATA_SIZE 2048 /* KB */
diff --git a/lib/misc/configure.h.in b/lib/misc/configure.h.in
index aae4f24..13ba882 100644
--- a/lib/misc/configure.h.in
+++ b/lib/misc/configure.h.in
@@ -546,9 +546,15 @@
/* The path to 'thin_check', if available. */
#undef THIN_CHECK_CMD
+/* The path to 'thin_dump', if available. */
+#undef THIN_DUMP_CMD
+
/* Define to 1 to include built-in support for thin provisioning. */
#undef THIN_INTERNAL
+/* The path to 'thin_repair', if available. */
+#undef THIN_REPAIR_CMD
+
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
10 years, 1 month
master - thin: metadata resize needs 1.9 version
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ea605d1ec72960...
Commit: ea605d1ec72960cf8076fb0260dd151a32750ff6
Parent: 7b58f104427911c4ef9a82a7726ccc62978e1cf5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jul 25 14:35:08 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 31 15:29:27 2013 +0200
thin: metadata resize needs 1.9 version
Version 1.8 is not yet fully usable for metadata resize.
---
WHATS_NEW | 1 +
lib/thin/thin.c | 2 +-
test/shell/lvresize-thin-metadata.sh | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 21c1f6d..71228c9 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.100 -
================================
+ Require 1.9 thin pool target version for online thin pool metadata resize.
Ignore previous LV seg with alloc contiguous & cling when num stripes varies.
Fix segfault if devices/global_filter is not specified correctly.
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index 863f051..d559219 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -584,7 +584,7 @@ static int _thin_target_present(struct cmd_context *cmd,
{ 1, 1, THIN_FEATURE_EXTERNAL_ORIGIN, "external_origin" },
{ 1, 4, THIN_FEATURE_BLOCK_SIZE, "block_size" },
{ 1, 5, THIN_FEATURE_DISCARDS_NON_POWER_2, "discards_non_power_2" },
- { 1, 8, THIN_FEATURE_METADATA_RESIZE, "metadata_resize" },
+ { 1, 9, THIN_FEATURE_METADATA_RESIZE, "metadata_resize" },
};
static const char _lvmconf[] = "global/thin_disabled_features";
diff --git a/test/shell/lvresize-thin-metadata.sh b/test/shell/lvresize-thin-metadata.sh
index d488a43..521b76c 100644
--- a/test/shell/lvresize-thin-metadata.sh
+++ b/test/shell/lvresize-thin-metadata.sh
@@ -11,7 +11,7 @@
. lib/test
-aux have_thin 1 8 0 || skip
+aux have_thin 1 9 0 || skip
aux prepare_pvs 3
10 years, 1 month
master - thin: move setting of THIN_POOL
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7b58f104427911...
Commit: 7b58f104427911c4ef9a82a7726ccc62978e1cf5
Parent: 5d9628475e81b15f3196a69ab4b3288466cd168f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 31 15:13:54 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 31 15:27:38 2013 +0200
thin: move setting of THIN_POOL
Set flag when attaching data LV which make segment THIN_POOL.
---
lib/metadata/thin_manip.c | 13 +++++++------
lib/thin/thin.c | 5 ++---
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 35e1ec7..6851b3f 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -53,6 +53,7 @@ int attach_pool_data_lv(struct lv_segment *pool_seg, struct logical_volume *pool
if (!set_lv_segment_area_lv(pool_seg, 0, pool_data_lv, 0, THIN_POOL_DATA))
return_0;
+ pool_seg->lv->status |= THIN_POOL;
lv_set_hidden(pool_data_lv);
return 1;
@@ -498,18 +499,18 @@ int create_pool(struct logical_volume *pool_lv, const struct segment_type *segty
goto_bad;
seg = first_seg(pool_lv);
- seg->segtype = segtype; /* Set as thin_pool segment */
- seg->lv->status |= THIN_POOL;
-
- if (!attach_pool_metadata_lv(seg, meta_lv))
- goto_bad;
-
/* Drop reference as attach_pool_data_lv() takes it again */
if (!remove_seg_from_segs_using_this_lv(data_lv, seg))
goto_bad;
+
if (!attach_pool_data_lv(seg, data_lv))
goto_bad;
+ if (!attach_pool_metadata_lv(seg, meta_lv))
+ goto_bad;
+
+ seg->segtype = segtype; /* Set as thin_pool segment */
+
return 1;
bad:
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index bdb9c88..863f051 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -103,11 +103,10 @@ static int _thin_pool_text_import(struct lv_segment *seg,
if (!(pool_data_lv = find_lv(seg->lv->vg, lv_name)))
return SEG_LOG_ERROR("Unknown pool %s in", lv_name);
- seg->lv->status |= THIN_POOL;
- if (!attach_pool_metadata_lv(seg, pool_metadata_lv))
+ if (!attach_pool_data_lv(seg, pool_data_lv))
return_0;
- if (!attach_pool_data_lv(seg, pool_data_lv))
+ if (!attach_pool_metadata_lv(seg, pool_metadata_lv))
return_0;
if (!dm_config_get_uint64(sn, "transaction_id", &seg->transaction_id))
10 years, 1 month
master - libdm: add DM_ABORT_ON_INTERNAL_ERRORS
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5d9628475e81b1...
Commit: 5d9628475e81b15f3196a69ab4b3288466cd168f
Parent: 4a722c5c8bcc902043ece29550a5d61ea7fdbef3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jul 25 14:32:09 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 31 15:27:34 2013 +0200
libdm: add DM_ABORT_ON_INTERNAL_ERRORS
Support tests with abort when libdm encounters internal
error - i.e. for dmsetup tool.
Code execution will be aborted when
env var DM_ABORT_ON_INTERNAL_ERRORS is set to 1
---
WHATS_NEW_DM | 1 +
libdm/libdevmapper.h | 1 +
libdm/libdm-common.c | 30 +++++++++++++++++-------------
test/lib/test.sh | 5 ++++-
4 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index cd77bc6..ffee9a3 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.79 -
================================
+ Add DM_ABORT_ON_INTERNAL_ERRORS env var support to abort on internal errors.
Version 1.02.78 - 24th July 2013
================================
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 0c415c6..0b03eaf 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -57,6 +57,7 @@ extern "C" {
* Use dm_log_with_errno_init(NULL) to restore the default log fn.
* Error messages may have a non-zero errno.
* Debug messages may have a non-zero class.
+ * Aborts on internal error when env DM_ABORT_ON_INTERNAL_ERRORS is 1
*/
typedef void (*dm_log_with_errno_fn) (int level, const char *file, int line,
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 8d5eca8..de4b747 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -114,22 +114,26 @@ static void _default_log_line(int level,
int line __attribute__((unused)), int dm_errno_or_class,
const char *f, va_list ap)
{
- int use_stderr = level & _LOG_STDERR;
+ static int _abort_on_internal_errors = -1;
+ FILE *out = (level & _LOG_STDERR) ? stderr : stdout;
level &= ~_LOG_STDERR;
- if (level > _LOG_WARN && !_verbose)
- return;
+ if (level <= _LOG_WARN || _verbose) {
+ if (level < _LOG_WARN)
+ out = stderr;
+ vfprintf(out, f, ap);
+ fputc('\n', out);
+ }
- if (level < _LOG_WARN)
- vfprintf(stderr, f, ap);
- else
- vfprintf(use_stderr ? stderr : stdout, f, ap);
+ if (_abort_on_internal_errors < 0)
+ /* Set when env DM_ABORT_ON_INTERNAL_ERRORS is 1 */
+ _abort_on_internal_errors =
+ !strcmp(getenv("DM_ABORT_ON_INTERNAL_ERRORS") ? : "0", "1");
- if (level < _LOG_WARN)
- fprintf(stderr, "\n");
- else
- fprintf(use_stderr ? stderr : stdout, "\n");
+ if (_abort_on_internal_errors &&
+ !strncmp(f, INTERNAL_ERROR, sizeof(INTERNAL_ERROR) - 1))
+ abort();
}
__attribute__((format(printf, 5, 6)))
diff --git a/test/lib/test.sh b/test/lib/test.sh
index 7e0df73..20da059 100644
--- a/test/lib/test.sh
+++ b/test/lib/test.sh
@@ -50,7 +50,10 @@ else
mkdir "$DM_DEV_DIR/mapper"
fi
-export DM_DEV_DIR LVM_SYSTEM_DIR
+# abort on the internal dm errors in the tests (allowing test user override)
+DM_ABORT_ON_INTERNAL_ERRORS=${DM_ABORT_ON_INTERNAL_ERRORS:-1}
+
+export DM_DEV_DIR LVM_SYSTEM_DIR DM_ABORT_ON_INTERNAL_ERRORS
cd "$TESTDIR"
10 years, 1 month
master - cleanup: use compile time strlen
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4a722c5c8bcc90...
Commit: 4a722c5c8bcc902043ece29550a5d61ea7fdbef3
Parent: ba1a8878d05e3753d9ae5a98e51afac71f078fc9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jul 25 14:18:18 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 31 15:24:45 2013 +0200
cleanup: use compile time strlen
Use sizeof instead of strlen().
---
lib/log/log.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/lib/log/log.c b/lib/log/log.c
index 06e053f..e0c1e73 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -196,8 +196,7 @@ void print_log(int level, const char *file, int line, int dm_errno_or_class,
level &= ~(_LOG_STDERR|_LOG_ONCE);
if (_abort_on_internal_errors &&
- !strncmp(format, INTERNAL_ERROR,
- strlen(INTERNAL_ERROR))) {
+ !strncmp(format, INTERNAL_ERROR, sizeof(INTERNAL_ERROR) - 1)) {
fatal_internal_error = 1;
/* Internal errors triggering abort cannot be suppressed. */
_log_suppress = 0;
10 years, 1 month
master - tests: add profileconf fn to generate profiles
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ba1a8878d05e37...
Commit: ba1a8878d05e3753d9ae5a98e51afac71f078fc9
Parent: b6bfddcd0a830d0c9312bc3ab906cb3d1b7a6dd9
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jul 30 15:44:15 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Jul 30 15:44:15 2013 +0200
tests: add profileconf fn to generate profiles
profileconf <profile_name> <config> ...
---
test/lib/aux.sh | 44 +++++++++++++++++++++++++++++++++-----------
1 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index f481db5..d61f17d 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -476,15 +476,24 @@ unhide_dev() {
lvmconf "$filter"
}
-lvmconf() {
+generate_config() {
+ if test -n "$profile_name"; then
+ config_values=PROFILE_VALUES_$profile_name
+ config=PROFILE_$profile_name
+ touch $config_values
+ else
+ config_values=CONFIG_VALUES
+ config=CONFIG
+ fi
+
LVM_TEST_LOCKING=${LVM_TEST_LOCKING:-1}
if test "$DM_DEV_DIR" = "/dev"; then
LVM_VERIFY_UDEV=${LVM_VERIFY_UDEV:-0}
else
LVM_VERIFY_UDEV=${LVM_VERIFY_UDEV:-1}
fi
- test -f CONFIG_VALUES || {
- cat > CONFIG_VALUES <<-EOF
+ test -f $config_values || {
+ cat > $config_values <<-EOF
devices/dir = "$DM_DEV_DIR"
devices/scan = "$DM_DEV_DIR"
devices/filter = "a|.*|"
@@ -523,23 +532,36 @@ EOF
local v
for v in "$@"; do
- echo "$v" >> CONFIG_VALUES
+ echo "$v" >> $config_values
done
- rm -f CONFIG
+ rm -f $config
local s
- for s in $(cat CONFIG_VALUES | cut -f1 -d/ | sort | uniq); do
- echo "$s {" >> CONFIG
+ for s in $(cat $config_values | cut -f1 -d/ | sort | uniq); do
+ echo "$s {" >> $config
local k
- for k in $(grep ^"$s"/ CONFIG_VALUES | cut -f1 -d= | sed -e 's, *$,,' | sort | uniq); do
- grep "^$k" CONFIG_VALUES | tail -n 1 | sed -e "s,^$s/, ," >> CONFIG
+ for k in $(grep ^"$s"/ $config_values | cut -f1 -d= | sed -e 's, *$,,' | sort | uniq); do
+ grep "^$k" $config_values | tail -n 1 | sed -e "s,^$s/, ," >> $config
done
- echo "}" >> CONFIG
- echo >> CONFIG
+ echo "}" >> $config
+ echo >> $config
done
+}
+
+lvmconf() {
+ unset profile_name
+ generate_config "$@"
mv -f CONFIG etc/lvm.conf
}
+profileconf() {
+ profile_name="$1"
+ shift
+ generate_config "$@"
+ test -d etc/profile || mkdir etc/profile
+ mv -f PROFILE_$profile_name etc/profile/$profile_name.profile
+}
+
apitest() {
local t=$1
shift
10 years, 1 month
master - alloc: fix lvextend when stripe number varies
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b6bfddcd0a830d...
Commit: b6bfddcd0a830d0c9312bc3ab906cb3d1b7a6dd9
Parent: 9b28255aac9386db6d51cd1b501a9f39e81778a5
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Mon Jul 29 19:35:45 2013 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Mon Jul 29 19:35:45 2013 +0100
alloc: fix lvextend when stripe number varies
The PREFERRED allocation mechanism requires the number of areas in the
previous LV segment to match the number in the new segment being
allocated. If they do not match, the code may crash.
E.g. https://bugzilla.redhat.com/989347
Introduce A_AREA_COUNT_MATCHES and when not set avoid referring
to the previous segment with the contiguous and cling policies.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 21 ++++++++++++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3318454..21c1f6d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.100 -
================================
+ Ignore previous LV seg with alloc contiguous & cling when num stripes varies.
Fix segfault if devices/global_filter is not specified correctly.
Version 2.02.99 - 24th July 2013
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 088c05d..24c66ef 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -47,6 +47,7 @@ typedef enum {
#define A_CLING_BY_TAGS 0x08 /* Must match tags against existing segment */
#define A_CAN_SPLIT 0x10
+#define A_AREA_COUNT_MATCHES 0x20 /* Existing lvseg has same number of areas as new segment */
#define SNAPSHOT_MIN_CHUNKS 3 /* Minimum number of chunks in snapshot */
@@ -1118,8 +1119,12 @@ static void _init_alloc_parms(struct alloc_handle *ah, struct alloc_parms *alloc
alloc_parms->flags = 0;
alloc_parms->extents_still_needed = extents_still_needed;
+ /* Only attempt contiguous/cling allocation to previous segment areas if the number of areas matches. */
+ if (alloc_parms->prev_lvseg && (ah->area_count == prev_lvseg->area_count))
+ alloc_parms->flags |= A_AREA_COUNT_MATCHES;
+
/* Are there any preceding segments we must follow on from? */
- if (alloc_parms->prev_lvseg) {
+ if (alloc_parms->prev_lvseg && (alloc_parms->flags & A_AREA_COUNT_MATCHES)) {
if (alloc_parms->alloc == ALLOC_CONTIGUOUS)
alloc_parms->flags |= A_CONTIGUOUS_TO_LVSEG;
else if ((alloc_parms->alloc == ALLOC_CLING) || (alloc_parms->alloc == ALLOC_CLING_BY_TAGS))
@@ -1721,7 +1726,8 @@ static area_use_t _check_pva(struct alloc_handle *ah, struct pv_area *pva, uint3
/* If maximise_cling is set, perform several checks, otherwise perform exactly one. */
if (!iteration_count && !log_iteration_count && alloc_parms->flags & (A_CONTIGUOUS_TO_LVSEG | A_CLING_TO_LVSEG | A_CLING_TO_ALLOCED)) {
/* Contiguous? */
- if (((alloc_parms->flags & A_CONTIGUOUS_TO_LVSEG) || (ah->maximise_cling && alloc_parms->prev_lvseg)) &&
+ if (((alloc_parms->flags & A_CONTIGUOUS_TO_LVSEG) ||
+ (ah->maximise_cling && alloc_parms->prev_lvseg && (alloc_parms->flags & A_AREA_COUNT_MATCHES))) &&
_check_contiguous(ah->cmd, alloc_parms->prev_lvseg, pva, alloc_state))
return PREFERRED;
@@ -1730,7 +1736,8 @@ static area_use_t _check_pva(struct alloc_handle *ah, struct pv_area *pva, uint3
return NEXT_AREA;
/* Cling to prev_lvseg? */
- if (((alloc_parms->flags & A_CLING_TO_LVSEG) || (ah->maximise_cling && alloc_parms->prev_lvseg)) &&
+ if (((alloc_parms->flags & A_CLING_TO_LVSEG) ||
+ (ah->maximise_cling && alloc_parms->prev_lvseg && (alloc_parms->flags & A_AREA_COUNT_MATCHES))) &&
_check_cling(ah, NULL, alloc_parms->prev_lvseg, pva, alloc_state))
/* If this PV is suitable, use this first area */
return PREFERRED;
@@ -1744,7 +1751,7 @@ static area_use_t _check_pva(struct alloc_handle *ah, struct pv_area *pva, uint3
if (!(alloc_parms->flags & A_CLING_BY_TAGS) || !ah->cling_tag_list_cn)
return NEXT_PV;
- if (alloc_parms->prev_lvseg) {
+ if (alloc_parms->prev_lvseg && (alloc_parms->flags & A_AREA_COUNT_MATCHES)) {
if (_check_cling(ah, ah->cling_tag_list_cn, alloc_parms->prev_lvseg, pva, alloc_state))
return PREFERRED;
} else if (_check_cling_to_alloced(ah, ah->cling_tag_list_cn, pva, alloc_state))
@@ -1967,8 +1974,12 @@ static int _find_some_parallel_space(struct alloc_handle *ah, const struct alloc
/* First area in each list is the largest */
dm_list_iterate_items(pva, &pvm->areas) {
/*
- * There are two types of allocations, which can't be mixed at present.
+ * There are two types of allocations, which can't be mixed at present:
+ *
* PREFERRED are stored immediately in a specific parallel slot.
+ * This requires the number of slots to match, so if comparing with
+ * prev_lvseg then A_AREA_COUNT_MATCHES must be set.
+ *
* USE_AREA are stored for later, then sorted and chosen from.
*/
switch(_check_pva(ah, pva, max_to_allocate, alloc_parms,
10 years, 1 month