mirror of
git://sourceware.org/git/lvm2.git
synced 2025-12-24 16:23:50 +03:00
Compare commits
102 Commits
dm_v1_02_0
...
dm_v1_02_0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8339f3ceb3 | ||
|
|
c0c9f3cc19 | ||
|
|
81f4813c29 | ||
|
|
94f57745b9 | ||
|
|
54fb2ebbe0 | ||
|
|
02d122b65b | ||
|
|
df0a5561a1 | ||
|
|
f7c55da7d0 | ||
|
|
b385f701ce | ||
|
|
05dd42f443 | ||
|
|
36d816d5cb | ||
|
|
92a6746e70 | ||
|
|
1728848a39 | ||
|
|
f9eb4e7487 | ||
|
|
d0b9f33aeb | ||
|
|
718583b241 | ||
|
|
6737127e9a | ||
|
|
19a7b4479b | ||
|
|
c340647502 | ||
|
|
0f987d2982 | ||
|
|
52bcaed169 | ||
|
|
177bd565ac | ||
|
|
c801c32fc5 | ||
|
|
d090cf3058 | ||
|
|
1e4b82cc94 | ||
|
|
3426f31184 | ||
|
|
b4fb7af1df | ||
|
|
b36647598b | ||
|
|
fd6b94f20e | ||
|
|
296dc0ed8a | ||
|
|
4f869e14d6 | ||
|
|
5704270e9d | ||
|
|
505b381e85 | ||
|
|
da6cb15393 | ||
|
|
16843f6cc8 | ||
|
|
64f3ad1fd4 | ||
|
|
ff4c4f99b3 | ||
|
|
f5d2e09569 | ||
|
|
f2bdbe0d4d | ||
|
|
c51a13caa6 | ||
|
|
7840c78a23 | ||
|
|
c706f3246b | ||
|
|
608eedf88d | ||
|
|
a564ca82be | ||
|
|
c868b1fee2 | ||
|
|
22374f718f | ||
|
|
abe3cfcf41 | ||
|
|
59db4b50cd | ||
|
|
bdae38765d | ||
|
|
66d3ceeb61 | ||
|
|
445dd17db3 | ||
|
|
cff78a2577 | ||
|
|
6a09e64195 | ||
|
|
22eabe5eab | ||
|
|
b69ba36c2d | ||
|
|
5240aad22b | ||
|
|
2897eb3cb3 | ||
|
|
d3f2f00c25 | ||
|
|
bacfb913a0 | ||
|
|
c99d0236a0 | ||
|
|
aac2b655f7 | ||
|
|
126c41e73a | ||
|
|
359ee54f0d | ||
|
|
28ab560907 | ||
|
|
ead252fee4 | ||
|
|
abf67914c4 | ||
|
|
127884e9dd | ||
|
|
654f5049eb | ||
|
|
979ca34259 | ||
|
|
4dd1086805 | ||
|
|
3503d4b72c | ||
|
|
b8d32a0d33 | ||
|
|
45dca55fc8 | ||
|
|
445d8ecd9f | ||
|
|
c980add503 | ||
|
|
133842392a | ||
|
|
8baf2ef155 | ||
|
|
20b71340bc | ||
|
|
61d8baf8b1 | ||
|
|
56a9645aa5 | ||
|
|
85877000a6 | ||
|
|
2f7d2477b6 | ||
|
|
21ea3f05f4 | ||
|
|
79d3492e90 | ||
|
|
5972777abe | ||
|
|
8e373ff868 | ||
|
|
a4db92da3a | ||
|
|
9b777eb281 | ||
|
|
bd3c652184 | ||
|
|
800f747570 | ||
|
|
2b8423437e | ||
|
|
8b4b6945f8 | ||
|
|
e5ecfec5c4 | ||
|
|
f95dbff71f | ||
|
|
098f6830a6 | ||
|
|
d1ecebdb52 | ||
|
|
590b654251 | ||
|
|
3bf190c8ab | ||
|
|
dcca7638e0 | ||
|
|
70e45ad37b | ||
|
|
db88210289 | ||
|
|
d2e0d96cc3 |
11
Makefile.in
11
Makefile.in
@@ -38,6 +38,7 @@ ifeq ($(MAKECMDGOALS),distclean)
|
||||
lib/snapshot \
|
||||
po \
|
||||
test/mm test/device test/format1 test/regex test/filters
|
||||
DISTCLEAN_TARGETS += lib/misc/configure.h
|
||||
endif
|
||||
|
||||
include make.tmpl
|
||||
@@ -57,3 +58,13 @@ po.pofile: tools.pofile daemons.pofile dmeventd.pofile
|
||||
pofile: po.pofile
|
||||
endif
|
||||
|
||||
ifneq ("@CFLOW_CMD@", "")
|
||||
tools.cflow: lib.cflow
|
||||
cflow: tools.cflow
|
||||
endif
|
||||
|
||||
ifneq ("@CSCOPE_CMD@", "")
|
||||
cscope.out: tools
|
||||
@CSCOPE_CMD@ -b -R
|
||||
all: cscope.out
|
||||
endif
|
||||
|
||||
75
WHATS_NEW
75
WHATS_NEW
@@ -1,3 +1,78 @@
|
||||
Version 2.02.08 -
|
||||
================================
|
||||
Add checks for duplicate LV name, lvid and PV id before writing metadata.
|
||||
Report all sanity check failures, not just the first.
|
||||
Fix missing lockfs on first snapshot creation.
|
||||
Add unreliable --trustcache option to reporting commands.
|
||||
Fix locking for mimage removal.
|
||||
Fix clvmd_init_rhel4 'status' exit code.
|
||||
|
||||
Version 2.02.07 - 17th July 2006
|
||||
================================
|
||||
Fix activation logic in lvchange --persistent.
|
||||
Don't ignore persistent minor numbers when activating.
|
||||
Use RTLD_GLOBAL when loading shared libraries.
|
||||
Add some forgotten memlock checks to _vg_read to protect against full scans.
|
||||
Add mutex to dmeventd_mirror to avoid concurrent execution.
|
||||
Fix vgreduce --removemissing to return success if VG is already consistent.
|
||||
Fix return code if VG specified on command line is not found.
|
||||
Fix PV tools to include orphaned PVs in default output again.
|
||||
Fixed unaligned access when using clvm.
|
||||
Fix an extra dev_close in a label_read error path.
|
||||
Append patches to commit emails.
|
||||
Fix target_register_events args.
|
||||
Prevent snapshots of mirrors.
|
||||
Add DISTCLEAN_TARGETS to make template for configure.h.
|
||||
More fixes to error paths.
|
||||
Fix lvcreate corelog validation.
|
||||
Add --config for overriding most config file settings from cmdline.
|
||||
Quote arguments when printing command line.
|
||||
Remove linefeed from 'initialising logging' message.
|
||||
Add 'Completed' debug message.
|
||||
Don't attempt library exit after reloading config files.
|
||||
Always compile with libdevmapper, even if device-mapper is disabled.
|
||||
|
||||
Version 2.02.06 - 12th May 2006
|
||||
===============================
|
||||
Propagate --monitor around cluster.
|
||||
Add --monitor to vgcreate and lvcreate to control dmeventd registration.
|
||||
Filter LCK_NONBLOCK in clvmd lock_vg.
|
||||
Add --nosync to lvcreate with LV flag NOTSYNCED.
|
||||
Use mirror's uuid for a core log.
|
||||
Add mirror log fault-handling policy.
|
||||
Improve mirror warning messages and tidy dmeventd syslog output.
|
||||
Propagate nosync flag around cluster.
|
||||
Allow vgreduce to handle mirror log failures.
|
||||
Add --corelog to lvcreate and lvconvert.
|
||||
Create a log header for replacement in-sync mirror log.
|
||||
Use set_lv() and dev_set() to wipe sections of devices.
|
||||
Add mirror_in_sync() flag to avoid unnecessary resync on activation.
|
||||
Add mirror_library description to example.conf.
|
||||
Fix uuid_from_num() buffer overrun.
|
||||
Make SIZE_SHORT the default for display_size().
|
||||
Fix some memory leaks in error paths found by coverity.
|
||||
Use C99 struct initialisers.
|
||||
Move DEFS into configure.h.
|
||||
Clean-ups to remove miscellaneous compiler warnings.
|
||||
Improve stripe size validation.
|
||||
Increase maximum stripe size limit to physical extent size for lvm2 metadata.
|
||||
Fix activation code to check for pre-existing mirror logs.
|
||||
Tighten region size validation.
|
||||
Ignore empty strings in config files.
|
||||
Require non-zero regionsize and document parameter on lvcreate man page.
|
||||
Invalidate cache if composition of VG changed externally.
|
||||
|
||||
Version 2.02.05 - 21st April 2006
|
||||
=================================
|
||||
Fix vgid string termination in recent cache code.
|
||||
|
||||
Version 2.02.04 - 19th April 2006
|
||||
=================================
|
||||
Check for libsepol.
|
||||
Add some cflow & scope support.
|
||||
Separate out DEFS from CFLAGS.
|
||||
Remove inlines and use unique function names.
|
||||
|
||||
Version 2.02.03 - 14th April 2006
|
||||
=================================
|
||||
vgrename accepts vgid and exported VG.
|
||||
|
||||
35
WHATS_NEW_DM
35
WHATS_NEW_DM
@@ -1,3 +1,38 @@
|
||||
Version 1.02.09 - 15 Aug 2006
|
||||
==============================
|
||||
Add --table argument to dmsetup for a one-line table.
|
||||
Abort if errors are found during cmdline option processing.
|
||||
Add lockfs indicator to debug output.
|
||||
|
||||
Version 1.02.08 - 17 July 2006
|
||||
==============================
|
||||
Append full patch to check in emails.
|
||||
Avoid duplicate dmeventd subdir with 'make distclean'.
|
||||
Update dmsetup man page.
|
||||
Add --force to dmsetup remove* to load error target.
|
||||
dmsetup remove_all also performs mknodes.
|
||||
Don't suppress identical table reloads if permission changes.
|
||||
Fix corelog segment line.
|
||||
Suppress some compiler warnings.
|
||||
|
||||
Version 1.02.07 - 11 May 2006
|
||||
=============================
|
||||
Add DM_CORELOG flag to dm_tree_node_add_mirror_target().
|
||||
Avoid a dmeventd compiler warning.
|
||||
|
||||
Version 1.02.06 - 10 May 2006
|
||||
=============================
|
||||
Move DEFS into configure.h.
|
||||
Fix leaks in error paths found by coverity.
|
||||
Remove dmsetup line buffer limitation.
|
||||
|
||||
Version 1.02.05 - 19 Apr 2006
|
||||
=============================
|
||||
Separate install_include target in makefiles.
|
||||
Separate out DEFS from CFLAGS.
|
||||
Support pkg-config.
|
||||
Check for libsepol.
|
||||
|
||||
Version 1.02.04 - 14 Apr 2006
|
||||
=============================
|
||||
Bring dmsetup man page up-to-date.
|
||||
|
||||
56
configure.in
56
configure.in
@@ -18,6 +18,9 @@ AC_PREREQ(2.53)
|
||||
dnl -- Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(lib/device/dev-cache.h)
|
||||
|
||||
################################################################################
|
||||
AC_CONFIG_HEADERS(lib/misc/configure.h)
|
||||
|
||||
################################################################################
|
||||
dnl -- Setup the directory where autoconf has auxilary files
|
||||
AC_CONFIG_AUX_DIR(autoconf)
|
||||
@@ -65,6 +68,8 @@ AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_RANLIB
|
||||
AC_PATH_PROG(CFLOW_CMD, cflow)
|
||||
AC_PATH_PROG(CSCOPE_CMD, cscope)
|
||||
|
||||
################################################################################
|
||||
dnl -- Checks for header files.
|
||||
@@ -150,7 +155,7 @@ AC_ARG_ENABLE(lvm1_fallback, [ --enable-lvm1_fallback Use this to fall back an
|
||||
AC_MSG_RESULT($LVM1_FALLBACK)
|
||||
|
||||
if test x$LVM1_FALLBACK = xyes; then
|
||||
CFLAGS="$CFLAGS -DLVM1_FALLBACK"
|
||||
AC_DEFINE([LVM1_FALLBACK], 1, [Define to 1 if 'lvm' should fall back to using LVM1 binaries if device-mapper is missing from the kernel])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -170,7 +175,7 @@ if [[ "x$LVM1" != xnone -a "x$LVM1" != xinternal -a "x$LVM1" != xshared ]];
|
||||
fi;
|
||||
|
||||
if test x$LVM1 = xinternal; then
|
||||
CFLAGS="$CFLAGS -DLVM1_INTERNAL"
|
||||
AC_DEFINE([LVM1_INTERNAL], 1, [Define to 1 to include built-in support for LVM1 metadata.])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -190,7 +195,7 @@ if [[ "x$POOL" != xnone -a "x$POOL" != xinternal -a "x$POOL" != xshared ]];
|
||||
fi;
|
||||
|
||||
if test x$POOL = xinternal; then
|
||||
CFLAGS="$CFLAGS -DPOOL_INTERNAL"
|
||||
AC_DEFINE([POOL_INTERNAL], 1, [Define to 1 to include built-in support for GFS pool metadata.])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -209,7 +214,7 @@ if [[ "x$CLUSTER" != xnone -a "x$CLUSTER" != xinternal -a "x$CLUSTER" != xshared
|
||||
fi;
|
||||
|
||||
if test x$CLUSTER = xinternal; then
|
||||
CFLAGS="$CFLAGS -DCLUSTER_LOCKING_INTERNAL"
|
||||
AC_DEFINE([CLUSTER_LOCKING_INTERNAL], 1, [Define to 1 to include built-in support for clustered LVM locking.])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -229,7 +234,7 @@ if [[ "x$SNAPSHOTS" != xnone -a "x$SNAPSHOTS" != xinternal -a "x$SNAPSHOTS" != x
|
||||
fi;
|
||||
|
||||
if test x$SNAPSHOTS = xinternal; then
|
||||
CFLAGS="$CFLAGS -DSNAPSHOT_INTERNAL"
|
||||
AC_DEFINE([SNAPSHOT_INTERNAL], 1, [Define to 1 to include built-in support for snapshots.])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -249,7 +254,7 @@ if [[ "x$MIRRORS" != xnone -a "x$MIRRORS" != xinternal -a "x$MIRRORS" != xshared
|
||||
fi;
|
||||
|
||||
if test x$MIRRORS = xinternal; then
|
||||
CFLAGS="$CFLAGS -DMIRRORED_INTERNAL"
|
||||
AC_DEFINE([MIRRORED_INTERNAL], 1, [Define to 1 to include built-in support for mirrors.])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -267,7 +272,7 @@ READLINE=$enableval, READLINE=no)
|
||||
AC_MSG_RESULT($READLINE)
|
||||
|
||||
if test x$READLINE = xyes; then
|
||||
CFLAGS="$CFLAGS -DREADLINE_SUPPORT"
|
||||
AC_DEFINE([READLINE_SUPPORT], 1, [Define to 1 to include the LVM readline shell.])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -305,6 +310,8 @@ AC_MSG_RESULT($DEBUG)
|
||||
dnl -- Normally turn off optimisation for debug builds
|
||||
if test x$DEBUG = xyes; then
|
||||
COPTIMISE_FLAG=
|
||||
else
|
||||
CSCOPE_CMD=
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -323,7 +330,7 @@ DEVMAPPER=$enableval)
|
||||
AC_MSG_RESULT($DEVMAPPER)
|
||||
|
||||
if test x$DEVMAPPER = xyes; then
|
||||
CFLAGS="$CFLAGS -DDEVMAPPER_SUPPORT"
|
||||
AC_DEFINE([DEVMAPPER_SUPPORT], 1, [Define to 1 to enable device-mapper interaction.])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -334,7 +341,7 @@ ODIRECT=$enableval)
|
||||
AC_MSG_RESULT($ODIRECT)
|
||||
|
||||
if test x$ODIRECT = xyes; then
|
||||
CFLAGS="$CFLAGS -DO_DIRECT_SUPPORT"
|
||||
AC_DEFINE([O_DIRECT_SUPPORT], 1, [Define to 1 to enable O_DIRECT support.])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -345,7 +352,7 @@ CMDLIB=$enableval, CMDLIB=no)
|
||||
AC_MSG_RESULT($CMDLIB)
|
||||
|
||||
if test x$CMDLIB = xyes; then
|
||||
CFLAGS="$CFLAGS -DCMDLIB"
|
||||
AC_DEFINE([CMDLIB], 1, [Define to 1 to build the shared command library.])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -370,7 +377,7 @@ AC_MSG_ERROR(
|
||||
fi
|
||||
|
||||
if test x$DMEVENTD = xyes; then
|
||||
CFLAGS="$CFLAGS -DDMEVENTD"
|
||||
AC_DEFINE([DMEVENTD], 1, [Define to 1 to enable the device-mapper event daemon.])
|
||||
fi
|
||||
################################################################################
|
||||
dnl -- Mess with default exec_prefix
|
||||
@@ -407,7 +414,7 @@ dnl -- Check for dlopen
|
||||
AC_CHECK_LIB(dl, dlopen, HAVE_LIBDL=yes, HAVE_LIBDL=no)
|
||||
|
||||
if [[ "x$HAVE_LIBDL" = xyes ]]; then
|
||||
CFLAGS="$CFLAGS -DHAVE_LIBDL"
|
||||
AC_DEFINE([HAVE_LIBDL], 1, [Define to 1 if dynamic libraries are available.])
|
||||
LIBS="-ldl $LIBS"
|
||||
else
|
||||
HAVE_LIBDL=no
|
||||
@@ -424,14 +431,22 @@ Features cannot be 'shared' when building statically
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
dnl -- Check for is_selinux_enabled
|
||||
dnl -- Check for selinux
|
||||
if test x$SELINUX = xyes; then
|
||||
AC_MSG_CHECKING(for sepol_check_context function)
|
||||
AC_CHECK_LIB(sepol, sepol_check_context, HAVE_SEPOL=yes, HAVE_SEPOL=no)
|
||||
AC_MSG_RESULT($HAVE_SEPOL)
|
||||
|
||||
if test x$HAVE_SEPOL = xyes; then
|
||||
LIBS="-lsepol $LIBS"
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for is_selinux_enabled function)
|
||||
AC_CHECK_LIB(selinux, is_selinux_enabled, HAVE_SELINUX=yes, HAVE_SELINUX=no)
|
||||
AC_MSG_RESULT($HAVE_SELINUX)
|
||||
|
||||
if test x$HAVE_SELINUX = xyes; then
|
||||
CFLAGS="$CFLAGS -DHAVE_SELINUX"
|
||||
AC_DEFINE([HAVE_SELINUX], 1, [Define to 1 to include support for selinux.])
|
||||
LIBS="-lselinux $LIBS"
|
||||
else
|
||||
AC_MSG_WARN(Disabling selinux)
|
||||
@@ -440,7 +455,7 @@ fi
|
||||
|
||||
################################################################################
|
||||
dnl -- Check for getopt
|
||||
AC_CHECK_HEADERS(getopt.h, CFLAGS="$CFLAGS -DHAVE_GETOPTLONG")
|
||||
AC_CHECK_HEADERS(getopt.h, AC_DEFINE([HAVE_GETOPTLONG], 1, [Define to 1 to if getopt_long is available.]))
|
||||
|
||||
################################################################################
|
||||
dnl -- Check for readline (Shamelessly copied from parted 1.4.17)
|
||||
@@ -455,8 +470,7 @@ Note: if you are using precompiled packages you will also need the development
|
||||
package as well (which may be called readline-devel or something similar).
|
||||
)
|
||||
)
|
||||
AC_CHECK_FUNC(rl_completion_matches, CFLAGS="$CFLAGS -DHAVE_RL_COMPLETION_MATCHES")
|
||||
|
||||
AC_CHECK_FUNC(rl_completion_matches, AC_DEFINE([HAVE_RL_COMPLETION_MATCHES], 1, [Define to 1 if rl_completion_matches() is available.]))
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -524,9 +538,7 @@ if test x$INTL = xyes; then
|
||||
AC_CHECK_HEADERS(libintl.h,,AC_MSG_ERROR(bailing out))
|
||||
fi
|
||||
|
||||
if test x$DEVMAPPER = xyes; then
|
||||
AC_CHECK_HEADERS(libdevmapper.h,,AC_MSG_ERROR(bailing out))
|
||||
fi
|
||||
AC_CHECK_HEADERS(libdevmapper.h,,AC_MSG_ERROR(bailing out))
|
||||
|
||||
if test x$HAVE_SELINUX = xyes; then
|
||||
AC_CHECK_HEADERS(selinux/selinux.h,,AC_MSG_ERROR(bailing out))
|
||||
@@ -536,7 +548,7 @@ fi
|
||||
AC_PATH_PROG(MODPROBE_CMD, modprobe)
|
||||
|
||||
if test x$MODPROBE_CMD != x; then
|
||||
CFLAGS="$CFLAGS -DMODPROBE_CMD=\\\"$MODPROBE_CMD\\\""
|
||||
AC_DEFINE_UNQUOTED([MODPROBE_CMD], ["$MODPROBE_CMD"], [The path to 'modprobe', if available.])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -581,6 +593,8 @@ AC_SUBST(CLVMD)
|
||||
AC_SUBST(CLUSTER)
|
||||
AC_SUBST(FSADM)
|
||||
AC_SUBST(DMEVENTD)
|
||||
AC_SUBST(CFLOW_CMD)
|
||||
AC_SUBST(CSCOPE_CMD)
|
||||
|
||||
################################################################################
|
||||
dnl -- First and last lines should not contain files to generate in order to
|
||||
|
||||
@@ -35,19 +35,19 @@ ifeq ("@CLVMD@", "all")
|
||||
endif
|
||||
|
||||
ifeq ("@DEBUG@", "yes")
|
||||
CFLAGS += -DDEBUG
|
||||
DEFS += -DDEBUG
|
||||
endif
|
||||
|
||||
ifeq ("$(GULM)", "yes")
|
||||
SOURCES += clvmd-gulm.c tcp-comms.c
|
||||
LMLIBS += -lccs -lgulm
|
||||
CFLAGS += -DUSE_GULM
|
||||
DEFS += -DUSE_GULM
|
||||
endif
|
||||
|
||||
ifeq ("$(CMAN)", "yes")
|
||||
SOURCES += clvmd-cman.c
|
||||
LMLIBS += -ldlm -lcman
|
||||
CFLAGS += -DUSE_CMAN
|
||||
DEFS += -DUSE_CMAN
|
||||
endif
|
||||
|
||||
TARGETS = \
|
||||
@@ -59,11 +59,10 @@ ifeq ("@DMEVENTD@", "yes")
|
||||
LVMLIBS += -ldevmapper-event
|
||||
endif
|
||||
|
||||
ifeq ("@DEVMAPPER@", "yes")
|
||||
LVMLIBS += -ldevmapper
|
||||
endif
|
||||
LVMLIBS += -ldevmapper
|
||||
|
||||
CFLAGS += -D_REENTRANT -fno-strict-aliasing
|
||||
DEFS += -D_REENTRANT
|
||||
CFLAGS += -fno-strict-aliasing
|
||||
|
||||
include $(top_srcdir)/make.tmpl
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ static int lock_vg(struct local_client *client)
|
||||
}
|
||||
else {
|
||||
|
||||
status = sync_lock(lockname, (int)lock_cmd, (int)lock_flags, &lkid);
|
||||
status = sync_lock(lockname, (int)lock_cmd, (lock_flags & LCK_NONBLOCK) ? LKF_NOQUEUE : 0, &lkid);
|
||||
if (status)
|
||||
status = errno;
|
||||
else
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "log.h"
|
||||
#include "activate.h"
|
||||
#include "locking.h"
|
||||
#include "defaults.h"
|
||||
|
||||
static struct cmd_context *cmd = NULL;
|
||||
static struct dm_hash_table *lv_hash = NULL;
|
||||
@@ -306,6 +307,12 @@ int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
|
||||
if (lock_flags & LCK_PARTIAL_MODE)
|
||||
init_partial(1);
|
||||
|
||||
if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
|
||||
init_mirror_in_sync(1);
|
||||
|
||||
if (!(lock_flags & LCK_DMEVENTD_REGISTER_MODE))
|
||||
init_dmeventd_register(0);
|
||||
|
||||
switch (command) {
|
||||
case LCK_LV_EXCLUSIVE:
|
||||
status = do_activate_lv(resource, lock_flags, LKM_EXMODE);
|
||||
@@ -337,6 +344,12 @@ int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
|
||||
if (lock_flags & LCK_PARTIAL_MODE)
|
||||
init_partial(0);
|
||||
|
||||
if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
|
||||
init_mirror_in_sync(0);
|
||||
|
||||
if (!(lock_flags & LCK_DMEVENTD_REGISTER_MODE))
|
||||
init_dmeventd_register(DEFAULT_DMEVENTD_MONITOR);
|
||||
|
||||
/* clean the pool for another command */
|
||||
dm_pool_empty(cmd->mem);
|
||||
|
||||
@@ -497,7 +510,7 @@ static void check_config()
|
||||
{
|
||||
int locking_type;
|
||||
|
||||
locking_type = find_config_int(cmd->cft->root, "global/locking_type", 1);
|
||||
locking_type = find_config_tree_int(cmd, "global/locking_type", 1);
|
||||
|
||||
if (locking_type == 3) /* compiled-in cluster support */
|
||||
return;
|
||||
@@ -505,7 +518,7 @@ static void check_config()
|
||||
if (locking_type == 2) { /* External library, check name */
|
||||
const char *libname;
|
||||
|
||||
libname = find_config_str(cmd->cft->root, "global/locking_library",
|
||||
libname = find_config_tree_str(cmd, "global/locking_library",
|
||||
"");
|
||||
if (strstr(libname, "liblvm2clusterlock.so"))
|
||||
return;
|
||||
|
||||
@@ -57,7 +57,7 @@ int init_comms(unsigned short port)
|
||||
struct sockaddr_in6 addr;
|
||||
|
||||
sock_hash = dm_hash_create(100);
|
||||
tcp_port = port ? port : DEFAULT_TCP_PORT;
|
||||
tcp_port = port ? : DEFAULT_TCP_PORT;
|
||||
|
||||
listen_fd = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ include ../make.tmpl
|
||||
|
||||
CLDFLAGS += -ldl -ldevmapper -lpthread
|
||||
|
||||
.PHONY: install_dynamic install_static
|
||||
.PHONY: install_dynamic install_static install_include \
|
||||
install_pkgconfig
|
||||
|
||||
INSTALL_TYPE = install_dynamic
|
||||
|
||||
@@ -38,18 +39,35 @@ ifeq ("@STATIC_LINK@", "yes")
|
||||
INSTALL_TYPE += install_static
|
||||
endif
|
||||
|
||||
install: $(INSTALL_TYPE)
|
||||
ifeq ("@PKGCONFIG@", "yes")
|
||||
INSTALL_TYPE += install_pkgconfig
|
||||
endif
|
||||
|
||||
install: $(INSTALL_TYPE) install_include
|
||||
|
||||
install_include:
|
||||
$(INSTALL) -D $(OWNER) $(GROUP) -m 444 libdevmapper-event.h \
|
||||
$(includedir)/libdevmapper-event.h
|
||||
|
||||
install_dynamic: libdevmapper-event.$(LIB_SUFFIX)
|
||||
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
|
||||
$(libdir)/libdevmapper-event.$(LIB_SUFFIX).$(LIB_VERSION)
|
||||
$(LN_S) -f libdevmapper-event.$(LIB_SUFFIX).$(LIB_VERSION) \
|
||||
$(libdir)/libdevmapper-event.$(LIB_SUFFIX)
|
||||
$(INSTALL) -D $(OWNER) $(GROUP) -m 444 libdevmapper-event.h \
|
||||
$(includedir)/libdevmapper-event.h
|
||||
|
||||
install_pkgconfig:
|
||||
$(INSTALL) -D $(OWNER) $(GROUP) -m 444 libdevmapper-event.pc \
|
||||
$(usrlibdir)/pkgconfig/devmapper-event.pc
|
||||
|
||||
install_static: libdevmapper-event.a
|
||||
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
|
||||
$(libdir)/libdevmapper-event.a.$(LIB_VERSION)
|
||||
$(LN_S) -f libdevmapper-event.a.$(LIB_VERSION) $(libdir)/libdevmapper-event.a
|
||||
|
||||
.PHONY: distclean_lib distclean
|
||||
|
||||
distclean_lib:
|
||||
$(RM) libdevmapper-event.pc
|
||||
|
||||
distclean: distclean_lib
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
* dmeventd - dm event daemon to monitor active mapped devices
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
#include "libdevmapper.h"
|
||||
#include "libdevmapper-event.h"
|
||||
#include "list.h"
|
||||
@@ -318,7 +321,7 @@ static int device_exists(char *device)
|
||||
struct stat st_buf;
|
||||
char path2[PATH_MAX];
|
||||
|
||||
if (!device)
|
||||
if (!device || !*device)
|
||||
return 0;
|
||||
|
||||
if (device[0] == '/') /* absolute path */
|
||||
@@ -718,8 +721,11 @@ static struct dso_data *load_dso(struct message_data *data)
|
||||
void *dl;
|
||||
struct dso_data *ret = NULL;
|
||||
|
||||
log_very_verbose("Opening shared library %s", data->dso_name);
|
||||
|
||||
if (!(dl = dlopen(data->dso_name, RTLD_NOW))){
|
||||
log_error("%s\n", dlerror());
|
||||
log_error("dmeventd %s dlopen failed: %s", data->dso_name,
|
||||
dlerror());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1207,14 +1213,14 @@ static void sig_alarm(int signum)
|
||||
/* Init thread signal handling. */
|
||||
static void init_thread_signals(void)
|
||||
{
|
||||
sigset_t sigset;
|
||||
sigset_t my_sigset;
|
||||
struct sigaction act;
|
||||
|
||||
memset(&act, 0, sizeof(act));
|
||||
act.sa_handler = sig_alarm;
|
||||
sigaction(SIGALRM, &act, NULL);
|
||||
sigfillset(&sigset);
|
||||
pthread_sigmask(SIG_BLOCK, &sigset, NULL);
|
||||
sigfillset(&my_sigset);
|
||||
pthread_sigmask(SIG_BLOCK, &my_sigset, NULL);
|
||||
}
|
||||
|
||||
static int daemonize(void)
|
||||
|
||||
12
daemons/dmeventd/libdevmapper-event.pc.in
Normal file
12
daemons/dmeventd/libdevmapper-event.pc.in
Normal file
@@ -0,0 +1,12 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: devmapper-event
|
||||
Description: device-mapper event library
|
||||
Version: @DM_LIB_VERSION@
|
||||
Requires: devmapper
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} -ldevmapper-event
|
||||
Libs.private: -lpthread -ldl
|
||||
@@ -31,6 +31,8 @@
|
||||
#define ME_INSYNC 1
|
||||
#define ME_FAILURE 2
|
||||
|
||||
static pthread_mutex_t _lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
/* FIXME: We may need to lock around operations to these */
|
||||
static int register_count = 0;
|
||||
static struct dm_pool *mem_pool = NULL;
|
||||
@@ -99,10 +101,13 @@ static int _get_mirror_event(char *params)
|
||||
return rtn;
|
||||
}
|
||||
|
||||
static void _temporary_log_fn(int level, const char *file, int line, const char *format)
|
||||
static void _temporary_log_fn(int level, const char *file,
|
||||
int line, const char *format)
|
||||
{
|
||||
return;
|
||||
syslog(LOG_DEBUG, "%s", format);
|
||||
if (!strncmp(format, "WARNING: ", 9) && (level < 5))
|
||||
syslog(LOG_CRIT, "%s", format);
|
||||
else
|
||||
syslog(LOG_DEBUG, "%s", format);
|
||||
}
|
||||
|
||||
static int _remove_failed_devices(const char *device)
|
||||
@@ -147,6 +152,10 @@ void process_event(const char *device, enum dm_event_type event)
|
||||
char *target_type = NULL;
|
||||
char *params;
|
||||
|
||||
if (pthread_mutex_trylock(&_lock)) {
|
||||
syslog(LOG_NOTICE, "Another thread is handling an event. Waiting...");
|
||||
pthread_mutex_lock(&_lock);
|
||||
}
|
||||
/* FIXME Move inside libdevmapper */
|
||||
if (!(dmt = dm_task_create(DM_DEVICE_STATUS))) {
|
||||
syslog(LOG_ERR, "Unable to create dm_task.\n");
|
||||
@@ -201,11 +210,12 @@ void process_event(const char *device, enum dm_event_type event)
|
||||
fail:
|
||||
if (dmt)
|
||||
dm_task_destroy(dmt);
|
||||
pthread_mutex_unlock(&_lock);
|
||||
}
|
||||
|
||||
int register_device(const char *device)
|
||||
{
|
||||
syslog(LOG_INFO, "Monitoring %s for events\n", device);
|
||||
syslog(LOG_INFO, "Monitoring mirror device, %s for events\n", device);
|
||||
|
||||
/*
|
||||
* Need some space for allocations. 1024 should be more
|
||||
@@ -224,8 +234,6 @@ int register_device(const char *device)
|
||||
|
||||
int unregister_device(const char *device)
|
||||
{
|
||||
syslog(LOG_INFO, "Stopped monitoring %s for events\n", device);
|
||||
|
||||
if (!(--register_count)) {
|
||||
dm_pool_destroy(mem_pool);
|
||||
mem_pool = NULL;
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#define ME_INSYNC 1
|
||||
#define ME_FAILURE 2
|
||||
|
||||
static pthread_mutex_t _lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
/* FIXME: We may need to lock around operations to these */
|
||||
static int register_count = 0;
|
||||
static struct dm_pool *mem_pool = NULL;
|
||||
@@ -99,10 +101,13 @@ static int _get_mirror_event(char *params)
|
||||
return rtn;
|
||||
}
|
||||
|
||||
static void _temporary_log_fn(int level, const char *file, int line, const char *format)
|
||||
static void _temporary_log_fn(int level, const char *file,
|
||||
int line, const char *format)
|
||||
{
|
||||
return;
|
||||
syslog(LOG_DEBUG, "%s", format);
|
||||
if (!strncmp(format, "WARNING: ", 9) && (level < 5))
|
||||
syslog(LOG_CRIT, "%s", format);
|
||||
else
|
||||
syslog(LOG_DEBUG, "%s", format);
|
||||
}
|
||||
|
||||
static int _remove_failed_devices(const char *device)
|
||||
@@ -147,6 +152,10 @@ void process_event(const char *device, enum dm_event_type event)
|
||||
char *target_type = NULL;
|
||||
char *params;
|
||||
|
||||
if (pthread_mutex_trylock(&_lock)) {
|
||||
syslog(LOG_NOTICE, "Another thread is handling an event. Waiting...");
|
||||
pthread_mutex_lock(&_lock);
|
||||
}
|
||||
/* FIXME Move inside libdevmapper */
|
||||
if (!(dmt = dm_task_create(DM_DEVICE_STATUS))) {
|
||||
syslog(LOG_ERR, "Unable to create dm_task.\n");
|
||||
@@ -201,11 +210,12 @@ void process_event(const char *device, enum dm_event_type event)
|
||||
fail:
|
||||
if (dmt)
|
||||
dm_task_destroy(dmt);
|
||||
pthread_mutex_unlock(&_lock);
|
||||
}
|
||||
|
||||
int register_device(const char *device)
|
||||
{
|
||||
syslog(LOG_INFO, "Monitoring %s for events\n", device);
|
||||
syslog(LOG_INFO, "Monitoring mirror device, %s for events\n", device);
|
||||
|
||||
/*
|
||||
* Need some space for allocations. 1024 should be more
|
||||
@@ -224,8 +234,6 @@ int register_device(const char *device)
|
||||
|
||||
int unregister_device(const char *device)
|
||||
{
|
||||
syslog(LOG_INFO, "Stopped monitoring %s for events\n", device);
|
||||
|
||||
if (!(--register_count)) {
|
||||
dm_pool_destroy(mem_pool);
|
||||
mem_pool = NULL;
|
||||
|
||||
@@ -232,9 +232,6 @@ activation {
|
||||
# target or make it return zeros.
|
||||
missing_stripe_filler = "/dev/ioerror"
|
||||
|
||||
# Size (in KB) of each copy operation when mirroring
|
||||
mirror_region_size = 512
|
||||
|
||||
# How much stack (in KB) to reserve for use while devices suspended
|
||||
reserved_stack = 256
|
||||
|
||||
@@ -251,6 +248,54 @@ activation {
|
||||
# "@*" matches if any tag defined on the host is also set in the LV or VG
|
||||
#
|
||||
# volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ]
|
||||
|
||||
# Size (in KB) of each copy operation when mirroring
|
||||
mirror_region_size = 512
|
||||
|
||||
# 'mirror_image_fault_policy' and 'mirror_log_fault_policy' define
|
||||
# how a device failure affecting a mirror is handled.
|
||||
# A mirror is composed of mirror images (copies) and a log.
|
||||
# A disk log ensures that a mirror does not need to be re-synced
|
||||
# (all copies made the same) every time a machine reboots or crashes.
|
||||
#
|
||||
# In the event of a failure, the specified policy will be used to
|
||||
# determine what happens:
|
||||
#
|
||||
# "remove" - Simply remove the faulty device and run without it. If
|
||||
# the log device fails, the mirror would convert to using
|
||||
# an in-memory log. This means the mirror will not
|
||||
# remember its sync status across crashes/reboots and
|
||||
# the entire mirror will be re-synced. If a
|
||||
# mirror image fails, the mirror will convert to a
|
||||
# non-mirrored device if there is only one remaining good
|
||||
# copy.
|
||||
#
|
||||
# "allocate" - Remove the faulty device and try to allocate space on
|
||||
# a new device to be a replacement for the failed device.
|
||||
# Using this policy for the log is fast and maintains the
|
||||
# ability to remember sync state through crashes/reboots.
|
||||
# Using this policy for a mirror device is slow, as it
|
||||
# requires the mirror to resynchronize the devices, but it
|
||||
# will preserve the mirror characteristic of the device.
|
||||
# This policy acts like "remove" if no suitable device and
|
||||
# space can be allocated for the replacement.
|
||||
# Currently this is not implemented properly and behaves
|
||||
# similarly to:
|
||||
#
|
||||
# "allocate_anywhere" - Operates like "allocate", but it does not
|
||||
# require that the new space being allocated be on a
|
||||
# device is not part of the mirror. For a log device
|
||||
# failure, this could mean that the log is allocated on
|
||||
# the same device as a mirror device. For a mirror
|
||||
# device, this could mean that the mirror device is
|
||||
# allocated on the same device as another mirror device.
|
||||
# This policy would not be wise for mirror devices
|
||||
# because it would break the redundant nature of the
|
||||
# mirror. This policy acts like "remove" if no suitable
|
||||
# device and space can be allocated for the replacement.
|
||||
|
||||
mirror_log_fault_policy = "allocate"
|
||||
mirror_device_fault_policy = "remove"
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +336,13 @@ activation {
|
||||
|
||||
# Event daemon
|
||||
#
|
||||
#dmeventd {
|
||||
# dmeventd {
|
||||
# mirror_library is the library used when monitoring a mirror device.
|
||||
#
|
||||
# "libdevmapper-event-lvm2mirror.so" attempts to recover from failures.
|
||||
# It removes failed devices from a volume group and reconfigures a
|
||||
# mirror as necessary.
|
||||
#
|
||||
# mirror_library = "libdevmapper-event-lvm2mirror.so"
|
||||
#}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
../lib/metadata/segtype.h
|
||||
../lib/mm/memlock.h
|
||||
../lib/mm/xlate.h
|
||||
../lib/misc/configure.h
|
||||
../lib/misc/crc.h
|
||||
../lib/misc/intl.h
|
||||
../lib/misc/lib.h
|
||||
|
||||
@@ -41,3 +41,5 @@ install:
|
||||
|
||||
install_cluster:
|
||||
|
||||
cflow:
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ SOURCES =\
|
||||
commands/toolcontext.c \
|
||||
config/config.c \
|
||||
datastruct/btree.c \
|
||||
datastruct/list.c \
|
||||
datastruct/str_list.c \
|
||||
device/dev-cache.c \
|
||||
device/dev-io.c \
|
||||
@@ -141,5 +142,14 @@ LIB_STATIC = liblvm.a
|
||||
|
||||
$(SUBDIRS): $(LIB_STATIC)
|
||||
|
||||
CLEAN_TARGETS += liblvm.cflow
|
||||
|
||||
include $(top_srcdir)/make.tmpl
|
||||
|
||||
liblvm.cflow: $(SOURCES)
|
||||
set -e; (echo -n "SOURCES += "; \
|
||||
echo $(SOURCES) | \
|
||||
sed "s/^/ /;s/ / $(top_srcdir)\/lib\//g;s/$$//"; \
|
||||
) > $@
|
||||
|
||||
cflow: liblvm.cflow
|
||||
|
||||
@@ -152,11 +152,16 @@ int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv)
|
||||
}
|
||||
|
||||
int pv_uses_vg(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
struct volume_group *vg)
|
||||
struct volume_group *vg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void activation_release(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void activation_exit(void)
|
||||
{
|
||||
return;
|
||||
@@ -193,7 +198,7 @@ static int _passes_activation_filter(struct cmd_context *cmd,
|
||||
char *str;
|
||||
char path[PATH_MAX];
|
||||
|
||||
if (!(cn = find_config_node(cmd->cft->root, "activation/volume_list"))) {
|
||||
if (!(cn = find_config_tree_node(cmd, "activation/volume_list"))) {
|
||||
/* If no host tags defined, activate */
|
||||
if (list_empty(&cmd->tags))
|
||||
return 1;
|
||||
@@ -523,7 +528,7 @@ static int _lv_deactivate(struct logical_volume *lv)
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _lv_suspend_lv(struct logical_volume *lv)
|
||||
static int _lv_suspend_lv(struct logical_volume *lv, int lockfs)
|
||||
{
|
||||
int r;
|
||||
struct dev_manager *dm;
|
||||
@@ -531,7 +536,7 @@ static int _lv_suspend_lv(struct logical_volume *lv)
|
||||
if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name)))
|
||||
return_0;
|
||||
|
||||
if (!(r = dev_manager_suspend(dm, lv)))
|
||||
if (!(r = dev_manager_suspend(dm, lv, lockfs)))
|
||||
stack;
|
||||
|
||||
dev_manager_destroy(dm);
|
||||
@@ -574,14 +579,29 @@ int lvs_in_vg_opened(struct volume_group *vg)
|
||||
return count;
|
||||
}
|
||||
|
||||
static int _register_dev_for_events(struct cmd_context *cmd,
|
||||
struct logical_volume *lv, int do_reg)
|
||||
/*
|
||||
* register_dev_for_events
|
||||
*
|
||||
* This function uses proper error codes (but breaks convention)
|
||||
* to return:
|
||||
* -1 on error
|
||||
* 0 if the lv's targets don't do event [un]registration
|
||||
* 0 if the lv is already [un]registered -- FIXME: not implemented
|
||||
* 1 if the lv had a segment which was [un]registered
|
||||
*
|
||||
* Returns: -1 on error
|
||||
*/
|
||||
int register_dev_for_events(struct cmd_context *cmd,
|
||||
struct logical_volume *lv, int do_reg)
|
||||
{
|
||||
#ifdef DMEVENTD
|
||||
int r = 0;
|
||||
struct list *tmp;
|
||||
struct lv_segment *seg;
|
||||
int (*reg) (struct dm_pool *mem, struct lv_segment *,
|
||||
struct config_tree *cft, int events);
|
||||
int (*reg) (struct lv_segment *, int events);
|
||||
|
||||
if (do_reg && !dmeventd_register_mode())
|
||||
return 1;
|
||||
|
||||
list_iterate(tmp, &lv->segments) {
|
||||
seg = list_item(tmp, struct lv_segment);
|
||||
@@ -594,16 +614,22 @@ static int _register_dev_for_events(struct cmd_context *cmd,
|
||||
} else if (seg->segtype->ops->target_unregister_events)
|
||||
reg = seg->segtype->ops->target_unregister_events;
|
||||
|
||||
if (reg)
|
||||
/* FIXME specify events */
|
||||
if (!reg(cmd->mem, seg, cmd->cft, 0)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!reg)
|
||||
continue;
|
||||
|
||||
/* FIXME specify events */
|
||||
if (!reg(seg, 0)) {
|
||||
stack;
|
||||
return -1;
|
||||
}
|
||||
|
||||
r = 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
return r;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
|
||||
@@ -611,6 +637,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
|
||||
{
|
||||
struct logical_volume *lv, *lv_pre;
|
||||
struct lvinfo info;
|
||||
int lockfs = 0;
|
||||
|
||||
if (!activation())
|
||||
return 1;
|
||||
@@ -641,11 +668,16 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
|
||||
}
|
||||
}
|
||||
|
||||
if (!_register_dev_for_events(cmd, lv, 0))
|
||||
if (register_dev_for_events(cmd, lv, 0) != 1)
|
||||
/* FIXME Consider aborting here */
|
||||
stack;
|
||||
|
||||
memlock_inc();
|
||||
if (!_lv_suspend_lv(lv)) {
|
||||
|
||||
if (lv_is_origin(lv_pre) || lv_is_cow(lv_pre))
|
||||
lockfs = 1;
|
||||
|
||||
if (!_lv_suspend_lv(lv, lockfs)) {
|
||||
memlock_dec();
|
||||
fs_unlock();
|
||||
return 0;
|
||||
@@ -694,7 +726,7 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
|
||||
memlock_dec();
|
||||
fs_unlock();
|
||||
|
||||
if (!_register_dev_for_events(cmd, lv, 1))
|
||||
if (register_dev_for_events(cmd, lv, 1) != 1)
|
||||
stack;
|
||||
|
||||
return 1;
|
||||
@@ -740,7 +772,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_register_dev_for_events(cmd, lv, 0))
|
||||
if (register_dev_for_events(cmd, lv, 0) != 1)
|
||||
stack;
|
||||
|
||||
memlock_inc();
|
||||
@@ -813,7 +845,7 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
|
||||
memlock_dec();
|
||||
fs_unlock();
|
||||
|
||||
if (!_register_dev_for_events(cmd, lv, 1))
|
||||
if (!register_dev_for_events(cmd, lv, 1) != 1)
|
||||
stack;
|
||||
|
||||
return r;
|
||||
@@ -859,28 +891,21 @@ int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv)
|
||||
* Does PV use VG somewhere in its construction?
|
||||
* Returns 1 on failure.
|
||||
*/
|
||||
int pv_uses_vg(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
struct volume_group *vg)
|
||||
int pv_uses_vg(struct physical_volume *pv,
|
||||
struct volume_group *vg)
|
||||
{
|
||||
struct dev_manager *dm;
|
||||
int r;
|
||||
|
||||
if (!activation())
|
||||
return 0;
|
||||
|
||||
if (!dm_is_dm_major(MAJOR(pv->dev->dev)))
|
||||
return 0;
|
||||
|
||||
if (!(dm = dev_manager_create(cmd, vg->name))) {
|
||||
stack;
|
||||
return 1;
|
||||
}
|
||||
return dev_manager_device_uses_vg(pv->dev, vg);
|
||||
}
|
||||
|
||||
r = dev_manager_device_uses_vg(dm, pv->dev, vg);
|
||||
|
||||
dev_manager_destroy(dm);
|
||||
|
||||
return r;
|
||||
void activation_release(void)
|
||||
{
|
||||
dev_manager_release();
|
||||
}
|
||||
|
||||
void activation_exit(void)
|
||||
|
||||
@@ -40,6 +40,7 @@ int target_present(const char *target_name, int use_modprobe);
|
||||
int target_version(const char *target_name, uint32_t *maj,
|
||||
uint32_t *min, uint32_t *patchlevel);
|
||||
|
||||
void activation_release(void);
|
||||
void activation_exit(void);
|
||||
|
||||
int lv_suspend(struct cmd_context *cmd, const char *lvid_s);
|
||||
@@ -80,10 +81,14 @@ int lv_mirror_percent(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
int lvs_in_vg_activated(struct volume_group *vg);
|
||||
int lvs_in_vg_opened(struct volume_group *vg);
|
||||
|
||||
|
||||
int register_dev_for_events(struct cmd_context *cmd,
|
||||
struct logical_volume *lv, int do_reg);
|
||||
|
||||
/*
|
||||
* Returns 1 if PV has a dependency tree that uses anything in VG.
|
||||
*/
|
||||
int pv_uses_vg(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
int pv_uses_vg(struct physical_volume *pv,
|
||||
struct volume_group *vg);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,6 +37,7 @@ typedef enum {
|
||||
ACTIVATE,
|
||||
DEACTIVATE,
|
||||
SUSPEND,
|
||||
SUSPEND_WITH_LOCKFS,
|
||||
CLEAN
|
||||
} action_t;
|
||||
|
||||
@@ -85,7 +86,7 @@ char *build_dlid(struct dev_manager *dm, const char *lvid, const char *layer)
|
||||
return _build_dlid(dm->mem, lvid, layer);
|
||||
}
|
||||
|
||||
static inline int _read_only_lv(struct logical_volume *lv)
|
||||
static int _read_only_lv(struct logical_volume *lv)
|
||||
{
|
||||
return (!(lv->vg->status & LVM_WRITE) || !(lv->status & LVM_WRITE));
|
||||
}
|
||||
@@ -329,7 +330,7 @@ static int _percent_run(struct dev_manager *dm, const char *name,
|
||||
|
||||
if (segtype->ops->target_percent &&
|
||||
!segtype->ops->target_percent(&dm->target_state, dm->mem,
|
||||
dm->cmd->cft, seg, params,
|
||||
dm->cmd, seg, params,
|
||||
&total_numerator,
|
||||
&total_denominator,
|
||||
percent))
|
||||
@@ -401,7 +402,7 @@ struct dev_manager *dev_manager_create(struct cmd_context *cmd,
|
||||
dm->mem = mem;
|
||||
|
||||
if (!stripe_filler) {
|
||||
stripe_filler = find_config_str(cmd->cft->root,
|
||||
stripe_filler = find_config_tree_str(cmd,
|
||||
"activation/missing_stripe_filler",
|
||||
DEFAULT_STRIPE_FILLER);
|
||||
}
|
||||
@@ -426,6 +427,11 @@ void dev_manager_destroy(struct dev_manager *dm)
|
||||
dm_pool_destroy(dm->mem);
|
||||
}
|
||||
|
||||
void dev_manager_release(void)
|
||||
{
|
||||
dm_lib_release();
|
||||
}
|
||||
|
||||
void dev_manager_exit(void)
|
||||
{
|
||||
dm_lib_exit();
|
||||
@@ -616,6 +622,9 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struc
|
||||
if (!_add_dev_to_dtree(dm, dtree, lv, "cow"))
|
||||
return_0;
|
||||
|
||||
if (!_add_dev_to_dtree(dm, dtree, lv, "_mlog"))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -661,7 +670,8 @@ fail:
|
||||
}
|
||||
|
||||
int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
|
||||
struct dm_tree_node *node, int start_area, int areas)
|
||||
struct dm_tree_node *node, uint32_t start_area,
|
||||
uint32_t areas)
|
||||
{
|
||||
uint64_t extent_size = seg->lv->vg->extent_size;
|
||||
uint32_t s;
|
||||
@@ -675,7 +685,7 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
|
||||
(seg_type(seg, s) == AREA_LV && !seg_lv(seg, s)))
|
||||
dm_tree_node_add_target_area(node,
|
||||
dm->stripe_filler,
|
||||
NULL, 0);
|
||||
NULL, UINT64_C(0));
|
||||
else if (seg_type(seg, s) == AREA_PV)
|
||||
dm_tree_node_add_target_area(node,
|
||||
dev_name(seg_dev(seg, s)),
|
||||
@@ -700,7 +710,6 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
|
||||
}
|
||||
|
||||
static int _add_origin_target_to_dtree(struct dev_manager *dm,
|
||||
struct dm_tree *dtree,
|
||||
struct dm_tree_node *dnode,
|
||||
struct logical_volume *lv)
|
||||
{
|
||||
@@ -716,7 +725,6 @@ static int _add_origin_target_to_dtree(struct dev_manager *dm,
|
||||
}
|
||||
|
||||
static int _add_snapshot_target_to_dtree(struct dev_manager *dm,
|
||||
struct dm_tree *dtree,
|
||||
struct dm_tree_node *dnode,
|
||||
struct logical_volume *lv)
|
||||
{
|
||||
@@ -745,7 +753,6 @@ static int _add_snapshot_target_to_dtree(struct dev_manager *dm,
|
||||
}
|
||||
|
||||
static int _add_target_to_dtree(struct dev_manager *dm,
|
||||
struct dm_tree *dtree,
|
||||
struct dm_tree_node *dnode,
|
||||
struct lv_segment *seg)
|
||||
{
|
||||
@@ -757,7 +764,7 @@ static int _add_target_to_dtree(struct dev_manager *dm,
|
||||
return 0;
|
||||
}
|
||||
|
||||
return seg->segtype->ops->add_target_line(dm, dm->mem, dm->cmd->cft,
|
||||
return seg->segtype->ops->add_target_line(dm, dm->mem, dm->cmd,
|
||||
&dm->target_state, seg,
|
||||
dnode,
|
||||
extent_size * seg->len,
|
||||
@@ -810,12 +817,12 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
|
||||
|
||||
/* Now we've added its dependencies, we can add the target itself */
|
||||
if (lv_is_origin(seg->lv) && !layer) {
|
||||
if (!_add_origin_target_to_dtree(dm, dtree, dnode, seg->lv))
|
||||
if (!_add_origin_target_to_dtree(dm, dnode, seg->lv))
|
||||
return_0;
|
||||
} else if (lv_is_cow(seg->lv) && !layer) {
|
||||
if (!_add_snapshot_target_to_dtree(dm, dtree, dnode, seg->lv))
|
||||
if (!_add_snapshot_target_to_dtree(dm, dnode, seg->lv))
|
||||
return_0;
|
||||
} else if (!_add_target_to_dtree(dm, dtree, dnode, seg))
|
||||
} else if (!_add_target_to_dtree(dm, dnode, seg))
|
||||
return_0;
|
||||
|
||||
if (lv_is_origin(seg->lv) && !layer)
|
||||
@@ -860,10 +867,10 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
|
||||
* Major/minor settings only apply to the visible layer.
|
||||
*/
|
||||
if (!(dnode = dm_tree_add_new_dev(dtree, name, dlid,
|
||||
layer ? lv->major : 0,
|
||||
layer ? lv->minor : 0,
|
||||
layer ? UINT32_C(0) : (uint32_t) lv->major,
|
||||
layer ? UINT32_C(0) : (uint32_t) lv->minor,
|
||||
_read_only_lv(lv),
|
||||
lv->vg->status & PRECOMMITTED,
|
||||
(lv->vg->status & PRECOMMITTED) ? 1 : 0,
|
||||
lvlayer)))
|
||||
return_0;
|
||||
|
||||
@@ -917,7 +924,7 @@ static int _create_lv_symlinks(struct dev_manager *dm, struct dm_tree_node *root
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _clean_tree(struct dev_manager *dm, struct logical_volume *lv, struct dm_tree_node *root)
|
||||
static int _clean_tree(struct dev_manager *dm, struct dm_tree_node *root)
|
||||
{
|
||||
void *handle = NULL;
|
||||
struct dm_tree_node *child;
|
||||
@@ -969,7 +976,7 @@ static int _tree_action(struct dev_manager *dm, struct logical_volume *lv, actio
|
||||
switch(action) {
|
||||
case CLEAN:
|
||||
/* Deactivate any unused non-toplevel nodes */
|
||||
if (!_clean_tree(dm, lv, root))
|
||||
if (!_clean_tree(dm, root))
|
||||
goto_out;
|
||||
break;
|
||||
case DEACTIVATE:
|
||||
@@ -978,8 +985,8 @@ static int _tree_action(struct dev_manager *dm, struct logical_volume *lv, actio
|
||||
goto_out;
|
||||
break;
|
||||
case SUSPEND:
|
||||
if (!lv_is_origin(lv) && !lv_is_cow(lv))
|
||||
dm_tree_skip_lockfs(root);
|
||||
dm_tree_skip_lockfs(root);
|
||||
case SUSPEND_WITH_LOCKFS:
|
||||
if (!dm_tree_suspend_children(root, dlid, ID_LEN + sizeof(UUID_PREFIX) - 1))
|
||||
goto_out;
|
||||
break;
|
||||
@@ -1043,16 +1050,17 @@ int dev_manager_deactivate(struct dev_manager *dm, struct logical_volume *lv)
|
||||
return r;
|
||||
}
|
||||
|
||||
int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv)
|
||||
int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv,
|
||||
int lockfs)
|
||||
{
|
||||
return _tree_action(dm, lv, SUSPEND);
|
||||
return _tree_action(dm, lv, lockfs ? SUSPEND_WITH_LOCKFS : SUSPEND);
|
||||
}
|
||||
|
||||
/*
|
||||
* Does device use VG somewhere in its construction?
|
||||
* Returns 1 if uncertain.
|
||||
*/
|
||||
int dev_manager_device_uses_vg(struct dev_manager *dm, struct device *dev,
|
||||
int dev_manager_device_uses_vg(struct device *dev,
|
||||
struct volume_group *vg)
|
||||
{
|
||||
struct dm_tree *dtree;
|
||||
@@ -1065,7 +1073,7 @@ int dev_manager_device_uses_vg(struct dev_manager *dm, struct device *dev,
|
||||
return r;
|
||||
}
|
||||
|
||||
if (!dm_tree_add_dev(dtree, MAJOR(dev->dev), MINOR(dev->dev))) {
|
||||
if (!dm_tree_add_dev(dtree, (uint32_t) MAJOR(dev->dev), (uint32_t) MINOR(dev->dev))) {
|
||||
log_error("Failed to add device %s (%" PRIu32 ":%" PRIu32") to dtree",
|
||||
dev_name(dev), (uint32_t) MAJOR(dev->dev), (uint32_t) MINOR(dev->dev));
|
||||
goto out;
|
||||
|
||||
@@ -29,6 +29,7 @@ struct device;
|
||||
struct dev_manager *dev_manager_create(struct cmd_context *cmd,
|
||||
const char *vg_name);
|
||||
void dev_manager_destroy(struct dev_manager *dm);
|
||||
void dev_manager_release(void);
|
||||
void dev_manager_exit(void);
|
||||
|
||||
/*
|
||||
@@ -46,7 +47,8 @@ int dev_manager_snapshot_percent(struct dev_manager *dm,
|
||||
int dev_manager_mirror_percent(struct dev_manager *dm,
|
||||
struct logical_volume *lv, int wait,
|
||||
float *percent, uint32_t *event_nr);
|
||||
int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv);
|
||||
int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv,
|
||||
int lockfs);
|
||||
int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv);
|
||||
int dev_manager_preload(struct dev_manager *dm, struct logical_volume *lv);
|
||||
int dev_manager_deactivate(struct dev_manager *dm, struct logical_volume *lv);
|
||||
@@ -59,7 +61,7 @@ int dev_manager_lv_rmnodes(const struct logical_volume *lv);
|
||||
*/
|
||||
int dev_manager_execute(struct dev_manager *dm);
|
||||
|
||||
int dev_manager_device_uses_vg(struct dev_manager *dm, struct device *dev,
|
||||
int dev_manager_device_uses_vg(struct device *dev,
|
||||
struct volume_group *vg);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@ int compose_areas_line(struct dev_manager *dm, struct lv_segment *seg,
|
||||
int start_area, int areas);
|
||||
|
||||
int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
|
||||
struct dm_tree_node *node, int start_area, int areas);
|
||||
struct dm_tree_node *node, uint32_t start_area, uint32_t areas);
|
||||
|
||||
int build_dev_string(struct dev_manager *dm, char *dlid, char *devbuf,
|
||||
size_t bufsize, const char *desc);
|
||||
|
||||
69
lib/cache/lvmcache.c
vendored
69
lib/cache/lvmcache.c
vendored
@@ -50,7 +50,7 @@ int lvmcache_init(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void lvmcache_lock_vgname(const char *vgname, int read_only)
|
||||
void lvmcache_lock_vgname(const char *vgname, int read_only __attribute((unused)))
|
||||
{
|
||||
if (!_lock_hash && !lvmcache_init()) {
|
||||
log_error("Internal cache initialisation failed");
|
||||
@@ -99,7 +99,7 @@ struct lvmcache_vginfo *vginfo_from_vgname(const char *vgname, const char *vgid)
|
||||
|
||||
if (vgid)
|
||||
do
|
||||
if (!strncmp(vgid, vginfo->vgid, sizeof(vginfo->vgid)))
|
||||
if (!strncmp(vgid, vginfo->vgid, ID_LEN))
|
||||
return vginfo;
|
||||
while ((vginfo = vginfo->next));
|
||||
|
||||
@@ -123,7 +123,10 @@ const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid)
|
||||
* we check cached labels here. Unfortunately vginfo is volatile. */
|
||||
list_init(&devs);
|
||||
list_iterate_items(info, &vginfo->infos) {
|
||||
devl = dm_malloc(sizeof(*devl));
|
||||
if (!(devl = dm_malloc(sizeof(*devl)))) {
|
||||
log_error("device_list element allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
devl->dev = info->dev;
|
||||
list_add(&devs, &devl->list);
|
||||
}
|
||||
@@ -139,7 +142,7 @@ const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid)
|
||||
|
||||
/* If vginfo changed, caller needs to rescan */
|
||||
if (!(vginfo = vginfo_from_vgname(vgname, vgid_found)) ||
|
||||
strncmp(vginfo->vgid, vgid_found, sizeof(vgid_found)))
|
||||
strncmp(vginfo->vgid, vgid_found, ID_LEN))
|
||||
return NULL;
|
||||
|
||||
return vginfo->fmt;
|
||||
@@ -166,14 +169,18 @@ struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid)
|
||||
const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid)
|
||||
{
|
||||
struct lvmcache_vginfo *vginfo;
|
||||
const char *vgname = NULL;
|
||||
|
||||
if ((vginfo = vginfo_from_vgid(vgid))) {
|
||||
if (mem)
|
||||
return dm_pool_strdup(mem, vginfo->vgname);
|
||||
return vginfo->vgname;
|
||||
}
|
||||
if (!*vgid)
|
||||
vgname = ORPHAN;
|
||||
|
||||
return NULL;
|
||||
if ((vginfo = vginfo_from_vgid(vgid)))
|
||||
vgname = vginfo->vgname;
|
||||
|
||||
if (mem && vgname)
|
||||
return dm_pool_strdup(mem, vgname);
|
||||
|
||||
return vgname;
|
||||
}
|
||||
|
||||
struct lvmcache_info *info_from_pvid(const char *pvid)
|
||||
@@ -234,7 +241,7 @@ int lvmcache_label_scan(struct cmd_context *cmd, int full_scan)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!(iter = dev_iter_create(cmd->filter, (full_scan == 2) ? 1: 0))) {
|
||||
if (!(iter = dev_iter_create(cmd->filter, (full_scan == 2) ? 1 : 0))) {
|
||||
log_error("dev_iter creation failed");
|
||||
goto out;
|
||||
}
|
||||
@@ -306,6 +313,32 @@ struct list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan)
|
||||
return vgnames;
|
||||
}
|
||||
|
||||
struct list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
|
||||
const char *vgid)
|
||||
{
|
||||
struct list *pvids;
|
||||
struct lvmcache_vginfo *vginfo;
|
||||
struct lvmcache_info *info;
|
||||
|
||||
if (!(pvids = str_list_create(cmd->mem))) {
|
||||
log_error("pvids list allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(vginfo = vginfo_from_vgname(vgname, vgid)))
|
||||
return pvids;
|
||||
|
||||
list_iterate_items(info, &vginfo->infos) {
|
||||
if (!str_list_add(cmd->mem, pvids,
|
||||
dm_pool_strdup(cmd->mem, info->dev->pvid))) {
|
||||
log_error("strlist allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return pvids;
|
||||
}
|
||||
|
||||
struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid)
|
||||
{
|
||||
struct label *label;
|
||||
@@ -413,8 +446,8 @@ static int _lvmcache_update_pvid(struct lvmcache_info *info, const char *pvid)
|
||||
|
||||
static int _lvmcache_update_vgid(struct lvmcache_info *info, const char *vgid)
|
||||
{
|
||||
if (!vgid || !info->vginfo || !strncmp(info->vginfo->vgid, vgid,
|
||||
sizeof(info->vginfo->vgid)))
|
||||
if (!vgid || !info->vginfo ||
|
||||
!strncmp(info->vginfo->vgid, vgid, ID_LEN))
|
||||
return 1;
|
||||
|
||||
if (info->vginfo && *info->vginfo->vgid)
|
||||
@@ -424,8 +457,8 @@ static int _lvmcache_update_vgid(struct lvmcache_info *info, const char *vgid)
|
||||
return 1;
|
||||
}
|
||||
|
||||
strncpy(info->vginfo->vgid, vgid, sizeof(info->vginfo->vgid));
|
||||
info->vginfo->vgid[sizeof(info->vginfo->vgid) - 1] = '\0';
|
||||
strncpy(info->vginfo->vgid, vgid, ID_LEN);
|
||||
info->vginfo->vgid[ID_LEN] = '\0';
|
||||
if (!dm_hash_insert(_vgid_hash, info->vginfo->vgid, info->vginfo)) {
|
||||
log_error("_lvmcache_update: vgid hash insertion failed: %s",
|
||||
info->vginfo->vgid);
|
||||
@@ -448,10 +481,10 @@ static int _insert_vginfo(struct lvmcache_vginfo *new_vginfo, const char *vgid,
|
||||
|
||||
/* Pre-existing VG takes precedence. Unexported VG takes precedence. */
|
||||
if (primary_vginfo) {
|
||||
if (!id_write_format((struct id *)vgid, uuid_new, sizeof(uuid_new)))
|
||||
if (!id_write_format((const struct id *)vgid, uuid_new, sizeof(uuid_new)))
|
||||
return_0;
|
||||
|
||||
if (!id_write_format((struct id *)&primary_vginfo->vgid, uuid_primary,
|
||||
if (!id_write_format((const struct id *)&primary_vginfo->vgid, uuid_primary,
|
||||
sizeof(uuid_primary)))
|
||||
return_0;
|
||||
|
||||
@@ -828,7 +861,7 @@ static void _lvmcache_destroy_vgnamelist(struct lvmcache_vginfo *vginfo)
|
||||
} while ((vginfo = next));
|
||||
}
|
||||
|
||||
static void _lvmcache_destroy_lockname(int present)
|
||||
static void _lvmcache_destroy_lockname(int present __attribute((unused)))
|
||||
{
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
4
lib/cache/lvmcache.h
vendored
4
lib/cache/lvmcache.h
vendored
@@ -101,4 +101,8 @@ struct list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan);
|
||||
/* Set full_scan to 1 to reread every filtered device label */
|
||||
struct list *lvmcache_get_vgids(struct cmd_context *cmd, int full_scan);
|
||||
|
||||
/* Returns list of struct str_lists containing pool-allocated copy of pvids */
|
||||
struct list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
|
||||
const char *vgid);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -84,10 +84,11 @@ static void _init_logging(struct cmd_context *cmd)
|
||||
time_t t;
|
||||
|
||||
const char *log_file;
|
||||
char timebuf[26];
|
||||
|
||||
/* Syslog */
|
||||
cmd->default_settings.syslog =
|
||||
find_config_int(cmd->cft->root, "log/syslog", DEFAULT_SYSLOG);
|
||||
find_config_tree_int(cmd, "log/syslog", DEFAULT_SYSLOG);
|
||||
if (cmd->default_settings.syslog != 1)
|
||||
fin_syslog();
|
||||
|
||||
@@ -96,37 +97,37 @@ static void _init_logging(struct cmd_context *cmd)
|
||||
|
||||
/* Debug level for log file output */
|
||||
cmd->default_settings.debug =
|
||||
find_config_int(cmd->cft->root, "log/level", DEFAULT_LOGLEVEL);
|
||||
find_config_tree_int(cmd, "log/level", DEFAULT_LOGLEVEL);
|
||||
init_debug(cmd->default_settings.debug);
|
||||
|
||||
/* Verbose level for tty output */
|
||||
cmd->default_settings.verbose =
|
||||
find_config_int(cmd->cft->root, "log/verbose", DEFAULT_VERBOSE);
|
||||
find_config_tree_int(cmd, "log/verbose", DEFAULT_VERBOSE);
|
||||
init_verbose(cmd->default_settings.verbose + VERBOSE_BASE_LEVEL);
|
||||
|
||||
/* Log message formatting */
|
||||
init_indent(find_config_int(cmd->cft->root, "log/indent",
|
||||
init_indent(find_config_tree_int(cmd, "log/indent",
|
||||
DEFAULT_INDENT));
|
||||
|
||||
cmd->default_settings.msg_prefix = find_config_str(cmd->cft->root,
|
||||
cmd->default_settings.msg_prefix = find_config_tree_str(cmd,
|
||||
"log/prefix",
|
||||
DEFAULT_MSG_PREFIX);
|
||||
init_msg_prefix(cmd->default_settings.msg_prefix);
|
||||
|
||||
cmd->default_settings.cmd_name = find_config_int(cmd->cft->root,
|
||||
cmd->default_settings.cmd_name = find_config_tree_int(cmd,
|
||||
"log/command_names",
|
||||
DEFAULT_CMD_NAME);
|
||||
init_cmd_name(cmd->default_settings.cmd_name);
|
||||
|
||||
/* Test mode */
|
||||
cmd->default_settings.test =
|
||||
find_config_int(cmd->cft->root, "global/test", 0);
|
||||
find_config_tree_int(cmd, "global/test", 0);
|
||||
|
||||
/* Settings for logging to file */
|
||||
if (find_config_int(cmd->cft->root, "log/overwrite", DEFAULT_OVERWRITE))
|
||||
if (find_config_tree_int(cmd, "log/overwrite", DEFAULT_OVERWRITE))
|
||||
append = 0;
|
||||
|
||||
log_file = find_config_str(cmd->cft->root, "log/file", 0);
|
||||
log_file = find_config_tree_str(cmd, "log/file", 0);
|
||||
|
||||
if (log_file) {
|
||||
release_log_memory();
|
||||
@@ -134,15 +135,17 @@ static void _init_logging(struct cmd_context *cmd)
|
||||
init_log_file(log_file, append);
|
||||
}
|
||||
|
||||
log_file = find_config_str(cmd->cft->root, "log/activate_file", 0);
|
||||
log_file = find_config_tree_str(cmd, "log/activate_file", 0);
|
||||
if (log_file)
|
||||
init_log_direct(log_file, append);
|
||||
|
||||
init_log_while_suspended(find_config_int(cmd->cft->root,
|
||||
init_log_while_suspended(find_config_tree_int(cmd,
|
||||
"log/activation", 0));
|
||||
|
||||
t = time(NULL);
|
||||
log_verbose("Logging initialised at %s", ctime(&t));
|
||||
ctime_r(&t, &timebuf[0]);
|
||||
timebuf[24] = '\0';
|
||||
log_verbose("Logging initialised at %s", timebuf);
|
||||
|
||||
/* Tell device-mapper about our logging */
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
@@ -155,7 +158,7 @@ static int _process_config(struct cmd_context *cmd)
|
||||
mode_t old_umask;
|
||||
|
||||
/* umask */
|
||||
cmd->default_settings.umask = find_config_int(cmd->cft->root,
|
||||
cmd->default_settings.umask = find_config_tree_int(cmd,
|
||||
"global/umask",
|
||||
DEFAULT_UMASK);
|
||||
|
||||
@@ -165,7 +168,7 @@ static int _process_config(struct cmd_context *cmd)
|
||||
|
||||
/* dev dir */
|
||||
if (lvm_snprintf(cmd->dev_dir, sizeof(cmd->dev_dir), "%s/",
|
||||
find_config_str(cmd->cft->root, "devices/dir",
|
||||
find_config_tree_str(cmd, "devices/dir",
|
||||
DEFAULT_DEV_DIR)) < 0) {
|
||||
log_error("Device directory given in config file too long");
|
||||
return 0;
|
||||
@@ -176,7 +179,7 @@ static int _process_config(struct cmd_context *cmd)
|
||||
|
||||
/* proc dir */
|
||||
if (lvm_snprintf(cmd->proc_dir, sizeof(cmd->proc_dir), "%s",
|
||||
find_config_str(cmd->cft->root, "global/proc",
|
||||
find_config_tree_str(cmd, "global/proc",
|
||||
DEFAULT_PROC_DIR)) < 0) {
|
||||
log_error("Device directory given in config file too long");
|
||||
return 0;
|
||||
@@ -189,17 +192,17 @@ static int _process_config(struct cmd_context *cmd)
|
||||
}
|
||||
|
||||
/* activation? */
|
||||
cmd->default_settings.activation = find_config_int(cmd->cft->root,
|
||||
cmd->default_settings.activation = find_config_tree_int(cmd,
|
||||
"global/activation",
|
||||
DEFAULT_ACTIVATION);
|
||||
set_activation(cmd->default_settings.activation);
|
||||
|
||||
cmd->default_settings.suffix = find_config_int(cmd->cft->root,
|
||||
cmd->default_settings.suffix = find_config_tree_int(cmd,
|
||||
"global/suffix",
|
||||
DEFAULT_SUFFIX);
|
||||
|
||||
if (!(cmd->default_settings.unit_factor =
|
||||
units_to_bytes(find_config_str(cmd->cft->root,
|
||||
units_to_bytes(find_config_tree_str(cmd,
|
||||
"global/units",
|
||||
DEFAULT_UNITS),
|
||||
&cmd->default_settings.unit_type))) {
|
||||
@@ -469,7 +472,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(cn = find_config_node(cmd->cft->root, "devices/scan"))) {
|
||||
if (!(cn = find_config_tree_node(cmd, "devices/scan"))) {
|
||||
if (!dev_cache_add_dir("/dev")) {
|
||||
log_error("Failed to add /dev to internal "
|
||||
"device cache");
|
||||
@@ -494,7 +497,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
|
||||
}
|
||||
}
|
||||
|
||||
if (!(cn = find_config_node(cmd->cft->root, "devices/loopfiles")))
|
||||
if (!(cn = find_config_tree_node(cmd, "devices/loopfiles")))
|
||||
return 1;
|
||||
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
@@ -536,14 +539,14 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
||||
* Listed first because it's very efficient at eliminating
|
||||
* unavailable devices.
|
||||
*/
|
||||
if (find_config_bool(cmd->cft->root, "devices/sysfs_scan",
|
||||
if (find_config_tree_bool(cmd, "devices/sysfs_scan",
|
||||
DEFAULT_SYSFS_SCAN)) {
|
||||
if ((filters[nr_filt] = sysfs_filter_create(cmd->proc_dir)))
|
||||
nr_filt++;
|
||||
}
|
||||
|
||||
/* regex filter. Optional. */
|
||||
if (!(cn = find_config_node(cmd->cft->root, "devices/filter")))
|
||||
if (!(cn = find_config_tree_node(cmd, "devices/filter")))
|
||||
log_very_verbose("devices/filter not found in config file: "
|
||||
"no regex filter installed");
|
||||
|
||||
@@ -553,14 +556,14 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
||||
}
|
||||
|
||||
/* device type filter. Required. */
|
||||
cn = find_config_node(cmd->cft->root, "devices/types");
|
||||
cn = find_config_tree_node(cmd, "devices/types");
|
||||
if (!(filters[nr_filt++] = lvm_type_filter_create(cmd->proc_dir, cn))) {
|
||||
log_error("Failed to create lvm type filter");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* md component filter. Optional, non-critical. */
|
||||
if (find_config_bool(cmd->cft->root, "devices/md_component_detection",
|
||||
if (find_config_tree_bool(cmd, "devices/md_component_detection",
|
||||
DEFAULT_MD_COMPONENT_DETECTION)) {
|
||||
init_md_filtering(1);
|
||||
if ((filters[nr_filt] = md_filter_create()))
|
||||
@@ -591,7 +594,7 @@ static int _init_filters(struct cmd_context *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
dev_cache = find_config_str(cmd->cft->root, "devices/cache",
|
||||
dev_cache = find_config_tree_str(cmd, "devices/cache",
|
||||
cache_file);
|
||||
if (!(f4 = persistent_filter_create(f3, dev_cache))) {
|
||||
log_error("Failed to create persistent device filter");
|
||||
@@ -599,7 +602,7 @@ static int _init_filters(struct cmd_context *cmd)
|
||||
}
|
||||
|
||||
/* Should we ever dump persistent filter state? */
|
||||
if (find_config_int(cmd->cft->root, "devices/write_cache_state", 1))
|
||||
if (find_config_tree_int(cmd, "devices/write_cache_state", 1))
|
||||
cmd->dump_filter = 1;
|
||||
|
||||
if (!*cmd->sys_dir)
|
||||
@@ -644,7 +647,7 @@ static int _init_formats(struct cmd_context *cmd)
|
||||
|
||||
#ifdef HAVE_LIBDL
|
||||
/* Load any formats in shared libs */
|
||||
if ((cn = find_config_node(cmd->cft->root, "global/format_libraries"))) {
|
||||
if ((cn = find_config_tree_node(cmd, "global/format_libraries"))) {
|
||||
|
||||
struct config_value *cv;
|
||||
struct format_type *(*init_format_fn) (struct cmd_context *);
|
||||
@@ -656,7 +659,7 @@ static int _init_formats(struct cmd_context *cmd)
|
||||
"global/format_libraries");
|
||||
return 0;
|
||||
}
|
||||
if (!(lib = load_shared_library(cmd->cft, cv->v.str,
|
||||
if (!(lib = load_shared_library(cmd, cv->v.str,
|
||||
"format", 0))) {
|
||||
stack;
|
||||
return 0;
|
||||
@@ -684,7 +687,7 @@ static int _init_formats(struct cmd_context *cmd)
|
||||
|
||||
cmd->fmt_backup = fmt;
|
||||
|
||||
format = find_config_str(cmd->cft->root, "global/format",
|
||||
format = find_config_tree_str(cmd, "global/format",
|
||||
DEFAULT_FORMAT);
|
||||
|
||||
list_iterate_items(fmt, &cmd->formats) {
|
||||
@@ -738,7 +741,7 @@ static int _init_segtypes(struct cmd_context *cmd)
|
||||
|
||||
#ifdef HAVE_LIBDL
|
||||
/* Load any formats in shared libs */
|
||||
if ((cn = find_config_node(cmd->cft->root, "global/segment_libraries"))) {
|
||||
if ((cn = find_config_tree_node(cmd, "global/segment_libraries"))) {
|
||||
|
||||
struct config_value *cv;
|
||||
struct segment_type *(*init_segtype_fn) (struct cmd_context *);
|
||||
@@ -752,7 +755,7 @@ static int _init_segtypes(struct cmd_context *cmd)
|
||||
"global/segment_libraries");
|
||||
return 0;
|
||||
}
|
||||
if (!(lib = load_shared_library(cmd->cft, cv->v.str,
|
||||
if (!(lib = load_shared_library(cmd, cv->v.str,
|
||||
"segment type", 0))) {
|
||||
stack;
|
||||
return 0;
|
||||
@@ -827,13 +830,13 @@ static int _init_backup(struct cmd_context *cmd)
|
||||
|
||||
/* set up archiving */
|
||||
cmd->default_settings.archive =
|
||||
find_config_bool(cmd->cft->root, "backup/archive",
|
||||
find_config_tree_bool(cmd, "backup/archive",
|
||||
DEFAULT_ARCHIVE_ENABLED);
|
||||
|
||||
days = (uint32_t) find_config_int(cmd->cft->root, "backup/retain_days",
|
||||
days = (uint32_t) find_config_tree_int(cmd, "backup/retain_days",
|
||||
DEFAULT_ARCHIVE_DAYS);
|
||||
|
||||
min = (uint32_t) find_config_int(cmd->cft->root, "backup/retain_min",
|
||||
min = (uint32_t) find_config_tree_int(cmd, "backup/retain_min",
|
||||
DEFAULT_ARCHIVE_NUMBER);
|
||||
|
||||
if (lvm_snprintf
|
||||
@@ -844,7 +847,7 @@ static int _init_backup(struct cmd_context *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
dir = find_config_str(cmd->cft->root, "backup/archive_dir",
|
||||
dir = find_config_tree_str(cmd, "backup/archive_dir",
|
||||
default_dir);
|
||||
|
||||
if (!archive_init(cmd, dir, days, min)) {
|
||||
@@ -854,7 +857,7 @@ static int _init_backup(struct cmd_context *cmd)
|
||||
|
||||
/* set up the backup */
|
||||
cmd->default_settings.backup =
|
||||
find_config_bool(cmd->cft->root, "backup/backup",
|
||||
find_config_tree_bool(cmd, "backup/backup",
|
||||
DEFAULT_BACKUP_ENABLED);
|
||||
|
||||
if (lvm_snprintf
|
||||
@@ -865,7 +868,7 @@ static int _init_backup(struct cmd_context *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
dir = find_config_str(cmd->cft->root, "backup/backup_dir", default_dir);
|
||||
dir = find_config_tree_str(cmd, "backup/backup_dir", default_dir);
|
||||
|
||||
if (!backup_init(cmd, dir)) {
|
||||
log_debug("backup_init failed.");
|
||||
@@ -921,7 +924,7 @@ struct cmd_context *create_toolcontext(struct arg *the_args)
|
||||
|
||||
if (!(cmd->libmem = dm_pool_create("library", 4 * 1024))) {
|
||||
log_error("Library memory pool creation failed");
|
||||
return 0;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!_init_lvm_conf(cmd))
|
||||
@@ -952,7 +955,7 @@ struct cmd_context *create_toolcontext(struct arg *the_args)
|
||||
|
||||
if (!(cmd->mem = dm_pool_create("command", 4 * 1024))) {
|
||||
log_error("Command memory pool creation failed");
|
||||
return 0;
|
||||
goto error;
|
||||
}
|
||||
|
||||
memlock_init(cmd);
|
||||
@@ -1021,7 +1024,7 @@ int refresh_toolcontext(struct cmd_context *cmd)
|
||||
persistent_filter_dump(cmd->filter);
|
||||
}
|
||||
|
||||
activation_exit();
|
||||
activation_release();
|
||||
lvmcache_destroy();
|
||||
label_exit();
|
||||
_destroy_segtypes(&cmd->segtypes);
|
||||
|
||||
@@ -71,6 +71,7 @@ struct cmd_context {
|
||||
struct list config_files;
|
||||
int config_valid;
|
||||
struct config_tree *cft;
|
||||
struct config_tree *cft_override;
|
||||
struct config_info default_settings;
|
||||
struct config_info current_settings;
|
||||
|
||||
|
||||
@@ -41,10 +41,10 @@ enum {
|
||||
};
|
||||
|
||||
struct parser {
|
||||
char *fb, *fe; /* file limits */
|
||||
const char *fb, *fe; /* file limits */
|
||||
|
||||
int t; /* token limits and type */
|
||||
char *tb, *te;
|
||||
const char *tb, *te;
|
||||
|
||||
int fd; /* descriptor for file being parsed */
|
||||
int line; /* line number we are on */
|
||||
@@ -77,7 +77,7 @@ static const int sep = '/';
|
||||
|
||||
#define match(t) do {\
|
||||
if (!_match_aux(p, (t))) {\
|
||||
log_error("Parse error at line %d: unexpected token", p->line); \
|
||||
log_error("Parse error at byte %d (line %d): unexpected token", p->tb - p->fb + 1, p->line); \
|
||||
return 0;\
|
||||
} \
|
||||
} while(0);
|
||||
@@ -101,12 +101,12 @@ struct config_tree *create_config_tree(const char *filename)
|
||||
struct dm_pool *mem = dm_pool_create("config", 10 * 1024);
|
||||
|
||||
if (!mem) {
|
||||
stack;
|
||||
log_error("Failed to allocate config pool.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(c = dm_pool_zalloc(mem, sizeof(*c)))) {
|
||||
stack;
|
||||
log_error("Failed to allocate config tree.");
|
||||
dm_pool_destroy(mem);
|
||||
return 0;
|
||||
}
|
||||
@@ -125,6 +125,46 @@ void destroy_config_tree(struct config_tree *cft)
|
||||
dm_pool_destroy(((struct cs *) cft)->mem);
|
||||
}
|
||||
|
||||
static int _parse_config_file(struct parser *p, struct config_tree *cft)
|
||||
{
|
||||
p->tb = p->te = p->fb;
|
||||
p->line = 1;
|
||||
_get_token(p, TOK_SECTION_E);
|
||||
if (!(cft->root = _file(p)))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct config_tree *create_config_tree_from_string(struct cmd_context *cmd,
|
||||
const char *config_settings)
|
||||
{
|
||||
struct cs *c;
|
||||
struct config_tree *cft;
|
||||
struct parser *p;
|
||||
|
||||
if (!(cft = create_config_tree(NULL)))
|
||||
return_NULL;
|
||||
|
||||
c = (struct cs *) cft;
|
||||
if (!(p = dm_pool_alloc(c->mem, sizeof(*p)))) {
|
||||
log_error("Failed to allocate config tree parser.");
|
||||
destroy_config_tree(cft);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p->mem = c->mem;
|
||||
p->fb = config_settings;
|
||||
p->fe = config_settings + strlen(config_settings);
|
||||
|
||||
if (!_parse_config_file(p, cft)) {
|
||||
destroy_config_tree(cft);
|
||||
return_NULL;
|
||||
}
|
||||
|
||||
return cft;
|
||||
}
|
||||
|
||||
int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
off_t offset, size_t size, off_t offset2, size_t size2,
|
||||
checksum_fn_t checksum_fn, uint32_t checksum)
|
||||
@@ -134,6 +174,7 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
int r = 0;
|
||||
int use_mmap = 1;
|
||||
off_t mmap_offset = 0;
|
||||
char *buf;
|
||||
|
||||
if (!(p = dm_pool_alloc(c->mem, sizeof(*p)))) {
|
||||
stack;
|
||||
@@ -156,22 +197,23 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
}
|
||||
p->fb = p->fb + mmap_offset;
|
||||
} else {
|
||||
if (!(p->fb = dm_malloc(size + size2))) {
|
||||
if (!(buf = dm_malloc(size + size2))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!dev_read(dev, (uint64_t) offset, size, p->fb)) {
|
||||
if (!dev_read(dev, (uint64_t) offset, size, buf)) {
|
||||
log_error("Read from %s failed", dev_name(dev));
|
||||
goto out;
|
||||
}
|
||||
if (size2) {
|
||||
if (!dev_read(dev, (uint64_t) offset2, size2,
|
||||
p->fb + size)) {
|
||||
buf + size)) {
|
||||
log_error("Circular read from %s failed",
|
||||
dev_name(dev));
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
p->fb = buf;
|
||||
}
|
||||
|
||||
if (checksum_fn && checksum !=
|
||||
@@ -183,11 +225,7 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
|
||||
p->fe = p->fb + size + size2;
|
||||
|
||||
/* parse */
|
||||
p->tb = p->te = p->fb;
|
||||
p->line = 1;
|
||||
_get_token(p, TOK_SECTION_E);
|
||||
if (!(cft->root = _file(p))) {
|
||||
if (!_parse_config_file(p, cft)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
@@ -196,7 +234,7 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
|
||||
out:
|
||||
if (!use_mmap)
|
||||
dm_free(p->fb);
|
||||
dm_free(buf);
|
||||
else {
|
||||
/* unmap the file */
|
||||
if (munmap((char *) (p->fb - mmap_offset), size + mmap_offset)) {
|
||||
@@ -529,7 +567,7 @@ static struct config_value *_type(struct parser *p)
|
||||
break;
|
||||
|
||||
default:
|
||||
log_error("Parse error at line %d: expected a value", p->line);
|
||||
log_error("Parse error at byte %d (line %d): expected a value", p->tb - p->fb + 1, p->line);
|
||||
return 0;
|
||||
}
|
||||
return v;
|
||||
@@ -688,14 +726,20 @@ static void _eat_space(struct parser *p)
|
||||
static struct config_value *_create_value(struct parser *p)
|
||||
{
|
||||
struct config_value *v = dm_pool_alloc(p->mem, sizeof(*v));
|
||||
memset(v, 0, sizeof(*v));
|
||||
|
||||
if (v)
|
||||
memset(v, 0, sizeof(*v));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static struct config_node *_create_node(struct parser *p)
|
||||
{
|
||||
struct config_node *n = dm_pool_alloc(p->mem, sizeof(*n));
|
||||
memset(n, 0, sizeof(*n));
|
||||
|
||||
if (n)
|
||||
memset(n, 0, sizeof(*n));
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -715,8 +759,8 @@ static char *_dup_tok(struct parser *p)
|
||||
/*
|
||||
* utility functions
|
||||
*/
|
||||
struct config_node *find_config_node(const struct config_node *cn,
|
||||
const char *path)
|
||||
static struct config_node *_find_config_node(const struct config_node *cn,
|
||||
const char *path)
|
||||
{
|
||||
const char *e;
|
||||
|
||||
@@ -747,14 +791,36 @@ struct config_node *find_config_node(const struct config_node *cn,
|
||||
return (struct config_node *) cn;
|
||||
}
|
||||
|
||||
const char *find_config_str(const struct config_node *cn,
|
||||
const char *path, const char *fail)
|
||||
static struct config_node *_find_first_config_node(const struct config_node *cn1,
|
||||
const struct config_node *cn2,
|
||||
const char *path)
|
||||
{
|
||||
const struct config_node *n = find_config_node(cn, path);
|
||||
struct config_node *cn;
|
||||
|
||||
if (n && n->v->type == CFG_STRING) {
|
||||
if (*n->v->v.str)
|
||||
log_very_verbose("Setting %s to %s", path, n->v->v.str);
|
||||
if (cn1 && (cn = _find_config_node(cn1, path)))
|
||||
return cn;
|
||||
|
||||
if (cn2 && (cn = _find_config_node(cn2, path)))
|
||||
return cn;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct config_node *find_config_node(const struct config_node *cn,
|
||||
const char *path)
|
||||
{
|
||||
return _find_config_node(cn, path);
|
||||
}
|
||||
|
||||
static const char *_find_config_str(const struct config_node *cn1,
|
||||
const struct config_node *cn2,
|
||||
const char *path, const char *fail)
|
||||
{
|
||||
const struct config_node *n = _find_first_config_node(cn1, cn2, path);
|
||||
|
||||
/* Empty strings are ignored */
|
||||
if ((n && n->v->type == CFG_STRING) && (*n->v->v.str)) {
|
||||
log_very_verbose("Setting %s to %s", path, n->v->v.str);
|
||||
return n->v->v.str;
|
||||
}
|
||||
|
||||
@@ -764,9 +830,17 @@ const char *find_config_str(const struct config_node *cn,
|
||||
return fail;
|
||||
}
|
||||
|
||||
int find_config_int(const struct config_node *cn, const char *path, int fail)
|
||||
const char *find_config_str(const struct config_node *cn,
|
||||
const char *path, const char *fail)
|
||||
{
|
||||
const struct config_node *n = find_config_node(cn, path);
|
||||
return _find_config_str(cn, NULL, path, fail);
|
||||
}
|
||||
|
||||
static int _find_config_int(const struct config_node *cn1,
|
||||
const struct config_node *cn2,
|
||||
const char *path, int fail)
|
||||
{
|
||||
const struct config_node *n = _find_first_config_node(cn1, cn2, path);
|
||||
|
||||
if (n && n->v->type == CFG_INT) {
|
||||
log_very_verbose("Setting %s to %d", path, n->v->v.i);
|
||||
@@ -778,10 +852,16 @@ int find_config_int(const struct config_node *cn, const char *path, int fail)
|
||||
return fail;
|
||||
}
|
||||
|
||||
float find_config_float(const struct config_node *cn, const char *path,
|
||||
float fail)
|
||||
int find_config_int(const struct config_node *cn, const char *path, int fail)
|
||||
{
|
||||
const struct config_node *n = find_config_node(cn, path);
|
||||
return _find_config_int(cn, NULL, path, fail);
|
||||
}
|
||||
|
||||
static float _find_config_float(const struct config_node *cn1,
|
||||
const struct config_node *cn2,
|
||||
const char *path, float fail)
|
||||
{
|
||||
const struct config_node *n = _find_first_config_node(cn1, cn2, path);
|
||||
|
||||
if (n && n->v->type == CFG_FLOAT) {
|
||||
log_very_verbose("Setting %s to %f", path, n->v->v.r);
|
||||
@@ -795,6 +875,36 @@ float find_config_float(const struct config_node *cn, const char *path,
|
||||
|
||||
}
|
||||
|
||||
float find_config_float(const struct config_node *cn, const char *path,
|
||||
float fail)
|
||||
{
|
||||
return _find_config_float(cn, NULL, path, fail);
|
||||
}
|
||||
|
||||
struct config_node *find_config_tree_node(struct cmd_context *cmd,
|
||||
const char *path)
|
||||
{
|
||||
return _find_first_config_node(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path);
|
||||
}
|
||||
|
||||
const char *find_config_tree_str(struct cmd_context *cmd,
|
||||
const char *path, const char *fail)
|
||||
{
|
||||
return _find_config_str(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path, fail);
|
||||
}
|
||||
|
||||
int find_config_tree_int(struct cmd_context *cmd, const char *path,
|
||||
int fail)
|
||||
{
|
||||
return _find_config_int(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path, fail);
|
||||
}
|
||||
|
||||
float find_config_tree_float(struct cmd_context *cmd, const char *path,
|
||||
float fail)
|
||||
{
|
||||
return _find_config_float(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path, fail);
|
||||
}
|
||||
|
||||
static int _str_in_array(const char *str, const char *values[])
|
||||
{
|
||||
int i;
|
||||
@@ -821,9 +931,11 @@ static int _str_to_bool(const char *str, int fail)
|
||||
return fail;
|
||||
}
|
||||
|
||||
int find_config_bool(const struct config_node *cn, const char *path, int fail)
|
||||
static int _find_config_bool(const struct config_node *cn1,
|
||||
const struct config_node *cn2,
|
||||
const char *path, int fail)
|
||||
{
|
||||
const struct config_node *n = find_config_node(cn, path);
|
||||
const struct config_node *n = _find_first_config_node(cn1, cn2, path);
|
||||
struct config_value *v;
|
||||
|
||||
if (!n)
|
||||
@@ -842,6 +954,16 @@ int find_config_bool(const struct config_node *cn, const char *path, int fail)
|
||||
return fail;
|
||||
}
|
||||
|
||||
int find_config_bool(const struct config_node *cn, const char *path, int fail)
|
||||
{
|
||||
return _find_config_bool(cn, NULL, path, fail);
|
||||
}
|
||||
|
||||
int find_config_tree_bool(struct cmd_context *cmd, const char *path, int fail)
|
||||
{
|
||||
return _find_config_bool(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path, fail);
|
||||
}
|
||||
|
||||
int get_config_uint32(const struct config_node *cn, const char *path,
|
||||
uint32_t *result)
|
||||
{
|
||||
|
||||
@@ -54,9 +54,11 @@ struct config_tree_list {
|
||||
};
|
||||
|
||||
struct config_tree *create_config_tree(const char *filename);
|
||||
struct config_tree *create_config_tree_from_string(struct cmd_context *cmd,
|
||||
const char *config_settings);
|
||||
void destroy_config_tree(struct config_tree *cft);
|
||||
|
||||
typedef uint32_t (*checksum_fn_t) (uint32_t initial, void *buf, uint32_t size);
|
||||
typedef uint32_t (*checksum_fn_t) (uint32_t initial, const void *buf, uint32_t size);
|
||||
|
||||
int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
off_t offset, size_t size, off_t offset2, size_t size2,
|
||||
@@ -71,20 +73,30 @@ int merge_config_tree(struct cmd_context *cmd, struct config_tree *cft,
|
||||
|
||||
struct config_node *find_config_node(const struct config_node *cn,
|
||||
const char *path);
|
||||
|
||||
const char *find_config_str(const struct config_node *cn, const char *path,
|
||||
const char *fail);
|
||||
|
||||
int find_config_int(const struct config_node *cn, const char *path, int fail);
|
||||
|
||||
float find_config_float(const struct config_node *cn, const char *path,
|
||||
float fail);
|
||||
|
||||
/*
|
||||
* These versions check an override tree, if present, first.
|
||||
*/
|
||||
struct config_node *find_config_tree_node(struct cmd_context *cmd,
|
||||
const char *path);
|
||||
const char *find_config_tree_str(struct cmd_context *cmd,
|
||||
const char *path, const char *fail);
|
||||
int find_config_tree_int(struct cmd_context *cmd, const char *path,
|
||||
int fail);
|
||||
float find_config_tree_float(struct cmd_context *cmd, const char *path,
|
||||
float fail);
|
||||
|
||||
/*
|
||||
* Understands (0, ~0), (y, n), (yes, no), (on,
|
||||
* off), (true, false).
|
||||
*/
|
||||
int find_config_bool(const struct config_node *cn, const char *path, int fail);
|
||||
int find_config_tree_bool(struct cmd_context *cmd, const char *path, int fail);
|
||||
|
||||
int get_config_uint32(const struct config_node *cn, const char *path,
|
||||
uint32_t *result);
|
||||
|
||||
@@ -34,7 +34,10 @@
|
||||
#define DEFAULT_LOCK_DIR "/var/lock/lvm"
|
||||
#define DEFAULT_LOCKING_LIB "lvm2_locking.so"
|
||||
|
||||
#define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
|
||||
#define DEFAULT_MIRROR_DEV_FAULT_POLICY "remove"
|
||||
#define DEFAULT_DMEVENTD_MIRROR_LIB "libdevmapper-event-lvm2mirror.so"
|
||||
#define DEFAULT_DMEVENTD_MONITOR 1
|
||||
|
||||
#define DEFAULT_UMASK 0077
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ void *btree_get_data(struct btree_iter *it)
|
||||
return ((struct node *) it)->data;
|
||||
}
|
||||
|
||||
static inline struct node *_left(struct node *n)
|
||||
static struct node *_left(struct node *n)
|
||||
{
|
||||
while (n->l)
|
||||
n = n->l;
|
||||
|
||||
136
lib/datastruct/list.c
Normal file
136
lib/datastruct/list.c
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 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"
|
||||
|
||||
/*
|
||||
* Initialise a list before use.
|
||||
* The list head's next and previous pointers point back to itself.
|
||||
*/
|
||||
void list_init(struct list *head)
|
||||
{
|
||||
head->n = head->p = head;
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert an element before 'head'.
|
||||
* If 'head' is the list head, this adds an element to the end of the list.
|
||||
*/
|
||||
void list_add(struct list *head, struct list *elem)
|
||||
{
|
||||
assert(head->n);
|
||||
|
||||
elem->n = head;
|
||||
elem->p = head->p;
|
||||
|
||||
head->p->n = elem;
|
||||
head->p = elem;
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert an element after 'head'.
|
||||
* If 'head' is the list head, this adds an element to the front of the list.
|
||||
*/
|
||||
void list_add_h(struct list *head, struct list *elem)
|
||||
{
|
||||
assert(head->n);
|
||||
|
||||
elem->n = head->n;
|
||||
elem->p = head;
|
||||
|
||||
head->n->p = elem;
|
||||
head->n = elem;
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete an element from its list.
|
||||
* Note that this doesn't change the element itself - it may still be safe
|
||||
* to follow its pointers.
|
||||
*/
|
||||
void list_del(struct list *elem)
|
||||
{
|
||||
elem->n->p = elem->p;
|
||||
elem->p->n = elem->n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is the list empty?
|
||||
*/
|
||||
int list_empty(struct list *head)
|
||||
{
|
||||
return head->n == head;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is this the first element of the list?
|
||||
*/
|
||||
int list_start(struct list *head, struct list *elem)
|
||||
{
|
||||
return elem->p == head;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is this the last element of the list?
|
||||
*/
|
||||
int list_end(struct list *head, struct list *elem)
|
||||
{
|
||||
return elem->n == head;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return first element of the list or NULL if empty
|
||||
*/
|
||||
struct list *list_first(struct list *head)
|
||||
{
|
||||
return (list_empty(head) ? NULL : head->n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return last element of the list or NULL if empty
|
||||
*/
|
||||
struct list *list_last(struct list *head)
|
||||
{
|
||||
return (list_empty(head) ? NULL : head->p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the previous element of the list, or NULL if we've reached the start.
|
||||
*/
|
||||
struct list *list_prev(struct list *head, struct list *elem)
|
||||
{
|
||||
return (list_start(head, elem) ? NULL : elem->p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the next element of the list, or NULL if we've reached the end.
|
||||
*/
|
||||
struct list *list_next(struct list *head, struct list *elem)
|
||||
{
|
||||
return (list_end(head, elem) ? NULL : elem->n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the number of elements in a list by walking it.
|
||||
*/
|
||||
unsigned int list_size(const struct list *head)
|
||||
{
|
||||
unsigned int s = 0;
|
||||
const struct list *v;
|
||||
|
||||
list_iterate(v, head)
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
@@ -33,107 +33,61 @@ struct list {
|
||||
* The list head's next and previous pointers point back to itself.
|
||||
*/
|
||||
#define LIST_INIT(name) struct list name = { &(name), &(name) }
|
||||
static inline void list_init(struct list *head)
|
||||
{
|
||||
head->n = head->p = head;
|
||||
}
|
||||
void list_init(struct list *head);
|
||||
|
||||
/*
|
||||
* Insert an element before 'head'.
|
||||
* If 'head' is the list head, this adds an element to the end of the list.
|
||||
*/
|
||||
static inline void list_add(struct list *head, struct list *elem)
|
||||
{
|
||||
assert(head->n);
|
||||
|
||||
elem->n = head;
|
||||
elem->p = head->p;
|
||||
|
||||
head->p->n = elem;
|
||||
head->p = elem;
|
||||
}
|
||||
void list_add(struct list *head, struct list *elem);
|
||||
|
||||
/*
|
||||
* Insert an element after 'head'.
|
||||
* If 'head' is the list head, this adds an element to the front of the list.
|
||||
*/
|
||||
static inline void list_add_h(struct list *head, struct list *elem)
|
||||
{
|
||||
assert(head->n);
|
||||
|
||||
elem->n = head->n;
|
||||
elem->p = head;
|
||||
|
||||
head->n->p = elem;
|
||||
head->n = elem;
|
||||
}
|
||||
void list_add_h(struct list *head, struct list *elem);
|
||||
|
||||
/*
|
||||
* Delete an element from its list.
|
||||
* Note that this doesn't change the element itself - it may still be safe
|
||||
* to follow its pointers.
|
||||
*/
|
||||
static inline void list_del(struct list *elem)
|
||||
{
|
||||
elem->n->p = elem->p;
|
||||
elem->p->n = elem->n;
|
||||
}
|
||||
void list_del(struct list *elem);
|
||||
|
||||
/*
|
||||
* Is the list empty?
|
||||
*/
|
||||
static inline int list_empty(struct list *head)
|
||||
{
|
||||
return head->n == head;
|
||||
}
|
||||
int list_empty(struct list *head);
|
||||
|
||||
/*
|
||||
* Is this the first element of the list?
|
||||
*/
|
||||
static inline int list_start(struct list *head, struct list *elem)
|
||||
{
|
||||
return elem->p == head;
|
||||
}
|
||||
int list_start(struct list *head, struct list *elem);
|
||||
|
||||
/*
|
||||
* Is this the last element of the list?
|
||||
*/
|
||||
static inline int list_end(struct list *head, struct list *elem)
|
||||
{
|
||||
return elem->n == head;
|
||||
}
|
||||
int list_end(struct list *head, struct list *elem);
|
||||
|
||||
/*
|
||||
* Return first element of the list or NULL if empty
|
||||
*/
|
||||
static inline struct list *list_first(struct list *head)
|
||||
{
|
||||
return (list_empty(head) ? NULL : head->n);
|
||||
}
|
||||
struct list *list_first(struct list *head);
|
||||
|
||||
/*
|
||||
* Return last element of the list or NULL if empty
|
||||
*/
|
||||
static inline struct list *list_last(struct list *head)
|
||||
{
|
||||
return (list_empty(head) ? NULL : head->p);
|
||||
}
|
||||
struct list *list_last(struct list *head);
|
||||
|
||||
/*
|
||||
* Return the previous element of the list, or NULL if we've reached the start.
|
||||
*/
|
||||
static inline struct list *list_prev(struct list *head, struct list *elem)
|
||||
{
|
||||
return (list_start(head, elem) ? NULL : elem->p);
|
||||
}
|
||||
struct list *list_prev(struct list *head, struct list *elem);
|
||||
|
||||
/*
|
||||
* Return the next element of the list, or NULL if we've reached the end.
|
||||
*/
|
||||
static inline struct list *list_next(struct list *head, struct list *elem)
|
||||
{
|
||||
return (list_end(head, elem) ? NULL : elem->n);
|
||||
}
|
||||
struct list *list_next(struct list *head, struct list *elem);
|
||||
|
||||
/*
|
||||
* Given the address v of an instance of 'struct list' called 'head'
|
||||
@@ -244,15 +198,6 @@ static inline struct list *list_next(struct list *head, struct list *elem)
|
||||
/*
|
||||
* Return the number of elements in a list by walking it.
|
||||
*/
|
||||
static inline unsigned int list_size(const struct list *head)
|
||||
{
|
||||
unsigned int s = 0;
|
||||
const struct list *v;
|
||||
|
||||
list_iterate(v, head)
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
unsigned int list_size(const struct list *head);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -479,7 +479,7 @@ static void _check_closed(struct device *dev)
|
||||
log_err("Device '%s' has been left open.", dev_name(dev));
|
||||
}
|
||||
|
||||
static inline void _check_for_open_devices(void)
|
||||
static void _check_for_open_devices(void)
|
||||
{
|
||||
dm_hash_iter(_cache.names, (dm_hash_iterate_fn) _check_closed);
|
||||
}
|
||||
@@ -645,8 +645,7 @@ struct dev_iter *dev_iter_create(struct dev_filter *f, int dev_scan)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (dev_scan) {
|
||||
if (dev_scan && !trust_cache()) {
|
||||
/* Flag gets reset between each command */
|
||||
if (!full_scan_done())
|
||||
persistent_filter_wipe(f); /* Calls _full_scan(1) */
|
||||
@@ -664,7 +663,7 @@ void dev_iter_destroy(struct dev_iter *iter)
|
||||
dm_free(iter);
|
||||
}
|
||||
|
||||
static inline struct device *_iter_next(struct dev_iter *iter)
|
||||
static struct device *_iter_next(struct dev_iter *iter)
|
||||
{
|
||||
struct device *d = btree_get_data(iter->current);
|
||||
iter->current = btree_next(iter->current);
|
||||
@@ -682,3 +681,14 @@ struct device *dev_iter_get(struct dev_iter *iter)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int dev_fd(struct device *dev)
|
||||
{
|
||||
return dev->fd;
|
||||
}
|
||||
|
||||
const char *dev_name(const struct device *dev)
|
||||
{
|
||||
return (dev) ? list_item(dev->aliases.n, struct str_list)->str :
|
||||
"unknown device";
|
||||
}
|
||||
|
||||
@@ -602,7 +602,7 @@ int dev_write(struct device *dev, uint64_t offset, size_t len, void *buffer)
|
||||
return _aligned_io(&where, buffer, 1);
|
||||
}
|
||||
|
||||
int dev_zero(struct device *dev, uint64_t offset, size_t len)
|
||||
int dev_set(struct device *dev, uint64_t offset, size_t len, int value)
|
||||
{
|
||||
size_t s;
|
||||
char buffer[4096];
|
||||
@@ -620,7 +620,7 @@ int dev_zero(struct device *dev, uint64_t offset, size_t len)
|
||||
" sectors", dev_name(dev), offset >> SECTOR_SHIFT,
|
||||
len >> SECTOR_SHIFT);
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
memset(buffer, value, sizeof(buffer));
|
||||
while (1) {
|
||||
s = len > sizeof(buffer) ? sizeof(buffer) : len;
|
||||
if (!dev_write(dev, offset, s, buffer))
|
||||
|
||||
@@ -62,7 +62,7 @@ static int _has_partition_table(struct device *dev)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!dev_read(dev, 0, sizeof(buf), &buf)) {
|
||||
if (!dev_read(dev, UINT64_C(0), sizeof(buf), &buf)) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -74,26 +74,18 @@ int dev_close_immediate(struct device *dev);
|
||||
void dev_close_all(void);
|
||||
int dev_test_excl(struct device *dev);
|
||||
|
||||
static inline int dev_fd(struct device *dev)
|
||||
{
|
||||
return dev->fd;
|
||||
}
|
||||
int dev_fd(struct device *dev);
|
||||
const char *dev_name(const struct device *dev);
|
||||
|
||||
int dev_read(struct device *dev, uint64_t offset, size_t len, void *buffer);
|
||||
int dev_write(struct device *dev, uint64_t offset, size_t len, void *buffer);
|
||||
int dev_append(struct device *dev, size_t len, void *buffer);
|
||||
int dev_zero(struct device *dev, uint64_t offset, size_t len);
|
||||
int dev_set(struct device *dev, uint64_t offset, size_t len, int value);
|
||||
void dev_flush(struct device *dev);
|
||||
|
||||
struct device *dev_create_file(const char *filename, struct device *dev,
|
||||
struct str_list *alias, int use_malloc);
|
||||
|
||||
static inline const char *dev_name(const struct device *dev)
|
||||
{
|
||||
return (dev) ? list_item(dev->aliases.n, struct str_list)->str :
|
||||
"unknown device";
|
||||
}
|
||||
|
||||
/* Return a valid device name from the alias list; NULL otherwise */
|
||||
const char *dev_name_confirmed(struct device *dev, int quiet);
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#define SIZE_BUF 128
|
||||
|
||||
typedef enum { SIZE_LONG = 0, SIZE_SHORT = 1, SIZE_UNIT = 2 } size_len_t;
|
||||
|
||||
static struct {
|
||||
alloc_policy_t alloc;
|
||||
const char *str;
|
||||
@@ -132,7 +134,7 @@ alloc_policy_t get_alloc_from_string(const char *str)
|
||||
}
|
||||
|
||||
/* Size supplied in sectors */
|
||||
const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
|
||||
static const char *_display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
|
||||
{
|
||||
int s;
|
||||
int suffix = 1, precision;
|
||||
@@ -200,6 +202,21 @@ const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
|
||||
return size_buf;
|
||||
}
|
||||
|
||||
const char *display_size_long(struct cmd_context *cmd, uint64_t size)
|
||||
{
|
||||
return _display_size(cmd, size, SIZE_LONG);
|
||||
}
|
||||
|
||||
const char *display_size_units(struct cmd_context *cmd, uint64_t size)
|
||||
{
|
||||
return _display_size(cmd, size, SIZE_UNIT);
|
||||
}
|
||||
|
||||
const char *display_size(struct cmd_context *cmd, uint64_t size)
|
||||
{
|
||||
return _display_size(cmd, size, SIZE_SHORT);
|
||||
}
|
||||
|
||||
void pvdisplay_colons(struct physical_volume *pv)
|
||||
{
|
||||
char uuid[64];
|
||||
@@ -228,7 +245,7 @@ void pvdisplay_colons(struct physical_volume *pv)
|
||||
|
||||
/* FIXME Include label fields */
|
||||
void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
void *handle)
|
||||
void *handle __attribute((unused)))
|
||||
{
|
||||
char uuid[64];
|
||||
const char *size;
|
||||
@@ -248,18 +265,17 @@ void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
log_print("VG Name %s%s", pv->vg_name,
|
||||
pv->status & EXPORTED_VG ? " (exported)" : "");
|
||||
|
||||
size = display_size(cmd, (uint64_t) pv->size, SIZE_SHORT);
|
||||
size = display_size(cmd, (uint64_t) pv->size);
|
||||
if (pv->pe_size && pv->pe_count) {
|
||||
|
||||
/******** FIXME display LVM on-disk data size
|
||||
size2 = display_size(pv->size, SIZE_SHORT);
|
||||
size2 = display_size(cmd, pv->size);
|
||||
********/
|
||||
|
||||
log_print("PV Size %s" " / not usable %s", /* [LVM: %s]", */
|
||||
size,
|
||||
display_size(cmd, (pv->size -
|
||||
(uint64_t) pv->pe_count * pv->pe_size),
|
||||
SIZE_SHORT));
|
||||
(uint64_t) pv->pe_count * pv->pe_size)));
|
||||
|
||||
} else
|
||||
log_print("PV Size %s", size);
|
||||
@@ -288,8 +304,10 @@ void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
return;
|
||||
}
|
||||
|
||||
int pvdisplay_short(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct physical_volume *pv, void *handle)
|
||||
int pvdisplay_short(struct cmd_context *cmd __attribute((unused)),
|
||||
struct volume_group *vg __attribute((unused)),
|
||||
struct physical_volume *pv,
|
||||
void *handle __attribute((unused)))
|
||||
{
|
||||
char uuid[64];
|
||||
|
||||
@@ -334,7 +352,7 @@ void lvdisplay_colons(struct logical_volume *lv)
|
||||
}
|
||||
|
||||
int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
void *handle)
|
||||
void *handle __attribute((unused)))
|
||||
{
|
||||
struct lvinfo info;
|
||||
int inkernel, snap_active = 0;
|
||||
@@ -404,23 +422,21 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
|
||||
log_print("LV Size %s",
|
||||
display_size(cmd,
|
||||
snap_seg ? snap_seg->origin->size : lv->size,
|
||||
SIZE_SHORT));
|
||||
snap_seg ? snap_seg->origin->size : lv->size));
|
||||
|
||||
log_print("Current LE %u",
|
||||
snap_seg ? snap_seg->origin->le_count : lv->le_count);
|
||||
|
||||
if (snap_seg) {
|
||||
log_print("COW-table size %s",
|
||||
display_size(cmd, (uint64_t) lv->size, SIZE_SHORT));
|
||||
display_size(cmd, (uint64_t) lv->size));
|
||||
log_print("COW-table LE %u", lv->le_count);
|
||||
|
||||
if (snap_active)
|
||||
log_print("Allocated to snapshot %.2f%% ", snap_percent);
|
||||
|
||||
log_print("Snapshot chunk size %s",
|
||||
display_size(cmd, (uint64_t) snap_seg->chunk_size,
|
||||
SIZE_SHORT));
|
||||
display_size(cmd, (uint64_t) snap_seg->chunk_size));
|
||||
}
|
||||
|
||||
log_print("Segments %u", list_size(&lv->segments));
|
||||
@@ -497,7 +513,7 @@ int lvdisplay_segments(struct logical_volume *lv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void vgdisplay_extents(struct volume_group *vg)
|
||||
void vgdisplay_extents(struct volume_group *vg __attribute((unused)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -544,7 +560,7 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
log_print("Open LV %u", lvs_in_vg_opened(vg));
|
||||
/****** FIXME Max LV Size
|
||||
log_print ( "MAX LV Size %s",
|
||||
( s1 = display_size ( LVM_LV_SIZE_MAX(vg), SIZE_SHORT)));
|
||||
( s1 = display_size ( LVM_LV_SIZE_MAX(vg))));
|
||||
free ( s1);
|
||||
*********/
|
||||
log_print("Max PV %u", vg->max_pv);
|
||||
@@ -553,12 +569,10 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
|
||||
log_print("VG Size %s",
|
||||
display_size(vg->cmd,
|
||||
(uint64_t) vg->extent_count * vg->extent_size,
|
||||
SIZE_SHORT));
|
||||
(uint64_t) vg->extent_count * vg->extent_size));
|
||||
|
||||
log_print("PE Size %s",
|
||||
display_size(vg->cmd, (uint64_t) vg->extent_size,
|
||||
SIZE_SHORT));
|
||||
display_size(vg->cmd, (uint64_t) vg->extent_size));
|
||||
|
||||
log_print("Total PE %u", vg->extent_count);
|
||||
|
||||
@@ -566,12 +580,11 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
vg->extent_count - vg->free_count,
|
||||
display_size(vg->cmd,
|
||||
((uint64_t) vg->extent_count - vg->free_count) *
|
||||
vg->extent_size, SIZE_SHORT));
|
||||
vg->extent_size));
|
||||
|
||||
log_print("Free PE / Size %u / %s", vg->free_count,
|
||||
display_size(vg->cmd,
|
||||
(uint64_t) vg->free_count * vg->extent_size,
|
||||
SIZE_SHORT));
|
||||
(uint64_t) vg->free_count * vg->extent_size));
|
||||
|
||||
if (!id_write_format(&vg->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
@@ -641,15 +654,12 @@ void vgdisplay_short(struct volume_group *vg)
|
||||
log_print("\"%s\" %-9s [%-9s used / %s free]", vg->name,
|
||||
/********* FIXME if "open" print "/used" else print "/idle"??? ******/
|
||||
display_size(vg->cmd,
|
||||
(uint64_t) vg->extent_count * vg->extent_size,
|
||||
SIZE_SHORT),
|
||||
(uint64_t) vg->extent_count * vg->extent_size),
|
||||
display_size(vg->cmd,
|
||||
((uint64_t) vg->extent_count -
|
||||
vg->free_count) * vg->extent_size,
|
||||
SIZE_SHORT),
|
||||
vg->free_count) * vg->extent_size),
|
||||
display_size(vg->cmd,
|
||||
(uint64_t) vg->free_count * vg->extent_size,
|
||||
SIZE_SHORT));
|
||||
(uint64_t) vg->free_count * vg->extent_size));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,13 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum { SIZE_LONG = 0, SIZE_SHORT = 1, SIZE_UNIT = 2 } size_len_t;
|
||||
|
||||
uint64_t units_to_bytes(const char *units, char *unit_type);
|
||||
|
||||
/* Specify size in KB */
|
||||
const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl);
|
||||
const char *display_size(struct cmd_context *cmd, uint64_t size);
|
||||
const char *display_size_long(struct cmd_context *cmd, uint64_t size);
|
||||
const char *display_size_units(struct cmd_context *cmd, uint64_t size);
|
||||
|
||||
char *display_uuid(char *uuidstr);
|
||||
void display_stripe(const struct lv_segment *seg, uint32_t s, const char *pre);
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
#include "lvm-string.h"
|
||||
#include "activate.h"
|
||||
|
||||
static const char *_name(const struct lv_segment *seg)
|
||||
static const char *_errseg_name(const struct lv_segment *seg)
|
||||
{
|
||||
return seg->segtype->name;
|
||||
}
|
||||
|
||||
static int _merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
|
||||
static int _errseg_merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
|
||||
{
|
||||
seg1->len += seg2->len;
|
||||
seg1->area_len += seg2->area_len;
|
||||
@@ -38,43 +38,45 @@ static int _merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
|
||||
}
|
||||
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem,
|
||||
struct config_tree *cft, void **target_state,
|
||||
struct lv_segment *seg,
|
||||
static int _errseg_add_target_line(struct dev_manager *dm __attribute((unused)),
|
||||
struct dm_pool *mem __attribute((unused)),
|
||||
struct cmd_context *cmd __attribute((unused)),
|
||||
void **target_state __attribute((unused)),
|
||||
struct lv_segment *seg __attribute((unused)),
|
||||
struct dm_tree_node *node, uint64_t len,
|
||||
uint32_t *pvmove_mirror_count)
|
||||
uint32_t *pvmove_mirror_count __attribute((unused)))
|
||||
{
|
||||
return dm_tree_node_add_error_target(node, len);
|
||||
}
|
||||
|
||||
static int _target_present(void)
|
||||
static int _errseg_target_present(void)
|
||||
{
|
||||
static int checked = 0;
|
||||
static int present = 0;
|
||||
static int _errseg_checked = 0;
|
||||
static int _errseg_present = 0;
|
||||
|
||||
/* Reported truncated in older kernels */
|
||||
if (!checked &&
|
||||
if (!_errseg_checked &&
|
||||
(target_present("error", 0) || target_present("erro", 0)))
|
||||
present = 1;
|
||||
_errseg_present = 1;
|
||||
|
||||
checked = 1;
|
||||
return present;
|
||||
_errseg_checked = 1;
|
||||
return _errseg_present;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void _destroy(const struct segment_type *segtype)
|
||||
static void _errseg_destroy(const struct segment_type *segtype)
|
||||
{
|
||||
dm_free((void *) segtype);
|
||||
dm_free((void *)segtype);
|
||||
}
|
||||
|
||||
static struct segtype_handler _error_ops = {
|
||||
name:_name,
|
||||
merge_segments:_merge_segments,
|
||||
.name = _errseg_name,
|
||||
.merge_segments = _errseg_merge_segments,
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
add_target_line:_add_target_line,
|
||||
target_present:_target_present,
|
||||
.add_target_line = _errseg_add_target_line,
|
||||
.target_present = _errseg_target_present,
|
||||
#endif
|
||||
destroy:_destroy,
|
||||
.destroy = _errseg_destroy,
|
||||
};
|
||||
|
||||
struct segment_type *init_error_segtype(struct cmd_context *cmd)
|
||||
|
||||
@@ -33,7 +33,7 @@ static int _and_p(struct dev_filter *f, struct device *dev)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _destroy(struct dev_filter *f)
|
||||
static void _composite_destroy(struct dev_filter *f)
|
||||
{
|
||||
struct dev_filter **filters = (struct dev_filter **) f->private;
|
||||
|
||||
@@ -70,7 +70,7 @@ struct dev_filter *composite_filter_create(int n, struct dev_filter **filters)
|
||||
}
|
||||
|
||||
cft->passes_filter = _and_p;
|
||||
cft->destroy = _destroy;
|
||||
cft->destroy = _composite_destroy;
|
||||
cft->private = filters_copy;
|
||||
|
||||
return cft;
|
||||
|
||||
@@ -217,7 +217,7 @@ static int _lookup_p(struct dev_filter *f, struct device *dev)
|
||||
return (l == PF_BAD_DEVICE) ? 0 : 1;
|
||||
}
|
||||
|
||||
static void _destroy(struct dev_filter *f)
|
||||
static void _persistent_destroy(struct dev_filter *f)
|
||||
{
|
||||
struct pfilter *pf = (struct pfilter *) f->private;
|
||||
|
||||
@@ -258,7 +258,7 @@ struct dev_filter *persistent_filter_create(struct dev_filter *real,
|
||||
}
|
||||
|
||||
f->passes_filter = _lookup_p;
|
||||
f->destroy = _destroy;
|
||||
f->destroy = _persistent_destroy;
|
||||
f->private = pf;
|
||||
|
||||
return f;
|
||||
|
||||
@@ -191,7 +191,7 @@ static int _accept_p(struct dev_filter *f, struct device *dev)
|
||||
return !rejected;
|
||||
}
|
||||
|
||||
static void _destroy(struct dev_filter *f)
|
||||
static void _regex_destroy(struct dev_filter *f)
|
||||
{
|
||||
struct rfilter *rf = (struct rfilter *) f->private;
|
||||
dm_pool_destroy(rf->mem);
|
||||
@@ -226,7 +226,7 @@ struct dev_filter *regex_filter_create(struct config_value *patterns)
|
||||
}
|
||||
|
||||
f->passes_filter = _accept_p;
|
||||
f->destroy = _destroy;
|
||||
f->destroy = _regex_destroy;
|
||||
f->private = rf;
|
||||
return f;
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ static struct dev_set *_dev_set_create(struct dm_pool *mem, const char *sys_bloc
|
||||
return ds;
|
||||
}
|
||||
|
||||
static inline unsigned _hash_dev(dev_t dev)
|
||||
static unsigned _hash_dev(dev_t dev)
|
||||
{
|
||||
return (major(dev) ^ minor(dev)) & (SET_BUCKETS - 1);
|
||||
}
|
||||
|
||||
@@ -204,6 +204,7 @@ static int _scan_proc_dev(const char *proc, const struct config_node *cn)
|
||||
if (cv->type != CFG_STRING) {
|
||||
log_error("Expecting string in devices/types "
|
||||
"in config file");
|
||||
fclose(pd);
|
||||
return 0;
|
||||
}
|
||||
dev_len = strlen(cv->v.str);
|
||||
@@ -213,12 +214,14 @@ static int _scan_proc_dev(const char *proc, const struct config_node *cn)
|
||||
log_error("Max partition count missing for %s "
|
||||
"in devices/types in config file",
|
||||
name);
|
||||
fclose(pd);
|
||||
return 0;
|
||||
}
|
||||
if (!cv->v.i) {
|
||||
log_error("Zero partition count invalid for "
|
||||
"%s in devices/types in config file",
|
||||
name);
|
||||
fclose(pd);
|
||||
return 0;
|
||||
}
|
||||
if (dev_len <= strlen(line + i) &&
|
||||
@@ -254,6 +257,7 @@ struct dev_filter *lvm_type_filter_create(const char *proc,
|
||||
|
||||
if (!_scan_proc_dev(proc, cn)) {
|
||||
stack;
|
||||
dm_free(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ static void _xlate_vgd(struct vg_disk *disk)
|
||||
|
||||
static void _xlate_extents(struct pe_disk *extents, uint32_t count)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
extents[i].lv_num = xlate16(extents[i].lv_num);
|
||||
@@ -116,7 +116,7 @@ static void _xlate_extents(struct pe_disk *extents, uint32_t count)
|
||||
static int _munge_formats(struct pv_disk *pvd)
|
||||
{
|
||||
uint32_t pe_start;
|
||||
int b, e;
|
||||
unsigned b, e;
|
||||
|
||||
switch (pvd->version) {
|
||||
case 1:
|
||||
@@ -153,8 +153,10 @@ static int _munge_formats(struct pv_disk *pvd)
|
||||
}
|
||||
|
||||
/* If UUID is missing, create one */
|
||||
if (pvd->pv_uuid[0] == '\0')
|
||||
uuid_from_num(pvd->pv_uuid, pvd->pv_number);
|
||||
if (pvd->pv_uuid[0] == '\0') {
|
||||
uuid_from_num((char *)pvd->pv_uuid, pvd->pv_number);
|
||||
pvd->pv_uuid[ID_LEN] = '\0';
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -172,9 +174,9 @@ static void _munge_exported_vg(struct pv_disk *pvd)
|
||||
return;
|
||||
/* FIXME also check vgd->status & VG_EXPORTED? */
|
||||
|
||||
l = strlen(pvd->vg_name);
|
||||
l = strlen((char *)pvd->vg_name);
|
||||
s = sizeof(EXPORTED_TAG);
|
||||
if (!strncmp(pvd->vg_name + l - s + 1, EXPORTED_TAG, s)) {
|
||||
if (!strncmp((char *)pvd->vg_name + l - s + 1, EXPORTED_TAG, s)) {
|
||||
pvd->vg_name[l - s + 1] = '\0';
|
||||
pvd->pv_status |= VG_EXPORTED;
|
||||
}
|
||||
@@ -237,14 +239,14 @@ int read_vgd(struct device *dev, struct vg_disk *vgd, struct pv_disk *pvd)
|
||||
|
||||
/* If UUID is missing, create one */
|
||||
if (vgd->vg_uuid[0] == '\0')
|
||||
uuid_from_num(vgd->vg_uuid, vgd->vg_number);
|
||||
uuid_from_num((char *)vgd->vg_uuid, vgd->vg_number);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _read_uuids(struct disk_list *data)
|
||||
{
|
||||
int num_read = 0;
|
||||
unsigned num_read = 0;
|
||||
struct uuid_list *ul;
|
||||
char buffer[NAME_LEN];
|
||||
uint64_t pos = data->pvd.pv_uuidlist_on_disk.base;
|
||||
@@ -269,7 +271,7 @@ static int _read_uuids(struct disk_list *data)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int _check_lvd(struct lv_disk *lvd)
|
||||
static int _check_lvd(struct lv_disk *lvd)
|
||||
{
|
||||
return !(lvd->lv_name[0] == '\0');
|
||||
}
|
||||
@@ -322,12 +324,12 @@ static int _read_extents(struct disk_list *data)
|
||||
static void __update_lvmcache(const struct format_type *fmt,
|
||||
struct disk_list *dl,
|
||||
struct device *dev, const char *vgid,
|
||||
int exported)
|
||||
unsigned exported)
|
||||
{
|
||||
struct lvmcache_info *info;
|
||||
|
||||
if (!(info = lvmcache_add(fmt->labeller, dl->pvd.pv_uuid, dev,
|
||||
dl->pvd.vg_name, vgid,
|
||||
if (!(info = lvmcache_add(fmt->labeller, (char *)dl->pvd.pv_uuid, dev,
|
||||
(char *)dl->pvd.vg_name, vgid,
|
||||
exported ? EXPORTED_VG : 0))) {
|
||||
stack;
|
||||
return;
|
||||
@@ -376,14 +378,14 @@ static struct disk_list *__read_disk(const struct format_type *fmt,
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (vg_name && strcmp(vg_name, dl->pvd.vg_name)) {
|
||||
if (vg_name && strcmp(vg_name, (char *)dl->pvd.vg_name)) {
|
||||
log_very_verbose("%s is not a member of the VG %s",
|
||||
name, vg_name);
|
||||
__update_lvmcache(fmt, dl, dev, NULL, 0);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
__update_lvmcache(fmt, dl, dev, dl->vgd.vg_uuid,
|
||||
__update_lvmcache(fmt, dl, dev, (char *)dl->vgd.vg_uuid,
|
||||
dl->vgd.vg_status & VG_EXPORTED);
|
||||
|
||||
if (!_read_uuids(dl)) {
|
||||
@@ -437,7 +439,7 @@ static void _add_pv_to_list(struct list *head, struct disk_list *data)
|
||||
|
||||
list_iterate_items(diskl, head) {
|
||||
pvd = &diskl->pvd;
|
||||
if (!strncmp(data->pvd.pv_uuid, pvd->pv_uuid,
|
||||
if (!strncmp((char *)data->pvd.pv_uuid, (char *)pvd->pv_uuid,
|
||||
sizeof(pvd->pv_uuid))) {
|
||||
if (MAJOR(data->dev->dev) != md_major()) {
|
||||
log_very_verbose("Ignoring duplicate PV %s on "
|
||||
@@ -456,7 +458,7 @@ static void _add_pv_to_list(struct list *head, struct disk_list *data)
|
||||
|
||||
/*
|
||||
* Build a list of pv_d's structures, allocated from mem.
|
||||
* We keep track of the first object allocated form the pool
|
||||
* We keep track of the first object allocated from the pool
|
||||
* so we can free off all the memory if something goes wrong.
|
||||
*/
|
||||
int read_pvs_in_vg(const struct format_type *fmt, const char *vg_name,
|
||||
@@ -574,7 +576,7 @@ static int _write_lvs(struct disk_list *data)
|
||||
|
||||
pos = data->pvd.lv_on_disk.base;
|
||||
|
||||
if (!dev_zero(data->dev, pos, data->pvd.lv_on_disk.size)) {
|
||||
if (!dev_set(data->dev, pos, data->pvd.lv_on_disk.size, 0)) {
|
||||
log_error("Couldn't zero lv area on device '%s'",
|
||||
dev_name(data->dev));
|
||||
return 0;
|
||||
|
||||
@@ -73,16 +73,16 @@ struct data_area {
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct pv_disk {
|
||||
uint8_t id[2];
|
||||
int8_t id[2];
|
||||
uint16_t version; /* lvm version */
|
||||
struct data_area pv_on_disk;
|
||||
struct data_area vg_on_disk;
|
||||
struct data_area pv_uuidlist_on_disk;
|
||||
struct data_area lv_on_disk;
|
||||
struct data_area pe_on_disk;
|
||||
uint8_t pv_uuid[NAME_LEN];
|
||||
uint8_t vg_name[NAME_LEN];
|
||||
uint8_t system_id[NAME_LEN]; /* for vgexport/vgimport */
|
||||
int8_t pv_uuid[NAME_LEN];
|
||||
int8_t vg_name[NAME_LEN];
|
||||
int8_t system_id[NAME_LEN]; /* for vgexport/vgimport */
|
||||
uint32_t pv_major;
|
||||
uint32_t pv_number;
|
||||
uint32_t pv_status;
|
||||
@@ -98,8 +98,8 @@ struct pv_disk {
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct lv_disk {
|
||||
uint8_t lv_name[NAME_LEN];
|
||||
uint8_t vg_name[NAME_LEN];
|
||||
int8_t lv_name[NAME_LEN];
|
||||
int8_t vg_name[NAME_LEN];
|
||||
uint32_t lv_access;
|
||||
uint32_t lv_status;
|
||||
uint32_t lv_open;
|
||||
@@ -122,8 +122,8 @@ struct lv_disk {
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct vg_disk {
|
||||
uint8_t vg_uuid[ID_LEN]; /* volume group UUID */
|
||||
uint8_t vg_name_dummy[NAME_LEN - ID_LEN]; /* rest of v1 VG name */
|
||||
int8_t vg_uuid[ID_LEN]; /* volume group UUID */
|
||||
int8_t vg_name_dummy[NAME_LEN - ID_LEN]; /* rest of v1 VG name */
|
||||
uint32_t vg_number; /* volume group number */
|
||||
uint32_t vg_access; /* read/write */
|
||||
uint32_t vg_status; /* active or not */
|
||||
@@ -223,7 +223,7 @@ int export_extents(struct disk_list *dl, uint32_t lv_num,
|
||||
|
||||
int import_pvs(const struct format_type *fmt, struct dm_pool *mem,
|
||||
struct volume_group *vg,
|
||||
struct list *pvds, struct list *results, int *count);
|
||||
struct list *pvds, struct list *results, uint32_t *count);
|
||||
|
||||
int import_lvs(struct dm_pool *mem, struct volume_group *vg, struct list *pvds);
|
||||
int export_lvs(struct disk_list *dl, struct volume_group *vg,
|
||||
|
||||
@@ -173,7 +173,7 @@ static struct volume_group *_build_vg(struct format_instance *fid,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct volume_group *_vg_read(struct format_instance *fid,
|
||||
static struct volume_group *_format1_vg_read(struct format_instance *fid,
|
||||
const char *vg_name,
|
||||
struct metadata_area *mda)
|
||||
{
|
||||
@@ -264,7 +264,7 @@ static int _flatten_vg(struct format_instance *fid, struct dm_pool *mem,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _vg_write(struct format_instance *fid, struct volume_group *vg,
|
||||
static int _format1_vg_write(struct format_instance *fid, struct volume_group *vg,
|
||||
struct metadata_area *mda)
|
||||
{
|
||||
struct dm_pool *mem = dm_pool_create("lvm1 vg_write", 1024 * 10);
|
||||
@@ -287,7 +287,7 @@ static int _vg_write(struct format_instance *fid, struct volume_group *vg,
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
static int _format1_pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
struct physical_volume *pv, struct list *mdas)
|
||||
{
|
||||
struct dm_pool *mem = dm_pool_create("lvm1 pv_read", 1024);
|
||||
@@ -326,7 +326,7 @@ static int _pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _pv_setup(const struct format_type *fmt,
|
||||
static int _format1_pv_setup(const struct format_type *fmt,
|
||||
uint64_t pe_start, uint32_t extent_count,
|
||||
uint32_t extent_size,
|
||||
int pvmetadatacopies,
|
||||
@@ -337,8 +337,7 @@ static int _pv_setup(const struct format_type *fmt,
|
||||
pv->size--;
|
||||
if (pv->size > MAX_PV_SIZE) {
|
||||
log_error("Physical volumes cannot be bigger than %s",
|
||||
display_size(fmt->cmd, (uint64_t) MAX_PV_SIZE,
|
||||
SIZE_SHORT));
|
||||
display_size(fmt->cmd, (uint64_t) MAX_PV_SIZE));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -364,7 +363,7 @@ static int _pv_setup(const struct format_type *fmt,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
|
||||
static int _format1_lv_setup(struct format_instance *fid, struct logical_volume *lv)
|
||||
{
|
||||
uint64_t max_size = UINT_MAX;
|
||||
|
||||
@@ -378,15 +377,14 @@ static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
|
||||
}
|
||||
if (lv->size > max_size) {
|
||||
log_error("logical volumes cannot be larger than %s",
|
||||
display_size(fid->fmt->cmd, max_size,
|
||||
SIZE_SHORT));
|
||||
display_size(fid->fmt->cmd, max_size));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
|
||||
static int _format1_pv_write(const struct format_type *fmt, struct physical_volume *pv,
|
||||
struct list *mdas, int64_t sector)
|
||||
{
|
||||
struct dm_pool *mem;
|
||||
@@ -449,7 +447,7 @@ static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
static int _format1_vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
{
|
||||
/* just check max_pv and max_lv */
|
||||
if (!vg->max_lv || vg->max_lv >= MAX_LV)
|
||||
@@ -460,18 +458,15 @@ static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
|
||||
if (vg->extent_size > MAX_PE_SIZE || vg->extent_size < MIN_PE_SIZE) {
|
||||
log_error("Extent size must be between %s and %s",
|
||||
display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE,
|
||||
SIZE_SHORT),
|
||||
display_size(fid->fmt->cmd, (uint64_t) MAX_PE_SIZE,
|
||||
SIZE_SHORT));
|
||||
display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE),
|
||||
display_size(fid->fmt->cmd, (uint64_t) MAX_PE_SIZE));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vg->extent_size % MIN_PE_SIZE) {
|
||||
log_error("Extent size must be multiple of %s",
|
||||
display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE,
|
||||
SIZE_SHORT));
|
||||
display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -484,8 +479,8 @@ static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _segtype_supported (struct format_instance *fid,
|
||||
struct segment_type *segtype)
|
||||
static int _format1_segtype_supported(struct format_instance *fid,
|
||||
const struct segment_type *segtype)
|
||||
{
|
||||
if (!(segtype->flags & SEG_FORMAT1_SUPPORT)) {
|
||||
stack;
|
||||
@@ -496,11 +491,11 @@ static int _segtype_supported (struct format_instance *fid,
|
||||
}
|
||||
|
||||
static struct metadata_area_ops _metadata_format1_ops = {
|
||||
vg_read:_vg_read,
|
||||
vg_write:_vg_write,
|
||||
.vg_read = _format1_vg_read,
|
||||
.vg_write = _format1_vg_write,
|
||||
};
|
||||
|
||||
static struct format_instance *_create_instance(const struct format_type *fmt,
|
||||
static struct format_instance *_format1_create_instance(const struct format_type *fmt,
|
||||
const char *vgname,
|
||||
const char *vgid,
|
||||
void *private)
|
||||
@@ -530,26 +525,26 @@ static struct format_instance *_create_instance(const struct format_type *fmt,
|
||||
return fid;
|
||||
}
|
||||
|
||||
static void _destroy_instance(struct format_instance *fid)
|
||||
static void _format1_destroy_instance(struct format_instance *fid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void _destroy(const struct format_type *fmt)
|
||||
static void _format1_destroy(const struct format_type *fmt)
|
||||
{
|
||||
dm_free((void *) fmt);
|
||||
}
|
||||
|
||||
static struct format_handler _format1_ops = {
|
||||
pv_read:_pv_read,
|
||||
pv_setup:_pv_setup,
|
||||
pv_write:_pv_write,
|
||||
lv_setup:_lv_setup,
|
||||
vg_setup:_vg_setup,
|
||||
segtype_supported:_segtype_supported,
|
||||
create_instance:_create_instance,
|
||||
destroy_instance:_destroy_instance,
|
||||
destroy:_destroy,
|
||||
.pv_read = _format1_pv_read,
|
||||
.pv_setup = _format1_pv_setup,
|
||||
.pv_write = _format1_pv_write,
|
||||
.lv_setup = _format1_lv_setup,
|
||||
.vg_setup = _format1_vg_setup,
|
||||
.segtype_supported = _format1_segtype_supported,
|
||||
.create_instance = _format1_create_instance,
|
||||
.destroy_instance = _format1_destroy_instance,
|
||||
.destroy = _format1_destroy,
|
||||
};
|
||||
|
||||
#ifdef LVM1_INTERNAL
|
||||
|
||||
@@ -56,7 +56,7 @@ int import_pv(struct dm_pool *mem, struct device *dev,
|
||||
memcpy(&pv->id, pvd->pv_uuid, ID_LEN);
|
||||
|
||||
pv->dev = dev;
|
||||
if (!(pv->vg_name = dm_pool_strdup(mem, pvd->vg_name))) {
|
||||
if (!(pv->vg_name = dm_pool_strdup(mem, (char *)pvd->vg_name))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@@ -65,10 +65,10 @@ int import_pv(struct dm_pool *mem, struct device *dev,
|
||||
|
||||
/* Store system_id from first PV if PV belongs to a VG */
|
||||
if (vg && !*vg->system_id)
|
||||
strncpy(vg->system_id, pvd->system_id, NAME_LEN);
|
||||
strncpy(vg->system_id, (char *)pvd->system_id, NAME_LEN);
|
||||
|
||||
if (vg &&
|
||||
strncmp(vg->system_id, pvd->system_id, sizeof(pvd->system_id)))
|
||||
strncmp(vg->system_id, (char *)pvd->system_id, sizeof(pvd->system_id)))
|
||||
log_very_verbose("System ID %s on %s differs from %s for "
|
||||
"volume group", pvd->system_id,
|
||||
dev_name(pv->dev), vg->system_id);
|
||||
@@ -124,19 +124,17 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem,
|
||||
|
||||
memcpy(pvd->pv_uuid, pv->id.uuid, ID_LEN);
|
||||
|
||||
if (!_check_vg_name(pv->vg_name)) {
|
||||
stack;
|
||||
return 0;
|
||||
if (pv->vg_name) {
|
||||
if (!_check_vg_name(pv->vg_name)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
strncpy((char *)pvd->vg_name, pv->vg_name, sizeof(pvd->vg_name));
|
||||
}
|
||||
|
||||
memset(pvd->vg_name, 0, sizeof(pvd->vg_name));
|
||||
|
||||
if (pv->vg_name)
|
||||
strncpy(pvd->vg_name, pv->vg_name, sizeof(pvd->vg_name));
|
||||
|
||||
/* Preserve existing system_id if it exists */
|
||||
if (vg && *vg->system_id)
|
||||
strncpy(pvd->system_id, vg->system_id, sizeof(pvd->system_id));
|
||||
strncpy((char *)pvd->system_id, vg->system_id, sizeof(pvd->system_id));
|
||||
|
||||
/* Is VG already exported or being exported? */
|
||||
if (vg && (vg->status & EXPORTED_VG)) {
|
||||
@@ -144,24 +142,24 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem,
|
||||
if (!*vg->system_id ||
|
||||
strncmp(vg->system_id, EXPORTED_TAG,
|
||||
sizeof(EXPORTED_TAG) - 1)) {
|
||||
if (!_system_id(cmd, pvd->system_id, EXPORTED_TAG)) {
|
||||
if (!_system_id(cmd, (char *)pvd->system_id, EXPORTED_TAG)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (strlen(pvd->vg_name) + sizeof(EXPORTED_TAG) >
|
||||
if (strlen((char *)pvd->vg_name) + sizeof(EXPORTED_TAG) >
|
||||
sizeof(pvd->vg_name)) {
|
||||
log_error("Volume group name %s too long to export",
|
||||
pvd->vg_name);
|
||||
return 0;
|
||||
}
|
||||
strcat(pvd->vg_name, EXPORTED_TAG);
|
||||
strcat((char *)pvd->vg_name, EXPORTED_TAG);
|
||||
}
|
||||
|
||||
/* Is VG being imported? */
|
||||
if (vg && !(vg->status & EXPORTED_VG) && *vg->system_id &&
|
||||
!strncmp(vg->system_id, EXPORTED_TAG, sizeof(EXPORTED_TAG) - 1)) {
|
||||
if (!_system_id(cmd, pvd->system_id, IMPORTED_TAG)) {
|
||||
if (!_system_id(cmd, (char *)pvd->system_id, IMPORTED_TAG)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@@ -169,7 +167,7 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem,
|
||||
|
||||
/* Generate system_id if PV is in VG */
|
||||
if (!pvd->system_id || !*pvd->system_id)
|
||||
if (!_system_id(cmd, pvd->system_id, "")) {
|
||||
if (!_system_id(cmd, (char *)pvd->system_id, "")) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@@ -177,8 +175,8 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem,
|
||||
/* Update internal system_id if we changed it */
|
||||
if (vg &&
|
||||
(!*vg->system_id ||
|
||||
strncmp(vg->system_id, pvd->system_id, sizeof(pvd->system_id))))
|
||||
strncpy(vg->system_id, pvd->system_id, NAME_LEN);
|
||||
strncmp(vg->system_id, (char *)pvd->system_id, sizeof(pvd->system_id))))
|
||||
strncpy(vg->system_id, (char *)pvd->system_id, NAME_LEN);
|
||||
|
||||
//pvd->pv_major = MAJOR(pv->dev);
|
||||
|
||||
@@ -204,12 +202,12 @@ int import_vg(struct dm_pool *mem,
|
||||
struct vg_disk *vgd = &dl->vgd;
|
||||
memcpy(vg->id.uuid, vgd->vg_uuid, ID_LEN);
|
||||
|
||||
if (!_check_vg_name(dl->pvd.vg_name)) {
|
||||
if (!_check_vg_name((char *)dl->pvd.vg_name)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(vg->name = dm_pool_strdup(mem, dl->pvd.vg_name))) {
|
||||
if (!(vg->name = dm_pool_strdup(mem, (char *)dl->pvd.vg_name))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@@ -292,7 +290,7 @@ int import_lv(struct dm_pool *mem, struct logical_volume *lv, struct lv_disk *lv
|
||||
{
|
||||
lvid_from_lvnum(&lv->lvid, &lv->vg->id, lvd->lv_number);
|
||||
|
||||
if (!(lv->name = _create_lv_name(mem, lvd->lv_name))) {
|
||||
if (!(lv->name = _create_lv_name(mem, (char *)lvd->lv_name))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@@ -342,10 +340,10 @@ static void _export_lv(struct lv_disk *lvd, struct volume_group *vg,
|
||||
struct logical_volume *lv, const char *dev_dir)
|
||||
{
|
||||
memset(lvd, 0, sizeof(*lvd));
|
||||
snprintf(lvd->lv_name, sizeof(lvd->lv_name), "%s%s/%s",
|
||||
snprintf((char *)lvd->lv_name, sizeof(lvd->lv_name), "%s%s/%s",
|
||||
dev_dir, vg->name, lv->name);
|
||||
|
||||
strcpy(lvd->vg_name, vg->name);
|
||||
strcpy((char *)lvd->vg_name, vg->name);
|
||||
|
||||
if (lv->status & LVM_READ)
|
||||
lvd->lv_access |= LV_READ;
|
||||
@@ -416,7 +414,7 @@ int export_extents(struct disk_list *dl, uint32_t lv_num,
|
||||
|
||||
int import_pvs(const struct format_type *fmt, struct dm_pool *mem,
|
||||
struct volume_group *vg,
|
||||
struct list *pvds, struct list *results, int *count)
|
||||
struct list *pvds, struct list *results, uint32_t *count)
|
||||
{
|
||||
struct disk_list *dl;
|
||||
struct pv_list *pvl;
|
||||
@@ -478,7 +476,7 @@ int import_lvs(struct dm_pool *mem, struct volume_group *vg, struct list *pvds)
|
||||
list_iterate_items(ll, &dl->lvds) {
|
||||
lvd = &ll->lvd;
|
||||
|
||||
if (!find_lv(vg, lvd->lv_name) &&
|
||||
if (!find_lv(vg, (char *)lvd->lv_name) &&
|
||||
!_add_lv(mem, vg, lvd)) {
|
||||
stack;
|
||||
return 0;
|
||||
@@ -586,14 +584,14 @@ int import_snapshots(struct dm_pool *mem, struct volume_group *vg,
|
||||
|
||||
lvnum = lvd->lv_number;
|
||||
|
||||
if (lvnum > MAX_LV) {
|
||||
if (lvnum >= MAX_LV) {
|
||||
log_err("Logical volume number "
|
||||
"out of bounds.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!lvs[lvnum] &&
|
||||
!(lvs[lvnum] = find_lv(vg, lvd->lv_name))) {
|
||||
!(lvs[lvnum] = find_lv(vg, (char *)lvd->lv_name))) {
|
||||
log_err("Couldn't find logical volume '%s'.",
|
||||
lvd->lv_name);
|
||||
return 0;
|
||||
|
||||
@@ -93,7 +93,7 @@ static int _fill_lv_array(struct lv_map **lvs,
|
||||
memset(lvs, 0, sizeof(*lvs) * MAX_LV);
|
||||
|
||||
list_iterate_items(ll, &dl->lvds) {
|
||||
if (!(lvm = dm_hash_lookup(maps, strrchr(ll->lvd.lv_name, '/')
|
||||
if (!(lvm = dm_hash_lookup(maps, strrchr((char *)ll->lvd.lv_name, '/')
|
||||
+ 1))) {
|
||||
log_err("Physical volume (%s) contains an "
|
||||
"unknown logical volume (%s).",
|
||||
|
||||
@@ -19,16 +19,18 @@
|
||||
/*
|
||||
* Only works with powers of 2.
|
||||
*/
|
||||
static inline uint32_t _round_up(uint32_t n, uint32_t size)
|
||||
static uint32_t _round_up(uint32_t n, uint32_t size)
|
||||
{
|
||||
size--;
|
||||
return (n + size) & ~size;
|
||||
}
|
||||
|
||||
static inline uint32_t _div_up(uint32_t n, uint32_t size)
|
||||
/* Unused.
|
||||
static uint32_t _div_up(uint32_t n, uint32_t size)
|
||||
{
|
||||
return _round_up(n, size) / size;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Each chunk of metadata should be aligned to
|
||||
|
||||
@@ -30,7 +30,7 @@ static void _not_supported(const char *op)
|
||||
op);
|
||||
}
|
||||
|
||||
static int _can_handle(struct labeller *l, char *buf, uint64_t sector)
|
||||
static int _lvm1_can_handle(struct labeller *l, char *buf, uint64_t sector)
|
||||
{
|
||||
struct pv_disk *pvd = (struct pv_disk *) buf;
|
||||
uint32_t version;
|
||||
@@ -48,29 +48,29 @@ static int _can_handle(struct labeller *l, char *buf, uint64_t sector)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _write(struct label *label, char *buf)
|
||||
static int _lvm1_write(struct label *label, char *buf)
|
||||
{
|
||||
_not_supported("write");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _read(struct labeller *l, struct device *dev, char *buf,
|
||||
static int _lvm1_read(struct labeller *l, struct device *dev, char *buf,
|
||||
struct label **label)
|
||||
{
|
||||
struct pv_disk *pvd = (struct pv_disk *) buf;
|
||||
struct vg_disk vgd;
|
||||
struct lvmcache_info *info;
|
||||
const char *vgid = NULL;
|
||||
int exported = 0;
|
||||
unsigned exported = 0;
|
||||
|
||||
munge_pvd(dev, pvd);
|
||||
|
||||
if (*pvd->vg_name && read_vgd(dev, &vgd, pvd)) {
|
||||
vgid = vgd.vg_uuid;
|
||||
vgid = (char *) vgd.vg_uuid;
|
||||
exported = pvd->pv_status & VG_EXPORTED;
|
||||
}
|
||||
|
||||
if (!(info = lvmcache_add(l, pvd->pv_uuid, dev, pvd->vg_name, vgid,
|
||||
if (!(info = lvmcache_add(l, (char *)pvd->pv_uuid, dev, (char *)pvd->vg_name, vgid,
|
||||
exported))) {
|
||||
stack;
|
||||
return 0;
|
||||
@@ -85,31 +85,31 @@ static int _read(struct labeller *l, struct device *dev, char *buf,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _initialise_label(struct labeller *l, struct label *label)
|
||||
static int _lvm1_initialise_label(struct labeller *l, struct label *label)
|
||||
{
|
||||
strcpy(label->type, "LVM1");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _destroy_label(struct labeller *l, struct label *label)
|
||||
static void _lvm1_destroy_label(struct labeller *l, struct label *label)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void _destroy(struct labeller *l)
|
||||
static void _lvm1_destroy(struct labeller *l)
|
||||
{
|
||||
dm_free(l);
|
||||
}
|
||||
|
||||
struct label_ops _lvm1_ops = {
|
||||
can_handle:_can_handle,
|
||||
write:_write,
|
||||
read:_read,
|
||||
verify:_can_handle,
|
||||
initialise_label:_initialise_label,
|
||||
destroy_label:_destroy_label,
|
||||
destroy:_destroy
|
||||
.can_handle = _lvm1_can_handle,
|
||||
.write = _lvm1_write,
|
||||
.read = _lvm1_read,
|
||||
.verify = _lvm1_can_handle,
|
||||
.initialise_label = _lvm1_initialise_label,
|
||||
.destroy_label = _lvm1_destroy_label,
|
||||
.destroy = _lvm1_destroy,
|
||||
};
|
||||
|
||||
struct labeller *lvm1_labeller_create(struct format_type *fmt)
|
||||
|
||||
@@ -46,7 +46,7 @@ int get_free_vg_number(struct format_instance *fid, struct dev_filter *filter,
|
||||
memset(numbers, 0, sizeof(numbers));
|
||||
|
||||
list_iterate_items(dl, &all_pvs) {
|
||||
if (!*dl->pvd.vg_name || !strcmp(dl->pvd.vg_name, candidate_vg))
|
||||
if (!*dl->pvd.vg_name || !strcmp((char *)dl->pvd.vg_name, candidate_vg))
|
||||
continue;
|
||||
|
||||
numbers[dl->vgd.vg_number] = 1;
|
||||
|
||||
@@ -248,7 +248,7 @@ static int _read_vg_pds(const struct format_type *fmt, struct dm_pool *mem,
|
||||
|
||||
uint32_t sp_count = 0;
|
||||
uint32_t *sp_devs = NULL;
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
/* FIXME: maybe should return a different error in memory
|
||||
* allocation failure */
|
||||
|
||||
@@ -79,7 +79,8 @@ static struct user_subpool *_build_usp(struct list *pls, struct dm_pool *mem,
|
||||
|
||||
static int _check_usp(char *vgname, struct user_subpool *usp, int sp_count)
|
||||
{
|
||||
int i, j;
|
||||
int i;
|
||||
unsigned j;
|
||||
|
||||
for (i = 0; i < sp_count; i++) {
|
||||
if (!usp[i].initialized) {
|
||||
@@ -88,7 +89,7 @@ static int _check_usp(char *vgname, struct user_subpool *usp, int sp_count)
|
||||
}
|
||||
for (j = 0; j < usp[i].num_devs; j++) {
|
||||
if (!usp[i].devs[j].initialized) {
|
||||
log_error("Missing device %d for subpool %d"
|
||||
log_error("Missing device %u for subpool %d"
|
||||
" in pool %s", j, i, vgname);
|
||||
return 0;
|
||||
}
|
||||
@@ -169,7 +170,7 @@ static struct volume_group *_build_vg_from_pds(struct format_instance
|
||||
return vg;
|
||||
}
|
||||
|
||||
static struct volume_group *_vg_read(struct format_instance *fid,
|
||||
static struct volume_group *_pool_vg_read(struct format_instance *fid,
|
||||
const char *vg_name,
|
||||
struct metadata_area *mda)
|
||||
{
|
||||
@@ -206,7 +207,7 @@ static struct volume_group *_vg_read(struct format_instance *fid,
|
||||
return vg;
|
||||
}
|
||||
|
||||
static int _pv_setup(const struct format_type *fmt,
|
||||
static int _pool_pv_setup(const struct format_type *fmt,
|
||||
uint64_t pe_start, uint32_t extent_count,
|
||||
uint32_t extent_size,
|
||||
int pvmetadatacopies,
|
||||
@@ -216,7 +217,7 @@ static int _pv_setup(const struct format_type *fmt,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
static int _pool_pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
struct physical_volume *pv, struct list *mdas)
|
||||
{
|
||||
struct dm_pool *mem = dm_pool_create("pool pv_read", 1024);
|
||||
@@ -262,11 +263,11 @@ static int _pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
static struct metadata_area_ops _metadata_format_pool_ops = {
|
||||
vg_read:_vg_read,
|
||||
.vg_read = _pool_vg_read,
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
static struct format_instance *_create_instance(const struct format_type *fmt,
|
||||
static struct format_instance *_pool_create_instance(const struct format_type *fmt,
|
||||
const char *vgname,
|
||||
const char *vgid,
|
||||
void *private)
|
||||
@@ -298,23 +299,23 @@ static struct format_instance *_create_instance(const struct format_type *fmt,
|
||||
return fid;
|
||||
}
|
||||
|
||||
static void _destroy_instance(struct format_instance *fid)
|
||||
static void _pool_destroy_instance(struct format_instance *fid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void _destroy(const struct format_type *fmt)
|
||||
static void _pool_destroy(const struct format_type *fmt)
|
||||
{
|
||||
dm_free((void *) fmt);
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
static struct format_handler _format_pool_ops = {
|
||||
pv_read:_pv_read,
|
||||
pv_setup:_pv_setup,
|
||||
create_instance:_create_instance,
|
||||
destroy_instance:_destroy_instance,
|
||||
destroy:_destroy,
|
||||
.pv_read = _pool_pv_read,
|
||||
.pv_setup = _pool_pv_setup,
|
||||
.create_instance = _pool_create_instance,
|
||||
.destroy_instance = _pool_destroy_instance,
|
||||
.destroy = _pool_destroy,
|
||||
};
|
||||
/* *INDENT-ON */
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ static int _add_stripe_seg(struct dm_pool *mem,
|
||||
{
|
||||
struct lv_segment *seg;
|
||||
struct segment_type *segtype;
|
||||
int j;
|
||||
unsigned j;
|
||||
uint32_t area_len;
|
||||
|
||||
if (usp->striping & (usp->striping - 1)) {
|
||||
@@ -249,7 +249,7 @@ static int _add_linear_seg(struct dm_pool *mem,
|
||||
{
|
||||
struct lv_segment *seg;
|
||||
struct segment_type *segtype;
|
||||
int j;
|
||||
unsigned j;
|
||||
uint32_t area_len;
|
||||
|
||||
if (!(segtype = get_segtype_from_string(lv->vg->cmd, "striped"))) {
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
static void _not_supported(const char *op)
|
||||
static void _pool_not_supported(const char *op)
|
||||
{
|
||||
log_error("The '%s' operation is not supported for the pool labeller.",
|
||||
op);
|
||||
}
|
||||
|
||||
static int _can_handle(struct labeller *l, char *buf, uint64_t sector)
|
||||
static int _pool_can_handle(struct labeller *l, char *buf, uint64_t sector)
|
||||
{
|
||||
|
||||
struct pool_disk pd;
|
||||
@@ -50,13 +50,13 @@ static int _can_handle(struct labeller *l, char *buf, uint64_t sector)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _write(struct label *label, char *buf)
|
||||
static int _pool_write(struct label *label, char *buf)
|
||||
{
|
||||
_not_supported("write");
|
||||
_pool_not_supported("write");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _read(struct labeller *l, struct device *dev, char *buf,
|
||||
static int _pool_read(struct labeller *l, struct device *dev, char *buf,
|
||||
struct label **label)
|
||||
{
|
||||
struct pool_list pl;
|
||||
@@ -64,31 +64,31 @@ static int _read(struct labeller *l, struct device *dev, char *buf,
|
||||
return read_pool_label(&pl, l, dev, buf, label);
|
||||
}
|
||||
|
||||
static int _initialise_label(struct labeller *l, struct label *label)
|
||||
static int _pool_initialise_label(struct labeller *l, struct label *label)
|
||||
{
|
||||
strcpy(label->type, "POOL");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _destroy_label(struct labeller *l, struct label *label)
|
||||
static void _pool_destroy_label(struct labeller *l, struct label *label)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void _destroy(struct labeller *l)
|
||||
static void _label_pool_destroy(struct labeller *l)
|
||||
{
|
||||
dm_free(l);
|
||||
}
|
||||
|
||||
struct label_ops _pool_ops = {
|
||||
can_handle:_can_handle,
|
||||
write:_write,
|
||||
read:_read,
|
||||
verify:_can_handle,
|
||||
initialise_label:_initialise_label,
|
||||
destroy_label:_destroy_label,
|
||||
destroy:_destroy
|
||||
.can_handle = _pool_can_handle,
|
||||
.write = _pool_write,
|
||||
.read = _pool_read,
|
||||
.verify = _pool_can_handle,
|
||||
.initialise_label = _pool_initialise_label,
|
||||
.destroy_label = _pool_destroy_label,
|
||||
.destroy = _label_pool_destroy,
|
||||
};
|
||||
|
||||
struct labeller *pool_labeller_create(struct format_type *fmt)
|
||||
|
||||
@@ -87,7 +87,7 @@ static int _split_vg(const char *filename, char *vgname, size_t vg_size,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _insert_file(struct list *head, struct archive_file *b)
|
||||
static void _insert_archive_file(struct list *head, struct archive_file *b)
|
||||
{
|
||||
struct archive_file *bf = NULL;
|
||||
|
||||
@@ -107,7 +107,7 @@ static void _insert_file(struct list *head, struct archive_file *b)
|
||||
list_add_h(&bf->list, &b->list);
|
||||
}
|
||||
|
||||
static char *_join(struct dm_pool *mem, const char *dir, const char *name)
|
||||
static char *_join_file_to_dir(struct dm_pool *mem, const char *dir, const char *name)
|
||||
{
|
||||
if (!dm_pool_begin_object(mem, 32) ||
|
||||
!dm_pool_grow_object(mem, dir, strlen(dir)) ||
|
||||
@@ -161,7 +161,7 @@ static struct list *_scan_archive(struct dm_pool *mem,
|
||||
if (strcmp(vgname, vgname_found))
|
||||
continue;
|
||||
|
||||
if (!(path = _join(mem, dir, dirent[i]->d_name))) {
|
||||
if (!(path = _join_file_to_dir(mem, dir, dirent[i]->d_name))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ static struct list *_scan_archive(struct dm_pool *mem,
|
||||
/*
|
||||
* Insert it to the correct part of the list.
|
||||
*/
|
||||
_insert_file(results, af);
|
||||
_insert_archive_file(results, af);
|
||||
}
|
||||
|
||||
out:
|
||||
@@ -328,7 +328,7 @@ static void _display_archive(struct cmd_context *cmd, struct archive_file *af)
|
||||
}
|
||||
|
||||
log_print("VG name: \t%s", vg->name);
|
||||
log_print("Description:\t%s", desc ? desc : "<No description>");
|
||||
log_print("Description:\t%s", desc ? : "<No description>");
|
||||
log_print("Backup Time:\t%s", ctime(&when));
|
||||
|
||||
dm_pool_free(cmd->mem, vg);
|
||||
@@ -360,7 +360,7 @@ int backup_list(struct cmd_context *cmd, const char *dir, const char *vgname)
|
||||
{
|
||||
struct archive_file af;
|
||||
|
||||
if (!(af.path = _join(cmd->mem, dir, vgname))) {
|
||||
if (!(af.path = _join_file_to_dir(cmd->mem, dir, vgname))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,8 @@ static int _out_with_comment_file(struct formatter *f, const char *comment,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _out_with_comment_raw(struct formatter *f, const char *comment,
|
||||
static int _out_with_comment_raw(struct formatter *f,
|
||||
const char *comment __attribute((unused)),
|
||||
const char *fmt, va_list ap)
|
||||
{
|
||||
int n;
|
||||
@@ -281,7 +282,7 @@ int out_text(struct formatter *f, const char *fmt, ...)
|
||||
}
|
||||
|
||||
static int _print_header(struct formatter *f,
|
||||
struct volume_group *vg, const char *desc)
|
||||
const char *desc)
|
||||
{
|
||||
time_t t;
|
||||
|
||||
@@ -354,8 +355,7 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
|
||||
* Get the pv%d name from the formatters hash
|
||||
* table.
|
||||
*/
|
||||
static inline const char *_get_pv_name(struct formatter *f,
|
||||
struct physical_volume *pv)
|
||||
static const char *_get_pv_name(struct formatter *f, struct physical_volume *pv)
|
||||
{
|
||||
return (pv) ? (const char *)
|
||||
dm_hash_lookup(f->pv_names, dev_name(pv->dev)) : "Missing";
|
||||
@@ -613,46 +613,27 @@ static int _build_pv_names(struct formatter *f, struct volume_group *vg)
|
||||
struct physical_volume *pv;
|
||||
char buffer[32], *name;
|
||||
|
||||
if (!(f->mem = dm_pool_create("text pv_names", 512))) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
if (!(f->mem = dm_pool_create("text pv_names", 512)))
|
||||
return_0;
|
||||
|
||||
if (!(f->pv_names = dm_hash_create(128))) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
if (!(f->pv_names = dm_hash_create(128)))
|
||||
return_0;
|
||||
|
||||
list_iterate_items(pvl, &vg->pvs) {
|
||||
pv = pvl->pv;
|
||||
|
||||
/* FIXME But skip if there's already an LV called pv%d ! */
|
||||
if (lvm_snprintf(buffer, sizeof(buffer), "pv%d", count++) < 0) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
if (lvm_snprintf(buffer, sizeof(buffer), "pv%d", count++) < 0)
|
||||
return_0;
|
||||
|
||||
if (!(name = dm_pool_strdup(f->mem, buffer))) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
if (!(name = dm_pool_strdup(f->mem, buffer)))
|
||||
return_0;
|
||||
|
||||
if (!dm_hash_insert(f->pv_names, dev_name(pv->dev), name)) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
if (!dm_hash_insert(f->pv_names, dev_name(pv->dev), name))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
bad:
|
||||
if (f->mem)
|
||||
dm_pool_destroy(f->mem);
|
||||
|
||||
if (f->pv_names)
|
||||
dm_hash_destroy(f->pv_names);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _text_vg_export(struct formatter *f,
|
||||
@@ -664,35 +645,33 @@ static int _text_vg_export(struct formatter *f,
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
#define fail do {stack; goto out;} while(0)
|
||||
|
||||
if (f->header && !_print_header(f, vg, desc))
|
||||
fail;
|
||||
if (f->header && !_print_header(f, desc))
|
||||
goto_out;
|
||||
|
||||
if (!out_text(f, "%s {", vg->name))
|
||||
fail;
|
||||
goto_out;
|
||||
|
||||
_inc_indent(f);
|
||||
|
||||
if (!_print_vg(f, vg))
|
||||
fail;
|
||||
goto_out;
|
||||
|
||||
outnl(f);
|
||||
if (!_print_pvs(f, vg))
|
||||
fail;
|
||||
goto_out;
|
||||
|
||||
outnl(f);
|
||||
if (!_print_lvs(f, vg))
|
||||
fail;
|
||||
goto_out;
|
||||
|
||||
_dec_indent(f);
|
||||
if (!out_text(f, "}"))
|
||||
fail;
|
||||
goto_out;
|
||||
|
||||
if (!f->header && !_print_header(f, vg, desc))
|
||||
fail;
|
||||
if (!f->header && !_print_header(f, desc))
|
||||
goto_out;
|
||||
|
||||
#undef fail
|
||||
r = 1;
|
||||
|
||||
out:
|
||||
|
||||
@@ -53,6 +53,7 @@ static struct flag _lv_flags[] = {
|
||||
{VISIBLE_LV, "VISIBLE"},
|
||||
{PVMOVE, "PVMOVE"},
|
||||
{LOCKED, "LOCKED"},
|
||||
{MIRROR_NOTSYNCED, "NOTSYNCED"},
|
||||
{MIRROR_IMAGE, NULL},
|
||||
{MIRROR_LOG, NULL},
|
||||
{MIRRORED, NULL},
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#define FMT_TEXT_NAME "lvm2"
|
||||
#define FMT_TEXT_ALIAS "text"
|
||||
|
||||
static struct format_instance *_create_text_instance(const struct format_type
|
||||
static struct format_instance *_text_create_text_instance(const struct format_type
|
||||
*fmt, const char *vgname,
|
||||
const char *vgid,
|
||||
void *context);
|
||||
@@ -69,7 +69,8 @@ struct text_context {
|
||||
* NOTE: Currently there can be only one vg per text file.
|
||||
*/
|
||||
|
||||
static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
static int _text_vg_setup(struct format_instance *fid __attribute((unused)),
|
||||
struct volume_group *vg)
|
||||
{
|
||||
if (vg->extent_size & (vg->extent_size - 1)) {
|
||||
log_error("Extent size must be power of 2");
|
||||
@@ -79,13 +80,14 @@ static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
|
||||
static int _text_lv_setup(struct format_instance *fid __attribute((unused)),
|
||||
struct logical_volume *lv)
|
||||
{
|
||||
/******** FIXME Any LV size restriction?
|
||||
uint64_t max_size = UINT_MAX;
|
||||
|
||||
if (lv->size > max_size) {
|
||||
char *dummy = display_size(max_size, SIZE_SHORT);
|
||||
char *dummy = display_size(max_size);
|
||||
log_error("logical volumes cannot be larger than %s", dummy);
|
||||
dm_free(dummy);
|
||||
return 0;
|
||||
@@ -143,7 +145,7 @@ static struct mda_header *_raw_read_mda_header(const struct format_type *fmt,
|
||||
|
||||
_xlate_mdah(mdah);
|
||||
|
||||
if (strncmp(mdah->magic, FMTT_MAGIC, sizeof(mdah->magic))) {
|
||||
if (strncmp((char *)mdah->magic, FMTT_MAGIC, sizeof(mdah->magic))) {
|
||||
log_error("Wrong magic number in metadata area header");
|
||||
return NULL;
|
||||
}
|
||||
@@ -167,7 +169,7 @@ static int _raw_write_mda_header(const struct format_type *fmt,
|
||||
struct device *dev,
|
||||
uint64_t start_byte, struct mda_header *mdah)
|
||||
{
|
||||
strncpy(mdah->magic, FMTT_MAGIC, sizeof(mdah->magic));
|
||||
strncpy((char *)mdah->magic, FMTT_MAGIC, sizeof(mdah->magic));
|
||||
mdah->version = FMTT_VERSION;
|
||||
mdah->start = start_byte;
|
||||
|
||||
@@ -859,7 +861,7 @@ static int _scan_file(const struct format_type *fmt)
|
||||
}
|
||||
|
||||
/* FIXME stat file to see if it's changed */
|
||||
fid = _create_text_instance(fmt, NULL, NULL,
|
||||
fid = _text_create_text_instance(fmt, NULL, NULL,
|
||||
NULL);
|
||||
if ((vg = _vg_read_file_name(fid, vgname,
|
||||
path)))
|
||||
@@ -884,6 +886,7 @@ const char *vgname_from_mda(const struct format_type *fmt,
|
||||
const char *vgname = NULL;
|
||||
unsigned int len = 0;
|
||||
char buf[NAME_LEN + 1];
|
||||
char uuid[64];
|
||||
|
||||
if (!dev_open(dev_area->dev)) {
|
||||
stack;
|
||||
@@ -939,10 +942,16 @@ const char *vgname_from_mda(const struct format_type *fmt,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!id_write_format(vgid, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
vgname = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
log_debug("%s: Found metadata at %" PRIu64 " size %" PRIu64
|
||||
" for %s (%s)",
|
||||
dev_name(dev_area->dev), dev_area->start + rlocn->offset,
|
||||
rlocn->size, vgname, vgid->uuid);
|
||||
rlocn->size, vgname, uuid);
|
||||
|
||||
out:
|
||||
if (!dev_close(dev_area->dev))
|
||||
@@ -979,7 +988,7 @@ static int _scan_raw(const struct format_type *fmt)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _scan(const struct format_type *fmt)
|
||||
static int _text_scan(const struct format_type *fmt)
|
||||
{
|
||||
return (_scan_file(fmt) & _scan_raw(fmt));
|
||||
}
|
||||
@@ -1064,9 +1073,9 @@ static int _mda_setup(const struct format_type *fmt,
|
||||
if (!add_mda(fmt, fmt->cmd->mem, mdas, pv->dev, start1,
|
||||
mda_size1)) return 0;
|
||||
|
||||
if (!dev_zero((struct device *) pv->dev, start1,
|
||||
(size_t) (mda_size1 >
|
||||
wipe_size ? wipe_size : mda_size1))) {
|
||||
if (!dev_set((struct device *) pv->dev, start1,
|
||||
(size_t) (mda_size1 >
|
||||
wipe_size ? : mda_size1), 0)) {
|
||||
log_error("Failed to wipe new metadata area");
|
||||
return 0;
|
||||
}
|
||||
@@ -1110,9 +1119,9 @@ static int _mda_setup(const struct format_type *fmt,
|
||||
if (mda_size2) {
|
||||
if (!add_mda(fmt, fmt->cmd->mem, mdas, pv->dev, start2,
|
||||
mda_size2)) return 0;
|
||||
if (!dev_zero(pv->dev, start2,
|
||||
(size_t) (mda_size1 >
|
||||
wipe_size ? wipe_size : mda_size1))) {
|
||||
if (!dev_set(pv->dev, start2,
|
||||
(size_t) (mda_size1 >
|
||||
wipe_size ? : mda_size1), 0)) {
|
||||
log_error("Failed to wipe new metadata area");
|
||||
return 0;
|
||||
}
|
||||
@@ -1125,7 +1134,7 @@ static int _mda_setup(const struct format_type *fmt,
|
||||
|
||||
/* Only for orphans */
|
||||
/* Set label_sector to -1 if rewriting existing label into same sector */
|
||||
static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
|
||||
static int _text_pv_write(const struct format_type *fmt, struct physical_volume *pv,
|
||||
struct list *mdas, int64_t label_sector)
|
||||
{
|
||||
struct label *label;
|
||||
@@ -1195,7 +1204,7 @@ static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
|
||||
}
|
||||
}
|
||||
if (!add_da
|
||||
(fmt, NULL, &info->das, pv->pe_start << SECTOR_SHIFT, UINT64_C(0))) {
|
||||
(NULL, &info->das, pv->pe_start << SECTOR_SHIFT, UINT64_C(0))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@@ -1250,7 +1259,7 @@ static int _add_raw(struct list *raw_list, struct device_area *dev_area)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
struct physical_volume *pv, struct list *mdas)
|
||||
{
|
||||
struct label *label;
|
||||
@@ -1332,7 +1341,7 @@ static int _pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _destroy_instance(struct format_instance *fid)
|
||||
static void _text_destroy_instance(struct format_instance *fid __attribute((unused)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1357,7 +1366,7 @@ static void _free_raws(struct list *raw_list)
|
||||
}
|
||||
}
|
||||
|
||||
static void _destroy(const struct format_type *fmt)
|
||||
static void _text_destroy(const struct format_type *fmt)
|
||||
{
|
||||
if (fmt->private) {
|
||||
_free_dirs(&((struct mda_lists *) fmt->private)->dirs);
|
||||
@@ -1365,36 +1374,36 @@ static void _destroy(const struct format_type *fmt)
|
||||
dm_free(fmt->private);
|
||||
}
|
||||
|
||||
dm_free((void *) fmt);
|
||||
dm_free((void *)fmt);
|
||||
}
|
||||
|
||||
static struct metadata_area_ops _metadata_text_file_ops = {
|
||||
vg_read:_vg_read_file,
|
||||
vg_read_precommit:_vg_read_precommit_file,
|
||||
vg_write:_vg_write_file,
|
||||
vg_remove:_vg_remove_file,
|
||||
vg_commit:_vg_commit_file
|
||||
.vg_read = _vg_read_file,
|
||||
.vg_read_precommit = _vg_read_precommit_file,
|
||||
.vg_write = _vg_write_file,
|
||||
.vg_remove = _vg_remove_file,
|
||||
.vg_commit = _vg_commit_file
|
||||
};
|
||||
|
||||
static struct metadata_area_ops _metadata_text_file_backup_ops = {
|
||||
vg_read:_vg_read_file,
|
||||
vg_write:_vg_write_file,
|
||||
vg_remove:_vg_remove_file,
|
||||
vg_commit:_vg_commit_file_backup
|
||||
.vg_read = _vg_read_file,
|
||||
.vg_write = _vg_write_file,
|
||||
.vg_remove = _vg_remove_file,
|
||||
.vg_commit = _vg_commit_file_backup
|
||||
};
|
||||
|
||||
static struct metadata_area_ops _metadata_text_raw_ops = {
|
||||
vg_read:_vg_read_raw,
|
||||
vg_read_precommit:_vg_read_precommit_raw,
|
||||
vg_write:_vg_write_raw,
|
||||
vg_remove:_vg_remove_raw,
|
||||
vg_precommit:_vg_precommit_raw,
|
||||
vg_commit:_vg_commit_raw,
|
||||
vg_revert:_vg_revert_raw
|
||||
.vg_read = _vg_read_raw,
|
||||
.vg_read_precommit = _vg_read_precommit_raw,
|
||||
.vg_write = _vg_write_raw,
|
||||
.vg_remove = _vg_remove_raw,
|
||||
.vg_precommit = _vg_precommit_raw,
|
||||
.vg_commit = _vg_commit_raw,
|
||||
.vg_revert = _vg_revert_raw
|
||||
};
|
||||
|
||||
/* pvmetadatasize in sectors */
|
||||
static int _pv_setup(const struct format_type *fmt,
|
||||
static int _text_pv_setup(const struct format_type *fmt,
|
||||
uint64_t pe_start, uint32_t extent_count,
|
||||
uint32_t extent_size,
|
||||
int pvmetadatacopies,
|
||||
@@ -1411,7 +1420,7 @@ static int _pv_setup(const struct format_type *fmt,
|
||||
/* FIXME if vg, adjust start/end of pe area to avoid mdas! */
|
||||
|
||||
/* FIXME Cope with pvchange */
|
||||
/* FIXME Merge code with _create_text_instance */
|
||||
/* FIXME Merge code with _text_create_text_instance */
|
||||
|
||||
/* If new vg, add any further mdas on this PV to the fid's mda list */
|
||||
if (vg) {
|
||||
@@ -1479,7 +1488,7 @@ static int _pv_setup(const struct format_type *fmt,
|
||||
}
|
||||
|
||||
/* NULL vgname means use only the supplied context e.g. an archive file */
|
||||
static struct format_instance *_create_text_instance(const struct format_type
|
||||
static struct format_instance *_text_create_text_instance(const struct format_type
|
||||
*fmt, const char *vgname,
|
||||
const char *vgid,
|
||||
void *context)
|
||||
@@ -1649,15 +1658,15 @@ void *create_text_context(struct cmd_context *cmd, const char *path,
|
||||
}
|
||||
|
||||
static struct format_handler _text_handler = {
|
||||
scan:_scan,
|
||||
pv_read:_pv_read,
|
||||
pv_setup:_pv_setup,
|
||||
pv_write:_pv_write,
|
||||
vg_setup:_vg_setup,
|
||||
lv_setup:_lv_setup,
|
||||
create_instance:_create_text_instance,
|
||||
destroy_instance:_destroy_instance,
|
||||
destroy:_destroy
|
||||
.scan = _text_scan,
|
||||
.pv_read = _text_pv_read,
|
||||
.pv_setup = _text_pv_setup,
|
||||
.pv_write = _text_pv_write,
|
||||
.vg_setup = _text_vg_setup,
|
||||
.lv_setup = _text_lv_setup,
|
||||
.create_instance = _text_create_text_instance,
|
||||
.destroy_instance = _text_destroy_instance,
|
||||
.destroy = _text_destroy
|
||||
};
|
||||
|
||||
static int _add_dir(const char *dir, struct list *dir_list)
|
||||
@@ -1747,10 +1756,12 @@ struct format_type *create_text_format(struct cmd_context *cmd)
|
||||
fmt->name = FMT_TEXT_NAME;
|
||||
fmt->alias = FMT_TEXT_ALIAS;
|
||||
fmt->features = FMT_SEGMENTS | FMT_MDAS | FMT_TAGS | FMT_PRECOMMIT |
|
||||
FMT_UNLIMITED_VOLS | FMT_RESIZE_PV;
|
||||
FMT_UNLIMITED_VOLS | FMT_RESIZE_PV |
|
||||
FMT_UNLIMITED_STRIPESIZE;
|
||||
|
||||
if (!(mda_lists = dm_malloc(sizeof(struct mda_lists)))) {
|
||||
log_error("Failed to allocate dir_list");
|
||||
dm_free(fmt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1762,15 +1773,17 @@ struct format_type *create_text_format(struct cmd_context *cmd)
|
||||
|
||||
if (!(fmt->labeller = text_labeller_create(fmt))) {
|
||||
log_error("Couldn't create text label handler.");
|
||||
dm_free(fmt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(label_register_handler(FMT_TEXT_NAME, fmt->labeller))) {
|
||||
log_error("Couldn't register text label handler.");
|
||||
dm_free(fmt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((cn = find_config_node(cmd->cft->root, "metadata/dirs"))) {
|
||||
if ((cn = find_config_tree_node(cmd, "metadata/dirs"))) {
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
if (cv->type != CFG_STRING) {
|
||||
log_error("Invalid string in config file: "
|
||||
@@ -1786,7 +1799,7 @@ struct format_type *create_text_format(struct cmd_context *cmd)
|
||||
}
|
||||
}
|
||||
|
||||
if ((cn = find_config_node(cmd->cft->root, "metadata/disk_areas"))) {
|
||||
if ((cn = find_config_tree_node(cmd, "metadata/disk_areas"))) {
|
||||
for (cn = cn->child; cn; cn = cn->sib) {
|
||||
if (!_get_config_disk_area(cmd, cn, &mda_lists->raws))
|
||||
goto err;
|
||||
|
||||
@@ -46,7 +46,7 @@ struct labeller *text_labeller_create(const struct format_type *fmt);
|
||||
|
||||
int pvhdr_read(struct device *dev, char *buf);
|
||||
|
||||
int add_da(const struct format_type *fmt, struct dm_pool *mem, struct list *das,
|
||||
int add_da(struct dm_pool *mem, struct list *das,
|
||||
uint64_t start, uint64_t size);
|
||||
void del_das(struct list *das);
|
||||
|
||||
|
||||
@@ -33,18 +33,18 @@ const char *text_vgname_import(const struct format_type *fmt,
|
||||
{
|
||||
struct config_tree *cft;
|
||||
struct text_vg_version_ops **vsn;
|
||||
const char *vgname;
|
||||
const char *vgname = NULL;
|
||||
|
||||
static int _initialised = 0;
|
||||
static int _text_import_initialised = 0;
|
||||
|
||||
if (!_initialised) {
|
||||
if (!_text_import_initialised) {
|
||||
_text_vsn_list[0] = text_vg_vsn1_init();
|
||||
_text_vsn_list[1] = NULL;
|
||||
_initialised = 1;
|
||||
_text_import_initialised = 1;
|
||||
}
|
||||
|
||||
if (!(cft = create_config_tree(NULL)))
|
||||
goto_out;
|
||||
return_NULL;
|
||||
|
||||
if ((!dev && !read_config_file(cft)) ||
|
||||
(dev && !read_config_fd(cft, dev, offset, size,
|
||||
@@ -83,21 +83,19 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
|
||||
struct config_tree *cft;
|
||||
struct text_vg_version_ops **vsn;
|
||||
|
||||
static int _initialised = 0;
|
||||
static int _text_vg_import_initialised = 0;
|
||||
|
||||
if (!_initialised) {
|
||||
if (!_text_vg_import_initialised) {
|
||||
_text_vsn_list[0] = text_vg_vsn1_init();
|
||||
_text_vsn_list[1] = NULL;
|
||||
_initialised = 1;
|
||||
_text_vg_import_initialised = 1;
|
||||
}
|
||||
|
||||
*desc = NULL;
|
||||
*when = 0;
|
||||
|
||||
if (!(cft = create_config_tree(file))) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
if (!(cft = create_config_tree(file)))
|
||||
return_NULL;
|
||||
|
||||
if ((!dev && !read_config_file(cft)) ||
|
||||
(dev && !read_config_fd(cft, dev, offset, size,
|
||||
@@ -131,6 +129,6 @@ struct volume_group *text_vg_import_file(struct format_instance *fid,
|
||||
const char *file,
|
||||
time_t *when, char **desc)
|
||||
{
|
||||
return text_vg_import_fd(fid, file, NULL, 0, 0, 0, 0, NULL, 0,
|
||||
return text_vg_import_fd(fid, file, NULL, (off_t)0, 0, (off_t)0, 0, NULL, 0,
|
||||
when, desc);
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ int text_import_areas(struct lv_segment *seg, const struct config_node *sn,
|
||||
} else {
|
||||
log_error("Couldn't find volume '%s' "
|
||||
"for segment '%s'.",
|
||||
cv->v.str ? cv->v.str : "NULL", seg_name);
|
||||
cv->v.str ? : "NULL", seg_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -849,13 +849,13 @@ static const char *_read_vgname(const struct format_type *fmt,
|
||||
}
|
||||
|
||||
static struct text_vg_version_ops _vsn1_ops = {
|
||||
check_version:_check_version,
|
||||
read_vg:_read_vg,
|
||||
read_desc:_read_desc,
|
||||
read_vgname:_read_vgname
|
||||
.check_version = _check_version,
|
||||
.read_vg = _read_vg,
|
||||
.read_desc = _read_desc,
|
||||
.read_vgname = _read_vgname,
|
||||
};
|
||||
|
||||
struct text_vg_version_ops *text_vg_vsn1_init(void)
|
||||
{
|
||||
return &_vsn1_ops;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ struct data_area_list {
|
||||
/* Fields with the suffix _xl should be xlate'd wherever they appear */
|
||||
/* On disk */
|
||||
struct pv_header {
|
||||
uint8_t pv_uuid[ID_LEN];
|
||||
int8_t pv_uuid[ID_LEN];
|
||||
|
||||
/* This size can be overridden if PV belongs to a VG */
|
||||
uint64_t device_size_xl; /* Bytes */
|
||||
@@ -58,7 +58,7 @@ struct raw_locn {
|
||||
/* Structure size limited to one sector */
|
||||
struct mda_header {
|
||||
uint32_t checksum_xl; /* Checksum of rest of mda_header */
|
||||
uint8_t magic[16]; /* To aid scans for metadata */
|
||||
int8_t magic[16]; /* To aid scans for metadata */
|
||||
uint32_t version;
|
||||
uint64_t start; /* Absolute start byte of mda_header */
|
||||
uint64_t size; /* Size of metadata area */
|
||||
@@ -83,6 +83,6 @@ struct mda_context {
|
||||
#define FMTT_VERSION 1
|
||||
#define MDA_HEADER_SIZE 512
|
||||
#define LVM2_LABEL "LVM2 001"
|
||||
#define MDA_SIZE_MIN (8 * getpagesize())
|
||||
#define MDA_SIZE_MIN (8 * (unsigned) getpagesize())
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,17 +23,19 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
static int _can_handle(struct labeller *l, char *buf, uint64_t sector)
|
||||
static int _text_can_handle(struct labeller *l __attribute((unused)),
|
||||
char *buf,
|
||||
uint64_t sector __attribute((unused)))
|
||||
{
|
||||
struct label_header *lh = (struct label_header *) buf;
|
||||
|
||||
if (!strncmp(lh->type, LVM2_LABEL, sizeof(lh->type)))
|
||||
if (!strncmp((char *)lh->type, LVM2_LABEL, sizeof(lh->type)))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _write(struct label *label, char *buf)
|
||||
static int _text_write(struct label *label, char *buf)
|
||||
{
|
||||
struct label_header *lh = (struct label_header *) buf;
|
||||
struct pv_header *pvhdr;
|
||||
@@ -46,7 +48,7 @@ static int _write(struct label *label, char *buf)
|
||||
/* FIXME Move to where label is created */
|
||||
strncpy(label->type, LVM2_LABEL, sizeof(label->type));
|
||||
|
||||
strncpy(lh->type, label->type, sizeof(label->type));
|
||||
strncpy((char *)lh->type, label->type, sizeof(label->type));
|
||||
|
||||
pvhdr = (struct pv_header *) ((void *) buf + xlate32(lh->offset_xl));
|
||||
info = (struct lvmcache_info *) label->info;
|
||||
@@ -86,7 +88,7 @@ static int _write(struct label *label, char *buf)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int add_da(const struct format_type *fmt, struct dm_pool *mem, struct list *das,
|
||||
int add_da(struct dm_pool *mem, struct list *das,
|
||||
uint64_t start, uint64_t size)
|
||||
{
|
||||
struct data_area_list *dal;
|
||||
@@ -179,14 +181,15 @@ void del_mdas(struct list *mdas)
|
||||
}
|
||||
}
|
||||
|
||||
static int _initialise_label(struct labeller *l, struct label *label)
|
||||
static int _text_initialise_label(struct labeller *l __attribute((unused)),
|
||||
struct label *label)
|
||||
{
|
||||
strncpy(label->type, LVM2_LABEL, sizeof(label->type));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _read(struct labeller *l, struct device *dev, char *buf,
|
||||
static int _text_read(struct labeller *l, struct device *dev, char *buf,
|
||||
struct label **label)
|
||||
{
|
||||
struct label_header *lh = (struct label_header *) buf;
|
||||
@@ -203,7 +206,7 @@ static int _read(struct labeller *l, struct device *dev, char *buf,
|
||||
|
||||
pvhdr = (struct pv_header *) ((void *) buf + xlate32(lh->offset_xl));
|
||||
|
||||
if (!(info = lvmcache_add(l, pvhdr->pv_uuid, dev, NULL, NULL, 0)))
|
||||
if (!(info = lvmcache_add(l, (char *)pvhdr->pv_uuid, dev, NULL, NULL, 0)))
|
||||
return_0;
|
||||
*label = info->label;
|
||||
|
||||
@@ -220,7 +223,7 @@ static int _read(struct labeller *l, struct device *dev, char *buf,
|
||||
/* Data areas holding the PEs */
|
||||
dlocn_xl = pvhdr->disk_areas_xl;
|
||||
while ((offset = xlate64(dlocn_xl->offset))) {
|
||||
add_da(info->fmt, NULL, &info->das, offset,
|
||||
add_da(NULL, &info->das, offset,
|
||||
xlate64(dlocn_xl->size));
|
||||
dlocn_xl++;
|
||||
}
|
||||
@@ -248,7 +251,8 @@ static int _read(struct labeller *l, struct device *dev, char *buf,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _destroy_label(struct labeller *l, struct label *label)
|
||||
static void _text_destroy_label(struct labeller *l __attribute((unused)),
|
||||
struct label *label)
|
||||
{
|
||||
struct lvmcache_info *info = (struct lvmcache_info *) label->info;
|
||||
|
||||
@@ -258,19 +262,19 @@ static void _destroy_label(struct labeller *l, struct label *label)
|
||||
del_das(&info->das);
|
||||
}
|
||||
|
||||
static void _destroy(struct labeller *l)
|
||||
static void _fmt_text_destroy(struct labeller *l)
|
||||
{
|
||||
dm_free(l);
|
||||
}
|
||||
|
||||
struct label_ops _text_ops = {
|
||||
can_handle:_can_handle,
|
||||
write:_write,
|
||||
read:_read,
|
||||
verify:_can_handle,
|
||||
initialise_label:_initialise_label,
|
||||
destroy_label:_destroy_label,
|
||||
destroy:_destroy
|
||||
.can_handle = _text_can_handle,
|
||||
.write = _text_write,
|
||||
.read = _text_read,
|
||||
.verify = _text_can_handle,
|
||||
.initialise_label = _text_initialise_label,
|
||||
.destroy_label = _text_destroy_label,
|
||||
.destroy = _fmt_text_destroy,
|
||||
};
|
||||
|
||||
struct labeller *text_labeller_create(const struct format_type *fmt)
|
||||
|
||||
@@ -128,7 +128,7 @@ static struct labeller *_find_labeller(struct device *dev, char *buf,
|
||||
lh = (struct label_header *) (readbuf +
|
||||
(sector << SECTOR_SHIFT));
|
||||
|
||||
if (!strncmp(lh->id, LABEL_ID, sizeof(lh->id))) {
|
||||
if (!strncmp((char *)lh->id, LABEL_ID, sizeof(lh->id))) {
|
||||
if (found) {
|
||||
log_error("Ignoring additional label on %s at "
|
||||
"sector %" PRIu64, dev_name(dev),
|
||||
@@ -222,7 +222,7 @@ int label_remove(struct device *dev)
|
||||
|
||||
wipe = 0;
|
||||
|
||||
if (!strncmp(lh->id, LABEL_ID, sizeof(lh->id))) {
|
||||
if (!strncmp((char *)lh->id, LABEL_ID, sizeof(lh->id))) {
|
||||
if (xlate64(lh->sector_xl) == sector)
|
||||
wipe = 1;
|
||||
} else {
|
||||
@@ -271,7 +271,7 @@ int label_read(struct device *dev, struct label **result)
|
||||
lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN,
|
||||
0, NULL);
|
||||
|
||||
goto out;
|
||||
return r;
|
||||
}
|
||||
|
||||
if (!(l = _find_labeller(dev, buf, §or)))
|
||||
@@ -307,7 +307,7 @@ int label_write(struct device *dev, struct label *label)
|
||||
|
||||
memset(buf, 0, LABEL_SIZE);
|
||||
|
||||
strncpy(lh->id, LABEL_ID, sizeof(lh->id));
|
||||
strncpy((char *)lh->id, LABEL_ID, sizeof(lh->id));
|
||||
lh->sector_xl = xlate64(label->sector);
|
||||
lh->offset_xl = xlate32(sizeof(*lh));
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ struct labeller;
|
||||
|
||||
/* On disk - 32 bytes */
|
||||
struct label_header {
|
||||
uint8_t id[8]; /* LABELONE */
|
||||
int8_t id[8]; /* LABELONE */
|
||||
uint64_t sector_xl; /* Sector number of this label */
|
||||
uint32_t crc_xl; /* From next field to end of sector */
|
||||
uint32_t offset_xl; /* Offset from start of struct to contents */
|
||||
uint8_t type[8]; /* LVM2 001 */
|
||||
int8_t type[8]; /* LVM2 001 */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* In core */
|
||||
|
||||
@@ -256,7 +256,7 @@ static int _cluster_request(char cmd, const char *node, void *data, int len,
|
||||
strcpy(rarray[i].node, inptr);
|
||||
inptr += strlen(inptr) + 1;
|
||||
|
||||
rarray[i].status = *(int *) inptr;
|
||||
memcpy(&rarray[i].status, inptr, sizeof(int));
|
||||
inptr += sizeof(int);
|
||||
|
||||
rarray[i].response = dm_malloc(strlen(inptr) + 1);
|
||||
@@ -333,6 +333,12 @@ static int _lock_for_cluster(unsigned char cmd, unsigned int flags, char *name)
|
||||
if (partial_mode())
|
||||
args[1] |= LCK_PARTIAL_MODE;
|
||||
|
||||
if (mirror_in_sync())
|
||||
args[1] |= LCK_MIRROR_NOSYNC_MODE;
|
||||
|
||||
if (dmeventd_register_mode())
|
||||
args[1] |= LCK_DMEVENTD_REGISTER_MODE;
|
||||
|
||||
/*
|
||||
* VG locks are just that: locks, and have no side effects
|
||||
* so we only need to do them on the local node because all
|
||||
@@ -386,11 +392,12 @@ int lock_resource(struct cmd_context *cmd, const char *resource, int flags)
|
||||
int cluster_cmd = 0;
|
||||
|
||||
assert(strlen(resource) < sizeof(lockname));
|
||||
assert(resource);
|
||||
|
||||
switch (flags & LCK_SCOPE_MASK) {
|
||||
case LCK_VG:
|
||||
/* If the VG name is empty then lock the unused PVs */
|
||||
if (!resource || !*resource)
|
||||
if (!*resource)
|
||||
lvm_snprintf(lockname, sizeof(lockname), "P_orphans");
|
||||
else
|
||||
lvm_snprintf(lockname, sizeof(lockname), "V_%s",
|
||||
@@ -445,7 +452,7 @@ void reset_locking(void)
|
||||
}
|
||||
|
||||
#ifdef CLUSTER_LOCKING_INTERNAL
|
||||
int init_cluster_locking(struct locking_type *locking, struct config_tree *cft)
|
||||
int init_cluster_locking(struct locking_type *locking, struct cmd_context *cmd)
|
||||
{
|
||||
locking->lock_resource = _lock_resource;
|
||||
locking->fin_locking = _locking_end;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "locking_types.h"
|
||||
#include "defaults.h"
|
||||
#include "sharedlib.h"
|
||||
#include "toolcontext.h"
|
||||
|
||||
static void *_locking_lib = NULL;
|
||||
static void (*_reset_fn) (void) = NULL;
|
||||
@@ -55,7 +56,7 @@ static void _reset_external_locking(void)
|
||||
_reset_fn();
|
||||
}
|
||||
|
||||
int init_external_locking(struct locking_type *locking, struct config_tree *cft)
|
||||
int init_external_locking(struct locking_type *locking, struct cmd_context *cmd)
|
||||
{
|
||||
const char *libname;
|
||||
|
||||
@@ -69,10 +70,10 @@ int init_external_locking(struct locking_type *locking, struct config_tree *cft)
|
||||
locking->reset_locking = _reset_external_locking;
|
||||
locking->flags = 0;
|
||||
|
||||
libname = find_config_str(cft->root, "global/locking_library",
|
||||
DEFAULT_LOCKING_LIB);
|
||||
libname = find_config_tree_str(cmd, "global/locking_library",
|
||||
DEFAULT_LOCKING_LIB);
|
||||
|
||||
if (!(_locking_lib = load_shared_library(cft, libname, "locking", 1))) {
|
||||
if (!(_locking_lib = load_shared_library(cmd, libname, "locking", 1))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@@ -90,5 +91,5 @@ int init_external_locking(struct locking_type *locking, struct config_tree *cft)
|
||||
}
|
||||
|
||||
log_verbose("Loaded external locking library %s", libname);
|
||||
return _init_fn(2, cft, &locking->flags);
|
||||
return _init_fn(2, cmd->cft, &locking->flags);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ static void _remove_ctrl_c_handler()
|
||||
log_sys_error("signal", "_remove_ctrl_c_handler");
|
||||
}
|
||||
|
||||
static void _trap_ctrl_c(int sig)
|
||||
static void _trap_ctrl_c(int sig __attribute((unused)))
|
||||
{
|
||||
_remove_ctrl_c_handler();
|
||||
log_error("CTRL-c detected: giving up waiting for lock");
|
||||
@@ -207,9 +207,11 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
|
||||
{
|
||||
char lockfile[PATH_MAX];
|
||||
|
||||
assert(resource);
|
||||
|
||||
switch (flags & LCK_SCOPE_MASK) {
|
||||
case LCK_VG:
|
||||
if (!resource || !*resource)
|
||||
if (!*resource)
|
||||
lvm_snprintf(lockfile, sizeof(lockfile),
|
||||
"%s/P_orphans", _lock_dir);
|
||||
else
|
||||
@@ -269,7 +271,7 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int init_file_locking(struct locking_type *locking, struct config_tree *cft)
|
||||
int init_file_locking(struct locking_type *locking, struct cmd_context *cmd)
|
||||
{
|
||||
locking->lock_resource = _file_lock_resource;
|
||||
locking->reset_locking = _reset_file_locking;
|
||||
@@ -277,8 +279,8 @@ int init_file_locking(struct locking_type *locking, struct config_tree *cft)
|
||||
locking->flags = 0;
|
||||
|
||||
/* Get lockfile directory from config file */
|
||||
strncpy(_lock_dir, find_config_str(cft->root, "global/locking_dir",
|
||||
DEFAULT_LOCK_DIR),
|
||||
strncpy(_lock_dir, find_config_tree_str(cmd, "global/locking_dir",
|
||||
DEFAULT_LOCK_DIR),
|
||||
sizeof(_lock_dir));
|
||||
|
||||
if (!create_dir(_lock_dir))
|
||||
|
||||
@@ -33,7 +33,7 @@ static int _vg_lock_count = 0; /* Number of locks held */
|
||||
static int _vg_write_lock_held = 0; /* VG write lock held? */
|
||||
static int _signals_blocked = 0;
|
||||
|
||||
static void _block_signals(int flags)
|
||||
static void _block_signals(int flags __attribute((unused)))
|
||||
{
|
||||
sigset_t set;
|
||||
|
||||
@@ -102,7 +102,7 @@ void reset_locking(void)
|
||||
_unblock_signals();
|
||||
}
|
||||
|
||||
static inline void _update_vg_lock_count(int flags)
|
||||
static void _update_vg_lock_count(int flags)
|
||||
{
|
||||
if ((flags & LCK_SCOPE_MASK) != LCK_VG)
|
||||
return;
|
||||
@@ -122,26 +122,26 @@ static inline void _update_vg_lock_count(int flags)
|
||||
/*
|
||||
* Select a locking type
|
||||
*/
|
||||
int init_locking(int type, struct config_tree *cft)
|
||||
int init_locking(int type, struct cmd_context *cmd)
|
||||
{
|
||||
init_lockingfailed(0);
|
||||
|
||||
switch (type) {
|
||||
case 0:
|
||||
init_no_locking(&_locking, cft);
|
||||
init_no_locking(&_locking, cmd);
|
||||
log_print("WARNING: Locking disabled. Be careful! "
|
||||
"This could corrupt your metadata.");
|
||||
return 1;
|
||||
|
||||
case 1:
|
||||
if (!init_file_locking(&_locking, cft))
|
||||
if (!init_file_locking(&_locking, cmd))
|
||||
break;
|
||||
log_very_verbose("File-based locking enabled.");
|
||||
return 1;
|
||||
|
||||
#ifdef HAVE_LIBDL
|
||||
case 2:
|
||||
if (!init_external_locking(&_locking, cft))
|
||||
if (!init_external_locking(&_locking, cmd))
|
||||
break;
|
||||
log_very_verbose("External locking enabled.");
|
||||
return 1;
|
||||
@@ -149,7 +149,7 @@ int init_locking(int type, struct config_tree *cft)
|
||||
|
||||
#ifdef CLUSTER_LOCKING_INTERNAL
|
||||
case 3:
|
||||
if (!init_cluster_locking(&_locking, cft))
|
||||
if (!init_cluster_locking(&_locking, cmd))
|
||||
break;
|
||||
log_very_verbose("Cluster locking enabled.");
|
||||
return 1;
|
||||
@@ -166,7 +166,7 @@ int init_locking(int type, struct config_tree *cft)
|
||||
/* FIXME Ensure only read ops are permitted */
|
||||
log_verbose("Locking disabled - only read operations permitted.");
|
||||
|
||||
init_no_locking(&_locking, cft);
|
||||
init_no_locking(&_locking, cmd);
|
||||
init_lockingfailed(1);
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -13,10 +13,13 @@
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _LVM_LOCKING_H
|
||||
#define _LVM_LOCKING_H
|
||||
|
||||
#include "uuid.h"
|
||||
#include "config.h"
|
||||
|
||||
int init_locking(int type, struct config_tree *cf);
|
||||
int init_locking(int type, struct cmd_context *cmd);
|
||||
void fin_locking(void);
|
||||
void reset_locking(void);
|
||||
int vg_write_lock_held(void);
|
||||
@@ -71,6 +74,9 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
|
||||
* Additional lock bits for cluster communication
|
||||
*/
|
||||
#define LCK_PARTIAL_MODE 0x00000001 /* Running in partial mode */
|
||||
#define LCK_MIRROR_NOSYNC_MODE 0x00000002 /* Mirrors don't require sync */
|
||||
#define LCK_DMEVENTD_REGISTER_MODE 0x00000004 /* Register with dmeventd */
|
||||
|
||||
|
||||
/*
|
||||
* Common combinations
|
||||
@@ -109,3 +115,4 @@ int suspend_lvs(struct cmd_context *cmd, struct list *lvs);
|
||||
int resume_lvs(struct cmd_context *cmd, struct list *lvs);
|
||||
int activate_lvs_excl(struct cmd_context *cmd, struct list *lvs);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -36,10 +36,10 @@ struct locking_type {
|
||||
/*
|
||||
* Locking types
|
||||
*/
|
||||
int init_no_locking(struct locking_type *locking, struct config_tree *cf);
|
||||
int init_no_locking(struct locking_type *locking, struct cmd_context *cmd);
|
||||
|
||||
int init_file_locking(struct locking_type *locking, struct config_tree *cf);
|
||||
int init_file_locking(struct locking_type *locking, struct cmd_context *cmd);
|
||||
|
||||
int init_external_locking(struct locking_type *locking, struct config_tree *cf);
|
||||
int init_external_locking(struct locking_type *locking, struct cmd_context *cmd);
|
||||
|
||||
int init_cluster_locking(struct locking_type *locking, struct config_tree *cf);
|
||||
int init_cluster_locking(struct locking_type *locking, struct cmd_context *cmd);
|
||||
|
||||
@@ -76,7 +76,7 @@ static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int init_no_locking(struct locking_type *locking, struct config_tree *cft)
|
||||
int init_no_locking(struct locking_type *locking, struct cmd_context *cmd)
|
||||
{
|
||||
locking->lock_resource = _no_lock_resource;
|
||||
locking->reset_locking = _no_reset_locking;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "device.h"
|
||||
#include "memlock.h"
|
||||
#include "lvm-string.h"
|
||||
#include "defaults.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <syslog.h>
|
||||
@@ -31,6 +32,7 @@ static int _partial = 0;
|
||||
static int _md_filtering = 0;
|
||||
static int _pvmove = 0;
|
||||
static int _full_scan_done = 0; /* Restrict to one full scan during each cmd */
|
||||
static int _trust_cache = 0; /* Don't scan when incomplete VGs encountered */
|
||||
static int _debug_level = 0;
|
||||
static int _syslog = 0;
|
||||
static int _log_to_file = 0;
|
||||
@@ -45,6 +47,8 @@ static int _security_level = SECURITY_LEVEL;
|
||||
static char _cmd_name[30] = "";
|
||||
static char _msg_prefix[30] = " ";
|
||||
static int _already_logging = 0;
|
||||
static int _mirror_in_sync = 0;
|
||||
static int _dmeventd_register = DEFAULT_DMEVENTD_MONITOR;
|
||||
|
||||
static lvm2_log_fn_t _lvm2_log_fn = NULL;
|
||||
|
||||
@@ -160,6 +164,11 @@ void init_full_scan_done(int level)
|
||||
_full_scan_done = level;
|
||||
}
|
||||
|
||||
void init_trust_cache(int trustcache)
|
||||
{
|
||||
_trust_cache = trustcache;
|
||||
}
|
||||
|
||||
void init_ignorelockingfailure(int level)
|
||||
{
|
||||
_ignorelockingfailure = level;
|
||||
@@ -175,6 +184,16 @@ void init_security_level(int level)
|
||||
_security_level = level;
|
||||
}
|
||||
|
||||
void init_mirror_in_sync(int in_sync)
|
||||
{
|
||||
_mirror_in_sync = in_sync;
|
||||
}
|
||||
|
||||
void init_dmeventd_register(int reg)
|
||||
{
|
||||
_dmeventd_register = reg;
|
||||
}
|
||||
|
||||
void init_cmd_name(int status)
|
||||
{
|
||||
_log_cmd_name = status;
|
||||
@@ -224,6 +243,11 @@ int full_scan_done()
|
||||
return _full_scan_done;
|
||||
}
|
||||
|
||||
int trust_cache()
|
||||
{
|
||||
return _trust_cache;
|
||||
}
|
||||
|
||||
int lockingfailed()
|
||||
{
|
||||
return _lockingfailed;
|
||||
@@ -239,6 +263,16 @@ int security_level()
|
||||
return _security_level;
|
||||
}
|
||||
|
||||
int mirror_in_sync(void)
|
||||
{
|
||||
return _mirror_in_sync;
|
||||
}
|
||||
|
||||
int dmeventd_register_mode(void)
|
||||
{
|
||||
return _dmeventd_register;
|
||||
}
|
||||
|
||||
void init_debug(int level)
|
||||
{
|
||||
_debug_level = level;
|
||||
|
||||
@@ -66,6 +66,7 @@ void init_partial(int level);
|
||||
void init_md_filtering(int level);
|
||||
void init_pvmove(int level);
|
||||
void init_full_scan_done(int level);
|
||||
void init_trust_cache(int trustcache);
|
||||
void init_debug(int level);
|
||||
void init_cmd_name(int status);
|
||||
void init_msg_prefix(const char *prefix);
|
||||
@@ -73,6 +74,8 @@ void init_indent(int indent);
|
||||
void init_ignorelockingfailure(int level);
|
||||
void init_lockingfailed(int level);
|
||||
void init_security_level(int level);
|
||||
void init_mirror_in_sync(int in_sync);
|
||||
void init_dmeventd_register(int reg);
|
||||
|
||||
void set_cmd_name(const char *cmd_name);
|
||||
|
||||
@@ -81,10 +84,13 @@ int partial_mode(void);
|
||||
int md_filtering(void);
|
||||
int pvmove_mode(void);
|
||||
int full_scan_done(void);
|
||||
int trust_cache(void);
|
||||
int debug_level(void);
|
||||
int ignorelockingfailure(void);
|
||||
int lockingfailed(void);
|
||||
int security_level(void);
|
||||
int mirror_in_sync(void);
|
||||
int dmeventd_register_mode(void);
|
||||
|
||||
/* Suppress messages to stdout/stderr (1) or everywhere (2) */
|
||||
/* Returns previous setting */
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#ifndef _LVM_LV_ALLOC_H
|
||||
|
||||
struct lv_segment *alloc_lv_segment(struct dm_pool *mem,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
struct logical_volume *lv,
|
||||
uint32_t le, uint32_t len,
|
||||
uint32_t status,
|
||||
@@ -44,7 +44,7 @@ void release_lv_segment_area(struct lv_segment *seg, uint32_t s,
|
||||
struct alloc_handle;
|
||||
struct alloc_handle *allocate_extents(struct volume_group *vg,
|
||||
struct logical_volume *lv,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
uint32_t stripes,
|
||||
uint32_t mirrors, uint32_t log_count,
|
||||
uint32_t extents,
|
||||
@@ -58,7 +58,7 @@ struct alloc_handle *allocate_extents(struct volume_group *vg,
|
||||
int lv_add_segment(struct alloc_handle *ah,
|
||||
uint32_t first_area, uint32_t num_areas,
|
||||
struct logical_volume *lv,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
uint32_t stripe_size,
|
||||
struct physical_volume *mirrored_pv,
|
||||
uint32_t mirrored_pe,
|
||||
@@ -68,12 +68,12 @@ int lv_add_segment(struct alloc_handle *ah,
|
||||
|
||||
int lv_add_log_segment(struct alloc_handle *ah, struct logical_volume *log_lv);
|
||||
int lv_add_virtual_segment(struct logical_volume *lv, uint32_t status,
|
||||
uint32_t extents, struct segment_type *segtype);
|
||||
uint32_t extents, const struct segment_type *segtype);
|
||||
int lv_add_mirror_segment(struct alloc_handle *ah,
|
||||
struct logical_volume *lv,
|
||||
struct logical_volume **sub_lvs,
|
||||
uint32_t mirrors,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
uint32_t status,
|
||||
uint32_t region_size,
|
||||
struct logical_volume *log_lv);
|
||||
|
||||
@@ -66,7 +66,7 @@ uint32_t find_free_lvnum(struct logical_volume *lv)
|
||||
* All lv_segments get created here.
|
||||
*/
|
||||
struct lv_segment *alloc_lv_segment(struct dm_pool *mem,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
struct logical_volume *lv,
|
||||
uint32_t le, uint32_t len,
|
||||
uint32_t status,
|
||||
@@ -124,7 +124,7 @@ struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv,
|
||||
uint32_t status, uint32_t old_le_count)
|
||||
{
|
||||
struct lv_segment *seg;
|
||||
struct segment_type *segtype;
|
||||
const struct segment_type *segtype;
|
||||
|
||||
segtype = get_segtype_from_string(lv->vg->cmd, "snapshot");
|
||||
if (!segtype) {
|
||||
@@ -418,7 +418,7 @@ struct alloc_handle {
|
||||
* Preparation for a specific allocation attempt
|
||||
*/
|
||||
static struct alloc_handle *_alloc_init(struct dm_pool *mem,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
alloc_policy_t alloc,
|
||||
uint32_t mirrors,
|
||||
uint32_t stripes,
|
||||
@@ -474,8 +474,6 @@ static struct alloc_handle *_alloc_init(struct dm_pool *mem,
|
||||
ah->alloc = alloc;
|
||||
ah->area_multiple = segtype_is_striped(segtype) ? ah->area_count : 1;
|
||||
|
||||
list_init(&ah->alloced_areas[0]);
|
||||
|
||||
for (s = 0; s < ah->area_count; s++)
|
||||
list_init(&ah->alloced_areas[s]);
|
||||
|
||||
@@ -495,12 +493,12 @@ void alloc_destroy(struct alloc_handle *ah)
|
||||
static int _setup_alloced_segment(struct logical_volume *lv, uint32_t status,
|
||||
uint32_t area_count,
|
||||
uint32_t stripe_size,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
struct alloced_area *aa,
|
||||
struct physical_volume *mirrored_pv,
|
||||
uint32_t mirrored_pe,
|
||||
uint32_t region_size,
|
||||
struct logical_volume *log_lv)
|
||||
struct logical_volume *log_lv __attribute((unused)))
|
||||
{
|
||||
uint32_t s, extents, area_multiple, extra_areas = 0;
|
||||
struct lv_segment *seg;
|
||||
@@ -553,7 +551,7 @@ static int _setup_alloced_segments(struct logical_volume *lv,
|
||||
uint32_t area_count,
|
||||
uint32_t status,
|
||||
uint32_t stripe_size,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
struct physical_volume *mirrored_pv,
|
||||
uint32_t mirrored_pe,
|
||||
uint32_t region_size,
|
||||
@@ -825,7 +823,7 @@ static int _allocate(struct alloc_handle *ah,
|
||||
uint32_t new_extents,
|
||||
struct list *allocatable_pvs,
|
||||
uint32_t stripes, uint32_t mirrors,
|
||||
struct segment_type *segtype)
|
||||
const struct segment_type *segtype)
|
||||
{
|
||||
struct pv_area **areas;
|
||||
uint32_t allocated = lv ? lv->le_count : 0;
|
||||
@@ -927,7 +925,7 @@ static int _allocate(struct alloc_handle *ah,
|
||||
}
|
||||
|
||||
int lv_add_virtual_segment(struct logical_volume *lv, uint32_t status,
|
||||
uint32_t extents, struct segment_type *segtype)
|
||||
uint32_t extents, const struct segment_type *segtype)
|
||||
{
|
||||
struct lv_segment *seg;
|
||||
|
||||
@@ -953,7 +951,7 @@ int lv_add_virtual_segment(struct logical_volume *lv, uint32_t status,
|
||||
*/
|
||||
struct alloc_handle *allocate_extents(struct volume_group *vg,
|
||||
struct logical_volume *lv,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
uint32_t stripes,
|
||||
uint32_t mirrors, uint32_t log_count,
|
||||
uint32_t extents,
|
||||
@@ -1008,7 +1006,7 @@ struct alloc_handle *allocate_extents(struct volume_group *vg,
|
||||
int lv_add_segment(struct alloc_handle *ah,
|
||||
uint32_t first_area, uint32_t num_areas,
|
||||
struct logical_volume *lv,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
uint32_t stripe_size,
|
||||
struct physical_volume *mirrored_pv,
|
||||
uint32_t mirrored_pe,
|
||||
@@ -1096,7 +1094,7 @@ int lv_add_mirror_segment(struct alloc_handle *ah,
|
||||
struct logical_volume *lv,
|
||||
struct logical_volume **sub_lvs,
|
||||
uint32_t mirrors,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
uint32_t status,
|
||||
uint32_t region_size,
|
||||
struct logical_volume *log_lv)
|
||||
@@ -1104,7 +1102,7 @@ int lv_add_mirror_segment(struct alloc_handle *ah,
|
||||
struct lv_segment *seg;
|
||||
uint32_t m;
|
||||
|
||||
if (list_empty(&log_lv->segments)) {
|
||||
if (log_lv && list_empty(&log_lv->segments)) {
|
||||
log_error("Log LV %s is empty.", log_lv->name);
|
||||
return 0;
|
||||
}
|
||||
@@ -1177,7 +1175,7 @@ int lv_add_more_mirrored_areas(struct logical_volume *lv,
|
||||
* Entry point for single-step LV allocation + extension.
|
||||
*/
|
||||
int lv_extend(struct logical_volume *lv,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
uint32_t stripes, uint32_t stripe_size,
|
||||
uint32_t mirrors, uint32_t extents,
|
||||
struct physical_volume *mirrored_pv, uint32_t mirrored_pe,
|
||||
|
||||
@@ -60,7 +60,7 @@ static int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,
|
||||
}
|
||||
|
||||
/* Ensure PV doesn't depend on another PV already in the VG */
|
||||
if (pv_uses_vg(fid->fmt->cmd, pv, vg)) {
|
||||
if (pv_uses_vg(pv, vg)) {
|
||||
log_error("Physical volume %s might be constructed from same "
|
||||
"volume group %s", pv_name, vg->name);
|
||||
return 0;
|
||||
@@ -266,7 +266,10 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
|
||||
vg->seqno = 0;
|
||||
|
||||
vg->status = (RESIZEABLE_VG | LVM_READ | LVM_WRITE);
|
||||
vg->system_id = dm_pool_alloc(mem, NAME_LEN);
|
||||
if (!(vg->system_id = dm_pool_alloc(mem, NAME_LEN))) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
*vg->system_id = '\0';
|
||||
|
||||
vg->extent_size = extent_size;
|
||||
@@ -719,23 +722,68 @@ int vg_remove(struct volume_group *vg)
|
||||
|
||||
int vg_validate(struct volume_group *vg)
|
||||
{
|
||||
struct lv_list *lvl;
|
||||
struct pv_list *pvl, *pvl2;
|
||||
struct lv_list *lvl, *lvl2;
|
||||
char uuid[64];
|
||||
int r = 1;
|
||||
|
||||
list_iterate_items(pvl, &vg->pvs) {
|
||||
list_iterate_items(pvl2, &vg->pvs) {
|
||||
if (pvl == pvl2)
|
||||
break;
|
||||
if (id_equal(&pvl->pv->id,
|
||||
&pvl2->pv->id)) {
|
||||
if (!id_write_format(&pvl->pv->id, uuid,
|
||||
sizeof(uuid)))
|
||||
stack;
|
||||
log_error("Internal error: Duplicate PV id "
|
||||
"%s detected for %s in %s.",
|
||||
uuid, dev_name(pvl->pv->dev),
|
||||
vg->name);
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!check_pv_segments(vg)) {
|
||||
log_error("Internal error: PV segments corrupted in %s.",
|
||||
vg->name);
|
||||
return 0;
|
||||
r = 0;
|
||||
}
|
||||
|
||||
list_iterate_items(lvl, &vg->lvs) {
|
||||
list_iterate_items(lvl2, &vg->lvs) {
|
||||
if (lvl == lvl2)
|
||||
break;
|
||||
if (!strcmp(lvl->lv->name, lvl2->lv->name)) {
|
||||
log_error("Internal error: Duplicate LV name "
|
||||
"%s detected in %s.", lvl->lv->name,
|
||||
vg->name);
|
||||
r = 0;
|
||||
}
|
||||
if (id_equal(&lvl->lv->lvid.id[1],
|
||||
&lvl2->lv->lvid.id[1])) {
|
||||
if (!id_write_format(&lvl->lv->lvid.id[1], uuid,
|
||||
sizeof(uuid)))
|
||||
stack;
|
||||
log_error("Internal error: Duplicate LV id "
|
||||
"%s detected for %s and %s in %s.",
|
||||
uuid, lvl->lv->name, lvl2->lv->name,
|
||||
vg->name);
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list_iterate_items(lvl, &vg->lvs) {
|
||||
if (!check_lv_segments(lvl->lv, 1)) {
|
||||
log_error("Internal error: LV segments corrupted in %s.",
|
||||
lvl->lv->name);
|
||||
return 0;
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -919,6 +967,8 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
|
||||
struct metadata_area *mda;
|
||||
int inconsistent = 0;
|
||||
int use_precommitted = precommitted;
|
||||
struct list *pvids;
|
||||
struct pv_list *pvl;
|
||||
|
||||
if (!*vgname) {
|
||||
if (use_precommitted) {
|
||||
@@ -950,6 +1000,12 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
|
||||
if (use_precommitted && !(fmt->features & FMT_PRECOMMIT))
|
||||
use_precommitted = 0;
|
||||
|
||||
/* Store pvids for later so we can check if any are missing */
|
||||
if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create format instance with appropriate metadata area */
|
||||
if (!(fid = fmt->ops->create_instance(fmt, vgname, vgid, NULL))) {
|
||||
log_error("Failed to create format instance");
|
||||
@@ -977,10 +1033,34 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
|
||||
}
|
||||
}
|
||||
|
||||
/* Ensure every PV in the VG was in the cache */
|
||||
if (correct_vg) {
|
||||
if (list_size(&correct_vg->pvs) != list_size(pvids)) {
|
||||
log_debug("Cached VG %s had incorrect PV list",
|
||||
vg->name);
|
||||
|
||||
if (memlock())
|
||||
inconsistent = 1;
|
||||
else
|
||||
correct_vg = NULL;
|
||||
} else list_iterate_items(pvl, &correct_vg->pvs) {
|
||||
if (!str_list_match_item(pvids, pvl->pv->dev->pvid)) {
|
||||
log_debug("Cached VG %s had incorrect PV list",
|
||||
vg->name);
|
||||
correct_vg = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Failed to find VG where we expected it - full scan and retry */
|
||||
if (!correct_vg) {
|
||||
inconsistent = 0;
|
||||
|
||||
if (memlock()) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
lvmcache_label_scan(cmd, 2);
|
||||
if (!(fmt = fmt_from_vgname(vgname, vgid))) {
|
||||
stack;
|
||||
@@ -1118,11 +1198,12 @@ static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd,
|
||||
vginfo->vgname && *vginfo->vgname) {
|
||||
if ((vg = _vg_read(cmd, vginfo->vgname, vgid,
|
||||
&consistent, precommitted)) &&
|
||||
!strncmp(vg->id.uuid, vgid, ID_LEN)) {
|
||||
!strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
|
||||
if (!consistent) {
|
||||
log_error("Volume group %s metadata is "
|
||||
"inconsistent", vginfo->vgname);
|
||||
return NULL;
|
||||
if (!partial_mode())
|
||||
return NULL;
|
||||
}
|
||||
return vg;
|
||||
}
|
||||
@@ -1149,7 +1230,7 @@ static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd,
|
||||
consistent = 0;
|
||||
if ((vg = _vg_read(cmd, vgname, vgid, &consistent,
|
||||
precommitted)) &&
|
||||
!strncmp(vg->id.uuid, vgid, ID_LEN)) {
|
||||
!strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
|
||||
if (!consistent) {
|
||||
log_error("Volume group %s metadata is "
|
||||
"inconsistent", vgname);
|
||||
@@ -1173,7 +1254,7 @@ struct logical_volume *lv_from_lvid(struct cmd_context *cmd, const char *lvid_s,
|
||||
lvid = (const union lvid *) lvid_s;
|
||||
|
||||
log_very_verbose("Finding volume group for uuid %s", lvid_s);
|
||||
if (!(vg = _vg_read_by_vgid(cmd, lvid->id[0].uuid, precommitted))) {
|
||||
if (!(vg = _vg_read_by_vgid(cmd, (char *)lvid->id[0].uuid, precommitted))) {
|
||||
log_error("Volume group for uuid not found: %s", lvid_s);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1315,7 +1396,7 @@ struct list *get_pvs(struct cmd_context *cmd)
|
||||
return results;
|
||||
}
|
||||
|
||||
int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
int pv_write(struct cmd_context *cmd __attribute((unused)), struct physical_volume *pv,
|
||||
struct list *mdas, int64_t label_sector)
|
||||
{
|
||||
if (!pv->fmt->ops->pv_write) {
|
||||
|
||||
@@ -23,14 +23,15 @@
|
||||
|
||||
#include "ctype.h"
|
||||
#include "dev-cache.h"
|
||||
#include "lvm-string.h"
|
||||
#include "uuid.h"
|
||||
|
||||
#define NAME_LEN 128
|
||||
#define MAX_STRIPES 128
|
||||
#define MAX_STRIPES 128U
|
||||
#define SECTOR_SHIFT 9L
|
||||
#define SECTOR_SIZE ( 1L << SECTOR_SHIFT )
|
||||
#define STRIPE_SIZE_MIN ( getpagesize() >> SECTOR_SHIFT) /* PAGESIZE in sectors */
|
||||
#define STRIPE_SIZE_MIN ( (unsigned) getpagesize() >> SECTOR_SHIFT) /* PAGESIZE in sectors */
|
||||
#define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
|
||||
#define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)
|
||||
#define PV_MIN_SIZE ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
|
||||
#define PE_ALIGN (65536UL >> SECTOR_SHIFT) /* PE alignment */
|
||||
#define MAX_RESTRICTED_LVS 255 /* Used by FMT_RESTRICTED_LVIDS */
|
||||
@@ -38,45 +39,47 @@
|
||||
/* Various flags */
|
||||
/* Note that the bits no longer necessarily correspond to LVM1 disk format */
|
||||
|
||||
#define PARTIAL_VG 0x00000001 /* VG */
|
||||
#define EXPORTED_VG 0x00000002 /* VG PV */
|
||||
#define RESIZEABLE_VG 0x00000004 /* VG */
|
||||
#define PARTIAL_VG 0x00000001U /* VG */
|
||||
#define EXPORTED_VG 0x00000002U /* VG PV */
|
||||
#define RESIZEABLE_VG 0x00000004U /* VG */
|
||||
|
||||
/* May any free extents on this PV be used or must they be left free? */
|
||||
#define ALLOCATABLE_PV 0x00000008 /* PV */
|
||||
#define ALLOCATABLE_PV 0x00000008U /* PV */
|
||||
|
||||
#define SPINDOWN_LV 0x00000010 /* LV */
|
||||
#define BADBLOCK_ON 0x00000020 /* LV */
|
||||
#define VISIBLE_LV 0x00000040 /* LV */
|
||||
#define FIXED_MINOR 0x00000080 /* LV */
|
||||
#define SPINDOWN_LV 0x00000010U /* LV */
|
||||
#define BADBLOCK_ON 0x00000020U /* LV */
|
||||
#define VISIBLE_LV 0x00000040U /* LV */
|
||||
#define FIXED_MINOR 0x00000080U /* LV */
|
||||
/* FIXME Remove when metadata restructuring is completed */
|
||||
#define SNAPSHOT 0x00001000 /* LV - internal use only */
|
||||
#define PVMOVE 0x00002000 /* VG LV SEG */
|
||||
#define LOCKED 0x00004000 /* LV */
|
||||
#define MIRRORED 0x00008000 /* LV - internal use only */
|
||||
#define VIRTUAL 0x00010000 /* LV - internal use only */
|
||||
#define MIRROR_LOG 0x00020000 /* LV */
|
||||
#define MIRROR_IMAGE 0x00040000 /* LV */
|
||||
#define ACTIVATE_EXCL 0x00080000 /* LV - internal use only */
|
||||
#define PRECOMMITTED 0x00100000 /* VG - internal use only */
|
||||
#define SNAPSHOT 0x00001000U /* LV - internal use only */
|
||||
#define PVMOVE 0x00002000U /* VG LV SEG */
|
||||
#define LOCKED 0x00004000U /* LV */
|
||||
#define MIRRORED 0x00008000U /* LV - internal use only */
|
||||
#define VIRTUAL 0x00010000U /* LV - internal use only */
|
||||
#define MIRROR_LOG 0x00020000U /* LV */
|
||||
#define MIRROR_IMAGE 0x00040000U /* LV */
|
||||
#define MIRROR_NOTSYNCED 0x00080000U /* LV */
|
||||
#define ACTIVATE_EXCL 0x00100000U /* LV - internal use only */
|
||||
#define PRECOMMITTED 0x00200000U /* VG - internal use only */
|
||||
|
||||
#define LVM_READ 0x00000100 /* LV VG */
|
||||
#define LVM_WRITE 0x00000200 /* LV VG */
|
||||
#define CLUSTERED 0x00000400 /* VG */
|
||||
#define SHARED 0x00000800 /* VG */
|
||||
#define LVM_READ 0x00000100U /* LV VG */
|
||||
#define LVM_WRITE 0x00000200U /* LV VG */
|
||||
#define CLUSTERED 0x00000400U /* VG */
|
||||
#define SHARED 0x00000800U /* VG */
|
||||
|
||||
/* Format features flags */
|
||||
#define FMT_SEGMENTS 0x00000001 /* Arbitrary segment params? */
|
||||
#define FMT_MDAS 0x00000002 /* Proper metadata areas? */
|
||||
#define FMT_TAGS 0x00000004 /* Tagging? */
|
||||
#define FMT_UNLIMITED_VOLS 0x00000008 /* Unlimited PVs/LVs? */
|
||||
#define FMT_RESTRICTED_LVIDS 0x00000010 /* LVID <= 255 */
|
||||
#define FMT_ORPHAN_ALLOCATABLE 0x00000020 /* Orphan PV allocatable? */
|
||||
#define FMT_PRECOMMIT 0x00000040 /* Supports pre-commit? */
|
||||
#define FMT_RESIZE_PV 0x00000080 /* Supports pvresize? */
|
||||
#define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */
|
||||
#define FMT_MDAS 0x00000002U /* Proper metadata areas? */
|
||||
#define FMT_TAGS 0x00000004U /* Tagging? */
|
||||
#define FMT_UNLIMITED_VOLS 0x00000008U /* Unlimited PVs/LVs? */
|
||||
#define FMT_RESTRICTED_LVIDS 0x00000010U /* LVID <= 255 */
|
||||
#define FMT_ORPHAN_ALLOCATABLE 0x00000020U /* Orphan PV allocatable? */
|
||||
#define FMT_PRECOMMIT 0x00000040U /* Supports pre-commit? */
|
||||
#define FMT_RESIZE_PV 0x00000080U /* Supports pvresize? */
|
||||
#define FMT_UNLIMITED_STRIPESIZE 0x00000100U /* Unlimited stripe size? */
|
||||
|
||||
typedef enum {
|
||||
ALLOC_INVALID,
|
||||
ALLOC_INVALID = 0,
|
||||
ALLOC_INHERIT,
|
||||
ALLOC_CONTIGUOUS,
|
||||
ALLOC_NORMAL,
|
||||
@@ -237,7 +240,7 @@ struct lv_segment {
|
||||
struct list list;
|
||||
struct logical_volume *lv;
|
||||
|
||||
struct segment_type *segtype;
|
||||
const struct segment_type *segtype;
|
||||
uint32_t le;
|
||||
uint32_t len;
|
||||
|
||||
@@ -376,7 +379,7 @@ struct format_handler {
|
||||
* Check whether particular segment type is supported.
|
||||
*/
|
||||
int (*segtype_supported) (struct format_instance *fid,
|
||||
struct segment_type *segtype);
|
||||
const struct segment_type *segtype);
|
||||
|
||||
/*
|
||||
* Create format instance with a particular metadata area
|
||||
@@ -461,7 +464,7 @@ int lv_empty(struct logical_volume *lv);
|
||||
|
||||
/* Entry point for all LV extent allocations */
|
||||
int lv_extend(struct logical_volume *lv,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
uint32_t stripes, uint32_t stripe_size,
|
||||
uint32_t mirrors, uint32_t extents,
|
||||
struct physical_volume *mirrored_pv, uint32_t mirrored_pe,
|
||||
@@ -566,7 +569,7 @@ int create_mirror_layers(struct alloc_handle *ah,
|
||||
uint32_t first_area,
|
||||
uint32_t num_mirrors,
|
||||
struct logical_volume *lv,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
uint32_t status,
|
||||
uint32_t region_size,
|
||||
struct logical_volume *log_lv);
|
||||
@@ -574,10 +577,12 @@ int add_mirror_layers(struct alloc_handle *ah,
|
||||
uint32_t num_mirrors,
|
||||
uint32_t existing_mirrors,
|
||||
struct logical_volume *lv,
|
||||
struct segment_type *segtype);
|
||||
const struct segment_type *segtype);
|
||||
|
||||
int remove_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
|
||||
struct list *removable_pvs, int remove_log);
|
||||
int reconfigure_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
|
||||
struct list *removable_pvs, int remove_log);
|
||||
/*
|
||||
* Given mirror image or mirror log segment, find corresponding mirror segment
|
||||
*/
|
||||
@@ -609,29 +614,4 @@ uint32_t find_free_lvnum(struct logical_volume *lv);
|
||||
char *generate_lv_name(struct volume_group *vg, const char *format,
|
||||
char *buffer, size_t len);
|
||||
|
||||
static inline int validate_name(const char *n)
|
||||
{
|
||||
register char c;
|
||||
register int len = 0;
|
||||
|
||||
if (!n || !*n)
|
||||
return 0;
|
||||
|
||||
/* Hyphen used as VG-LV separator - ambiguity if LV starts with it */
|
||||
if (*n == '-')
|
||||
return 0;
|
||||
|
||||
if (!strcmp(n, ".") || !strcmp(n, ".."))
|
||||
return 0;
|
||||
|
||||
while ((len++, c = *n++))
|
||||
if (!isalnum(c) && c != '.' && c != '_' && c != '-' && c != '+')
|
||||
return 0;
|
||||
|
||||
if (len > NAME_LEN)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,6 +23,13 @@
|
||||
#include "lvm-string.h"
|
||||
#include "locking.h" /* FIXME Should not be used in this file */
|
||||
|
||||
#include "defaults.h" /* FIXME: should this be defaults.h? */
|
||||
|
||||
/* These are the flags that represent the mirror failure restoration policies */
|
||||
#define MIRROR_REMOVE 0
|
||||
#define MIRROR_ALLOCATE 1
|
||||
#define MIRROR_ALLOCATE_ANYWHERE 2
|
||||
|
||||
struct lv_segment *find_mirror_seg(struct lv_segment *seg)
|
||||
{
|
||||
return seg->mirror_seg;
|
||||
@@ -36,7 +43,7 @@ uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
|
||||
{
|
||||
uint32_t region_max;
|
||||
|
||||
region_max = (1 << (ffs(extents) - 1)) * extent_size;
|
||||
region_max = (1 << (ffs((int)extents) - 1)) * extent_size;
|
||||
|
||||
if (region_max < region_size) {
|
||||
region_size = region_max;
|
||||
@@ -192,6 +199,12 @@ int remove_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
|
||||
|
||||
/* Delete the 'orphan' LVs */
|
||||
for (m = num_mirrors; m < old_area_count; m++) {
|
||||
/* LV is now independent of the mirror so must acquire lock. */
|
||||
if (!activate_lv(mirrored_seg->lv->vg->cmd, seg_lv(mirrored_seg, m))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!deactivate_lv(mirrored_seg->lv->vg->cmd, seg_lv(mirrored_seg, m))) {
|
||||
stack;
|
||||
return 0;
|
||||
@@ -204,6 +217,11 @@ int remove_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
|
||||
}
|
||||
|
||||
if (lv1) {
|
||||
if (!activate_lv(mirrored_seg->lv->vg->cmd, lv1)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!deactivate_lv(mirrored_seg->lv->vg->cmd, lv1)) {
|
||||
stack;
|
||||
return 0;
|
||||
@@ -216,6 +234,11 @@ int remove_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
|
||||
}
|
||||
|
||||
if (log_lv) {
|
||||
if (!activate_lv(mirrored_seg->lv->vg->cmd, log_lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!deactivate_lv(mirrored_seg->lv->vg->cmd, log_lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
@@ -230,11 +253,168 @@ int remove_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int get_mirror_fault_policy(struct cmd_context *cmd, int log_policy)
|
||||
{
|
||||
const char *policy;
|
||||
|
||||
if (log_policy)
|
||||
policy = find_config_str(NULL, "activation/mirror_log_fault_policy",
|
||||
DEFAULT_MIRROR_LOG_FAULT_POLICY);
|
||||
else
|
||||
policy = find_config_str(NULL, "activation/mirror_device_fault_policy",
|
||||
DEFAULT_MIRROR_DEV_FAULT_POLICY);
|
||||
|
||||
if (!strcmp(policy, "remove"))
|
||||
return MIRROR_REMOVE;
|
||||
else if (!strcmp(policy, "allocate"))
|
||||
return MIRROR_ALLOCATE;
|
||||
else if (!strcmp(policy, "allocate_anywhere"))
|
||||
return MIRROR_ALLOCATE_ANYWHERE;
|
||||
|
||||
if (log_policy)
|
||||
log_error("Bad activation/mirror_log_fault_policy");
|
||||
else
|
||||
log_error("Bad activation/mirror_device_fault_policy");
|
||||
|
||||
return MIRROR_REMOVE;
|
||||
}
|
||||
|
||||
static int get_mirror_log_fault_policy(struct cmd_context *cmd)
|
||||
{
|
||||
return get_mirror_fault_policy(cmd, 1);
|
||||
}
|
||||
|
||||
static int get_mirror_device_fault_policy(struct cmd_context *cmd)
|
||||
{
|
||||
return get_mirror_fault_policy(cmd, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* replace_mirror_images
|
||||
* @mirrored_seg: segment (which may be linear now) to restore
|
||||
* @num_mirrors: number of copies we should end up with
|
||||
* @replace_log: replace log if not present
|
||||
* @in_sync: was the original mirror in-sync?
|
||||
*
|
||||
* in_sync will be set to 0 if new mirror devices are being added
|
||||
* In other words, it is only useful if the log (and only the log)
|
||||
* is being restored.
|
||||
*
|
||||
* Returns: 0 on failure, 1 on reconfig, -1 if no reconfig done
|
||||
*/
|
||||
static int replace_mirror_images(struct lv_segment *mirrored_seg,
|
||||
uint32_t num_mirrors,
|
||||
int log_policy, int in_sync)
|
||||
{
|
||||
int r = -1;
|
||||
struct logical_volume *lv = mirrored_seg->lv;
|
||||
|
||||
/* FIXME: Use lvconvert rather than duplicating its code */
|
||||
|
||||
if (mirrored_seg->area_count < num_mirrors) {
|
||||
log_error("WARNING: Failed to replace mirror device in %s/%s",
|
||||
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
|
||||
|
||||
if ((mirrored_seg->area_count > 1) && !mirrored_seg->log_lv)
|
||||
log_error("WARNING: Use 'lvconvert -m %d %s/%s --corelog' to replace failed devices",
|
||||
num_mirrors - 1, lv->vg->name, lv->name);
|
||||
else
|
||||
log_error("WARNING: Use 'lvconvert -m %d %s/%s' to replace failed devices",
|
||||
num_mirrors - 1, lv->vg->name, lv->name);
|
||||
r = 0;
|
||||
|
||||
/* REMEMBER/FIXME: set in_sync to 0 if a new mirror device was added */
|
||||
in_sync = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: right now, we ignore the allocation policy specified to
|
||||
* allocate the new log.
|
||||
*/
|
||||
if ((mirrored_seg->area_count > 1) && !mirrored_seg->log_lv &&
|
||||
(log_policy != MIRROR_REMOVE)) {
|
||||
log_error("WARNING: Failed to replace mirror log device in %s/%s",
|
||||
lv->vg->name, lv->name);
|
||||
|
||||
log_error("WARNING: Use 'lvconvert -m %d %s/%s' to replace failed devices",
|
||||
mirrored_seg->area_count - 1 , lv->vg->name, lv->name);
|
||||
r = 0;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int reconfigure_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
|
||||
struct list *removable_pvs, int remove_log)
|
||||
{
|
||||
int r;
|
||||
int insync = 0;
|
||||
int log_policy, dev_policy;
|
||||
uint32_t old_num_mirrors = mirrored_seg->area_count;
|
||||
int had_log = (mirrored_seg->log_lv) ? 1 : 0;
|
||||
float sync_percent = 0;
|
||||
|
||||
/* was the mirror in-sync before problems? */
|
||||
if (!lv_mirror_percent(mirrored_seg->lv->vg->cmd,
|
||||
mirrored_seg->lv, 0, &sync_percent, NULL))
|
||||
log_error("WARNING: Unable to determine mirror sync status of %s/%s.",
|
||||
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
|
||||
else if (sync_percent >= 100.0)
|
||||
insync = 1;
|
||||
|
||||
/*
|
||||
* While we are only removing devices, we can have sync set.
|
||||
* Setting this is only useful if we are moving to core log
|
||||
* otherwise the disk log will contain the sync information
|
||||
*/
|
||||
init_mirror_in_sync(insync);
|
||||
|
||||
r = remove_mirror_images(mirrored_seg, num_mirrors,
|
||||
removable_pvs, remove_log);
|
||||
if (!r)
|
||||
/* Unable to remove bad devices */
|
||||
return 0;
|
||||
|
||||
log_print("WARNING: Bad device removed from mirror volume, %s/%s",
|
||||
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
|
||||
|
||||
log_policy = get_mirror_log_fault_policy(mirrored_seg->lv->vg->cmd);
|
||||
dev_policy = get_mirror_device_fault_policy(mirrored_seg->lv->vg->cmd);
|
||||
|
||||
r = replace_mirror_images(mirrored_seg,
|
||||
(dev_policy != MIRROR_REMOVE) ?
|
||||
old_num_mirrors : num_mirrors,
|
||||
log_policy, insync);
|
||||
|
||||
if (!r)
|
||||
/* Failed to replace device(s) */
|
||||
log_error("WARNING: Unable to find substitute device for mirror volume, %s/%s",
|
||||
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
|
||||
else if (r > 0)
|
||||
/* Success in replacing device(s) */
|
||||
log_print("WARNING: Mirror volume, %s/%s restored - substitute for failed device found.",
|
||||
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
|
||||
else
|
||||
/* Bad device removed, but not replaced because of policy */
|
||||
if (mirrored_seg->area_count == 1) {
|
||||
log_print("WARNING: Mirror volume, %s/%s converted to linear due to device failure.",
|
||||
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
|
||||
} else if (had_log && !mirrored_seg->log_lv) {
|
||||
log_print("WARNING: Mirror volume, %s/%s disk log removed due to device failure.",
|
||||
mirrored_seg->lv->vg->name, mirrored_seg->lv->name);
|
||||
}
|
||||
/*
|
||||
* If we made it here, we at least removed the bad device.
|
||||
* Consider this success.
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _create_layers_for_mirror(struct alloc_handle *ah,
|
||||
uint32_t first_area,
|
||||
uint32_t num_mirrors,
|
||||
struct logical_volume *lv,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
struct logical_volume **img_lvs)
|
||||
{
|
||||
uint32_t m;
|
||||
@@ -284,7 +464,7 @@ int create_mirror_layers(struct alloc_handle *ah,
|
||||
uint32_t first_area,
|
||||
uint32_t num_mirrors,
|
||||
struct logical_volume *lv,
|
||||
struct segment_type *segtype,
|
||||
const struct segment_type *segtype,
|
||||
uint32_t status,
|
||||
uint32_t region_size,
|
||||
struct logical_volume *log_lv)
|
||||
@@ -328,7 +508,7 @@ int add_mirror_layers(struct alloc_handle *ah,
|
||||
uint32_t num_mirrors,
|
||||
uint32_t existing_mirrors,
|
||||
struct logical_volume *lv,
|
||||
struct segment_type *segtype)
|
||||
const struct segment_type *segtype)
|
||||
{
|
||||
struct logical_volume **img_lvs;
|
||||
|
||||
@@ -367,7 +547,7 @@ int insert_pvmove_mirrors(struct cmd_context *cmd,
|
||||
uint32_t pe;
|
||||
int lv_used = 0;
|
||||
uint32_t s, start_le, extent_count = 0u;
|
||||
struct segment_type *segtype;
|
||||
const struct segment_type *segtype;
|
||||
struct pe_range *per;
|
||||
uint32_t pe_start, pe_end, per_end, stripe_multiplier;
|
||||
|
||||
@@ -555,7 +735,7 @@ int remove_pvmove_mirrors(struct volume_group *vg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
release_lv_segment_area(mir_seg, !c, mir_seg->area_len);
|
||||
release_lv_segment_area(mir_seg, c ? 0 : 1U, mir_seg->area_len);
|
||||
|
||||
/* Replace mirror with error segment */
|
||||
if (!
|
||||
|
||||
@@ -136,8 +136,8 @@ int pv_split_segment(struct physical_volume *pv, uint32_t pe)
|
||||
}
|
||||
|
||||
static struct pv_segment null_pv_segment = {
|
||||
pv: NULL,
|
||||
pe: 0
|
||||
.pv = NULL,
|
||||
.pe = 0,
|
||||
};
|
||||
|
||||
struct pv_segment *assign_peg_to_lvseg(struct physical_volume *pv,
|
||||
|
||||
@@ -25,13 +25,13 @@ struct config_node;
|
||||
struct dev_manager;
|
||||
|
||||
/* Feature flags */
|
||||
#define SEG_CAN_SPLIT 0x00000001
|
||||
#define SEG_AREAS_STRIPED 0x00000002
|
||||
#define SEG_AREAS_MIRRORED 0x00000004
|
||||
#define SEG_SNAPSHOT 0x00000008
|
||||
#define SEG_FORMAT1_SUPPORT 0x00000010
|
||||
#define SEG_VIRTUAL 0x00000020
|
||||
#define SEG_CANNOT_BE_ZEROED 0x00000040
|
||||
#define SEG_CAN_SPLIT 0x00000001U
|
||||
#define SEG_AREAS_STRIPED 0x00000002U
|
||||
#define SEG_AREAS_MIRRORED 0x00000004U
|
||||
#define SEG_SNAPSHOT 0x00000008U
|
||||
#define SEG_FORMAT1_SUPPORT 0x00000010U
|
||||
#define SEG_VIRTUAL 0x00000020U
|
||||
#define SEG_CANNOT_BE_ZEROED 0x00000040U
|
||||
|
||||
#define seg_is_mirrored(seg) ((seg)->segtype->flags & SEG_AREAS_MIRRORED ? 1 : 0)
|
||||
#define seg_is_striped(seg) ((seg)->segtype->flags & SEG_AREAS_STRIPED ? 1 : 0)
|
||||
@@ -67,23 +67,19 @@ struct segtype_handler {
|
||||
int (*merge_segments) (struct lv_segment * seg1,
|
||||
struct lv_segment * seg2);
|
||||
int (*add_target_line) (struct dev_manager *dm, struct dm_pool *mem,
|
||||
struct config_tree *cft, void **target_state,
|
||||
struct cmd_context *cmd, void **target_state,
|
||||
struct lv_segment *seg,
|
||||
struct dm_tree_node *node, uint64_t len,
|
||||
uint32_t *pvmove_mirror_count);
|
||||
int (*target_percent) (void **target_state, struct dm_pool * mem,
|
||||
struct config_tree * cft,
|
||||
struct lv_segment * seg, char *params,
|
||||
struct cmd_context *cmd,
|
||||
struct lv_segment *seg, char *params,
|
||||
uint64_t *total_numerator,
|
||||
uint64_t *total_denominator, float *percent);
|
||||
int (*target_present) (void);
|
||||
void (*destroy) (const struct segment_type * segtype);
|
||||
int (*target_register_events) (struct dm_pool *mem,
|
||||
struct lv_segment *seg,
|
||||
struct config_tree *cft, int events);
|
||||
int (*target_unregister_events) (struct dm_pool *mem,
|
||||
struct lv_segment *seg,
|
||||
struct config_tree *cft, int events);
|
||||
int (*target_register_events) (struct lv_segment *seg, int events);
|
||||
int (*target_unregister_events) (struct lv_segment *seg, int events);
|
||||
};
|
||||
|
||||
struct segment_type *get_segtype_from_string(struct cmd_context *cmd,
|
||||
|
||||
@@ -43,12 +43,12 @@ struct mirror_state {
|
||||
uint32_t default_region_size;
|
||||
};
|
||||
|
||||
static const char *_name(const struct lv_segment *seg)
|
||||
static const char *_mirrored_name(const struct lv_segment *seg)
|
||||
{
|
||||
return seg->segtype->name;
|
||||
}
|
||||
|
||||
static void _display(const struct lv_segment *seg)
|
||||
static void _mirrored_display(const struct lv_segment *seg)
|
||||
{
|
||||
const char *size;
|
||||
uint32_t s;
|
||||
@@ -60,8 +60,7 @@ static void _display(const struct lv_segment *seg)
|
||||
|
||||
if (seg->region_size) {
|
||||
size = display_size(seg->lv->vg->cmd,
|
||||
(uint64_t) seg->region_size,
|
||||
SIZE_SHORT);
|
||||
(uint64_t) seg->region_size);
|
||||
log_print(" Mirror region size\t%s", size);
|
||||
}
|
||||
|
||||
@@ -73,7 +72,7 @@ static void _display(const struct lv_segment *seg)
|
||||
log_print(" ");
|
||||
}
|
||||
|
||||
static int _text_import_area_count(struct config_node *sn, uint32_t *area_count)
|
||||
static int _mirrored_text_import_area_count(struct config_node *sn, uint32_t *area_count)
|
||||
{
|
||||
if (!get_config_uint32(sn, "mirror_count", area_count)) {
|
||||
log_error("Couldn't read 'mirror_count' for "
|
||||
@@ -84,7 +83,7 @@ static int _text_import_area_count(struct config_node *sn, uint32_t *area_count)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _text_import(struct lv_segment *seg, const struct config_node *sn,
|
||||
static int _mirrored_text_import(struct lv_segment *seg, const struct config_node *sn,
|
||||
struct dm_hash_table *pv_hash)
|
||||
{
|
||||
const struct config_node *cn;
|
||||
@@ -139,7 +138,7 @@ static int _text_import(struct lv_segment *seg, const struct config_node *sn,
|
||||
return text_import_areas(seg, sn, cn, pv_hash, MIRROR_IMAGE);
|
||||
}
|
||||
|
||||
static int _text_export(const struct lv_segment *seg, struct formatter *f)
|
||||
static int _mirrored_text_export(const struct lv_segment *seg, struct formatter *f)
|
||||
{
|
||||
outf(f, "mirror_count = %u", seg->area_count);
|
||||
if (seg->status & PVMOVE)
|
||||
@@ -154,8 +153,8 @@ static int _text_export(const struct lv_segment *seg, struct formatter *f)
|
||||
}
|
||||
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
static struct mirror_state *_init_target(struct dm_pool *mem,
|
||||
struct config_tree *cft)
|
||||
static struct mirror_state *_mirrored_init_target(struct dm_pool *mem,
|
||||
struct cmd_context *cmd)
|
||||
{
|
||||
struct mirror_state *mirr_state;
|
||||
|
||||
@@ -165,17 +164,18 @@ static struct mirror_state *_init_target(struct dm_pool *mem,
|
||||
}
|
||||
|
||||
mirr_state->default_region_size = 2 *
|
||||
find_config_int(cft->root,
|
||||
find_config_tree_int(cmd,
|
||||
"activation/mirror_region_size",
|
||||
DEFAULT_MIRROR_REGION_SIZE);
|
||||
|
||||
return mirr_state;
|
||||
}
|
||||
|
||||
static int _target_percent(void **target_state, struct dm_pool *mem,
|
||||
struct config_tree *cft, struct lv_segment *seg,
|
||||
static int _mirrored_target_percent(void **target_state, struct dm_pool *mem,
|
||||
struct cmd_context *cmd, struct lv_segment *seg,
|
||||
char *params, uint64_t *total_numerator,
|
||||
uint64_t *total_denominator, float *percent)
|
||||
uint64_t *total_denominator,
|
||||
float *percent __attribute((unused)))
|
||||
{
|
||||
struct mirror_state *mirr_state;
|
||||
uint64_t numerator, denominator;
|
||||
@@ -184,7 +184,7 @@ static int _target_percent(void **target_state, struct dm_pool *mem,
|
||||
char *pos = params;
|
||||
|
||||
if (!*target_state)
|
||||
*target_state = _init_target(mem, cft);
|
||||
*target_state = _mirrored_init_target(mem, cmd);
|
||||
|
||||
mirr_state = *target_state;
|
||||
|
||||
@@ -238,34 +238,47 @@ static int _add_log(struct dev_manager *dm, struct lv_segment *seg,
|
||||
(seg->lv->vg->status & CLUSTERED)))
|
||||
clustered = 1;
|
||||
|
||||
if (seg->log_lv &&
|
||||
!(log_dlid = build_dlid(dm, seg->log_lv->lvid.s, NULL))) {
|
||||
log_error("Failed to build uuid for log LV %s.",
|
||||
seg->log_lv->name);
|
||||
return 0;
|
||||
if (seg->log_lv) {
|
||||
/* If disk log, use its UUID */
|
||||
if (!(log_dlid = build_dlid(dm, seg->log_lv->lvid.s, NULL))) {
|
||||
log_error("Failed to build uuid for log LV %s.",
|
||||
seg->log_lv->name);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
/* If core log, use mirror's UUID and set DM_CORELOG flag */
|
||||
if (!(log_dlid = build_dlid(dm, seg->lv->lvid.s, NULL))) {
|
||||
log_error("Failed to build uuid for mirror LV %s.",
|
||||
seg->lv->name);
|
||||
return 0;
|
||||
}
|
||||
log_flags |= DM_CORELOG;
|
||||
}
|
||||
|
||||
if (mirror_in_sync() && !(seg->status & PVMOVE))
|
||||
log_flags |= DM_NOSYNC;
|
||||
|
||||
if (_block_on_error_available && !(seg->status & PVMOVE))
|
||||
log_flags |= DM_BLOCK_ON_ERROR;
|
||||
|
||||
return dm_tree_node_add_mirror_target_log(node, region_size, clustered, log_dlid, area_count, log_flags);
|
||||
}
|
||||
|
||||
static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem,
|
||||
struct config_tree *cft, void **target_state,
|
||||
static int _mirrored_add_target_line(struct dev_manager *dm, struct dm_pool *mem,
|
||||
struct cmd_context *cmd, void **target_state,
|
||||
struct lv_segment *seg,
|
||||
struct dm_tree_node *node, uint64_t len,
|
||||
uint32_t *pvmove_mirror_count)
|
||||
{
|
||||
struct mirror_state *mirr_state;
|
||||
uint32_t area_count = seg->area_count;
|
||||
int start_area = 0u;
|
||||
unsigned start_area = 0u;
|
||||
int mirror_status = MIRR_RUNNING;
|
||||
uint32_t region_size, region_max;
|
||||
int r;
|
||||
|
||||
if (!*target_state)
|
||||
*target_state = _init_target(mem, cft);
|
||||
*target_state = _mirrored_init_target(mem, cmd);
|
||||
|
||||
mirr_state = *target_state;
|
||||
|
||||
@@ -299,7 +312,7 @@ static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem,
|
||||
region_size = seg->region_size;
|
||||
} else {
|
||||
/* Find largest power of 2 region size unit we can use */
|
||||
region_max = (1 << (ffs(seg->area_len) - 1)) *
|
||||
region_max = (1 << (ffs((int)seg->area_len) - 1)) *
|
||||
seg->lv->vg->extent_size;
|
||||
|
||||
region_size = mirr_state->default_region_size;
|
||||
@@ -322,16 +335,16 @@ static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem,
|
||||
return add_areas_line(dm, seg, node, start_area, area_count);
|
||||
}
|
||||
|
||||
static int _target_present(void)
|
||||
static int _mirrored_target_present(void)
|
||||
{
|
||||
static int checked = 0;
|
||||
static int present = 0;
|
||||
static int _mirrored_checked = 0;
|
||||
static int _mirrored_present = 0;
|
||||
uint32_t maj, min, patchlevel;
|
||||
unsigned maj2, min2, patchlevel2;
|
||||
char vsn[80];
|
||||
|
||||
if (!checked) {
|
||||
present = target_present("mirror", 1);
|
||||
if (!_mirrored_checked) {
|
||||
_mirrored_present = target_present("mirror", 1);
|
||||
|
||||
/*
|
||||
* block_on_error available with mirror target >= 1.1
|
||||
@@ -348,13 +361,13 @@ static int _target_present(void)
|
||||
_block_on_error_available = 1;
|
||||
}
|
||||
|
||||
checked = 1;
|
||||
_mirrored_checked = 1;
|
||||
|
||||
return present;
|
||||
return _mirrored_present;
|
||||
}
|
||||
|
||||
#ifdef DMEVENTD
|
||||
static int _setup_registration(struct dm_pool *mem, struct config_tree *cft,
|
||||
static int _setup_registration(struct dm_pool *mem, struct cmd_context *cmd,
|
||||
char **dso)
|
||||
{
|
||||
char *path;
|
||||
@@ -365,10 +378,10 @@ static int _setup_registration(struct dm_pool *mem, struct config_tree *cft,
|
||||
return 0;
|
||||
}
|
||||
|
||||
libpath = find_config_str(cft->root, "dmeventd/mirror_library",
|
||||
DEFAULT_DMEVENTD_MIRROR_LIB);
|
||||
libpath = find_config_tree_str(cmd, "dmeventd/mirror_library",
|
||||
DEFAULT_DMEVENTD_MIRROR_LIB);
|
||||
|
||||
get_shared_library_path(cft, libpath, path, PATH_MAX);
|
||||
get_shared_library_path(cmd, libpath, path, PATH_MAX);
|
||||
|
||||
*dso = path;
|
||||
|
||||
@@ -377,9 +390,8 @@ static int _setup_registration(struct dm_pool *mem, struct config_tree *cft,
|
||||
|
||||
/* FIXME This gets run while suspended and performs banned operations. */
|
||||
/* FIXME Merge these two functions */
|
||||
static int _target_register_events(struct dm_pool *mem,
|
||||
struct lv_segment *seg,
|
||||
struct config_tree *cft, int events)
|
||||
static int _target_register_events(struct lv_segment *seg,
|
||||
int events)
|
||||
{
|
||||
char *dso, *name;
|
||||
struct logical_volume *lv;
|
||||
@@ -388,12 +400,12 @@ static int _target_register_events(struct dm_pool *mem,
|
||||
lv = seg->lv;
|
||||
vg = lv->vg;
|
||||
|
||||
if (!_setup_registration(mem, cft, &dso)) {
|
||||
if (!_setup_registration(vg->cmd->mem, vg->cmd, &dso)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(name = build_dm_name(mem, vg->name, lv->name, NULL)))
|
||||
if (!(name = build_dm_name(vg->cmd->mem, vg->name, lv->name, NULL)))
|
||||
return_0;
|
||||
|
||||
/* FIXME Save a returned handle here so we can unregister it later */
|
||||
@@ -405,9 +417,8 @@ static int _target_register_events(struct dm_pool *mem,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _target_unregister_events(struct dm_pool *mem,
|
||||
struct lv_segment *seg,
|
||||
struct config_tree *cft, int events)
|
||||
static int _target_unregister_events(struct lv_segment *seg,
|
||||
int events)
|
||||
{
|
||||
char *dso;
|
||||
char *name;
|
||||
@@ -418,10 +429,10 @@ static int _target_unregister_events(struct dm_pool *mem,
|
||||
vg = lv->vg;
|
||||
|
||||
/* FIXME Remove this and use handle to avoid config file race */
|
||||
if (!_setup_registration(mem, cft, &dso))
|
||||
if (!_setup_registration(vg->cmd->mem, vg->cmd, &dso))
|
||||
return_0;
|
||||
|
||||
if (!(name = build_dm_name(mem, vg->name, lv->name, NULL)))
|
||||
if (!(name = build_dm_name(vg->cmd->mem, vg->name, lv->name, NULL)))
|
||||
return_0;
|
||||
|
||||
/* FIXME Use handle returned by registration function instead of dso */
|
||||
@@ -436,27 +447,27 @@ static int _target_unregister_events(struct dm_pool *mem,
|
||||
#endif /* DMEVENTD */
|
||||
#endif /* DEVMAPPER_SUPPORT */
|
||||
|
||||
static void _destroy(const struct segment_type *segtype)
|
||||
static void _mirrored_destroy(const struct segment_type *segtype)
|
||||
{
|
||||
dm_free((void *) segtype);
|
||||
}
|
||||
|
||||
static struct segtype_handler _mirrored_ops = {
|
||||
name:_name,
|
||||
display:_display,
|
||||
text_import_area_count:_text_import_area_count,
|
||||
text_import:_text_import,
|
||||
text_export:_text_export,
|
||||
.name = _mirrored_name,
|
||||
.display = _mirrored_display,
|
||||
.text_import_area_count = _mirrored_text_import_area_count,
|
||||
.text_import = _mirrored_text_import,
|
||||
.text_export = _mirrored_text_export,
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
add_target_line:_add_target_line,
|
||||
target_percent:_target_percent,
|
||||
target_present:_target_present,
|
||||
.add_target_line = _mirrored_add_target_line,
|
||||
.target_percent = _mirrored_target_percent,
|
||||
.target_present = _mirrored_target_present,
|
||||
#ifdef DMEVENTD
|
||||
target_register_events:_target_register_events,
|
||||
target_unregister_events:_target_unregister_events,
|
||||
.target_register_events = _target_register_events,
|
||||
.target_unregister_events = _target_unregister_events,
|
||||
#endif
|
||||
#endif
|
||||
destroy:_destroy,
|
||||
.destroy = _mirrored_destroy,
|
||||
};
|
||||
|
||||
#ifdef MIRRORED_INTERNAL
|
||||
|
||||
429
lib/misc/configure.h.in
Normal file
429
lib/misc/configure.h.in
Normal file
@@ -0,0 +1,429 @@
|
||||
/* lib/misc/configure.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to 1 if the `closedir' function returns void instead of `int'. */
|
||||
#undef CLOSEDIR_VOID
|
||||
|
||||
/* Define to 1 to include built-in support for clustered LVM locking. */
|
||||
#undef CLUSTER_LOCKING_INTERNAL
|
||||
|
||||
/* Define to 1 to build the shared command library. */
|
||||
#undef CMDLIB
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
#undef CRAY_STACKSEG_END
|
||||
|
||||
/* Define to 1 if using `alloca.c'. */
|
||||
#undef C_ALLOCA
|
||||
|
||||
/* Define to 1 to enable device-mapper interaction. */
|
||||
#undef DEVMAPPER_SUPPORT
|
||||
|
||||
/* Define to 1 to enable the device-mapper event daemon. */
|
||||
#undef DMEVENTD
|
||||
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
#undef HAVE_ALLOCA
|
||||
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||
*/
|
||||
#undef HAVE_ALLOCA_H
|
||||
|
||||
/* Define to 1 if you have the <asm/byteorder.h> header file. */
|
||||
#undef HAVE_ASM_BYTEORDER_H
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#undef HAVE_ASSERT_H
|
||||
|
||||
/* Define to 1 if you have the <ctype.h> header file. */
|
||||
#undef HAVE_CTYPE_H
|
||||
|
||||
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_DIRENT_H
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
|
||||
#undef HAVE_DOPRNT
|
||||
|
||||
/* Define to 1 if you have the `dup2' function. */
|
||||
#undef HAVE_DUP2
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#undef HAVE_FORK
|
||||
|
||||
/* Define to 1 if you have the <fstab.h> header file. */
|
||||
#undef HAVE_FSTAB_H
|
||||
|
||||
/* Define to 1 if you have the `gethostname' function. */
|
||||
#undef HAVE_GETHOSTNAME
|
||||
|
||||
/* Define to 1 if you have the `getmntent' function. */
|
||||
#undef HAVE_GETMNTENT
|
||||
|
||||
/* Define to 1 to if getopt_long is available. */
|
||||
#undef HAVE_GETOPTLONG
|
||||
|
||||
/* Define to 1 if you have the <getopt.h> header file. */
|
||||
#undef HAVE_GETOPT_H
|
||||
|
||||
/* Define to 1 if you have the `getpagesize' function. */
|
||||
#undef HAVE_GETPAGESIZE
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <libdevmapper.h> header file. */
|
||||
#undef HAVE_LIBDEVMAPPER_H
|
||||
|
||||
/* Define to 1 if dynamic libraries are available. */
|
||||
#undef HAVE_LIBDL
|
||||
|
||||
/* Define to 1 if you have the <libgen.h> header file. */
|
||||
#undef HAVE_LIBGEN_H
|
||||
|
||||
/* Define to 1 if you have the <libintl.h> header file. */
|
||||
#undef HAVE_LIBINTL_H
|
||||
|
||||
/* Define to 1 if you have the `readline' library (-lreadline). */
|
||||
#undef HAVE_LIBREADLINE
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define to 1 if you have the <linux/fs.h> header file. */
|
||||
#undef HAVE_LINUX_FS_H
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#undef HAVE_LOCALE_H
|
||||
|
||||
/* Define to 1 if `lstat' has the bug that it succeeds when given the
|
||||
zero-length file name argument. */
|
||||
#undef HAVE_LSTAT_EMPTY_STRING_BUG
|
||||
|
||||
/* Define to 1 if you have the <machine/endian.h> header file. */
|
||||
#undef HAVE_MACHINE_ENDIAN_H
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
|
||||
to 0 otherwise. */
|
||||
#undef HAVE_MALLOC
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#undef HAVE_MALLOC_H
|
||||
|
||||
/* Define to 1 if you have the `memmove' function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* Define to 1 if you have the `mkdir' function. */
|
||||
#undef HAVE_MKDIR
|
||||
|
||||
/* Define to 1 if you have a working `mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
/* Define to 1 if you have the <mntent.h> header file. */
|
||||
#undef HAVE_MNTENT_H
|
||||
|
||||
/* Define to 1 if you have the `munmap' function. */
|
||||
#undef HAVE_MUNMAP
|
||||
|
||||
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#undef HAVE_NETDB_H
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#undef HAVE_NETINET_IN_H
|
||||
|
||||
/* Define to 1 if you have the <pthread.h> header file. */
|
||||
#undef HAVE_PTHREAD_H
|
||||
|
||||
/* Define to 1 if you have the <readline/history.h> header file. */
|
||||
#undef HAVE_READLINE_HISTORY_H
|
||||
|
||||
/* Define to 1 if you have the <readline/readline.h> header file. */
|
||||
#undef HAVE_READLINE_READLINE_H
|
||||
|
||||
/* Define to 1 if rl_completion_matches() is available. */
|
||||
#undef HAVE_RL_COMPLETION_MATCHES
|
||||
|
||||
/* Define to 1 if you have the `rmdir' function. */
|
||||
#undef HAVE_RMDIR
|
||||
|
||||
/* Define to 1 if you have the <search.h> header file. */
|
||||
#undef HAVE_SEARCH_H
|
||||
|
||||
/* Define to 1 if you have the `select' function. */
|
||||
#undef HAVE_SELECT
|
||||
|
||||
/* Define to 1 to include support for selinux. */
|
||||
#undef HAVE_SELINUX
|
||||
|
||||
/* Define to 1 if you have the <selinux/selinux.h> header file. */
|
||||
#undef HAVE_SELINUX_SELINUX_H
|
||||
|
||||
/* Define to 1 if you have the `setlocale' function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#undef HAVE_SIGNAL_H
|
||||
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#undef HAVE_SOCKET
|
||||
|
||||
/* Define to 1 if `stat' has the bug that it succeeds when given the
|
||||
zero-length file name argument. */
|
||||
#undef HAVE_STAT_EMPTY_STRING_BUG
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#undef HAVE_STDDEF_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdio.h> header file. */
|
||||
#undef HAVE_STDIO_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#undef HAVE_STRCASECMP
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#undef HAVE_STRCHR
|
||||
|
||||
/* Define to 1 if you have the `strdup' function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define to 1 if you have the `strerror' function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the `strncasecmp' function. */
|
||||
#undef HAVE_STRNCASECMP
|
||||
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
#undef HAVE_STRRCHR
|
||||
|
||||
/* Define to 1 if you have the `strstr' function. */
|
||||
#undef HAVE_STRSTR
|
||||
|
||||
/* Define to 1 if you have the `strtol' function. */
|
||||
#undef HAVE_STRTOL
|
||||
|
||||
/* Define to 1 if you have the `strtoul' function. */
|
||||
#undef HAVE_STRTOUL
|
||||
|
||||
/* Define to 1 if `st_rdev' is member of `struct stat'. */
|
||||
#undef HAVE_STRUCT_STAT_ST_RDEV
|
||||
|
||||
/* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use
|
||||
`HAVE_STRUCT_STAT_ST_RDEV' instead. */
|
||||
#undef HAVE_ST_RDEV
|
||||
|
||||
/* Define to 1 if you have the <syslog.h> header file. */
|
||||
#undef HAVE_SYSLOG_H
|
||||
|
||||
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_DIR_H
|
||||
|
||||
/* Define to 1 if you have the <sys/disk.h> header file. */
|
||||
#undef HAVE_SYS_DISK_H
|
||||
|
||||
/* Define to 1 if you have the <sys/file.h> header file. */
|
||||
#undef HAVE_SYS_FILE_H
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#undef HAVE_SYS_IOCTL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/mman.h> header file. */
|
||||
#undef HAVE_SYS_MMAN_H
|
||||
|
||||
/* Define to 1 if you have the <sys/mount.h> header file. */
|
||||
#undef HAVE_SYS_MOUNT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define to 1 if you have the <sys/resource.h> header file. */
|
||||
#undef HAVE_SYS_RESOURCE_H
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
#undef HAVE_SYS_UIO_H
|
||||
|
||||
/* Define to 1 if you have the <sys/un.h> header file. */
|
||||
#undef HAVE_SYS_UN_H
|
||||
|
||||
/* Define to 1 if you have the <sys/utsname.h> header file. */
|
||||
#undef HAVE_SYS_UTSNAME_H
|
||||
|
||||
/* Define to 1 if you have the <sys/vfs.h> header file. */
|
||||
#undef HAVE_SYS_VFS_H
|
||||
|
||||
/* Define to 1 if you have the <sys/wait.h> header file. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#undef HAVE_TIME_H
|
||||
|
||||
/* Define to 1 if you have the `uname' function. */
|
||||
#undef HAVE_UNAME
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the <utmpx.h> header file. */
|
||||
#undef HAVE_UTMPX_H
|
||||
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
#undef HAVE_VFORK
|
||||
|
||||
/* Define to 1 if you have the <vfork.h> header file. */
|
||||
#undef HAVE_VFORK_H
|
||||
|
||||
/* Define to 1 if you have the `vprintf' function. */
|
||||
#undef HAVE_VPRINTF
|
||||
|
||||
/* Define to 1 if `fork' works. */
|
||||
#undef HAVE_WORKING_FORK
|
||||
|
||||
/* Define to 1 if `vfork' works. */
|
||||
#undef HAVE_WORKING_VFORK
|
||||
|
||||
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
|
||||
slash. */
|
||||
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
|
||||
|
||||
/* Define to 1 if 'lvm' should fall back to using LVM1 binaries if
|
||||
device-mapper is missing from the kernel */
|
||||
#undef LVM1_FALLBACK
|
||||
|
||||
/* Define to 1 to include built-in support for LVM1 metadata. */
|
||||
#undef LVM1_INTERNAL
|
||||
|
||||
/* Define to 1 to include built-in support for mirrors. */
|
||||
#undef MIRRORED_INTERNAL
|
||||
|
||||
/* The path to 'modprobe', if available. */
|
||||
#undef MODPROBE_CMD
|
||||
|
||||
/* Define to 1 to enable O_DIRECT support. */
|
||||
#undef O_DIRECT_SUPPORT
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 to include built-in support for GFS pool metadata. */
|
||||
#undef POOL_INTERNAL
|
||||
|
||||
/* Define to 1 to include the LVM readline shell. */
|
||||
#undef READLINE_SUPPORT
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Define to the type of arg 1 for `select'. */
|
||||
#undef SELECT_TYPE_ARG1
|
||||
|
||||
/* Define to the type of args 2, 3 and 4 for `select'. */
|
||||
#undef SELECT_TYPE_ARG234
|
||||
|
||||
/* Define to the type of arg 5 for `select'. */
|
||||
#undef SELECT_TYPE_ARG5
|
||||
|
||||
/* Define to 1 to include built-in support for snapshots. */
|
||||
#undef SNAPSHOT_INTERNAL
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
#undef STACK_DIRECTION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
#undef TM_IN_SYS_TIME
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
/* 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 rpl_malloc if the replacement function should be used. */
|
||||
#undef malloc
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
#undef mode_t
|
||||
|
||||
/* Define to `long' if <sys/types.h> does not define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
#undef pid_t
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define as `fork' if `vfork' does not work. */
|
||||
#undef vfork
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "crc.h"
|
||||
|
||||
/* Calculate an endian-independent CRC of supplied buffer */
|
||||
uint32_t calc_crc(uint32_t initial, void *buf, uint32_t size)
|
||||
uint32_t calc_crc(uint32_t initial, const void *buf, uint32_t size)
|
||||
{
|
||||
static const uint32_t crctab[] = {
|
||||
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
|
||||
@@ -27,7 +27,7 @@ uint32_t calc_crc(uint32_t initial, void *buf, uint32_t size)
|
||||
0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
|
||||
};
|
||||
uint32_t i, crc = initial;
|
||||
uint8_t *data = (uint8_t *) buf;
|
||||
const uint8_t *data = (const uint8_t *) buf;
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
crc ^= *data++;
|
||||
|
||||
@@ -18,6 +18,6 @@
|
||||
|
||||
#define INITIAL_CRC 0xf597a6cf
|
||||
|
||||
uint32_t calc_crc(uint32_t initial, void *buf, uint32_t size);
|
||||
uint32_t calc_crc(uint32_t initial, const void *buf, uint32_t size);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#ifndef _LVM_LIB_H
|
||||
#define _LVM_LIB_H
|
||||
|
||||
#include <configure.h>
|
||||
|
||||
#define _REENTRANT
|
||||
#define _GNU_SOURCE
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
@@ -13,7 +13,11 @@
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _LVM_EXEC_H
|
||||
#define _LVM_EXEC_H
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
int exec_cmd(const char *command, const char *fscmd, const char *lv_path,
|
||||
const char *size);
|
||||
#endif
|
||||
|
||||
@@ -35,10 +35,10 @@ int create_temp_name(const char *dir, char *buffer, size_t len, int *fd)
|
||||
pid_t pid;
|
||||
char hostname[255];
|
||||
struct flock lock = {
|
||||
l_type:F_WRLCK,
|
||||
l_whence:0,
|
||||
l_start:0,
|
||||
l_len:0
|
||||
.l_type = F_WRLCK,
|
||||
.l_whence = 0,
|
||||
.l_start = 0,
|
||||
.l_len = 0
|
||||
};
|
||||
|
||||
num = rand();
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _LVM_FILE_H
|
||||
#define _LVM_FILE_H
|
||||
|
||||
/*
|
||||
* Create a temporary filename, and opens a descriptor to the file.
|
||||
*/
|
||||
@@ -44,3 +47,5 @@ int create_dir(const char *dir);
|
||||
|
||||
/* Sync directory changes */
|
||||
void sync_dir(const char *file);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -159,7 +159,9 @@ char *build_dm_name(struct dm_pool *mem, const char *vgname,
|
||||
_quote_hyphens(&out, lvname);
|
||||
|
||||
if (layer && *layer) {
|
||||
*out++ = '-';
|
||||
/* No hyphen if the layer begins with _ e.g. _mlog */
|
||||
if (*layer != '_')
|
||||
*out++ = '-';
|
||||
_quote_hyphens(&out, layer);
|
||||
}
|
||||
*out = '\0';
|
||||
@@ -208,3 +210,27 @@ int split_dm_name(struct dm_pool *mem, const char *dmname,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int validate_name(const char *n)
|
||||
{
|
||||
register char c;
|
||||
register int len = 0;
|
||||
|
||||
if (!n || !*n)
|
||||
return 0;
|
||||
|
||||
/* Hyphen used as VG-LV separator - ambiguity if LV starts with it */
|
||||
if (*n == '-')
|
||||
return 0;
|
||||
|
||||
if (!strcmp(n, ".") || !strcmp(n, ".."))
|
||||
return 0;
|
||||
|
||||
while ((len++, c = *n++))
|
||||
if (!isalnum(c) && c != '.' && c != '_' && c != '-' && c != '+')
|
||||
return 0;
|
||||
|
||||
if (len > NAME_LEN)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#define NAME_LEN 128
|
||||
|
||||
struct pool;
|
||||
|
||||
/*
|
||||
@@ -40,4 +42,6 @@ char *build_dm_name(struct dm_pool *mem, const char *vg,
|
||||
int split_dm_name(struct dm_pool *mem, const char *dmname,
|
||||
char **vgname, char **lvname, char **layer);
|
||||
|
||||
int validate_name(const char *n);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#include <sys/stat.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
void get_shared_library_path(struct config_tree *cft, const char *libname,
|
||||
char *path, int path_len)
|
||||
void get_shared_library_path(struct cmd_context *cmd, const char *libname,
|
||||
char *path, size_t path_len)
|
||||
{
|
||||
struct stat info;
|
||||
const char *lib_dir;
|
||||
@@ -31,29 +31,29 @@ void get_shared_library_path(struct config_tree *cft, const char *libname,
|
||||
/* If libname doesn't begin with '/' then use lib_dir/libname,
|
||||
* if present */
|
||||
if (libname[0] == '/' ||
|
||||
!(lib_dir = find_config_str(cft->root, "global/library_dir", 0)) ||
|
||||
!(lib_dir = find_config_tree_str(cmd, "global/library_dir", 0)) ||
|
||||
(lvm_snprintf(path, path_len, "%s/%s", lib_dir,
|
||||
libname) == -1) || stat(path, &info) == -1)
|
||||
strncpy(path, libname, path_len);
|
||||
}
|
||||
|
||||
void *load_shared_library(struct config_tree *cft, const char *libname,
|
||||
void *load_shared_library(struct cmd_context *cmd, const char *libname,
|
||||
const char *desc, int silent)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
void *library;
|
||||
|
||||
get_shared_library_path(cft, libname, path, sizeof(path));
|
||||
get_shared_library_path(cmd, libname, path, sizeof(path));
|
||||
|
||||
log_very_verbose("Opening shared %s library %s", desc, path);
|
||||
|
||||
if (!(library = dlopen(path, RTLD_LAZY))) {
|
||||
if (!(library = dlopen(path, RTLD_LAZY | RTLD_GLOBAL))) {
|
||||
if (silent && ignorelockingfailure())
|
||||
log_verbose("Unable to open external %s library %s",
|
||||
desc, path);
|
||||
log_verbose("Unable to open external %s library %s: %s",
|
||||
desc, path, dlerror());
|
||||
else
|
||||
log_error("Unable to open external %s library %s",
|
||||
desc, path);
|
||||
log_error("Unable to open external %s library %s: %s",
|
||||
desc, path, dlerror());
|
||||
}
|
||||
|
||||
return library;
|
||||
|
||||
@@ -13,10 +13,15 @@
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _LVM_SHAREDLIB_H
|
||||
#define _LVM_SHAREDLIB_H
|
||||
|
||||
#include "config.h"
|
||||
#include <dlfcn.h>
|
||||
|
||||
void get_shared_library_path(struct config_tree *cft, const char *libname,
|
||||
char *path, int path_len);
|
||||
void *load_shared_library(struct config_tree *cf, const char *libname,
|
||||
void get_shared_library_path(struct cmd_context *cmd, const char *libname,
|
||||
char *path, size_t path_len);
|
||||
void *load_shared_library(struct cmd_context *cmd, const char *libname,
|
||||
const char *what, int silent);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -90,7 +90,7 @@ static void _release_memory(void)
|
||||
}
|
||||
|
||||
/* Stop memory getting swapped out */
|
||||
static void _lock_memory(void)
|
||||
static void _lock_mem(void)
|
||||
{
|
||||
#ifdef MCL_CURRENT
|
||||
if (mlockall(MCL_CURRENT | MCL_FUTURE))
|
||||
@@ -109,7 +109,7 @@ static void _lock_memory(void)
|
||||
_default_priority, strerror(errno));
|
||||
}
|
||||
|
||||
static void _unlock_memory(void)
|
||||
static void _unlock_mem(void)
|
||||
{
|
||||
#ifdef MCL_CURRENT
|
||||
if (munlockall())
|
||||
@@ -126,14 +126,14 @@ static void _unlock_memory(void)
|
||||
void memlock_inc(void)
|
||||
{
|
||||
if (!_memlock_count++)
|
||||
_lock_memory();
|
||||
_lock_mem();
|
||||
log_debug("memlock_count inc to %d", _memlock_count);
|
||||
}
|
||||
|
||||
void memlock_dec(void)
|
||||
{
|
||||
if (_memlock_count && (!--_memlock_count))
|
||||
_unlock_memory();
|
||||
_unlock_mem();
|
||||
log_debug("memlock_count dec to %d", _memlock_count);
|
||||
}
|
||||
|
||||
@@ -144,13 +144,13 @@ int memlock(void)
|
||||
|
||||
void memlock_init(struct cmd_context *cmd)
|
||||
{
|
||||
_size_stack = find_config_int(cmd->cft->root,
|
||||
_size_stack = find_config_tree_int(cmd,
|
||||
"activation/reserved_stack",
|
||||
DEFAULT_RESERVED_STACK) * 1024;
|
||||
_size_malloc_tmp = find_config_int(cmd->cft->root,
|
||||
_size_malloc_tmp = find_config_tree_int(cmd,
|
||||
"activation/reserved_memory",
|
||||
DEFAULT_RESERVED_MEMORY) * 1024;
|
||||
_default_priority = find_config_int(cmd->cft->root,
|
||||
_default_priority = find_config_tree_int(cmd,
|
||||
"activation/process_priority",
|
||||
DEFAULT_PROCESS_PRIORITY);
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ static void _calc_functions(struct matcher *m)
|
||||
}
|
||||
}
|
||||
|
||||
static inline struct dfa_state *_create_dfa_state(struct dm_pool *mem)
|
||||
static struct dfa_state *_create_dfa_state(struct dm_pool *mem)
|
||||
{
|
||||
return dm_pool_zalloc(mem, sizeof(struct dfa_state));
|
||||
}
|
||||
@@ -196,17 +196,13 @@ static int _calc_states(struct matcher *m, struct rx_node *rx)
|
||||
struct state_queue *h, *t, *tmp;
|
||||
struct dfa_state *dfa, *ldfa;
|
||||
int i, a, set_bits = 0, count = 0;
|
||||
dm_bitset_t bs = dm_bitset_create(m->scratch, m->num_nodes), dfa_bits;
|
||||
dm_bitset_t bs, dfa_bits;
|
||||
|
||||
if (!tt) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!tt)
|
||||
return_0;
|
||||
|
||||
if (!bs) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
if (!(bs = dm_bitset_create(m->scratch, m->num_nodes)))
|
||||
return_0;
|
||||
|
||||
/* create first state */
|
||||
dfa = _create_dfa_state(m->mem);
|
||||
@@ -284,6 +280,7 @@ struct matcher *matcher_create(struct dm_pool *mem, const char **patterns,
|
||||
|
||||
if (!(m = dm_pool_alloc(mem, sizeof(*m)))) {
|
||||
stack;
|
||||
dm_pool_destroy(scratch);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -337,8 +334,7 @@ struct matcher *matcher_create(struct dm_pool *mem, const char **patterns,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct dfa_state *_step_matcher(int c,
|
||||
struct dfa_state *cs, int *r)
|
||||
static struct dfa_state *_step_matcher(int c, struct dfa_state *cs, int *r)
|
||||
{
|
||||
if (!(cs = cs->lookup[(unsigned char) c]))
|
||||
return NULL;
|
||||
|
||||
@@ -38,7 +38,7 @@ static void _single_char(struct parse_sp *ps, unsigned int c, const char *ptr)
|
||||
* Get the next token from the regular expression.
|
||||
* Returns: 1 success, 0 end of input, -1 error.
|
||||
*/
|
||||
static int _get_token(struct parse_sp *ps)
|
||||
static int _rx_get_token(struct parse_sp *ps)
|
||||
{
|
||||
int neg = 0, range = 0;
|
||||
char c, lc = 0;
|
||||
@@ -230,17 +230,17 @@ static struct rx_node *_term(struct parse_sp *ps)
|
||||
}
|
||||
|
||||
dm_bit_copy(n->charset, ps->charset);
|
||||
_get_token(ps); /* match charset */
|
||||
_rx_get_token(ps); /* match charset */
|
||||
break;
|
||||
|
||||
case '(':
|
||||
_get_token(ps); /* match '(' */
|
||||
_rx_get_token(ps); /* match '(' */
|
||||
n = _or_term(ps);
|
||||
if (ps->type != ')') {
|
||||
log_error("missing ')' in regular expression");
|
||||
return 0;
|
||||
}
|
||||
_get_token(ps); /* match ')' */
|
||||
_rx_get_token(ps); /* match ')' */
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -280,7 +280,7 @@ static struct rx_node *_closure_term(struct parse_sp *ps)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_get_token(ps);
|
||||
_rx_get_token(ps);
|
||||
l = n;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ static struct rx_node *_or_term(struct parse_sp *ps)
|
||||
if (ps->type != '|')
|
||||
return l;
|
||||
|
||||
_get_token(ps); /* match '|' */
|
||||
_rx_get_token(ps); /* match '|' */
|
||||
|
||||
if (!(r = _or_term(ps))) {
|
||||
log_error("Badly formed 'or' expression");
|
||||
@@ -344,7 +344,7 @@ struct rx_node *rx_parse_tok(struct dm_pool *mem,
|
||||
ps->charset = dm_bitset_create(mem, 256);
|
||||
ps->cursor = begin;
|
||||
ps->rx_end = end;
|
||||
_get_token(ps); /* load the first token */
|
||||
_rx_get_token(ps); /* load the first token */
|
||||
|
||||
if (!(r = _or_term(ps))) {
|
||||
log_error("Parse error in regex");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user