mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Randomly select which mdas to use or ignore.
Add some missing standard configure.in checks.
This commit is contained in:
parent
44cd0f4780
commit
d911ec67a9
@ -1,5 +1,7 @@
|
||||
Version 2.02.70 -
|
||||
================================
|
||||
Randomly select which mdas to use or ignore.
|
||||
Add some missing standard configure.in checks.
|
||||
Add printf format attributes to yes_no_prompt and fix a caller.
|
||||
Always pass unsuspended dm devices through persistent filter to other filters.
|
||||
Move test for suspended dm devices ahead of other filters.
|
||||
|
29
configure.in
29
configure.in
@ -78,12 +78,14 @@ AC_PATH_PROG(CSCOPE_CMD, cscope)
|
||||
################################################################################
|
||||
dnl -- Check for header files.
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_MAJOR
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_HEADER_TIME
|
||||
|
||||
AC_CHECK_HEADERS([locale.h stddef.h syslog.h sys/file.h sys/time.h assert.h \
|
||||
libgen.h signal.h sys/mman.h sys/resource.h sys/utsname.h sys/wait.h time.h], ,
|
||||
langinfo.h libgen.h signal.h sys/mman.h sys/resource.h sys/utsname.h \
|
||||
sys/wait.h time.h], ,
|
||||
[AC_MSG_ERROR(bailing out)])
|
||||
|
||||
case "$host_os" in
|
||||
@ -108,22 +110,36 @@ AC_TYPE_PID_T
|
||||
AC_TYPE_SIGNAL
|
||||
AC_TYPE_SIZE_T
|
||||
AC_TYPE_MODE_T
|
||||
AC_TYPE_INT8_T
|
||||
AC_TYPE_INT16_T
|
||||
AC_TYPE_INT32_T
|
||||
AC_TYPE_INT64_T
|
||||
AC_TYPE_SSIZE_T
|
||||
AC_TYPE_UID_T
|
||||
AC_TYPE_UINT8_T
|
||||
AC_TYPE_UINT16_T
|
||||
AC_TYPE_UINT32_T
|
||||
AC_TYPE_UINT64_T
|
||||
AC_CHECK_MEMBERS([struct stat.st_rdev])
|
||||
AC_STRUCT_TM
|
||||
|
||||
################################################################################
|
||||
dnl -- Check for functions
|
||||
AC_CHECK_FUNCS([gethostname getpagesize memset mkdir rmdir munmap setlocale \
|
||||
strcasecmp strchr strdup strncasecmp strerror strrchr strstr strtol strtoul \
|
||||
uname], , [AC_MSG_ERROR(bailing out)])
|
||||
AC_SEARCH_LIBS([floor], [m], , [AC_MSG_ERROR(bailing out)])
|
||||
AC_CHECK_FUNCS([floor ftruncate gethostname getpagesize \
|
||||
gettimeofday memset mkdir mkfifo rmdir munmap nl_langinfo setenv setlocale \
|
||||
strcasecmp strchr strcspn strspn strdup strncasecmp strerror strrchr \
|
||||
strstr strtol strtoul uname], , [AC_MSG_ERROR(bailing out)])
|
||||
AC_CHECK_FUNCS(siginterrupt)
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_CLOSEDIR_VOID
|
||||
AC_FUNC_CHOWN
|
||||
AC_FUNC_FORK
|
||||
AC_FUNC_LSTAT
|
||||
AC_FUNC_MALLOC
|
||||
AC_FUNC_MEMCMP
|
||||
AC_FUNC_MMAP
|
||||
AC_FUNC_REALLOC
|
||||
AC_FUNC_STAT
|
||||
AC_FUNC_STRTOD
|
||||
AC_FUNC_VPRINTF
|
||||
@ -981,7 +997,6 @@ if test x$CLVMD != xnone; then
|
||||
AC_CHECK_HEADERS(mntent.h netdb.h netinet/in.h pthread.h search.h sys/mount.h sys/socket.h sys/uio.h sys/un.h utmpx.h,,AC_MSG_ERROR(bailing out))
|
||||
AC_CHECK_FUNCS(dup2 getmntent memmove select socket,,AC_MSG_ERROR(bailing out))
|
||||
AC_FUNC_GETMNTENT
|
||||
# AC_FUNC_REALLOC
|
||||
AC_FUNC_SELECT_ARGTYPES
|
||||
fi
|
||||
|
||||
@ -990,6 +1005,10 @@ if test x$CLUSTER != xnone; then
|
||||
AC_CHECK_FUNCS(socket,,AC_MSG_ERROR(bailing out))
|
||||
fi
|
||||
|
||||
if test x$DMEVENTD = xyes; then
|
||||
AC_CHECK_HEADERS(arpa/inet.h,,AC_MSG_ERROR(bailing out))
|
||||
fi
|
||||
|
||||
if test x$HAVE_LIBDL = xyes; then
|
||||
AC_CHECK_HEADERS(dlfcn.h,,AC_MSG_ERROR(bailing out))
|
||||
fi
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "defaults.h"
|
||||
#include "filter-persistent.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
/*
|
||||
@ -1013,63 +1014,140 @@ static int _recalc_extents(uint32_t *extents, const char *desc1,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static dm_bitset_t _bitset_with_random_bits(struct dm_pool *mem, uint32_t num_bits,
|
||||
uint32_t num_set_bits, unsigned *seed)
|
||||
{
|
||||
dm_bitset_t bs;
|
||||
unsigned bit_selected;
|
||||
char buf[32];
|
||||
uint32_t i = num_bits - num_set_bits;
|
||||
|
||||
if (!(bs = dm_bitset_create(mem, (unsigned) num_bits))) {
|
||||
log_error("Failed to allocate bitset for setting random bits.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!dm_pool_begin_object(mem, 512)) {
|
||||
log_error("dm_pool_begin_object failed for random list of bits.");
|
||||
dm_pool_free(mem, bs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Perform loop num_set_bits times, selecting one bit each time */
|
||||
while (i++ < num_bits) {
|
||||
/* Select a random bit between 0 and (i-1) inclusive. */
|
||||
bit_selected = (unsigned) floor(i * (rand_r(seed) / (RAND_MAX + 1.0)));
|
||||
|
||||
/*
|
||||
* If the bit was already set, set the new bit that became
|
||||
* choosable for the first time during this pass.
|
||||
* This maintains a uniform probability distribution by compensating
|
||||
* for being unable to select it until this pass.
|
||||
*/
|
||||
if (dm_bit(bs, bit_selected))
|
||||
bit_selected = i - 1;
|
||||
|
||||
dm_bit_set(bs, bit_selected);
|
||||
|
||||
if (dm_snprintf(buf, sizeof(buf), "%u ", bit_selected) < 0) {
|
||||
log_error("snprintf random bit failed.");
|
||||
dm_pool_free(mem, bs);
|
||||
return NULL;
|
||||
}
|
||||
if (!dm_pool_grow_object(mem, buf, strlen(buf))) {
|
||||
log_error("Failed to generate list of random bits.");
|
||||
dm_pool_free(mem, bs);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
log_debug("Selected %" PRIu32 " random bits from %" PRIu32 ": %s", num_set_bits, num_bits, (char *) dm_pool_end_object(mem));
|
||||
|
||||
return bs;
|
||||
}
|
||||
|
||||
static int _vg_ignore_mdas(struct volume_group *vg, uint32_t num_to_ignore)
|
||||
{
|
||||
struct metadata_area *mda;
|
||||
uint32_t mda_used_count = vg_mda_used_count(vg);
|
||||
dm_bitset_t mda_to_ignore_bs;
|
||||
int r = 1;
|
||||
|
||||
log_debug("Adjusting ignored mdas on vg %s: %" PRIu32 " mdas in use "
|
||||
log_debug("Adjusting ignored mdas on vg %s: %" PRIu32 " of %" PRIu32 " mdas in use "
|
||||
"but %" PRIu32 " required. Changing %" PRIu32 " flags.",
|
||||
vg->name, vg_mda_copies(vg), vg_mda_used_count(vg), num_to_ignore);
|
||||
vg->name, mda_used_count, vg_mda_count(vg), vg_mda_copies(vg), num_to_ignore);
|
||||
|
||||
if (!num_to_ignore)
|
||||
return 1;
|
||||
|
||||
/* FIXME: flip bits on random mdas */
|
||||
if (!(mda_to_ignore_bs = _bitset_with_random_bits(vg->vgmem, mda_used_count,
|
||||
num_to_ignore, &vg->cmd->rand_seed)))
|
||||
return_0;
|
||||
|
||||
dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use)
|
||||
if (!mda_is_ignored(mda)) {
|
||||
if (!mda_is_ignored(mda) && (--mda_used_count,
|
||||
dm_bit(mda_to_ignore_bs, mda_used_count))) {
|
||||
mda_set_ignored(mda, 1);
|
||||
if (!--num_to_ignore)
|
||||
return 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
log_error(INTERNAL_ERROR "Unable to find %"PRIu32" metadata areas to ignore "
|
||||
"on volume group %s", num_to_ignore, vg->name);
|
||||
|
||||
return 0;
|
||||
r = 0;
|
||||
|
||||
out:
|
||||
dm_pool_free(vg->vgmem, mda_to_ignore_bs);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _vg_unignore_mdas(struct volume_group *vg, uint32_t num_to_unignore)
|
||||
{
|
||||
struct metadata_area *mda, *tmda;
|
||||
uint32_t mda_used_count = vg_mda_used_count(vg);
|
||||
uint32_t mda_count = vg_mda_count(vg);
|
||||
uint32_t mda_free_count = mda_count - mda_used_count;
|
||||
dm_bitset_t mda_to_unignore_bs;
|
||||
int r = 1;
|
||||
|
||||
if (!num_to_unignore)
|
||||
return 1;
|
||||
|
||||
log_debug("Adjusting ignored mdas on vg %s: %" PRIu32 " mdas in use "
|
||||
log_debug("Adjusting ignored mdas on vg %s: %" PRIu32 " of %" PRIu32 " mdas in use "
|
||||
"but %" PRIu32 " required. Changing %" PRIu32 " flags.",
|
||||
vg->name, vg_mda_copies(vg), vg_mda_used_count(vg), num_to_unignore);
|
||||
vg->name, vg_mda_copies(vg), mda_count, mda_used_count, num_to_unignore);
|
||||
|
||||
if (!(mda_to_unignore_bs = _bitset_with_random_bits(vg->vgmem, mda_free_count,
|
||||
num_to_unignore, &vg->cmd->rand_seed)))
|
||||
return_0;
|
||||
|
||||
/* FIXME: Select mdas to change at random */
|
||||
dm_list_iterate_items_safe(mda, tmda, &vg->fid->metadata_areas_ignored)
|
||||
if (mda_is_ignored(mda)) {
|
||||
if (mda_is_ignored(mda) && (--mda_free_count,
|
||||
dm_bit(mda_to_unignore_bs, mda_free_count))) {
|
||||
mda_set_ignored(mda, 0);
|
||||
dm_list_move(&vg->fid->metadata_areas_in_use,
|
||||
&mda->list);
|
||||
if (!--num_to_unignore)
|
||||
return 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use)
|
||||
if (mda_is_ignored(mda)) {
|
||||
if (mda_is_ignored(mda) &&
|
||||
dm_bit(mda_to_unignore_bs, num_to_unignore - 1)) {
|
||||
mda_set_ignored(mda, 0);
|
||||
if (!--num_to_unignore)
|
||||
return 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
log_error(INTERNAL_ERROR "Unable to find %"PRIu32" metadata areas to unignore "
|
||||
"on volume group %s", num_to_unignore, vg->name);
|
||||
|
||||
return 0;
|
||||
r = 0;
|
||||
|
||||
out:
|
||||
dm_pool_free(vg->vgmem, mda_to_unignore_bs);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _vg_adjust_ignored_mdas(struct volume_group *vg)
|
||||
@ -1673,11 +1751,9 @@ struct physical_volume * pvcreate_single(struct cmd_context *cmd,
|
||||
log_very_verbose("Writing physical volume data to disk \"%s\"",
|
||||
pv_name);
|
||||
|
||||
if (pp->metadataignore) {
|
||||
dm_list_iterate_items(mda, &mdas) {
|
||||
if (pp->metadataignore)
|
||||
dm_list_iterate_items(mda, &mdas)
|
||||
mda_set_ignored(mda, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(pv_write(cmd, pv, &mdas, pp->labelsector))) {
|
||||
log_error("Failed to write physical volume \"%s\"", pv_name);
|
||||
|
@ -60,6 +60,9 @@
|
||||
*/
|
||||
#undef HAVE_ALLOCA_H
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#undef HAVE_ARPA_INET_H
|
||||
|
||||
/* Define to 1 if you have the <asm/byteorder.h> header file. */
|
||||
#undef HAVE_ASM_BYTEORDER_H
|
||||
|
||||
@ -72,6 +75,9 @@
|
||||
/* Define to 1 if you have the <ccs.h> header file. */
|
||||
#undef HAVE_CCS_H
|
||||
|
||||
/* Define to 1 if your system has a working `chown' function. */
|
||||
#undef HAVE_CHOWN
|
||||
|
||||
/* Define to 1 if you have the <corosync/confdb.h> header file. */
|
||||
#undef HAVE_COROSYNC_CONFDB_H
|
||||
|
||||
@ -96,9 +102,15 @@
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the `floor' function. */
|
||||
#undef HAVE_FLOOR
|
||||
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#undef HAVE_FORK
|
||||
|
||||
/* Define to 1 if you have the `ftruncate' function. */
|
||||
#undef HAVE_FTRUNCATE
|
||||
|
||||
/* Define to 1 if you have the `gethostname' function. */
|
||||
#undef HAVE_GETHOSTNAME
|
||||
|
||||
@ -117,9 +129,15 @@
|
||||
/* Define to 1 if you have the `getpagesize' function. */
|
||||
#undef HAVE_GETPAGESIZE
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <langinfo.h> header file. */
|
||||
#undef HAVE_LANGINFO_H
|
||||
|
||||
/* Define to 1 if you have the <libcman.h> header file. */
|
||||
#undef HAVE_LIBCMAN_H
|
||||
|
||||
@ -173,6 +191,9 @@
|
||||
/* Define to 1 if you have the `mkdir' function. */
|
||||
#undef HAVE_MKDIR
|
||||
|
||||
/* Define to 1 if you have the `mkfifo' function. */
|
||||
#undef HAVE_MKFIFO
|
||||
|
||||
/* Define to 1 if you have a working `mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
@ -191,6 +212,9 @@
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#undef HAVE_NETINET_IN_H
|
||||
|
||||
/* Define to 1 if you have the `nl_langinfo' function. */
|
||||
#undef HAVE_NL_LANGINFO
|
||||
|
||||
/* Define to 1 if you have the <pthread.h> header file. */
|
||||
#undef HAVE_PTHREAD_H
|
||||
|
||||
@ -200,6 +224,10 @@
|
||||
/* Define to 1 if you have the <readline/readline.h> header file. */
|
||||
#undef HAVE_READLINE_READLINE_H
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
|
||||
and to 0 otherwise. */
|
||||
#undef HAVE_REALLOC
|
||||
|
||||
/* Define to 1 to include support for realtime clock. */
|
||||
#undef HAVE_REALTIME
|
||||
|
||||
@ -224,6 +252,9 @@
|
||||
/* Define to 1 if sepol_check_context is available. */
|
||||
#undef HAVE_SEPOL
|
||||
|
||||
/* Define to 1 if you have the `setenv' function. */
|
||||
#undef HAVE_SETENV
|
||||
|
||||
/* Define to 1 if you have the `setlocale' function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
@ -261,6 +292,9 @@
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#undef HAVE_STRCHR
|
||||
|
||||
/* Define to 1 if you have the `strcspn' function. */
|
||||
#undef HAVE_STRCSPN
|
||||
|
||||
/* Define to 1 if you have the `strdup' function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
@ -279,6 +313,9 @@
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
#undef HAVE_STRRCHR
|
||||
|
||||
/* Define to 1 if you have the `strspn' function. */
|
||||
#undef HAVE_STRSPN
|
||||
|
||||
/* Define to 1 if you have the `strstr' function. */
|
||||
#undef HAVE_STRSTR
|
||||
|
||||
@ -403,6 +440,14 @@
|
||||
/* Path to lvm binary. */
|
||||
#undef LVM_PATH
|
||||
|
||||
/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
|
||||
*/
|
||||
#undef MAJOR_IN_MKDEV
|
||||
|
||||
/* Define to 1 if `major', `minor', and `makedev' are declared in
|
||||
<sysmacros.h>. */
|
||||
#undef MAJOR_IN_SYSMACROS
|
||||
|
||||
/* Define to 1 to include built-in support for mirrors. */
|
||||
#undef MIRRORED_INTERNAL
|
||||
|
||||
@ -471,15 +516,49 @@
|
||||
/* Define to 1 to enable synchronisation with udev processing. */
|
||||
#undef UDEV_SYNC_SUPPORT
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
#undef _UINT32_T
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
#undef _UINT64_T
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
#undef _UINT8_T
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef gid_t
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
#undef inline
|
||||
#endif
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 16 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef int16_t
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef int32_t
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 64 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef int64_t
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 8 bits if such
|
||||
a type exists and the standard includes do not define it. */
|
||||
#undef int8_t
|
||||
|
||||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
#undef malloc
|
||||
|
||||
@ -492,8 +571,33 @@
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
#undef pid_t
|
||||
|
||||
/* Define to rpl_realloc if the replacement function should be used. */
|
||||
#undef realloc
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
#undef ssize_t
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef uid_t
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 16 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef uint16_t
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef uint32_t
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 64 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef uint64_t
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 8 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef uint8_t
|
||||
|
||||
/* Define as `fork' if `vfork' does not work. */
|
||||
#undef vfork
|
||||
|
Loading…
Reference in New Issue
Block a user