1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-17 06:04:23 +03:00

Attempt to load missing targets using modprobe.

This commit is contained in:
Alasdair Kergon 2005-10-17 17:56:27 +00:00
parent 191abde97e
commit a653923fe7
10 changed files with 143 additions and 57 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.00 - Version 2.02.00 -
=================================== ===================================
Attempt to load missing targets using modprobe.
Add -a to lvscan. Add -a to lvscan.
Move mknodes into libdevmapper. Move mknodes into libdevmapper.
Move bitset, hash, pool and dbg_malloc into libdevmapper. Move bitset, hash, pool and dbg_malloc into libdevmapper.

50
configure vendored
View File

@ -310,7 +310,7 @@ ac_includes_default="\
#endif" #endif"
ac_default_prefix=/usr ac_default_prefix=/usr
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S SET_MAKE RANLIB ac_ct_RANLIB CPP EGREP ALLOCA LIBOBJS POW_LIB MSGFMT JOBS STATIC_LINK LVM1 POOL SNAPSHOTS MIRRORS OWNER GROUP COPTIMISE_FLAG CLDFLAGS CLDWHOLEARCHIVE CLDNOWHOLEARCHIVE LDDEPS SOFLAG LVM_VERSION LVM1_FALLBACK DEBUG DEVMAPPER HAVE_LIBDL HAVE_SELINUX CMDLIB LOCALEDIR CONFDIR STATICDIR INTL_PACKAGE INTL CLVMD CLUSTER FSADM LTLIBOBJS' ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S SET_MAKE RANLIB ac_ct_RANLIB CPP EGREP ALLOCA LIBOBJS POW_LIB MSGFMT MODPROBE_CMD JOBS STATIC_LINK LVM1 POOL SNAPSHOTS MIRRORS OWNER GROUP COPTIMISE_FLAG CLDFLAGS CLDWHOLEARCHIVE CLDNOWHOLEARCHIVE LDDEPS SOFLAG LVM_VERSION LVM1_FALLBACK DEBUG DEVMAPPER HAVE_LIBDL HAVE_SELINUX CMDLIB LOCALEDIR CONFDIR STATICDIR INTL_PACKAGE INTL CLVMD CLUSTER FSADM LTLIBOBJS'
ac_subst_files='' ac_subst_files=''
# Initialize some variables set by options. # Initialize some variables set by options.
@ -1465,7 +1465,7 @@ case "$host_os" in
LDDEPS="$LDDEPS" LDDEPS="$LDDEPS"
LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS"
SOFLAG="-dynamiclib" SOFLAG="-dynamiclib"
DEVMAPPER=no DEVMAPPER=yes
ODIRECT=no ODIRECT=no
SELINUX=no SELINUX=no
CLUSTER=none CLUSTER=none
@ -10768,6 +10768,51 @@ done
fi fi
################################################################################
# Extract the first word of "modprobe", so it can be a program name with args.
set dummy modprobe; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_MODPROBE_CMD+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
case $MODPROBE_CMD in
[\\/]* | ?:[\\/]*)
ac_cv_path_MODPROBE_CMD="$MODPROBE_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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_MODPROBE_CMD="$as_dir/$ac_word$ac_exec_ext"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
;;
esac
fi
MODPROBE_CMD=$ac_cv_path_MODPROBE_CMD
if test -n "$MODPROBE_CMD"; then
echo "$as_me:$LINENO: result: $MODPROBE_CMD" >&5
echo "${ECHO_T}$MODPROBE_CMD" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
if test x$MODPROBE_CMD != x; then
CFLAGS="$CFLAGS -DMODPROBE_CMD=\\\"$MODPROBE_CMD\\\""
fi
################################################################################ ################################################################################
if test "-f VERSION"; then if test "-f VERSION"; then
LVM_VERSION="\"`cat VERSION`\"" LVM_VERSION="\"`cat VERSION`\""
@ -11501,6 +11546,7 @@ s,@ALLOCA@,$ALLOCA,;t t
s,@LIBOBJS@,$LIBOBJS,;t t s,@LIBOBJS@,$LIBOBJS,;t t
s,@POW_LIB@,$POW_LIB,;t t s,@POW_LIB@,$POW_LIB,;t t
s,@MSGFMT@,$MSGFMT,;t t s,@MSGFMT@,$MSGFMT,;t t
s,@MODPROBE_CMD@,$MODPROBE_CMD,;t t
s,@JOBS@,$JOBS,;t t s,@JOBS@,$JOBS,;t t
s,@STATIC_LINK@,$STATIC_LINK,;t t s,@STATIC_LINK@,$STATIC_LINK,;t t
s,@LVM1@,$LVM1,;t t s,@LVM1@,$LVM1,;t t

View File

@ -50,7 +50,7 @@ case "$host_os" in
LDDEPS="$LDDEPS" LDDEPS="$LDDEPS"
LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS"
SOFLAG="-dynamiclib" SOFLAG="-dynamiclib"
DEVMAPPER=no DEVMAPPER=yes
ODIRECT=no ODIRECT=no
SELINUX=no SELINUX=no
CLUSTER=none CLUSTER=none
@ -515,6 +515,13 @@ if test x$HAVE_SELINUX = xyes; then
AC_CHECK_HEADERS(selinux/selinux.h,,AC_MSG_ERROR(bailing out)) AC_CHECK_HEADERS(selinux/selinux.h,,AC_MSG_ERROR(bailing out))
fi fi
################################################################################
AC_PATH_PROG(MODPROBE_CMD, modprobe)
if test x$MODPROBE_CMD != x; then
CFLAGS="$CFLAGS -DMODPROBE_CMD=\\\"$MODPROBE_CMD\\\""
fi
################################################################################ ################################################################################
if test "-f VERSION"; then if test "-f VERSION"; then
LVM_VERSION="\"`cat VERSION`\"" LVM_VERSION="\"`cat VERSION`\""

