master - wiping: log_warn instead of log_error if blkid wipe ignored for a signature
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=697fb353dc5ecf...
Commit: 697fb353dc5ecf813199c598eed07983868fdd56
Parent: 2a7c2539c63f72d6c50df54f53271e567fa948ee
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jul 21 10:34:04 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Jul 21 10:34:04 2015 +0200
wiping: log_warn instead of log_error if blkid wipe ignored for a signature
Comply with the rules we have for log_error and log_warn...
$ pvcreate /dev/sda1
Failed to get offset of the xfs_external_log signature on /dev/sda1.
1 existing signature left on the device.
Aborting pvcreate on /dev/sda1.
$ pvcreate /dev/sda1 --force
WARNING: Failed to get offset of the xfs_external_log signature on /dev/sda1.
Physical volume "/dev/sda1" successfully created
---
lib/device/dev-type.c | 41 +++++++++++++++++++++++++++++++----------
1 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index f9d82b0..873e02e 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -528,12 +528,13 @@ static inline int _type_in_flag_list(const char *type, uint32_t flag_list)
((flag_list & TYPE_DM_SNAPSHOT_COW) && !strcmp(type, "DM_snapshot_cow")));
}
+#define MSG_FAILED_SIG_OFFSET "Failed to get offset of the %s signature on %s."
+#define MSG_FAILED_SIG_LENGTH "Failed to get length of the %s signature on %s."
+
static int _blkid_wipe(blkid_probe probe, struct device *dev, const char *name,
uint32_t types_to_exclude, uint32_t types_no_prompt,
int yes, force_t force)
{
- static const char _msg_failed_offset[] = "Failed to get offset of the %s signature on %s.";
- static const char _msg_failed_length[] = "Failed to get length of the %s signature on %s.";
static const char _msg_wiping[] = "Wiping %s signature on %s.";
const char *offset = NULL, *type = NULL, *magic = NULL,
*usage = NULL, *label = NULL, *uuid = NULL;
@@ -544,21 +545,41 @@ static int _blkid_wipe(blkid_probe probe, struct device *dev, const char *name,
if (_type_in_flag_list(type, types_to_exclude))
return 2;
if (blkid_probe_lookup_value(probe, "SBMAGIC_OFFSET", &offset, NULL)) {
- log_error(_msg_failed_offset, type, name);
- return (force < DONT_PROMPT) ? 0 : 2;
+ if (force < DONT_PROMPT) {
+ log_error(MSG_FAILED_SIG_OFFSET, type, name);
+ return 0;
+ } else {
+ log_error("WARNING: " MSG_FAILED_SIG_OFFSET, type, name);
+ return 2;
+ }
}
if (blkid_probe_lookup_value(probe, "SBMAGIC", &magic, &len)) {
- log_error(_msg_failed_length, type, name);
- return (force < DONT_PROMPT) ? 0 : 2;
+ if (force < DONT_PROMPT) {
+ log_error(MSG_FAILED_SIG_LENGTH, type, name);
+ return 0;
+ } else {
+ log_warn("WARNING: " MSG_FAILED_SIG_LENGTH, type, name);
+ return 2;
+ }
}
} else if (!blkid_probe_lookup_value(probe, "PTTYPE", &type, NULL)) {
if (blkid_probe_lookup_value(probe, "PTMAGIC_OFFSET", &offset, NULL)) {
- log_error(_msg_failed_offset, type, name);
- return (force < DONT_PROMPT) ? 0 : 2;
+ if (force < DONT_PROMPT) {
+ log_error(MSG_FAILED_SIG_OFFSET, type, name);
+ return 0;
+ } else {
+ log_warn("WARNING: " MSG_FAILED_SIG_OFFSET, type, name);
+ return 2;
+ }
}
if (blkid_probe_lookup_value(probe, "PTMAGIC", &magic, &len)) {
- log_error(_msg_failed_length, type, name);
- return (force < DONT_PROMPT) ? 0 : 2;
+ if (force < DONT_PROMPT) {
+ log_error(MSG_FAILED_SIG_LENGTH, type, name);
+ return 0;
+ } else {
+ log_warn("WARNING: " MSG_FAILED_SIG_LENGTH, type, name);
+ return 2;
+ }
}
usage = "partition table";
} else
7 years, 8 months
master - wiping: ignore errors during detection if use_blkid_wiping=1 and --force is used
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2a7c2539c63f72...
Commit: 2a7c2539c63f72d6c50df54f53271e567fa948ee
Parent: 500fd8b9bfc6f15d2417c829bce33ea4768261b8
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jul 21 09:54:20 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Jul 21 09:54:20 2015 +0200
wiping: ignore errors during detection if use_blkid_wiping=1 and --force is used
libblkid may return the list of signatures found, but it may not
provide offset and size for each signature detected. This may
happen in case signatures are mixed up or there are more, possibly
overlapping, signatures found.
Make lvm commands pass if such situation happens and we're using
--force (or any stronger force method).
For example:
$ pvcreate /dev/sda1
Failed to get offset of the xfs_external_log signature on /dev/sda1.
1 existing signature left on the device.
Aborting pvcreate on /dev/sda1.
$ pvcreate --force /dev/sda1
Failed to get offset of the xfs_external_log signature on /dev/sda1.
Physical volume "/dev/sda1" successfully created
---
WHATS_NEW | 1 +
lib/device/dev-type.c | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3cd9111..22a0233 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.126 -
================================
+ Ignore errors during detection if use_blkid_wiping=1 and --force is used.
Recognise DM_ABORT_ON_INTERNAL_ERRORS env var override in lvm logging fn.
Fix alloc segfault when extending LV with fewer stripes than in first seg.
Fix handling of cache policy name.
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 82e37e0..f9d82b0 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -545,20 +545,20 @@ static int _blkid_wipe(blkid_probe probe, struct device *dev, const char *name,
return 2;
if (blkid_probe_lookup_value(probe, "SBMAGIC_OFFSET", &offset, NULL)) {
log_error(_msg_failed_offset, type, name);
- return 0;
+ return (force < DONT_PROMPT) ? 0 : 2;
}
if (blkid_probe_lookup_value(probe, "SBMAGIC", &magic, &len)) {
log_error(_msg_failed_length, type, name);
- return 0;
+ return (force < DONT_PROMPT) ? 0 : 2;
}
} else if (!blkid_probe_lookup_value(probe, "PTTYPE", &type, NULL)) {
if (blkid_probe_lookup_value(probe, "PTMAGIC_OFFSET", &offset, NULL)) {
log_error(_msg_failed_offset, type, name);
- return 0;
+ return (force < DONT_PROMPT) ? 0 : 2;
}
if (blkid_probe_lookup_value(probe, "PTMAGIC", &magic, &len)) {
log_error(_msg_failed_length, type, name);
- return 0;
+ return (force < DONT_PROMPT) ? 0 : 2;
}
usage = "partition table";
} else
7 years, 8 months
master - log: Add DM_ABORT_ON_INTERNAL_ERRORS lvm override.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=500fd8b9bfc6f1...
Commit: 500fd8b9bfc6f15d2417c829bce33ea4768261b8
Parent: b4be988732e909d34ae7b4868bf30cf44c087518
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Mon Jul 20 15:48:59 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Mon Jul 20 15:48:59 2015 +0100
log: Add DM_ABORT_ON_INTERNAL_ERRORS lvm override.
Recognise DM_ABORT_ON_INTERNAL_ERRORS in the lvm logging function as
well as the default dm function it replaces.
---
WHATS_NEW | 1 +
lib/log/log.c | 21 ++++++++++++++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 596a92f..3cd9111 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.126 -
================================
+ Recognise DM_ABORT_ON_INTERNAL_ERRORS env var override in lvm logging fn.
Fix alloc segfault when extending LV with fewer stripes than in first seg.
Fix handling of cache policy name.
Set cache policy before with the first lvm2 cache pool metadata commit.
diff --git a/lib/log/log.c b/lib/log/log.c
index a439d1d..9929090 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -36,7 +36,7 @@ static int _indent = 1;
static int _log_suppress = 0;
static char _msg_prefix[30] = " ";
static int _already_logging = 0;
-static int _abort_on_internal_errors = 0;
+static int _abort_on_internal_errors_config = 0;
static lvm2_log_fn_t _lvm2_log_fn = NULL;
@@ -218,9 +218,10 @@ void init_indent(int indent)
_indent = indent;
}
+/* If present, environment setting will override this. */
void init_abort_on_internal_errors(int fatal)
{
- _abort_on_internal_errors = fatal;
+ _abort_on_internal_errors_config = fatal;
}
void reset_lvm_errno(int store_errmsg)
@@ -277,10 +278,24 @@ void print_log(int level, const char *file, int line, int dm_errno_or_class,
size_t msglen;
const char *indent_spaces = "";
FILE *stream;
+ static int _abort_on_internal_errors_env_present = -1;
+ static int _abort_on_internal_errors_env = 0;
+ char *env_str;
level &= ~(_LOG_STDERR|_LOG_ONCE);
- if (_abort_on_internal_errors &&
+ if (_abort_on_internal_errors_env_present < 0) {
+ if ((env_str = getenv("DM_ABORT_ON_INTERNAL_ERRORS"))) {
+ _abort_on_internal_errors_env_present = 1;
+ /* Set when env DM_ABORT_ON_INTERNAL_ERRORS is not "0" */
+ _abort_on_internal_errors_env = strcmp(env_str, "0");
+ } else
+ _abort_on_internal_errors_env_present = 0;
+ }
+
+ /* Use value from environment if present, otherwise use value from config. */
+ if (((_abort_on_internal_errors_env_present && _abort_on_internal_errors_env) ||
+ (!_abort_on_internal_errors_env_present && _abort_on_internal_errors_config)) &&
!strncmp(format, INTERNAL_ERROR, sizeof(INTERNAL_ERROR) - 1)) {
fatal_internal_error = 1;
/* Internal errors triggering abort cannot be suppressed. */
7 years, 8 months
master - vgchange/lvchange: enforce the shared VG lock from lvmlockd
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b4be988732e909...
Commit: b4be988732e909d34ae7b4868bf30cf44c087518
Parent: b785a50da415cd8ee48e971f720640457514032d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Jul 17 15:13:22 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Jul 17 15:35:34 2015 -0500
vgchange/lvchange: enforce the shared VG lock from lvmlockd
The vgchange/lvchange activation commands read the VG, and
don't write it, so they acquire a shared VG lock from lvmlockd.
When other commands fail to acquire a shared VG lock from
lvmlockd, a warning is printed and they continue without it.
(Without it, the VG metadata they display from lvmetad may
not be up to date.)
vgchange/lvchange -a shouldn't continue without the shared
lock for a couple reasons:
. Usually they will just continue on and fail to acquire the
LV locks for activation, so continuing is pointless.
. More importantly, without the sh VG lock, the VG metadata
used by the command may be stale, and the LV locks shown
in the VG metadata may no longer be current. In the
case of sanlock, this would result in odd, unpredictable
errors when lvmlockd doesn't find the expected lock on
disk. In the case of dlm, the invalid LV lock could be
granted for the non-existing LV.
The solution is to not continue after the shared lock fails,
in the same way that a command fails if an exclusive lock fails.
---
lib/commands/toolcontext.h | 1 +
lib/metadata/metadata.c | 2 +-
tools/lvchange.c | 4 +++-
tools/vgchange.c | 4 +++-
4 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 283783f..4e8998d 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -107,6 +107,7 @@ struct cmd_context {
unsigned lockd_vg_disable:1;
unsigned lockd_lv_disable:1;
unsigned lockd_vg_default_sh:1;
+ unsigned lockd_vg_enforce_sh:1;
struct dev_types *dev_types;
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 56ed3fb..8757331 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4803,7 +4803,7 @@ static int _access_vg_lock_type(struct cmd_context *cmd, struct volume_group *vg
* no lock.
*/
if (lockd_state & LDST_FAIL) {
- if (lockd_state & LDST_EX) {
+ if ((lockd_state & LDST_EX) || cmd->lockd_vg_enforce_sh) {
log_error("Cannot access VG %s due to failed lock.", vg->name);
*failure |= FAILED_LOCK_MODE;
return 0;
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 58e0fb2..823c36a 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1294,8 +1294,10 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
* are cases where lvchange does not modify the vg, so they can use
* the sh lock mode.
*/
- if (arg_count(cmd, activate_ARG) || arg_count(cmd, refresh_ARG))
+ if (arg_count(cmd, activate_ARG) || arg_count(cmd, refresh_ARG)) {
cmd->lockd_vg_default_sh = 1;
+ cmd->lockd_vg_enforce_sh = 1;
+ }
return process_each_lv(cmd, argc, argv,
update ? READ_FOR_UPDATE : 0, NULL,
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 9612222..824fd91 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -1017,8 +1017,10 @@ static int _lockd_vgchange(struct cmd_context *cmd, int argc, char **argv)
return 0;
}
- if (arg_is_set(cmd, activate_ARG) || arg_is_set(cmd, refresh_ARG))
+ if (arg_is_set(cmd, activate_ARG) || arg_is_set(cmd, refresh_ARG)) {
cmd->lockd_vg_default_sh = 1;
+ cmd->lockd_vg_enforce_sh = 1;
+ }
/* Starting a vg lockspace means there are no locks available yet. */
7 years, 8 months
master - test: Help, default and relative paths in runner
by Marian Csontos
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b785a50da415cd...
Commit: b785a50da415cd8ee48e971f720640457514032d
Parent: 2bc0525e939ea38c74a814bd51683955599824a3
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Wed Jul 15 14:20:37 2015 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Fri Jul 17 20:36:50 2015 +0200
test: Help, default and relative paths in runner
Add help message.
Handle relative paths first.
Use `.` for OUTDIR instead of `/` if empty.
---
test/lib/brick-shelltest.h | 138 ++++++++++++++++++++++++++++++++++++--------
1 files changed, 114 insertions(+), 24 deletions(-)
diff --git a/test/lib/brick-shelltest.h b/test/lib/brick-shelltest.h
index 21e1eec..b29e626 100644
--- a/test/lib/brick-shelltest.h
+++ b/test/lib/brick-shelltest.h
@@ -79,6 +79,8 @@
#include <unistd.h>
#endif
+#include "configure.h"
+
#ifndef BRICK_SHELLTEST_H
#define BRICK_SHELLTEST_H
@@ -1088,6 +1090,7 @@ struct Args {
return std::find( args.begin(), args.end(), fl ) != args.end();
}
+ // TODO: This does not handle `--option=VALUE`:
std::string opt( std::string fl ) {
V::iterator i = std::find( args.begin(), args.end(), fl );
if ( i == args.end() || i + 1 == args.end() )
@@ -1117,11 +1120,88 @@ void split( std::string s, C &c ) {
}
+const char *DEF_FLAVOURS="ndev-vanilla";
+
+std::string resolve_path(std::string a_path, const char *default_path=".")
+{
+ char temp[PATH_MAX];
+ const char *p;
+ p = a_path.empty() ? default_path : a_path.c_str();
+ if ( !realpath( p, temp ) )
+ throw syserr( "Failed to resolve path", p );
+ return temp;
+}
+
static int run( int argc, const char **argv, std::string fl_envvar = "TEST_FLAVOUR" )
{
Args args( argc, argv );
Options opt;
+ if ( args.has( "--help" ) ) {
+ std::cout <<
+ " lvm2-testsuite - Run a lvm2 testsuite.\n\n"
+ "lvm2-testsuite"
+ "\n\t"
+ " [--flavours FLAVOURS]"
+ " [--only TESTS]"
+ "\n\t"
+ " [--outdir OUTDIR]"
+ " [--testdir TESTDIR]"
+ " [--workdir WORKDIR]"
+ "\n\t"
+ " [--batch|--verbose|--interactive]"
+ "\n\t"
+ " [--fatal-timeouts]"
+ " [--continue]"
+ " [--heartbeat]"
+ " [--watch WATCH]"
+ " [--timeout TIMEOUT]"
+ " [--nokmsg]\n\n"
+ /* TODO: list of flavours:
+ "lvm2-testsuite"
+ "\n\t"
+ " --list-flavours [--testdir TESTDIR]"
+ */
+ "\n\n"
+ "OPTIONS:\n\n"
+ // TODO: looks like this could be worth a man page...
+ "Filters:\n"
+ " --flavours FLAVOURS\n\t\t- comma separated list of flavours to run.\n\t\t For the list of flavours see `$TESTDIR/lib/flavour-*`.\n\t\t Default: \"" << DEF_FLAVOURS << "\".\n"
+ " --only TESTS\t- comma separated list of tests to run. Default: All tests.\n"
+ "\n"
+ "Directories:\n"
+ " --testdir TESTDIR\n\t\t- directory where tests reside. Default: \"" TESTSUITE_DATA "\".\n"
+ " --workdir WORKDIR\n\t\t- directory to change to when running tests.\n\t\t This is directory containing testing libs. Default: TESTDIR.\n"
+ " --outdir OUTDIR\n\t\t- directory where all the output files should go. Default: \".\".\n"
+ "\n"
+ "Formatting:\n"
+ " --batch\t- Brief format for automated runs.\n"
+ " --verbose\t- More verbose format for automated runs displaying progress on stdout.\n"
+ " --interactive\t- Verbose format for interactive runs.\n"
+ "\n"
+ "Other:\n"
+ " --fatal-timeouts\n\t\t- exit after encountering 2 timeouts in a row.\n"
+ " --continue\t- If set append to journal. Otherwise it will be overwritten.\n"
+ " --heartbeat HEARTBEAT\n\t\t- Name of file to update periodicaly while running.\n"
+ " --watch WATCH\t- Comma separated list of files to watch and print.\n"
+ " --timeout TIMEOUT\n\t\t- Period of silence in seconds considered a timeout. Default: 180.\n"
+ " --nokmsg\t- Do not try to read kernel messages.\n"
+ "\n\n"
+ "ENV.VARIABLES:\n\n"
+ " T\t\t- see --only\n"
+ " INTERACTIVE\t- see --interactive\n"
+ " VERBOSE\t- see --verbose\n"
+ " BATCH\t\t- see --batch\n"
+ " LVM_TEST_CAN_CLOBBER_DMESG\n\t\t- when set and non-empty tests are allowed to flush\n\t\t kmsg in an attempt to read it."
+ "\n\n"
+ "FORMATS:\n\n"
+ "When multiple formats are specified interactive overrides verbose\n"
+ "which overrides batch. Command line options override environment\n"
+ "variables.\n\n"
+ ;
+ return 0;
+ }
+
opt.flavour_envvar = fl_envvar;
if ( args.has( "--continue" ) )
@@ -1138,26 +1218,44 @@ static int run( int argc, const char **argv, std::string fl_envvar = "TEST_FLAVO
if ( args.has( "--heartbeat" ) )
opt.heartbeat = args.opt( "--heartbeat" );
- if ( args.has( "--batch" ) || hasenv( "BATCH" ) ) {
- opt.verbose = false;
- opt.batch = true;
- }
+ if ( args.has( "--batch" ) || args.has( "--verbose" ) || args.has( "--interactive" ) ) {
+ if ( args.has( "--batch" ) ) {
+ opt.verbose = false;
+ opt.batch = true;
+ }
- if ( args.has( "--verbose" ) || hasenv( "VERBOSE" ) ) {
- opt.batch = false;
- opt.verbose = true;
- }
+ if ( args.has( "--verbose" ) ) {
+ opt.batch = false;
+ opt.verbose = true;
+ }
+
+ if ( args.has( "--interactive" ) ) {
+ opt.verbose = false;
+ opt.batch = false;
+ opt.interactive = true;
+ }
+ } else {
+ if ( hasenv( "BATCH" ) ) {
+ opt.verbose = false;
+ opt.batch = true;
+ }
+
+ if ( hasenv( "VERBOSE" ) ) {
+ opt.batch = false;
+ opt.verbose = true;
+ }
- if ( args.has( "--interactive" ) || hasenv( "INTERACTIVE" ) ) {
- opt.verbose = false;
- opt.batch = false;
- opt.interactive = true;
+ if ( hasenv( "INTERACTIVE" ) ) {
+ opt.verbose = false;
+ opt.batch = false;
+ opt.interactive = true;
+ }
}
if ( args.has( "--flavours" ) )
split( args.opt( "--flavours" ), opt.flavours );
else
- opt.flavours.push_back( "vanilla" );
+ split( DEF_FLAVOURS, opt.flavours );
if ( args.has( "--watch" ) )
split( args.opt( "--watch" ), opt.watch );
@@ -1168,17 +1266,9 @@ static int run( int argc, const char **argv, std::string fl_envvar = "TEST_FLAVO
if ( args.has( "--nokmsg" ) )
opt.kmsg = false;
- opt.outdir = args.opt( "--outdir" );
- opt.testdir = args.opt( "--testdir" );
- opt.workdir = args.opt( "--workdir" );
-
- if ( opt.testdir.empty() )
- opt.testdir = TESTSUITE_DATA;
-
- if ( opt.workdir.empty() )
- opt.workdir = opt.testdir;
-
- opt.testdir += "/";
+ opt.testdir = resolve_path( args.opt( "--testdir" ), TESTSUITE_DATA ) + "/";
+ opt.workdir = resolve_path( args.opt( "--workdir" ), opt.testdir.c_str() );
+ opt.outdir = resolve_path( args.opt( "--outdir" ), "." );
setup_handlers();
7 years, 8 months
master - test: Fix hardcoded /usr/share in testsuite
by Marian Csontos
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2bc0525e939ea3...
Commit: 2bc0525e939ea38c74a814bd51683955599824a3
Parent: 85b42d7c9551993f2d9cb48bb84e555ba0af5197
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Tue Jul 14 20:27:31 2015 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Fri Jul 17 20:36:50 2015 +0200
test: Fix hardcoded /usr/share in testsuite
---
configure | 14 ++++++++++++++
configure.in | 11 +++++++++++
lib/misc/configure.h.in | 3 +++
test/lib/brick-shelltest.h | 2 +-
4 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/configure b/configure
index 48f5381..139f332 100755
--- a/configure
+++ b/configure
@@ -649,6 +649,7 @@ UDEV_SYNC
UDEV_RULES
UDEV_PC
THIN
+TESTSUITE_DATA
TESTING
STATIC_LINK
STATICDIR
@@ -7351,6 +7352,9 @@ $as_echo "$ac_cv_flag_HAVE_FULL_RELRO" >&6; }
################################################################################
+if test "$prefix" = NONE; then
+ datarootdir=${ac_default_prefix}/share
+fi
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking file owner" >&5
@@ -10813,6 +10817,16 @@ fi
fi
################################################################################
+TESTSUITE_DATA='${datarootdir}/lvm2-testsuite'
+# double eval needed ${datarootdir} -> ${prefix}/share -> real path
+
+cat >>confdefs.h <<_ACEOF
+#define TESTSUITE_DATA "$(eval echo $(eval echo $TESTSUITE_DATA))"
+_ACEOF
+
+
+
+################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable valgrind awareness of pools" >&5
$as_echo_n "checking whether to enable valgrind awareness of pools... " >&6; }
# Check whether --enable-valgrind_pool was given.
diff --git a/configure.in b/configure.in
index ca461af..7bb18a4 100644
--- a/configure.in
+++ b/configure.in
@@ -174,6 +174,9 @@ AC_SUBST(HAVE_FULL_RELRO)
################################################################################
dnl -- Prefix is /usr by default, the exec_prefix default is setup later
AC_PREFIX_DEFAULT(/usr)
+if test "$prefix" = NONE; then
+ datarootdir=${ac_default_prefix}/share
+fi
################################################################################
dnl -- Setup the ownership of the files
@@ -1062,6 +1065,13 @@ if test "$TESTING" = yes; then
fi
################################################################################
+dnl -- Set LVM2 testsuite data
+TESTSUITE_DATA='${datarootdir}/lvm2-testsuite'
+# double eval needed ${datarootdir} -> ${prefix}/share -> real path
+AC_DEFINE_UNQUOTED(TESTSUITE_DATA, ["$(eval echo $(eval echo $TESTSUITE_DATA))"], [Path to testsuite data])
+
+
+################################################################################
dnl -- Enable valgrind awareness of memory pools
AC_MSG_CHECKING(whether to enable valgrind awareness of pools)
AC_ARG_ENABLE(valgrind_pool,
@@ -1971,6 +1981,7 @@ AC_SUBST(SNAPSHOTS)
AC_SUBST(STATICDIR)
AC_SUBST(STATIC_LINK)
AC_SUBST(TESTING)
+AC_SUBST(TESTSUITE_DATA)
AC_SUBST(THIN)
AC_SUBST(THIN_CHECK_CMD)
AC_SUBST(THIN_DUMP_CMD)
diff --git a/lib/misc/configure.h.in b/lib/misc/configure.h.in
index d9f5a7d..13e8a2d 100644
--- a/lib/misc/configure.h.in
+++ b/lib/misc/configure.h.in
@@ -632,6 +632,9 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
+/* Path to testsuite data */
+#undef TESTSUITE_DATA
+
/* The path to 'thin_check', if available. */
#undef THIN_CHECK_CMD
diff --git a/test/lib/brick-shelltest.h b/test/lib/brick-shelltest.h
index e64a166..21e1eec 100644
--- a/test/lib/brick-shelltest.h
+++ b/test/lib/brick-shelltest.h
@@ -1173,7 +1173,7 @@ static int run( int argc, const char **argv, std::string fl_envvar = "TEST_FLAVO
opt.workdir = args.opt( "--workdir" );
if ( opt.testdir.empty() )
- opt.testdir = "/usr/share/lvm2-testsuite";
+ opt.testdir = TESTSUITE_DATA;
if ( opt.workdir.empty() )
opt.workdir = opt.testdir;
7 years, 8 months
master - lvmlockd: improve errors when lvm is built without a lock manager
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=85b42d7c955199...
Commit: 85b42d7c9551993f2d9cb48bb84e555ba0af5197
Parent: c7fc06a262bacb6355485edebc5f7b7037471106
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jul 16 16:28:57 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Jul 17 11:16:18 2015 -0500
lvmlockd: improve errors when lvm is built without a lock manager
When lvmlockd is compiled without support for one of the
lock managers (sanlock or dlm), and a command tries to use
one of them, explain that in the error message.
---
daemons/lvmlockd/lvmlockd-core.c | 21 +++++++++++++++++----
daemons/lvmlockd/lvmlockd-internal.h | 20 ++++++++++++++++++++
lib/locking/lvmlockd.c | 13 ++++++++++++-
3 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 19d96f0..a01c8a6 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -4167,9 +4167,9 @@ static void client_recv_action(struct client *cl)
strncpy(cl->name, cl_name, MAX_NAME);
if (!gl_use_dlm && !gl_use_sanlock && (lm > 0)) {
- if (lm == LD_LM_DLM)
+ if (lm == LD_LM_DLM && lm_support_dlm())
gl_use_dlm = 1;
- else if (lm == LD_LM_SANLOCK)
+ else if (lm == LD_LM_SANLOCK && lm_support_sanlock())
gl_use_sanlock = 1;
log_debug("set gl_use_%s", lm_str(lm));
@@ -4233,6 +4233,18 @@ static void client_recv_action(struct client *cl)
cl->name[0] ? cl->name : "client", cl->pid, cl->id,
op_str(act->op), rt_str(act->rt), act->vg_name, mode_str(act->mode), opts);
+ if (lm == LD_LM_DLM && !lm_support_dlm()) {
+ log_debug("dlm not supported");
+ rv = -EPROTONOSUPPORT;
+ goto out;
+ }
+
+ if (lm == LD_LM_SANLOCK && !lm_support_sanlock()) {
+ log_debug("sanlock not supported");
+ rv = -EPROTONOSUPPORT;
+ goto out;
+ }
+
switch (act->op) {
case LD_OP_START:
rv = add_lockspace(act);
@@ -4265,6 +4277,7 @@ static void client_recv_action(struct client *cl)
rv = -EINVAL;
};
+out:
if (rv < 0) {
act->result = rv;
add_client_result(act);
@@ -5685,9 +5698,9 @@ int main(int argc, char *argv[])
break;
case 'g':
lm = str_to_lm(optarg);
- if (lm == LD_LM_DLM)
+ if (lm == LD_LM_DLM && lm_support_dlm())
gl_use_dlm = 1;
- else if (lm == LD_LM_SANLOCK)
+ else if (lm == LD_LM_SANLOCK && lm_support_sanlock())
gl_use_sanlock = 1;
else {
fprintf(stderr, "invalid gl-type option");
diff --git a/daemons/lvmlockd/lvmlockd-internal.h b/daemons/lvmlockd/lvmlockd-internal.h
index e9b6277..1fd7125 100644
--- a/daemons/lvmlockd/lvmlockd-internal.h
+++ b/daemons/lvmlockd/lvmlockd-internal.h
@@ -350,6 +350,11 @@ int lm_get_lockspaces_dlm(struct list_head *ls_rejoin);
int lm_data_size_dlm(void);
int lm_is_running_dlm(void);
+static inline int lm_support_dlm(void)
+{
+ return 1;
+}
+
#else
static inline int lm_init_vg_dlm(char *ls_name, char *vg_name, uint32_t flags, char *vg_args)
@@ -410,6 +415,11 @@ static inline int lm_is_running_dlm(void)
return 0;
}
+static inline int lm_support_dlm(void)
+{
+ return 0;
+}
+
#endif /* dlm support */
#ifdef LOCKDSANLOCK_SUPPORT
@@ -437,6 +447,11 @@ int lm_data_size_sanlock(void);
int lm_is_running_sanlock(void);
int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free_offset);
+static inline int lm_support_sanlock(void)
+{
+ return 1;
+}
+
#else
static inline int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_args)
@@ -537,6 +552,11 @@ static inline int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free
return -1;
}
+static inline int lm_support_sanlock(void)
+{
+ return 0;
+}
+
#endif /* sanlock support */
#endif /* _LVM_LVMLOCKD_INTERNAL_H */
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index a0dff8a..ac8c155 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -522,6 +522,9 @@ static int _init_vg_dlm(struct cmd_context *cmd, struct volume_group *vg)
case -EMANAGER:
log_error("VG %s init failed: lock manager dlm is not running", vg->name);
break;
+ case -EPROTONOSUPPORT:
+ log_error("VG %s init failed: lock manager dlm is not supported by lvmlockd", vg->name);
+ break;
default:
log_error("VG %s init failed: %d", vg->name, result);
}
@@ -624,6 +627,9 @@ static int _init_vg_sanlock(struct cmd_context *cmd, struct volume_group *vg)
case -EMANAGER:
log_error("VG %s init failed: lock manager sanlock is not running", vg->name);
break;
+ case -EPROTONOSUPPORT:
+ log_error("VG %s init failed: lock manager sanlock is not supported by lvmlockd", vg->name);
+ break;
case -EMSGSIZE:
log_error("VG %s init failed: no disk space for leases", vg->name);
break;
@@ -952,6 +958,9 @@ int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg)
case -EMANAGER:
log_error("VG %s start failed: lock manager %s is not running", vg->name, vg->lock_type);
break;
+ case -EPROTONOSUPPORT:
+ log_error("VG %s start failed: lock manager %s is not supported by lvmlockd", vg->name, vg->lock_type);
+ break;
default:
log_error("VG %s start failed: %d", vg->name, result);
}
@@ -1233,8 +1242,10 @@ int lockd_gl_create(struct cmd_context *cmd, const char *def_mode, const char *v
if (result < 0) {
if (result == -ESTARTING)
log_error("Global lock failed: lockspace is starting.");
- else if (result -EAGAIN)
+ else if (result == -EAGAIN)
log_error("Global lock failed: held by other host.");
+ else if (result == -EPROTONOSUPPORT)
+ log_error("VG create failed: lock manager %s is not supported by lvmlockd.", vg_lock_type);
else
log_error("Global lock failed: error %d", result);
return 0;
7 years, 8 months
master - test: Ignore known concurrent VG clvmd failure.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c7fc06a262bacb...
Commit: c7fc06a262bacb6355485edebc5f7b7037471106
Parent: 268f53ed0de087b0d42429a8b18c191f12a331cb
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Jul 17 12:56:52 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Jul 17 12:56:52 2015 +0100
test: Ignore known concurrent VG clvmd failure.
Don't abort test when clvmd processes two VGs concurrently.
CLVMD: ioctl/libdm-iface.c:1940 Internal error: Performing unsafe table load while 3 device(s) are known to be suspended: (253:19)
---
test/shell/pvmove-abort-all.sh | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/test/shell/pvmove-abort-all.sh b/test/shell/pvmove-abort-all.sh
index da43da6..2867163 100644
--- a/test/shell/pvmove-abort-all.sh
+++ b/test/shell/pvmove-abort-all.sh
@@ -11,6 +11,10 @@
# Check pvmove --abort behaviour for all VGs and PVs
+# Ignore known failure when clvmd is processing sequences of commands for two VGs in parallel - 2015/07/17 agk
+# CLVMD: ioctl/libdm-iface.c:1940 Internal error: Performing unsafe table load while 3 device(s) are known to be suspended: (253:19)
+export DM_ABORT_ON_INTERNAL_ERRORS=0
+
. lib/inittest
aux prepare_pvs 6 60
7 years, 8 months
master - lockd: fix error cases when built without lvmlockd
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=268f53ed0de087...
Commit: 268f53ed0de087b0d42429a8b18c191f12a331cb
Parent: b93b85378d119e8396b0469574770cd097a988f0
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jul 16 15:12:07 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jul 16 15:22:06 2015 -0500
lockd: fix error cases when built without lvmlockd
When lvm is built without lvmlockd support, vgcreate using a
shared lock type would succeed and create a local VG (the
--shared option was effectively ignored). Make it fail.
Fix the same issue when using vgchange to change a VG to a
shared lock type.
Make the error messages consistent.
---
lib/locking/lvmlockd.h | 9 +++++++++
tools/toollib.c | 8 ++++----
tools/vgchange.c | 10 ++++++++++
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/lib/locking/lvmlockd.h b/lib/locking/lvmlockd.h
index 2bd2fcc..ffd6a99 100644
--- a/lib/locking/lvmlockd.h
+++ b/lib/locking/lvmlockd.h
@@ -167,6 +167,14 @@ static inline int lockd_start_wait(struct cmd_context *cmd)
static inline int lockd_gl_create(struct cmd_context *cmd, const char *def_mode, const char *vg_lock_type)
{
+ /*
+ * When lvm is built without lvmlockd support, creating a VG with
+ * a shared lock type should fail.
+ */
+ if (is_lockd_type(vg_lock_type)) {
+ log_error("Using a shared lock type requires lvmlockd.");
+ return 0;
+ }
return 1;
}
@@ -220,6 +228,7 @@ static inline int lockd_free_lv(struct cmd_context *cmd, struct volume_group *vg
static inline const char *lockd_running_lock_type(struct cmd_context *cmd)
{
+ log_error("Using a shared lock type requires lvmlockd.");
return NULL;
}
diff --git a/tools/toollib.c b/tools/toollib.c
index 7bbe897..5d5e4d6 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -927,7 +927,7 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
} else if (arg_is_set(cmd, shared_ARG)) {
if (use_lvmlockd) {
if (!(lock_type = lockd_running_lock_type(cmd))) {
- log_error("Failed to detect a running lock manager to select lock_type.");
+ log_error("Failed to detect a running lock manager to select lock type.");
return 0;
}
@@ -936,7 +936,7 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
return 0;
} else {
- log_error("The --shared option requires lvmlockd (use_lvmlockd=1).");
+ log_error("Using a shared lock type requires lvmlockd.");
return 0;
}
@@ -961,13 +961,13 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
case LOCK_TYPE_SANLOCK:
case LOCK_TYPE_DLM:
if (!use_lvmlockd) {
- log_error("lock_type %s requires use_lvmlockd configuration setting", lock_type);
+ log_error("Using a shared lock type requires lvmlockd.");
return 0;
}
break;
case LOCK_TYPE_CLVM:
if (!use_clvmd) {
- log_error("lock_type clvm requires locking_type 3 configuration setting");
+ log_error("Using clvm requires locking_type 3.");
return 0;
}
break;
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 72a5c1e..9612222 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -1007,6 +1007,16 @@ static int _lockd_vgchange(struct cmd_context *cmd, int argc, char **argv)
{
/* The default vg lock mode is ex, but these options only need sh. */
+ if (!lvmlockd_use() && arg_is_set(cmd, locktype_ARG)) {
+ log_error("Using lock type requires lvmlockd.");
+ return 0;
+ }
+
+ if (!lvmlockd_use() && (arg_is_set(cmd, lockstart_ARG) || arg_is_set(cmd, lockstop_ARG))) {
+ log_error("Using lock start and lock stop requires lvmlockd.");
+ return 0;
+ }
+
if (arg_is_set(cmd, activate_ARG) || arg_is_set(cmd, refresh_ARG))
cmd->lockd_vg_default_sh = 1;
7 years, 8 months
master - alloc: Fix lvextend failure when varying stripes.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b93b85378d119e...
Commit: b93b85378d119e8396b0469574770cd097a988f0
Parent: e15db1592642d5eb0a2a76b35882502c541302c7
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Jul 15 23:12:54 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Jul 15 23:12:54 2015 +0100
alloc: Fix lvextend failure when varying stripes.
A segfault was reported when extending an LV with a smaller number of
stripes than originally used. Under unusual circumstances, the cling
detection code could successfully find a match against the excess
stripe positions and think it had finished prematurely leading to an
allocation being pursued with a length of zero.
Rename ix_offset to num_positional_areas and move it to struct
alloc_state so that _is_condition() can obtain access to it.
In _is_condition(), areas_size can no longer be assumed to match the
number of positional slots being filled so check this newly-exposed
num_positional_areas directly instead. If the slot is outside the
range we are trying to fill, just ignore the match for now.
(Also note that the code still only performs cling detection against
the first segment of the LV.)
---
WHATS_NEW | 3 ++
lib/metadata/lv_manip.c | 72 ++++++++++++++++++++++++++---------------------
2 files changed, 43 insertions(+), 32 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 43fa004..596a92f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,10 +1,13 @@
Version 2.02.126 -
================================
+ Fix alloc segfault when extending LV with fewer stripes than in first seg.
Fix handling of cache policy name.
Set cache policy before with the first lvm2 cache pool metadata commit.
Fix detection of thin-pool overprovisioning (2.02.124).
Fix lvmpolld segfaults on 32 bit architectures.
+ Add lvmlockd lock_args validation to vg_validate.
Fix ignored --startstopservices option if running lvmconf with systemd.
+ Hide sanlock LVs when processing LVs in VG unless named or --all used.
Version 2.02.125 - 7th July 2015
================================
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 19d0ca7..86411d5 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -74,6 +74,7 @@ struct alloc_state {
uint32_t areas_size;
uint32_t log_area_count_still_needed; /* Number of areas still needing to be allocated for the log */
uint32_t allocated; /* Total number of extents allocated so far */
+ uint32_t num_positional_areas; /* Number of parallel allocations that must be contiguous/cling */
};
struct lv_names {
@@ -2242,6 +2243,10 @@ static int _is_condition(struct cmd_context *cmd __attribute__((unused)),
if (!pvmatch->condition(pvmatch, pvseg, pvmatch->pva))
return 1; /* Continue */
+ if (positional && (s >= pvmatch->alloc_state->num_positional_areas))
+ return 1;
+
+ /* FIXME The previous test should make this one redundant. */
if (positional && (s >= pvmatch->alloc_state->areas_size))
return 1;
@@ -2479,6 +2484,8 @@ static void _clear_areas(struct alloc_state *alloc_state)
{
uint32_t s;
+ alloc_state->num_positional_areas = 0;
+
for (s = 0; s < alloc_state->areas_size; s++)
alloc_state->areas[s].pva = NULL;
}
@@ -2521,9 +2528,10 @@ static void _report_needed_allocation_space(struct alloc_handle *ah,
metadata_count = alloc_state->log_area_count_still_needed;
}
- log_debug_alloc("Still need %s%" PRIu32 " total extents from %" PRIu32 " remaining:",
+ log_debug_alloc("Still need %s%" PRIu32 " total extents from %" PRIu32 " remaining (%" PRIu32 " positional slots):",
ah->approx_alloc ? "up to " : "",
- parallel_area_size * parallel_areas_count + metadata_size * metadata_count, pv_maps_size(pvms));
+ parallel_area_size * parallel_areas_count + metadata_size * metadata_count, pv_maps_size(pvms),
+ alloc_state->num_positional_areas);
log_debug_alloc(" %" PRIu32 " (%" PRIu32 " data/%" PRIu32
" parity) parallel areas of %" PRIu32 " extents each",
parallel_areas_count, ah->area_count, ah->parity_count, parallel_area_size);
@@ -2578,7 +2586,6 @@ static int _find_some_parallel_space(struct alloc_handle *ah,
struct pv_area *pva;
unsigned preferred_count = 0;
unsigned already_found_one;
- unsigned ix_offset = 0; /* Offset for non-preferred allocations */
unsigned ix_log_offset; /* Offset to start of areas to use for log */
unsigned too_small_for_log_count; /* How many too small for log? */
unsigned iteration_count = 0; /* cling_to_alloced may need 2 iterations */
@@ -2588,27 +2595,28 @@ static int _find_some_parallel_space(struct alloc_handle *ah,
uint32_t devices_needed = ah->area_count + ah->parity_count;
uint32_t required;
- /* ix_offset holds the number of parallel allocations that must be contiguous/cling */
+ _clear_areas(alloc_state);
+ _reset_unreserved(pvms);
+
+ /* num_positional_areas holds the number of parallel allocations that must be contiguous/cling */
+ /* These appear first in the array, so it is also the offset to the non-preferred allocations */
/* At most one of A_CONTIGUOUS_TO_LVSEG, A_CLING_TO_LVSEG or A_CLING_TO_ALLOCED may be set */
if (!(alloc_parms->flags & A_POSITIONAL_FILL))
- ix_offset = 0;
+ alloc_state->num_positional_areas = 0;
else if (alloc_parms->flags & (A_CONTIGUOUS_TO_LVSEG | A_CLING_TO_LVSEG))
- ix_offset = _stripes_per_mimage(alloc_parms->prev_lvseg) * alloc_parms->prev_lvseg->area_count;
+ alloc_state->num_positional_areas = _stripes_per_mimage(alloc_parms->prev_lvseg) * alloc_parms->prev_lvseg->area_count;
else if (alloc_parms->flags & A_CLING_TO_ALLOCED)
- ix_offset = ah->area_count;
+ alloc_state->num_positional_areas = ah->area_count;
if (alloc_parms->alloc == ALLOC_NORMAL || (alloc_parms->flags & A_CLING_TO_ALLOCED))
log_debug_alloc("Cling_to_allocated is %sset",
alloc_parms->flags & A_CLING_TO_ALLOCED ? "" : "not ");
if (alloc_parms->flags & A_POSITIONAL_FILL)
- log_debug_alloc("%u preferred area(s) to be filled positionally.", ix_offset);
+ log_debug_alloc("%u preferred area(s) to be filled positionally.", alloc_state->num_positional_areas);
else
log_debug_alloc("Areas to be sorted and filled sequentially.");
- _clear_areas(alloc_state);
- _reset_unreserved(pvms);
-
_report_needed_allocation_space(ah, alloc_state, pvms);
/* ix holds the number of areas found on other PVs */
@@ -2616,7 +2624,7 @@ static int _find_some_parallel_space(struct alloc_handle *ah,
if (log_iteration_count) {
log_debug_alloc("Found %u areas for %" PRIu32 " parallel areas and %" PRIu32 " log areas so far.", ix, devices_needed, alloc_state->log_area_count_still_needed);
} else if (iteration_count)
- log_debug_alloc("Filled %u out of %u preferred areas so far.", preferred_count, ix_offset);
+ log_debug_alloc("Filled %u out of %u preferred areas so far.", preferred_count, alloc_state->num_positional_areas);
/*
* Provide for escape from the loop if no progress is made.
@@ -2657,7 +2665,7 @@ static int _find_some_parallel_space(struct alloc_handle *ah,
* not enough for the logs.
*/
if (log_iteration_count) {
- for (s = devices_needed; s < ix + ix_offset; s++)
+ for (s = devices_needed; s < ix + alloc_state->num_positional_areas; s++)
if (alloc_state->areas[s].pva && alloc_state->areas[s].pva->map->pv == pvm->pv)
goto next_pv;
/* On a second pass, avoid PVs already used in an uncommitted area */
@@ -2705,8 +2713,8 @@ static int _find_some_parallel_space(struct alloc_handle *ah,
}
/* Reserve required amount of pva */
- required = _calc_required_extents(ah, pva, ix + ix_offset - 1, max_to_allocate, alloc_parms->alloc);
- if (!_reserve_required_area(ah, alloc_state, pva, required, ix + ix_offset - 1, pva->unreserved))
+ required = _calc_required_extents(ah, pva, ix + alloc_state->num_positional_areas - 1, max_to_allocate, alloc_parms->alloc);
+ if (!_reserve_required_area(ah, alloc_state, pva, required, ix + alloc_state->num_positional_areas - 1, pva->unreserved))
return_0;
}
@@ -2717,23 +2725,23 @@ static int _find_some_parallel_space(struct alloc_handle *ah,
/* With cling and contiguous we stop if we found a match for *all* the areas */
/* FIXME Rename these variables! */
if ((alloc_parms->alloc == ALLOC_ANYWHERE &&
- ix + ix_offset >= devices_needed + alloc_state->log_area_count_still_needed) ||
- (preferred_count == ix_offset &&
- (ix_offset == devices_needed + alloc_state->log_area_count_still_needed)))
+ ix + alloc_state->num_positional_areas >= devices_needed + alloc_state->log_area_count_still_needed) ||
+ (preferred_count == alloc_state->num_positional_areas &&
+ (alloc_state->num_positional_areas == devices_needed + alloc_state->log_area_count_still_needed)))
break;
}
} while ((alloc_parms->alloc == ALLOC_ANYWHERE && last_ix != ix && ix < devices_needed + alloc_state->log_area_count_still_needed) ||
/* With cling_to_alloced and normal, if there were gaps in the preferred areas, have a second iteration */
(alloc_parms->alloc == ALLOC_NORMAL && preferred_count &&
- (preferred_count < ix_offset || alloc_state->log_area_count_still_needed) &&
+ (preferred_count < alloc_state->num_positional_areas || alloc_state->log_area_count_still_needed) &&
(alloc_parms->flags & A_CLING_TO_ALLOCED) && !iteration_count++) ||
/* Extra iteration needed to fill log areas on PVs already used? */
- (alloc_parms->alloc == ALLOC_NORMAL && preferred_count == ix_offset && !ah->mirror_logs_separate &&
+ (alloc_parms->alloc == ALLOC_NORMAL && preferred_count == alloc_state->num_positional_areas && !ah->mirror_logs_separate &&
(ix + preferred_count >= devices_needed) &&
(ix + preferred_count < devices_needed + alloc_state->log_area_count_still_needed) && !log_iteration_count++));
/* Non-zero ix means at least one USE_AREA was returned */
- if (preferred_count < ix_offset && !(alloc_parms->flags & A_CLING_TO_ALLOCED) && !ix)
+ if (preferred_count < alloc_state->num_positional_areas && !(alloc_parms->flags & A_CLING_TO_ALLOCED) && !ix)
return 1;
if (ix + preferred_count < devices_needed + alloc_state->log_area_count_still_needed)
@@ -2748,17 +2756,17 @@ static int _find_some_parallel_space(struct alloc_handle *ah,
}
} else if (ix > 1) {
log_debug_alloc("Sorting %u areas", ix);
- qsort(alloc_state->areas + ix_offset, ix, sizeof(*alloc_state->areas),
+ qsort(alloc_state->areas + alloc_state->num_positional_areas, ix, sizeof(*alloc_state->areas),
_comp_area);
}
/* If there are gaps in our preferred areas, fill them from the sorted part of the array */
- if (preferred_count && preferred_count != ix_offset) {
+ if (preferred_count && preferred_count != alloc_state->num_positional_areas) {
for (s = 0; s < devices_needed; s++)
if (!alloc_state->areas[s].pva) {
- alloc_state->areas[s].pva = alloc_state->areas[ix_offset].pva;
- alloc_state->areas[s].used = alloc_state->areas[ix_offset].used;
- alloc_state->areas[ix_offset++].pva = NULL;
+ alloc_state->areas[s].pva = alloc_state->areas[alloc_state->num_positional_areas].pva;
+ alloc_state->areas[s].used = alloc_state->areas[alloc_state->num_positional_areas].used;
+ alloc_state->areas[alloc_state->num_positional_areas++].pva = NULL;
}
}
@@ -2772,14 +2780,14 @@ static int _find_some_parallel_space(struct alloc_handle *ah,
/* FIXME This logic is due to its heritage and can be simplified! */
if (alloc_state->log_area_count_still_needed) {
/* How many areas are too small for the log? */
- while (too_small_for_log_count < ix_offset + ix &&
- (*(alloc_state->areas + ix_offset + ix - 1 -
+ while (too_small_for_log_count < alloc_state->num_positional_areas + ix &&
+ (*(alloc_state->areas + alloc_state->num_positional_areas + ix - 1 -
too_small_for_log_count)).used < ah->log_len)
too_small_for_log_count++;
- ix_log_offset = ix_offset + ix - too_small_for_log_count - ah->log_area_count;
+ ix_log_offset = alloc_state->num_positional_areas + ix - too_small_for_log_count - ah->log_area_count;
}
- if (ix + ix_offset < devices_needed +
+ if (ix + alloc_state->num_positional_areas < devices_needed +
(alloc_state->log_area_count_still_needed ? alloc_state->log_area_count_still_needed +
too_small_for_log_count : 0))
return 1;
@@ -2793,12 +2801,12 @@ static int _find_some_parallel_space(struct alloc_handle *ah,
/*
* This code covers the initial allocation - after that there is something to 'cling' to
* and we shouldn't get this far.
- * ix_offset is assumed to be 0 with A_PARTITION_BY_TAGS.
+ * alloc_state->num_positional_areas is assumed to be 0 with A_PARTITION_BY_TAGS.
*
* FIXME Consider a second attempt with A_PARTITION_BY_TAGS if, for example, the largest area
* had all the tags set, but other areas don't.
*/
- if ((alloc_parms->flags & A_PARTITION_BY_TAGS) && !ix_offset) {
+ if ((alloc_parms->flags & A_PARTITION_BY_TAGS) && !alloc_state->num_positional_areas) {
if (!_limit_to_one_area_per_tag(ah, alloc_state, ix_log_offset, &ix))
return_0;
7 years, 8 months