64
lib/misc/lvm-exec.c Normal file
View File

@ -0,0 +1,64 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
#include "lvm-exec.h"
#include <unistd.h>
#include <sys/wait.h>
/*
* Execute and wait for external command
*/
int exec_cmd(const char *command, const char *fscmd, const char *lv_path,
const char *size)
{
pid_t pid;
int status;
log_verbose("Executing: %s %s %s %s", command, fscmd, lv_path, size);
if ((pid = fork()) == -1) {
log_error("fork failed: %s", strerror(errno));
return 0;
}
if (!pid) {
/* Child */
/* FIXME Use execve directly */
execlp(command, command, fscmd, lv_path, size, NULL);
log_sys_error("execlp", command);
exit(errno);
}
/* Parent */
if (wait4(pid, &status, 0, NULL) != pid) {
log_error("wait4 child process %u failed: %s", pid,
strerror(errno));
return 0;
}
if (!WIFEXITED(status)) {
log_error("Child %u exited abnormally", pid);
return 0;
}
if (WEXITSTATUS(status)) {
log_error("%s failed: %u", command, WEXITSTATUS(status));
return 0;
}
return 1;
}

19
lib/misc/lvm-exec.h Normal file
View File

@ -0,0 +1,19 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
int exec_cmd(const char *command, const char *fscmd, const char *lv_path,
const char *size);

View File

@ -27,7 +27,7 @@ static const char *_name(const struct lv_segment *seg)
} }
static int _text_import(struct lv_segment *seg, const struct config_node *sn, static int _text_import(struct lv_segment *seg, const struct config_node *sn,
struct hash_table *pv_hash) struct dm_hash_table *pv_hash)
{ {
uint32_t chunk_size; uint32_t chunk_size;
const char *org_name, *cow_name; const char *org_name, *cow_name;

View File

@ -72,8 +72,6 @@ static int _check_mirror_status(struct cmd_context *cmd,
float segment_percent = 0.0, overall_percent = 0.0; float segment_percent = 0.0, overall_percent = 0.0;
uint32_t event_nr = 0; uint32_t event_nr = 0;
void *x;
/* By default, caller should not retry */ /* By default, caller should not retry */
*finished = 1; *finished = 1;
@ -87,7 +85,7 @@ void *x;
return 0; return 0;
} }
if (!lv_mirror_percent(lv_mirr, !parms->interval, &segment_percent, if (!lv_mirror_percent(cmd, lv_mirr, !parms->interval, &segment_percent,
&event_nr)) { &event_nr)) {
log_error("ABORTING: Mirror percentage check failed."); log_error("ABORTING: Mirror percentage check failed.");
return 0; return 0;
@ -99,9 +97,6 @@ void *x;
else else
log_verbose("%s: Moved: %.1f%%", name, overall_percent); log_verbose("%s: Moved: %.1f%%", name, overall_percent);
x = dm_pool_alloc(cmd->mem, 1);
dm_pool_free(cmd->mem, x);
if (segment_percent < 100.0) { if (segment_percent < 100.0) {
/* The only case the caller *should* try again later */ /* The only case the caller *should* try again later */
*finished = 0; *finished = 0;

View File

@ -969,50 +969,6 @@ struct volume_group *recover_vg(struct cmd_context *cmd, const char *vgname,
return vg_read(cmd, vgname, &consistent); return vg_read(cmd, vgname, &consistent);
} }
/*
* Execute and wait for external command
*/
int exec_cmd(const char *command, const char *fscmd, const char *lv_path,
const char *size)
{
pid_t pid;
int status;
log_verbose("Executing: %s %s %s %s", command, fscmd, lv_path, size);
if ((pid = fork()) == -1) {
log_error("fork failed: %s", strerror(errno));
return 0;
}
if (!pid) {
/* Child */
/* FIXME Use execve directly */
execlp(command, command, fscmd, lv_path, size, NULL);
log_sys_error("execlp", command);
exit(errno);
}
/* Parent */
if (wait4(pid, &status, 0, NULL) != pid) {
log_error("wait4 child process %u failed: %s", pid,
strerror(errno));
return 0;
}
if (!WIFEXITED(status)) {
log_error("Child %u exited abnormally", pid);
return 0;
}
if (WEXITSTATUS(status)) {
log_error("%s failed: %u", command, WEXITSTATUS(status));
return 0;
}
return 1;
}
int apply_lvname_restrictions(const char *name) int apply_lvname_restrictions(const char *name)
{ {
if (!strncmp(name, "snapshot", 8)) { if (!strncmp(name, "snapshot", 8)) {

View File

@ -86,9 +86,6 @@ struct list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int ar
struct list *clone_pv_list(struct dm_pool *mem, struct list *pvs); struct list *clone_pv_list(struct dm_pool *mem, struct list *pvs);
int exec_cmd(const char *command, const char *fscmd, const char *lv_path,
const char *size);
int apply_lvname_restrictions(const char *name); int apply_lvname_restrictions(const char *name);
int validate_vg_name(struct cmd_context *cmd, const char *vg_name); int validate_vg_name(struct cmd_context *cmd, const char *vg_name);

View File

@ -41,6 +41,7 @@
#include "metadata.h" #include "metadata.h"
#include "list.h" #include "list.h"
#include "locking.h" #include "locking.h"
#include "lvm-exec.h"
#include "lvm-file.h" #include "lvm-file.h"
#include "lvm-string.h" #include "lvm-string.h"
#include "segtype.h" #include "segtype.h"