mirror of
git://sourceware.org/git/lvm2.git
synced 2025-12-25 20:23:49 +03:00
Compare commits
143 Commits
v2_02_37
...
dm_v1_02_2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc633e03aa | ||
|
|
797d0f1ef1 | ||
|
|
1be3e86aa0 | ||
|
|
e56dd38021 | ||
|
|
410904bef1 | ||
|
|
026cc120e7 | ||
|
|
ef2fda05cf | ||
|
|
92277e3ae2 | ||
|
|
fbc34d70b0 | ||
|
|
91dcddbdf7 | ||
|
|
874f42ad6c | ||
|
|
1989ef4ebc | ||
|
|
4f4c72c065 | ||
|
|
666cc72661 | ||
|
|
4524e8f5c9 | ||
|
|
bd07a29886 | ||
|
|
a0d865492e | ||
|
|
de27790de8 | ||
|
|
9c910b7be2 | ||
|
|
7f23ab94e2 | ||
|
|
77dc036c8f | ||
|
|
aa6e8d82ce | ||
|
|
3010285bb3 | ||
|
|
aaad3252f8 | ||
|
|
9065f534d8 | ||
|
|
52361c94e5 | ||
|
|
798be60fef | ||
|
|
6294154b15 | ||
|
|
6594fe077d | ||
|
|
582706cde6 | ||
|
|
6537cbdc17 | ||
|
|
53959459bb | ||
|
|
22d6121099 | ||
|
|
48d7f6f2f4 | ||
|
|
9fd4ddc490 | ||
|
|
a4d2fddbb2 | ||
|
|
c54a3f2721 | ||
|
|
04c0dba697 | ||
|
|
5406e3b7c5 | ||
|
|
6b624b7d00 | ||
|
|
2d364d4d80 | ||
|
|
1f27bf3774 | ||
|
|
d30a2653b5 | ||
|
|
3086822cd2 | ||
|
|
2c08336490 | ||
|
|
5936ac58c2 | ||
|
|
ded77e3f5c | ||
|
|
8a29df0a6c | ||
|
|
9db22babaf | ||
|
|
c318c5ed61 | ||
|
|
61243c65cd | ||
|
|
4a5d5cb462 | ||
|
|
cbf1447ebd | ||
|
|
30104441bf | ||
|
|
b4a70804f0 | ||
|
|
74f6707bde | ||
|
|
223eb8c84d | ||
|
|
107d000606 | ||
|
|
43e05607af | ||
|
|
55793452d5 | ||
|
|
686ba37255 | ||
|
|
03ed19dad5 | ||
|
|
ad2b6e5de1 | ||
|
|
767676d6ff | ||
|
|
bc7a54c615 | ||
|
|
1bda393678 | ||
|
|
bb5495c6bd | ||
|
|
484f905749 | ||
|
|
e0d61a4336 | ||
|
|
e643a16ba5 | ||
|
|
98fadec2b6 | ||
|
|
14f464ecb0 | ||
|
|
2ecdaf9bd4 | ||
|
|
707c898f66 | ||
|
|
69e4400774 | ||
|
|
695efde68d | ||
|
|
0c4b769011 | ||
|
|
e53eff0634 | ||
|
|
6c75243a06 | ||
|
|
efde37880b | ||
|
|
7d8f6381be | ||
|
|
3c361e3393 | ||
|
|
8440ecef5e | ||
|
|
6401f1b1c9 | ||
|
|
7487a7c988 | ||
|
|
f44584fa10 | ||
|
|
7b32165614 | ||
|
|
b0dc94d187 | ||
|
|
0383c4e1d8 | ||
|
|
a8c5758222 | ||
|
|
a7fabfd8cb | ||
|
|
5d5b575d16 | ||
|
|
ac1373653c | ||
|
|
b097aa787b | ||
|
|
723be0fe69 | ||
|
|
f0597a03de | ||
|
|
65f0656f54 | ||
|
|
507ece15a5 | ||
|
|
30be4d1613 | ||
|
|
366e89bda0 | ||
|
|
f159c3f768 | ||
|
|
8506d1d567 | ||
|
|
111829da46 | ||
|
|
605798073e | ||
|
|
8320f2b094 | ||
|
|
df0d8d809b | ||
|
|
062886df64 | ||
|
|
148ea3aaa8 | ||
|
|
ab5f66c13a | ||
|
|
e65ffb8e68 | ||
|
|
949c1ab517 | ||
|
|
946d8ee046 | ||
|
|
c54a8a2e10 | ||
|
|
31177e4f85 | ||
|
|
750f81b4b5 | ||
|
|
987ff02a45 | ||
|
|
f5adaf813c | ||
|
|
78ff7dc7f0 | ||
|
|
d1fced3324 | ||
|
|
e7df9c289b | ||
|
|
a78d7231a9 | ||
|
|
ba7ae0002e | ||
|
|
a090f7b839 | ||
|
|
34ed15a987 | ||
|
|
cacec4c910 | ||
|
|
3e47d4e65b | ||
|
|
8b42fa150b | ||
|
|
60e660b9c7 | ||
|
|
fe74f013e3 | ||
|
|
24c0c70f90 | ||
|
|
757f91ca89 | ||
|
|
5c34f7847e | ||
|
|
de456f014e | ||
|
|
d29565066d | ||
|
|
4d52c9233b | ||
|
|
6da1ca0cb9 | ||
|
|
2f02f1518a | ||
|
|
e8863707de | ||
|
|
6a336dfc69 | ||
|
|
35dec1b9e4 | ||
|
|
f148280c99 | ||
|
|
599fe39749 | ||
|
|
44f3fcb238 |
40
Makefile.in
40
Makefile.in
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
# Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
|
||||
# Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
@@ -36,9 +36,10 @@ ifeq ($(MAKECMDGOALS),distclean)
|
||||
lib/locking \
|
||||
lib/mirror \
|
||||
lib/snapshot \
|
||||
po \
|
||||
test/mm test/device test/format1 test/regex test/filters
|
||||
test \
|
||||
po
|
||||
DISTCLEAN_TARGETS += lib/misc/configure.h
|
||||
DISTCLEAN_DIRS += lcov_reports*
|
||||
endif
|
||||
|
||||
include make.tmpl
|
||||
@@ -71,3 +72,36 @@ endif
|
||||
|
||||
check: all
|
||||
$(MAKE) -C test all
|
||||
|
||||
ifneq ("@LCOV@", "")
|
||||
.PHONY: lcov-reset lcov lcov-dated
|
||||
|
||||
ifeq ($(MAKECMDGOALS),lcov-dated)
|
||||
LCOV_REPORTS_DIR=$(top_srcdir)/lcov_reports-$(shell date +%Y%m%d%k%M%S)
|
||||
else
|
||||
LCOV_REPORTS_DIR=$(top_srcdir)/lcov_reports
|
||||
endif
|
||||
|
||||
lcov-reset:
|
||||
$(LCOV) -d $(top_srcdir)/dmeventd --zerocounters
|
||||
$(LCOV) -d $(top_srcdir)/lib --zerocounters
|
||||
$(LCOV) -d $(top_srcdir)/tools --zerocounters
|
||||
|
||||
lcov: all
|
||||
$(RM) -rf $(LCOV_REPORTS_DIR)
|
||||
$(MKDIR_P) $(LCOV_REPORTS_DIR)
|
||||
$(LCOV) -b $(top_srcdir)/lib -d $(top_srcdir)/lib -c -o $(LCOV_REPORTS_DIR)/lib.info
|
||||
$(LCOV) -b $(top_srcdir)/tools -d $(top_srcdir)/tools -c -o $(LCOV_REPORTS_DIR)/tools.info
|
||||
DMEVENTD_INFO="$(LCOV_REPORTS_DIR)/dmeventd.info" ;\
|
||||
DMEVENTD_INFO_A="-a $$DMEVENTDINFO" ;\
|
||||
$(LCOV) -b $(top_srcdir)/dmeventd -d $(top_srcdir)/dmeventd -c -o $$DMEVENTD_INFO || DMEVENTD_INFO_A="" ;\
|
||||
$(LCOV) $$DMEVENTD_INFO_A -a $(LCOV_REPORTS_DIR)/lib.info \
|
||||
-a $(LCOV_REPORTS_DIR)/tools.info \
|
||||
-o $(LCOV_REPORTS_DIR)/lvm.info
|
||||
ifneq ("@GENHTML@", "")
|
||||
$(GENHTML) -o $(LCOV_REPORTS_DIR) -p $(top_srcdir) $(LCOV_REPORTS_DIR)/lvm.info
|
||||
endif
|
||||
|
||||
lcov-dated: lcov
|
||||
|
||||
endif
|
||||
|
||||
74
WHATS_NEW
74
WHATS_NEW
@@ -1,3 +1,77 @@
|
||||
Version 2.02.40 -
|
||||
================================
|
||||
Avoid shuffling remaining mirror images when removing one, retaining primary.
|
||||
Add missing LV error target activation in _remove_mirror_images.
|
||||
Prevent resizing an LV while lvconvert is using it.
|
||||
Avoid repeatedly wiping cache while VG_GLOBAL is held in vgscan & pvscan.
|
||||
Fix pvresize to not allow resize if PV has two metadata areas.
|
||||
Fix setting of volume limit count if converting to lvm1 format.
|
||||
Fix vgconvert logical volume id metadata validation.
|
||||
Fix lvmdump metadata gather option (-m) to work correctly.
|
||||
Fix allocation bug in text metadata format write error path.
|
||||
Fix vgcfgbackup to properly check filename if template is used.
|
||||
configure aborts if lcov or genhtml are missing with --enable-profiling
|
||||
vgremove tries to remove lv snapshot first.
|
||||
Added function lv_remove_with_dependencies().
|
||||
Improve file descriptor leak detection to display likely culprit and filename.
|
||||
Change clustered mirror kernel module name from cmirror to dm-log-clustered.
|
||||
Avoid looping forever in _pv_analyze_mda_raw used by pvck.
|
||||
Change lvchange exit status to indicate if any part of the operation failed.
|
||||
Fix pvchange and pvremove to handle PVs without mdas.
|
||||
Refactor _text_pv_read and always return mda list if requested.
|
||||
Fix configure to work w/o readline unless --enable-readline used. (2.02.39)
|
||||
Remove is_lvm_partition template which has not yet been coded.
|
||||
Refactor pvcreate to separate parameter parsing from validation logic.
|
||||
Check for label_write() failure in _text_pv_write().
|
||||
Add pvcreate tests and update vgsplit tests to handle lvm1 and lvm2 metadata.
|
||||
Fix pvchange -M1 -u to preserve existing extent locations when there's a VG.
|
||||
Cease recognising snapshot-in-use percentages returned by early devt kernels.
|
||||
Add backward-compatible flags field to on-disk format_text metadata.
|
||||
Fix dmeventd monitoring libraries to link against liblvm2cmd again. (2.02.39)
|
||||
|
||||
Version 2.02.39 - 27th June 2008
|
||||
================================
|
||||
Enable readline by default if available.
|
||||
Update autoconf to 2008-01-16.
|
||||
Add $DISTCLEAN_DIRS to make.tmpl.in.
|
||||
Create coverage reports with --enable-profiling and make lcov or lcov-dated.
|
||||
Fix up cache for PVs without mdas after consistent VG metadata is processed.
|
||||
Update validation of safe mirror log type conversions in lvconvert.
|
||||
Fix lvconvert to disallow snapshot and mirror combinations.
|
||||
Fix reporting of LV fields alongside unallocated PV segments.
|
||||
Add --unquoted and --rows to reporting tools.
|
||||
Add and use uninitialized_var() macro to suppress invalid compiler warnings.
|
||||
Introduce enum for md minor sb version to suppress compiler warning.
|
||||
Avoid undefined return value after _memlock manipulation in lvm2_run.
|
||||
Avoid link failure if configured without --enable-cmdlib or --enable-readline.
|
||||
Make clvmd return at once if other nodes down in a gulm or openais cluster.
|
||||
Fix and improve readahead 'auto' calculation for stripe_size.
|
||||
Fix lvchange output for -r auto setting if auto is already set.
|
||||
Add test case for readahead.
|
||||
Avoid ambiguous use of identifier error_message_produced.
|
||||
Begin syncing configure.in for merge/unification with device-mapper.
|
||||
Fix add_mirror_images not to dereference uninitialized log_lv upon failure.
|
||||
Don't call openlog for every debug line output by clvmd.
|
||||
Add --force to lvextend and lvresize.
|
||||
Fix vgchange not to activate component mirror volumes directly.
|
||||
Fix test directory clean up in make distclean.
|
||||
|
||||
Version 2.02.38 - 11th June 2008
|
||||
================================
|
||||
Fix tracking of validity of PVs with no mdas in lvmcache.
|
||||
Fix return values for reporting commands when run with no PVs, LVs, or VGs.
|
||||
Add omitted unlock_vg() call when sigint_caught() during vg processing.
|
||||
Fix free_count when reading pool metadata.
|
||||
Fix segfault when using pvcreate on a device containing pool metadata.
|
||||
Fix segfault after _free_vginfo by remembering to remove vginfo from list.
|
||||
Tweak detection of invalid fid after changes to PVs in VG in _vg_read.
|
||||
Revert assuming precommitted metadata is live when activating (unnecessary).
|
||||
Drop cached metadata for disappearing VG in vgmerge.
|
||||
In script-processing mode, stop if any command fails.
|
||||
Warn if command exits with non-zero status code without a prior log_error.
|
||||
Check lv_count in vg_validate.
|
||||
Add --nameprefixes to reporting tools for field name prefix output format.
|
||||
|
||||
Version 2.02.37 - 6th June 2008
|
||||
===============================
|
||||
Make clvmd-cman use a hash rather than an array for node updown info.
|
||||
|
||||
25
WHATS_NEW_DM
25
WHATS_NEW_DM
@@ -1,11 +1,30 @@
|
||||
Version 1.02.26 -
|
||||
=================================
|
||||
Version 1.02.29 -
|
||||
=====================================
|
||||
|
||||
Version 1.02.28 - 18th September 2008
|
||||
=====================================
|
||||
Only resume devices in dm_tree_preload_children if size changes.
|
||||
Extend deptree buffers so the largest possible device numbers fit.
|
||||
Generate versioned libdevmapper-event.so.
|
||||
Underline longer report help text headings.
|
||||
|
||||
Version 1.02.27 - 25th June 2008
|
||||
================================
|
||||
Align struct memblock in dbg_malloc for sparc.
|
||||
Add --unquoted and --rows to dmsetup.
|
||||
Avoid compiler warning about cast in dmsetup.c's OFFSET_OF macro.
|
||||
Fix inverted no_flush debug message.
|
||||
Remove --enable-jobs from configure. (Set at runtime instead.)
|
||||
Bring configure.in and list.h into line with the lvm2 versions.
|
||||
|
||||
Version 1.02.26 - 6th June 2008
|
||||
===============================
|
||||
Initialise params buffer to empty string in _emit_segment.
|
||||
Skip add_dev_node when ioctls disabled.
|
||||
Make dm_hash_iter safe against deletion.
|
||||
Accept a NULL pointer to dm_free silently.
|
||||
Add tables_loaded, readonly and suspended columns to reports.
|
||||
Add --prefixes to dmsetup.
|
||||
Add --nameprefixes to dmsetup.
|
||||
Add field name prefix option to reporting functions.
|
||||
Calculate string size within dm_pool_grow_object.
|
||||
|
||||
|
||||
60
autoconf/config.guess
vendored
60
autoconf/config.guess
vendored
@@ -1,10 +1,10 @@
|
||||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
||||
# Inc.
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2006-07-02'
|
||||
timestamp='2008-01-23'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@@ -56,8 +56,8 @@ version="\
|
||||
GNU config.guess ($timestamp)
|
||||
|
||||
Originally written by Per Bothner.
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
|
||||
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
@@ -161,6 +161,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
arm*) machine=arm-unknown ;;
|
||||
sh3el) machine=shl-unknown ;;
|
||||
sh3eb) machine=sh-unknown ;;
|
||||
sh5el) machine=sh5le-unknown ;;
|
||||
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
|
||||
esac
|
||||
# The Operating System including object format, if it has switched
|
||||
@@ -329,7 +330,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
|
||||
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit ;;
|
||||
i86pc:SunOS:5.*:*)
|
||||
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
|
||||
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit ;;
|
||||
sun4*:SunOS:6*:*)
|
||||
@@ -531,7 +532,7 @@ EOF
|
||||
echo rs6000-ibm-aix3.2
|
||||
fi
|
||||
exit ;;
|
||||
*:AIX:*:[45])
|
||||
*:AIX:*:[456])
|
||||
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
|
||||
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
|
||||
IBM_ARCH=rs6000
|
||||
@@ -780,7 +781,7 @@ EOF
|
||||
i*:CYGWIN*:*)
|
||||
echo ${UNAME_MACHINE}-pc-cygwin
|
||||
exit ;;
|
||||
i*:MINGW*:*)
|
||||
*:MINGW*:*)
|
||||
echo ${UNAME_MACHINE}-pc-mingw32
|
||||
exit ;;
|
||||
i*:windows32*:*)
|
||||
@@ -790,12 +791,18 @@ EOF
|
||||
i*:PW*:*)
|
||||
echo ${UNAME_MACHINE}-pc-pw32
|
||||
exit ;;
|
||||
x86:Interix*:[3456]*)
|
||||
echo i586-pc-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
EM64T:Interix*:[3456]*)
|
||||
echo x86_64-unknown-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
*:Interix*:[3456]*)
|
||||
case ${UNAME_MACHINE} in
|
||||
x86)
|
||||
echo i586-pc-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
EM64T | authenticamd)
|
||||
echo x86_64-unknown-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
IA64)
|
||||
echo ia64-unknown-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
esac ;;
|
||||
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
|
||||
echo i${UNAME_MACHINE}-pc-mks
|
||||
exit ;;
|
||||
@@ -829,7 +836,14 @@ EOF
|
||||
echo ${UNAME_MACHINE}-pc-minix
|
||||
exit ;;
|
||||
arm*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
eval $set_cc_for_build
|
||||
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
|
||||
| grep -q __ARM_EABI__
|
||||
then
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
else
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
|
||||
fi
|
||||
exit ;;
|
||||
avr32*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
@@ -950,6 +964,9 @@ EOF
|
||||
x86_64:Linux:*:*)
|
||||
echo x86_64-unknown-linux-gnu
|
||||
exit ;;
|
||||
xtensa*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
i*86:Linux:*:*)
|
||||
# The BFD linker knows what the default object file format is, so
|
||||
# first see if it will tell us. cd to the root directory to prevent
|
||||
@@ -1208,6 +1225,15 @@ EOF
|
||||
SX-6:SUPER-UX:*:*)
|
||||
echo sx6-nec-superux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
SX-7:SUPER-UX:*:*)
|
||||
echo sx7-nec-superux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
SX-8:SUPER-UX:*:*)
|
||||
echo sx8-nec-superux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
SX-8R:SUPER-UX:*:*)
|
||||
echo sx8r-nec-superux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
Power*:Rhapsody:*:*)
|
||||
echo powerpc-apple-rhapsody${UNAME_RELEASE}
|
||||
exit ;;
|
||||
@@ -1458,9 +1484,9 @@ This script, last modified $timestamp, has failed to recognize
|
||||
the operating system you are using. It is advised that you
|
||||
download the most up to date version of the config scripts from
|
||||
|
||||
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
|
||||
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
|
||||
and
|
||||
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
|
||||
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
|
||||
|
||||
If the version you run ($0) is already up to date, please
|
||||
send the following data and any information you think might be
|
||||
|
||||
66
autoconf/config.sub
vendored
66
autoconf/config.sub
vendored
@@ -1,10 +1,10 @@
|
||||
#! /bin/sh
|
||||
# Configuration validation subroutine script.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
||||
# Inc.
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2006-09-20'
|
||||
timestamp='2008-01-16'
|
||||
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
@@ -72,8 +72,8 @@ Report bugs and patches to <config-patches@gnu.org>."
|
||||
version="\
|
||||
GNU config.sub ($timestamp)
|
||||
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
|
||||
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
@@ -245,12 +245,12 @@ case $basic_machine in
|
||||
| bfin \
|
||||
| c4x | clipper \
|
||||
| d10v | d30v | dlx | dsp16xx \
|
||||
| fr30 | frv \
|
||||
| fido | fr30 | frv \
|
||||
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
|
||||
| i370 | i860 | i960 | ia64 \
|
||||
| ip2k | iq2000 \
|
||||
| m32c | m32r | m32rle | m68000 | m68k | m88k \
|
||||
| maxq | mb | microblaze | mcore \
|
||||
| maxq | mb | microblaze | mcore | mep \
|
||||
| mips | mipsbe | mipseb | mipsel | mipsle \
|
||||
| mips16 \
|
||||
| mips64 | mips64el \
|
||||
@@ -324,7 +324,7 @@ case $basic_machine in
|
||||
| clipper-* | craynv-* | cydra-* \
|
||||
| d10v-* | d30v-* | dlx-* \
|
||||
| elxsi-* \
|
||||
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
|
||||
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
|
||||
| h8300-* | h8500-* \
|
||||
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
|
||||
| i*86-* | i860-* | i960-* | ia64-* \
|
||||
@@ -369,10 +369,14 @@ case $basic_machine in
|
||||
| v850-* | v850e-* | vax-* \
|
||||
| we32k-* \
|
||||
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
|
||||
| xstormy16-* | xtensa-* \
|
||||
| xstormy16-* | xtensa*-* \
|
||||
| ymp-* \
|
||||
| z8k-*)
|
||||
;;
|
||||
# Recognize the basic CPU types without company name, with glob match.
|
||||
xtensa*)
|
||||
basic_machine=$basic_machine-unknown
|
||||
;;
|
||||
# Recognize the various machine names and aliases which stand
|
||||
# for a CPU type and a company and sometimes even an OS.
|
||||
386bsd)
|
||||
@@ -443,6 +447,14 @@ case $basic_machine in
|
||||
basic_machine=ns32k-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
blackfin)
|
||||
basic_machine=bfin-unknown
|
||||
os=-linux
|
||||
;;
|
||||
blackfin-*)
|
||||
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
os=-linux
|
||||
;;
|
||||
c90)
|
||||
basic_machine=c90-cray
|
||||
os=-unicos
|
||||
@@ -475,8 +487,8 @@ case $basic_machine in
|
||||
basic_machine=craynv-cray
|
||||
os=-unicosmp
|
||||
;;
|
||||
cr16c)
|
||||
basic_machine=cr16c-unknown
|
||||
cr16)
|
||||
basic_machine=cr16-unknown
|
||||
os=-elf
|
||||
;;
|
||||
crds | unos)
|
||||
@@ -668,6 +680,14 @@ case $basic_machine in
|
||||
basic_machine=m68k-isi
|
||||
os=-sysv
|
||||
;;
|
||||
m68knommu)
|
||||
basic_machine=m68k-unknown
|
||||
os=-linux
|
||||
;;
|
||||
m68knommu-*)
|
||||
basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
os=-linux
|
||||
;;
|
||||
m88k-omron*)
|
||||
basic_machine=m88k-omron
|
||||
;;
|
||||
@@ -683,6 +703,10 @@ case $basic_machine in
|
||||
basic_machine=i386-pc
|
||||
os=-mingw32
|
||||
;;
|
||||
mingw32ce)
|
||||
basic_machine=arm-unknown
|
||||
os=-mingw32ce
|
||||
;;
|
||||
miniframe)
|
||||
basic_machine=m68000-convergent
|
||||
;;
|
||||
@@ -809,6 +833,14 @@ case $basic_machine in
|
||||
basic_machine=i860-intel
|
||||
os=-osf
|
||||
;;
|
||||
parisc)
|
||||
basic_machine=hppa-unknown
|
||||
os=-linux
|
||||
;;
|
||||
parisc-*)
|
||||
basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
os=-linux
|
||||
;;
|
||||
pbd)
|
||||
basic_machine=sparc-tti
|
||||
;;
|
||||
@@ -925,6 +957,9 @@ case $basic_machine in
|
||||
basic_machine=sh-hitachi
|
||||
os=-hms
|
||||
;;
|
||||
sh5el)
|
||||
basic_machine=sh5le-unknown
|
||||
;;
|
||||
sh64)
|
||||
basic_machine=sh64-unknown
|
||||
;;
|
||||
@@ -1014,6 +1049,10 @@ case $basic_machine in
|
||||
basic_machine=tic6x-unknown
|
||||
os=-coff
|
||||
;;
|
||||
tile*)
|
||||
basic_machine=tile-unknown
|
||||
os=-linux-gnu
|
||||
;;
|
||||
tx39)
|
||||
basic_machine=mipstx39-unknown
|
||||
;;
|
||||
@@ -1219,7 +1258,7 @@ case $os in
|
||||
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
|
||||
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
|
||||
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
|
||||
| -skyos* | -haiku* | -rdos* | -toppers*)
|
||||
| -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
-qnx*)
|
||||
@@ -1414,6 +1453,9 @@ case $basic_machine in
|
||||
m68*-cisco)
|
||||
os=-aout
|
||||
;;
|
||||
mep-*)
|
||||
os=-elf
|
||||
;;
|
||||
mips*-cisco)
|
||||
os=-elf
|
||||
;;
|
||||
|
||||
282
configure.in
282
configure.in
@@ -1,8 +1,6 @@
|
||||
##
|
||||
###############################################################################
|
||||
## Copyright (C) 2000-2004 Sistina Software, Inc. All rights reserved.
|
||||
## Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
|
||||
##
|
||||
## This file is part of LVM2.
|
||||
## Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
|
||||
##
|
||||
## This copyrighted material is made available to anyone wishing to use,
|
||||
## modify, copy, or redistribute it subject to the terms and conditions
|
||||
@@ -18,9 +16,7 @@ AC_PREREQ(2.57)
|
||||
dnl -- Process this file with autoconf to produce a configure script.
|
||||
AC_INIT
|
||||
AC_CONFIG_SRCDIR([lib/device/dev-cache.h])
|
||||
|
||||
################################################################################
|
||||
AC_CONFIG_HEADERS(lib/misc/configure.h)
|
||||
AC_CONFIG_HEADERS([lib/misc/configure.h])
|
||||
|
||||
################################################################################
|
||||
dnl -- Setup the directory where autoconf has auxilary files
|
||||
@@ -32,57 +28,63 @@ AC_CANONICAL_TARGET([])
|
||||
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
CFLAGS="$CFLAGS"
|
||||
COPTIMISE_FLAG="-O2"
|
||||
CLDFLAGS="$CLDFLAGS -Wl,--version-script,.export.sym"
|
||||
CLDWHOLEARCHIVE="-Wl,-whole-archive"
|
||||
CLDNOWHOLEARCHIVE="-Wl,-no-whole-archive"
|
||||
LDDEPS="$LDDEPS .export.sym"
|
||||
LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
|
||||
LIB_SUFFIX="so"
|
||||
LIB_SUFFIX=so
|
||||
DEVMAPPER=yes
|
||||
ODIRECT=yes
|
||||
DM_IOCTLS=yes
|
||||
SELINUX=yes
|
||||
REALTIME=yes
|
||||
CLUSTER=internal
|
||||
FSADM=no ;;
|
||||
FSADM=no
|
||||
;;
|
||||
darwin*)
|
||||
CFLAGS="$CFLAGS -no-cpp-precomp -fno-common"
|
||||
COPTIMISE_FLAG="-O2"
|
||||
CLDFLAGS="$CLDFLAGS"
|
||||
CLDWHOLEARCHIVE="-all_load"
|
||||
CLDNOWHOLEARCHIVE=
|
||||
LDDEPS="$LDDEPS"
|
||||
LDFLAGS="$LDFLAGS"
|
||||
LIB_SUFFIX="dylib"
|
||||
LIB_SUFFIX=dylib
|
||||
DEVMAPPER=yes
|
||||
ODIRECT=no
|
||||
DM_IOCTLS=no
|
||||
SELINUX=no
|
||||
REALTIME=no
|
||||
CLUSTER=none
|
||||
FSADM=no ;;
|
||||
FSADM=no
|
||||
;;
|
||||
esac
|
||||
|
||||
################################################################################
|
||||
dnl -- Checks for programs.
|
||||
AC_PROG_AWK
|
||||
AC_PROG_CC
|
||||
|
||||
dnl probably no longer needed in 2008, but...
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_MKDIR_P
|
||||
AC_PROG_RANLIB
|
||||
AC_PATH_PROG(CFLOW_CMD, cflow)
|
||||
AC_PATH_PROG(CSCOPE_CMD, cscope)
|
||||
|
||||
################################################################################
|
||||
dnl -- Checks for header files.
|
||||
dnl -- Check for header files.
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_HEADER_TIME
|
||||
|
||||
AC_CHECK_HEADERS(fcntl.h limits.h locale.h stddef.h syslog.h sys/file.h sys/ioctl.h sys/param.h sys/time.h,,AC_MSG_ERROR(bailing out))
|
||||
AC_CHECK_HEADERS(assert.h ctype.h libgen.h signal.h stdio.h sys/mman.h sys/resource.h sys/stat.h sys/types.h sys/utsname.h sys/wait.h time.h,,AC_MSG_ERROR(bailing out))
|
||||
AC_CHECK_HEADERS([locale.h stddef.h syslog.h sys/file.h sys/time.h assert.h \
|
||||
libgen.h signal.h sys/mman.h sys/resource.h sys/utsname.h sys/wait.h time.h], ,
|
||||
[AC_MSG_ERROR(bailing out)])
|
||||
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
@@ -91,12 +93,19 @@ case "$host_os" in
|
||||
AC_CHECK_HEADERS(machine/endian.h sys/disk.h,,AC_MSG_ERROR(bailing out)) ;;
|
||||
esac
|
||||
|
||||
AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h getopt.h inttypes.h limits.h \
|
||||
stdarg.h stdio.h stdlib.h string.h sys/ioctl.h sys/param.h sys/stat.h \
|
||||
sys/types.h unistd.h], , [AC_MSG_ERROR(bailing out)])
|
||||
AC_CHECK_HEADERS(termios.h sys/statvfs.h)
|
||||
|
||||
################################################################################
|
||||
dnl -- Checks for typedefs, structures, and compiler characteristics.
|
||||
dnl -- Check for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_C_INLINE
|
||||
AC_CHECK_MEMBERS([struct stat.st_rdev])
|
||||
AC_TYPE_OFF_T
|
||||
AC_TYPE_PID_T
|
||||
AC_TYPE_SIGNAL
|
||||
AC_TYPE_SIZE_T
|
||||
AC_TYPE_MODE_T
|
||||
AC_CHECK_MEMBERS([struct stat.st_rdev])
|
||||
@@ -104,7 +113,9 @@ AC_STRUCT_TM
|
||||
|
||||
################################################################################
|
||||
dnl -- Check for functions
|
||||
AC_CHECK_FUNCS(gethostname getpagesize memset munmap setlocale strcasecmp strchr strdup strncasecmp strerror strrchr strstr strtol strtoul,,AC_MSG_ERROR(bailing out))
|
||||
AC_CHECK_FUNCS([gethostname getpagesize memset mkdir rmdir munmap setlocale \
|
||||
strcasecmp strchr strdup strncasecmp strerror strrchr strstr strtol strtoul \
|
||||
uname], , [AC_MSG_ERROR(bailing out)])
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_CLOSEDIR_VOID
|
||||
AC_FUNC_FORK
|
||||
@@ -114,22 +125,19 @@ AC_FUNC_MEMCMP
|
||||
AC_FUNC_MMAP
|
||||
AC_FUNC_STAT
|
||||
AC_FUNC_STRTOD
|
||||
AC_FUNC_VPRINTF
|
||||
|
||||
################################################################################
|
||||
dnl -- Prefix is /usr by default, the exec_prefix default is setup later
|
||||
AC_PREFIX_DEFAULT(/usr)
|
||||
|
||||
################################################################################
|
||||
dnl -- Parallel make jobs?
|
||||
AC_ARG_ENABLE(jobs, [ --enable-jobs=NUM Number of jobs to run simultaneously], JOBS=-j$enableval, JOBS=-j2)
|
||||
|
||||
################################################################################
|
||||
dnl -- Setup the ownership of the files
|
||||
AC_MSG_CHECKING(file owner)
|
||||
OWNER="root"
|
||||
|
||||
AC_ARG_WITH(user,
|
||||
[ --with-user=USER Set the owner of installed files ],
|
||||
[ --with-user=USER Set the owner of installed files [[USER=root]] ],
|
||||
[ OWNER="$withval" ])
|
||||
AC_MSG_RESULT($OWNER)
|
||||
|
||||
@@ -142,7 +150,7 @@ dnl -- Setup the group ownership of the files
|
||||
AC_MSG_CHECKING(group owner)
|
||||
GROUP="root"
|
||||
AC_ARG_WITH(group,
|
||||
[ --with-group=GROUP Set the group owner of installed files ],
|
||||
[ --with-group=GROUP Set the group owner of installed files [[GROUP=root]] ],
|
||||
[ GROUP="$withval" ])
|
||||
AC_MSG_RESULT($GROUP)
|
||||
|
||||
@@ -261,30 +269,13 @@ if test x$MIRRORS = xinternal; then
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
dnl -- Enables staticly-linked tools
|
||||
AC_MSG_CHECKING(whether to use static linking)
|
||||
AC_ARG_ENABLE(static_link, [ --enable-static_link Use this to link the tools to their libraries
|
||||
statically. Default is dynamic linking], STATIC_LINK=$enableval, STATIC_LINK=no)
|
||||
AC_MSG_RESULT($STATIC_LINK)
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable readline
|
||||
dnl -- Disable readline
|
||||
AC_MSG_CHECKING(whether to enable readline)
|
||||
AC_ARG_ENABLE(readline, [ --enable-readline Enable readline support],
|
||||
READLINE=$enableval, READLINE=no)
|
||||
AC_ARG_ENABLE([readline],
|
||||
[ --disable-readline Disable readline support],
|
||||
[READLINE=$enableval], [READLINE=maybe])
|
||||
AC_MSG_RESULT($READLINE)
|
||||
|
||||
if test x$READLINE = xyes; then
|
||||
AC_DEFINE([READLINE_SUPPORT], 1, [Define to 1 to include the LVM readline shell.])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
dnl -- Disable selinux
|
||||
AC_MSG_CHECKING(whether to enable selinux support)
|
||||
AC_ARG_ENABLE(selinux, [ --disable-selinux Disable selinux support],
|
||||
SELINUX=$enableval)
|
||||
AC_MSG_RESULT($SELINUX)
|
||||
|
||||
################################################################################
|
||||
dnl -- Disable realtime clock support
|
||||
AC_MSG_CHECKING(whether to enable realtime support)
|
||||
@@ -314,7 +305,7 @@ fi
|
||||
dnl -- Enable debugging
|
||||
AC_MSG_CHECKING(whether to enable debugging)
|
||||
AC_ARG_ENABLE(debug, [ --enable-debug Enable debugging],
|
||||
DEBUG=$enableval, DEBUG=no)
|
||||
DEBUG=$enableval, DEBUG=no)
|
||||
AC_MSG_RESULT($DEBUG)
|
||||
|
||||
dnl -- Normally turn off optimisation for debug builds
|
||||
@@ -328,10 +319,27 @@ fi
|
||||
dnl -- Override optimisation
|
||||
AC_MSG_CHECKING(for C optimisation flag)
|
||||
AC_ARG_WITH(optimisation,
|
||||
[ --with-optimisation=OPT C optimisation flag [OPT=-O2] ],
|
||||
[ --with-optimisation=OPT C optimisation flag [[OPT=-O2]] ],
|
||||
[ COPTIMISE_FLAG="$withval" ])
|
||||
AC_MSG_RESULT($COPTIMISE_FLAG)
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable profiling
|
||||
AC_MSG_CHECKING(whether to gather gcov profiling data)
|
||||
AC_ARG_ENABLE(profiling,
|
||||
AC_HELP_STRING(--enable-profiling, [Gather gcov profiling data]),
|
||||
PROFILING=$enableval, PROFILING=no)
|
||||
AC_MSG_RESULT($PROFILING)
|
||||
|
||||
if test "x$PROFILING" = xyes; then
|
||||
COPTIMISE_FLAG="$COPTIMISE_FLAG -fprofile-arcs -ftest-coverage"
|
||||
AC_PATH_PROG(LCOV, lcov, no)
|
||||
AC_PATH_PROG(GENHTML, genhtml, no)
|
||||
if test "$LCOV" = no -o "$GENHTML" = no ; then
|
||||
AC_MSG_ERROR([lcov and genhtml are required for profiling])
|
||||
fi
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
dnl -- Disable devmapper
|
||||
AC_MSG_CHECKING(whether to use device-mapper)
|
||||
@@ -360,6 +368,11 @@ AC_MSG_CHECKING(whether to compile liblvm2cmd.so)
|
||||
AC_ARG_ENABLE(cmdlib, [ --enable-cmdlib Build shared command library],
|
||||
CMDLIB=$enableval, CMDLIB=no)
|
||||
AC_MSG_RESULT($CMDLIB)
|
||||
AC_SUBST([LVM2CMD_LIB])
|
||||
test x$CMDLIB = xyes \
|
||||
&& LVM2CMD_LIB=-llvm2cmd \
|
||||
|| LVM2CMD_LIB=
|
||||
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable fsadm
|
||||
@@ -376,33 +389,35 @@ DMEVENTD=$enableval)
|
||||
AC_MSG_RESULT($DMEVENTD)
|
||||
|
||||
dnl -- dmeventd currently requires internal mirror support
|
||||
if test x$DMEVENTD = xyes && test x$MIRRORS != xinternal; then
|
||||
AC_MSG_ERROR(
|
||||
--enable-dmeventd currently requires --with-mirrors=internal
|
||||
)
|
||||
if test x$DMEVENTD = xyes; then
|
||||
if test x$MIRRORS != xinternal; then
|
||||
AC_MSG_ERROR(
|
||||
--enable-dmeventd currently requires --with-mirrors=internal
|
||||
)
|
||||
fi
|
||||
if test x$CMDLIB = xno; then
|
||||
AC_MSG_ERROR(
|
||||
--enable-dmeventd requires --enable-cmdlib to be used as well
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$DMEVENTD = xyes; then
|
||||
AC_DEFINE([DMEVENTD], 1, [Define to 1 to enable the device-mapper event daemon.])
|
||||
fi
|
||||
################################################################################
|
||||
dnl -- Mess with default exec_prefix
|
||||
dnl -- Clear default exec_prefix - install into /sbin rather than /usr/sbin
|
||||
if [[ "x$exec_prefix" = xNONE -a "x$prefix" = xNONE ]];
|
||||
then exec_prefix="";
|
||||
fi;
|
||||
|
||||
################################################################################
|
||||
dnl -- Checks for library functions.
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
AC_TYPE_SIGNAL
|
||||
AC_FUNC_VPRINTF
|
||||
AC_CHECK_FUNCS(mkdir rmdir uname,,AC_MSG_ERROR(bailing out))
|
||||
|
||||
################################################################################
|
||||
dnl -- Check for termcap (Shamelessly copied from parted 1.4.17)
|
||||
if test x$READLINE = xyes; then
|
||||
AC_SEARCH_LIBS(tgetent, ncurses curses termcap termlib, ,
|
||||
AC_MSG_ERROR(
|
||||
if test x$READLINE != xno; then
|
||||
AC_SEARCH_LIBS([tgetent], [ncurses curses termcap termlib],
|
||||
[tg_found=yes], [tg_found=no])
|
||||
test x$READLINE:$tg_found = xyes:no &&
|
||||
AC_MSG_ERROR(
|
||||
termcap could not be found which is required for the
|
||||
--enable-readline option (which is enabled by default). Either disable readline
|
||||
support with --disable-readline or download and install termcap from:
|
||||
@@ -412,7 +427,6 @@ Note: if you are using precompiled packages you will also need the development
|
||||
Note: (n)curses also seems to work as a substitute for termcap. This was
|
||||
not found either - but you could try installing that as well.
|
||||
)
|
||||
)
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -436,12 +450,30 @@ Features cannot be 'shared' when building statically
|
||||
)
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
dnl -- Enables statically-linked tools
|
||||
AC_MSG_CHECKING(whether to use static linking)
|
||||
AC_ARG_ENABLE(static_link,
|
||||
[ --enable-static_link Use this to link the tools to their libraries
|
||||
statically. Default is dynamic linking],
|
||||
STATIC_LINK=$enableval, STATIC_LINK=no)
|
||||
AC_MSG_RESULT($STATIC_LINK)
|
||||
|
||||
################################################################################
|
||||
dnl -- Disable selinux
|
||||
AC_MSG_CHECKING(whether to enable selinux support)
|
||||
AC_ARG_ENABLE(selinux, [ --disable-selinux Disable selinux support],
|
||||
SELINUX=$enableval)
|
||||
AC_MSG_RESULT($SELINUX)
|
||||
|
||||
################################################################################
|
||||
dnl -- Check for selinux
|
||||
if test x$SELINUX = xyes; then
|
||||
AC_CHECK_LIB(sepol, sepol_check_context, HAVE_SEPOL=yes, HAVE_SEPOL=no)
|
||||
|
||||
if test x$HAVE_SEPOL = xyes; then
|
||||
AC_DEFINE([HAVE_SEPOL], 1,
|
||||
[Define to 1 if sepol_check_context is available.])
|
||||
LIBS="-lsepol $LIBS"
|
||||
fi
|
||||
|
||||
@@ -454,7 +486,7 @@ if test x$SELINUX = xyes; then
|
||||
AC_MSG_WARN(Disabling selinux)
|
||||
fi
|
||||
|
||||
# With --enable-static_link and selinux enabled, linking lvm.static
|
||||
# With --enable-static_link and selinux enabled, linking
|
||||
# fails on at least Debian unstable due to unsatisfied references
|
||||
# to pthread_mutex_lock and _unlock. See if we need -lpthread.
|
||||
if test "$STATIC_LINK-$HAVE_SELINUX" = yes-yes; then
|
||||
@@ -482,13 +514,15 @@ fi
|
||||
|
||||
################################################################################
|
||||
dnl -- Check for getopt
|
||||
AC_CHECK_HEADERS(getopt.h, AC_DEFINE([HAVE_GETOPTLONG], 1, [Define to 1 to if getopt_long is available.]))
|
||||
AC_CHECK_HEADERS(getopt.h, AC_DEFINE([HAVE_GETOPTLONG], 1, [Define to 1 if getopt_long is available.]))
|
||||
|
||||
################################################################################
|
||||
dnl -- Check for readline (Shamelessly copied from parted 1.4.17)
|
||||
if test x$READLINE = xyes; then
|
||||
AC_CHECK_LIB(readline, readline, ,
|
||||
AC_MSG_ERROR(
|
||||
if test x$READLINE != xno; then
|
||||
rl_found=yes
|
||||
AC_CHECK_LIB([readline], [readline], , [rl_found=no])
|
||||
test x$READLINE:$rl_found = xyes:no &&
|
||||
AC_MSG_ERROR(
|
||||
GNU Readline could not be found which is required for the
|
||||
--enable-readline option (which is enabled by default). Either disable readline
|
||||
support with --disable-readline or download and install readline from:
|
||||
@@ -496,8 +530,11 @@ support with --disable-readline or download and install readline from:
|
||||
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, AC_DEFINE([HAVE_RL_COMPLETION_MATCHES], 1, [Define to 1 if rl_completion_matches() is available.]))
|
||||
if test $rl_found = yes; then
|
||||
AC_CHECK_FUNCS([rl_completion_matches])
|
||||
AC_DEFINE([READLINE_SUPPORT], 1,
|
||||
[Define to 1 to include the LVM readline shell.])
|
||||
fi
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@@ -517,25 +554,25 @@ if test x$INTL = xyes; then
|
||||
fi;
|
||||
|
||||
AC_ARG_WITH(localedir,
|
||||
[ --with-localedir=DIR Translation files in DIR [PREFIX/share/locale]],
|
||||
[ LOCALEDIR="$withval" ],
|
||||
[ LOCALEDIR='${prefix}/share/locale' ])
|
||||
[ --with-localedir=DIR Translation files in DIR [[PREFIX/share/locale]] ],
|
||||
[ LOCALEDIR="$withval" ],
|
||||
[ LOCALEDIR='${prefix}/share/locale' ])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
AC_ARG_WITH(confdir,
|
||||
[ --with-confdir=DIR Configuration files in DIR [/etc]],
|
||||
[ CONFDIR="$withval" ],
|
||||
[ CONFDIR='/etc' ])
|
||||
[ CONFDIR="$withval" ],
|
||||
[ CONFDIR='/etc' ])
|
||||
|
||||
AC_ARG_WITH(staticdir,
|
||||
[ --with-staticdir=DIR Static binary in DIR [EXEC_PREFIX/sbin]],
|
||||
[ STATICDIR="$withval" ],
|
||||
[ STATICDIR='${exec_prefix}/sbin' ])
|
||||
[ STATICDIR="$withval" ],
|
||||
[ STATICDIR='${exec_prefix}/sbin' ])
|
||||
|
||||
AC_ARG_WITH(dmdir,
|
||||
[ --with-dmdir=DIR Build against device-mapper source tree in DIR],
|
||||
[ DMDIR="$withval" CPPFLAGS="$CPPFLAGS -I$DMDIR/include"],
|
||||
[ DMDIR="$withval" CPPFLAGS="$CPPFLAGS -I$DMDIR/include"],
|
||||
[ DMDIR= ])
|
||||
|
||||
# Convert a relative dir name to absolute.
|
||||
@@ -585,51 +622,56 @@ if test x$MODPROBE_CMD != x; then
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
if test "-f VERSION"; then
|
||||
LVM_VERSION="\"`cat VERSION`\""
|
||||
else
|
||||
LVM_VERSION="Unknown"
|
||||
fi
|
||||
LVM_VERSION="\"`cat VERSION 2>/dev/null || echo Unknown`\""
|
||||
|
||||
################################################################################
|
||||
AC_SUBST(JOBS)
|
||||
AC_SUBST(STATIC_LINK)
|
||||
AC_SUBST(LVM1)
|
||||
AC_SUBST(POOL)
|
||||
AC_SUBST(SNAPSHOTS)
|
||||
AC_SUBST(MIRRORS)
|
||||
AC_SUBST(OWNER)
|
||||
AC_SUBST(GROUP)
|
||||
AC_SUBST(BUILD_DMEVENTD)
|
||||
AC_SUBST(CFLAGS)
|
||||
AC_SUBST(COPTIMISE_FLAG)
|
||||
AC_SUBST(CFLOW_CMD)
|
||||
AC_SUBST(CLDFLAGS)
|
||||
AC_SUBST(CLDWHOLEARCHIVE)
|
||||
AC_SUBST(CLDNOWHOLEARCHIVE)
|
||||
AC_SUBST(LDDEPS)
|
||||
AC_SUBST(LDFLAGS)
|
||||
AC_SUBST(LIB_SUFFIX)
|
||||
AC_SUBST(LIBS)
|
||||
AC_SUBST(LVM_VERSION)
|
||||
AC_SUBST(LVM1_FALLBACK)
|
||||
AC_SUBST(CLDWHOLEARCHIVE)
|
||||
AC_SUBST(CLUSTER)
|
||||
AC_SUBST(CLVMD)
|
||||
AC_SUBST(CMDLIB)
|
||||
AC_SUBST(COPTIMISE_FLAG)
|
||||
AC_SUBST(CSCOPE_CMD)
|
||||
AC_SUBST(DEBUG)
|
||||
AC_SUBST(DEVMAPPER)
|
||||
AC_SUBST(HAVE_LIBDL)
|
||||
AC_SUBST(HAVE_SELINUX)
|
||||
AC_SUBST(HAVE_REALTIME)
|
||||
AC_SUBST(CMDLIB)
|
||||
AC_SUBST(MSGFMT)
|
||||
AC_SUBST(LOCALEDIR)
|
||||
AC_SUBST(CONFDIR)
|
||||
AC_SUBST(STATICDIR)
|
||||
AC_SUBST(DMDIR)
|
||||
AC_SUBST(INTL_PACKAGE)
|
||||
AC_SUBST(INTL)
|
||||
AC_SUBST(CLVMD)
|
||||
AC_SUBST(CLUSTER)
|
||||
AC_SUBST(FSADM)
|
||||
# FIXME: rename to LVM_USE_DMEVENTD
|
||||
AC_SUBST(DMEVENTD)
|
||||
AC_SUBST(CFLOW_CMD)
|
||||
AC_SUBST(CSCOPE_CMD)
|
||||
AC_SUBST(DM_COMPAT)
|
||||
AC_SUBST(DM_DEVICE_GID)
|
||||
AC_SUBST(DM_DEVICE_MODE)
|
||||
AC_SUBST(DM_DEVICE_UID)
|
||||
AC_SUBST(DM_IOCTLS)
|
||||
AC_SUBST(DM_LIB_VERSION)
|
||||
AC_SUBST(FSADM)
|
||||
AC_SUBST(GROUP)
|
||||
AC_SUBST(HAVE_LIBDL)
|
||||
AC_SUBST(HAVE_REALTIME)
|
||||
AC_SUBST(HAVE_SELINUX)
|
||||
AC_SUBST(INTL)
|
||||
AC_SUBST(INTL_PACKAGE)
|
||||
AC_SUBST(JOBS)
|
||||
AC_SUBST(LDDEPS)
|
||||
AC_SUBST(LIBS)
|
||||
AC_SUBST(LIB_SUFFIX)
|
||||
AC_SUBST(LOCALEDIR)
|
||||
AC_SUBST(LVM1)
|
||||
AC_SUBST(LVM1_FALLBACK)
|
||||
# FIXME: rename to LVM_CONF_DIR
|
||||
AC_SUBST(CONFDIR)
|
||||
AC_SUBST(LVM_VERSION)
|
||||
AC_SUBST(MIRRORS)
|
||||
AC_SUBST(MSGFMT)
|
||||
AC_SUBST(OWNER)
|
||||
AC_SUBST(PKGCONFIG)
|
||||
AC_SUBST(POOL)
|
||||
AC_SUBST(SNAPSHOTS)
|
||||
AC_SUBST(STATICDIR)
|
||||
AC_SUBST(STATIC_LINK)
|
||||
AC_SUBST([LIB_PTHREAD])
|
||||
|
||||
################################################################################
|
||||
@@ -638,22 +680,22 @@ dnl -- keep utility scripts running properly
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
make.tmpl
|
||||
include/Makefile
|
||||
lib/Makefile
|
||||
man/Makefile
|
||||
po/Makefile
|
||||
dmeventd/Makefile
|
||||
daemons/Makefile
|
||||
daemons/clvmd/Makefile
|
||||
dmeventd/Makefile
|
||||
dmeventd/mirror/Makefile
|
||||
dmeventd/snapshot/Makefile
|
||||
doc/Makefile
|
||||
include/Makefile
|
||||
lib/Makefile
|
||||
lib/format1/Makefile
|
||||
lib/format_pool/Makefile
|
||||
lib/locking/Makefile
|
||||
lib/mirror/Makefile
|
||||
lib/snapshot/Makefile
|
||||
test/Makefile
|
||||
man/Makefile
|
||||
po/Makefile
|
||||
scripts/Makefile
|
||||
tools/Makefile
|
||||
tools/version.h
|
||||
|
||||
@@ -665,6 +665,7 @@ static int _cluster_do_node_callback(struct local_client *master_client,
|
||||
{
|
||||
struct dm_hash_node *hn;
|
||||
struct node_info *ninfo;
|
||||
int somedown = 0;
|
||||
|
||||
dm_hash_iterate(hn, node_hash)
|
||||
{
|
||||
@@ -686,12 +687,14 @@ static int _cluster_do_node_callback(struct local_client *master_client,
|
||||
client = dm_hash_lookup_binary(sock_hash, csid, GULM_MAX_CSID_LEN);
|
||||
|
||||
}
|
||||
DEBUGLOG("down_callback2. node %s, state = %d\n", ninfo->name, ninfo->state);
|
||||
if (ninfo->state != NODE_DOWN)
|
||||
callback(master_client, csid, ninfo->state == NODE_CLVMD);
|
||||
|
||||
|
||||
if (ninfo->state != NODE_CLVMD)
|
||||
somedown = -1;
|
||||
}
|
||||
return 0;
|
||||
return somedown;
|
||||
}
|
||||
|
||||
/* Convert gulm error codes to unix errno numbers */
|
||||
|
||||
@@ -452,6 +452,7 @@ static int _cluster_do_node_callback(struct local_client *master_client,
|
||||
{
|
||||
struct dm_hash_node *hn;
|
||||
struct node_info *ninfo;
|
||||
int somedown = 0;
|
||||
|
||||
dm_hash_iterate(hn, node_hash)
|
||||
{
|
||||
@@ -465,8 +466,10 @@ static int _cluster_do_node_callback(struct local_client *master_client,
|
||||
|
||||
if (ninfo->state != NODE_DOWN)
|
||||
callback(master_client, csid, ninfo->state == NODE_CLVMD);
|
||||
if (ninfo->state != NODE_CLVMD)
|
||||
somedown = -1;
|
||||
}
|
||||
return 0;
|
||||
return somedown;
|
||||
}
|
||||
|
||||
/* Real locking */
|
||||
|
||||
@@ -182,8 +182,10 @@ void debuglog(const char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
if (debug == DEBUG_SYSLOG) {
|
||||
if (!syslog_init)
|
||||
if (!syslog_init) {
|
||||
openlog("clvmd", LOG_PID, LOG_DAEMON);
|
||||
syslog_init = 1;
|
||||
}
|
||||
|
||||
va_start(ap,fmt);
|
||||
vsyslog(LOG_DEBUG, fmt, ap);
|
||||
|
||||
@@ -23,6 +23,7 @@ ifeq ("@LIB_SUFFIX@","dylib")
|
||||
LIB_SHARED = libdevmapper-event.dylib
|
||||
else
|
||||
LIB_SHARED = libdevmapper-event.so
|
||||
VERSIONED_SHLIB = $(LIB_SHARED).$(LIB_VERSION)
|
||||
endif
|
||||
|
||||
TARGETS = dmeventd
|
||||
@@ -33,7 +34,7 @@ include ../make.tmpl
|
||||
LDFLAGS += -ldl -ldevmapper -lpthread
|
||||
CLDFLAGS += -ldl -ldevmapper -lpthread
|
||||
|
||||
dmeventd: $(LIB_SHARED) dmeventd.o
|
||||
dmeventd: $(LIB_SHARED) $(VERSIONED_SHLIB) dmeventd.o
|
||||
$(CC) -o $@ dmeventd.o $(CFLAGS) $(LDFLAGS) \
|
||||
-L. -ldevmapper-event $(LIBS) -rdynamic
|
||||
|
||||
@@ -74,6 +75,10 @@ install_static: libdevmapper-event.a
|
||||
$(libdir)/libdevmapper-event.a.$(LIB_VERSION)
|
||||
$(LN_S) -f libdevmapper-event.a.$(LIB_VERSION) $(libdir)/libdevmapper-event.a
|
||||
|
||||
$(VERSIONED_SHLIB): $(LIB_SHARED)
|
||||
$(RM) -f $@
|
||||
$(LN_S) $(LIB_SHARED) $@
|
||||
|
||||
.PHONY: distclean_lib distclean
|
||||
|
||||
distclean_lib:
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <arpa/inet.h> /* for htonl, ntohl */
|
||||
|
||||
#ifdef linux
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
# Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
|
||||
# Copyright (C) 2004-2005, 2008 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
@@ -17,7 +17,7 @@ top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
INCLUDES += -I${top_srcdir}/tools
|
||||
CLDFLAGS += -L${top_srcdir}/tools -ldevmapper -llvm2cmd
|
||||
CLDFLAGS += -L${top_srcdir}/tools -ldevmapper @LVM2CMD_LIB@
|
||||
|
||||
SOURCES = dmeventd_mirror.c
|
||||
|
||||
@@ -33,4 +33,3 @@ install: libdevmapper-event-lvm2mirror.$(LIB_SUFFIX)
|
||||
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
|
||||
$(libdir)/$<.$(LIB_VERSION)
|
||||
$(LN_S) -f $<.$(LIB_VERSION) $(libdir)/$<
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
INCLUDES += -I${top_srcdir}/tools
|
||||
CLDFLAGS += -L${top_srcdir}/tools -ldevmapper -llvm2cmd
|
||||
CLDFLAGS += -L${top_srcdir}/tools -ldevmapper @LVM2CMD_LIB@
|
||||
|
||||
SOURCES = dmeventd_snapshot.c
|
||||
|
||||
@@ -33,4 +33,3 @@ install: libdevmapper-event-lvm2snapshot.$(LIB_SUFFIX)
|
||||
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
|
||||
$(libdir)/$<.$(LIB_VERSION)
|
||||
$(LN_S) -f $<.$(LIB_VERSION) $(libdir)/$<
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
# Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
|
||||
# Copyright (C) 2004-2005, 2008 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
@@ -17,7 +17,7 @@ top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
INCLUDES += -I${top_srcdir}/tools
|
||||
CLDFLAGS += -L${top_srcdir}/tools -ldevmapper -llvm2cmd
|
||||
CLDFLAGS += -L${top_srcdir}/tools -ldevmapper @LVM2CMD_LIB@
|
||||
|
||||
SOURCES = dmeventd_mirror.c
|
||||
|
||||
@@ -33,4 +33,3 @@ install: libdevmapper-event-lvm2mirror.$(LIB_SUFFIX)
|
||||
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
|
||||
$(libdir)/$<.$(LIB_VERSION)
|
||||
$(LN_S) -f $<.$(LIB_VERSION) $(libdir)/$<
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
INCLUDES += -I${top_srcdir}/tools
|
||||
CLDFLAGS += -L${top_srcdir}/tools -ldevmapper -llvm2cmd
|
||||
CLDFLAGS += -L${top_srcdir}/tools -ldevmapper @LVM2CMD_LIB@
|
||||
|
||||
SOURCES = dmeventd_snapshot.c
|
||||
|
||||
@@ -33,4 +33,3 @@ install: libdevmapper-event-lvm2snapshot.$(LIB_SUFFIX)
|
||||
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
|
||||
$(libdir)/$<.$(LIB_VERSION)
|
||||
$(LN_S) -f $<.$(LIB_VERSION) $(libdir)/$<
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ SOURCES =\
|
||||
format_text/import_vsn1.c \
|
||||
format_text/tags.c \
|
||||
format_text/text_label.c \
|
||||
freeseg/freeseg.c \
|
||||
label/label.c \
|
||||
locking/file_locking.c \
|
||||
locking/locking.c \
|
||||
|
||||
@@ -993,11 +993,7 @@ int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
|
||||
if (!activation())
|
||||
goto activate;
|
||||
|
||||
/*
|
||||
* If we're activating and precommitted metadata is still cached,
|
||||
* we assume it matches the new live metadata.
|
||||
*/
|
||||
if (!(lv = lv_from_lvid(cmd, lvid_s, 1)))
|
||||
if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
|
||||
return 0;
|
||||
|
||||
if (!_passes_activation_filter(cmd, lv)) {
|
||||
@@ -1022,11 +1018,7 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
|
||||
if (!activation())
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* If we're activating and precommitted metadata is still cached,
|
||||
* we assume it matches the new live metadata.
|
||||
*/
|
||||
if (!(lv = lv_from_lvid(cmd, lvid_s, 1)))
|
||||
if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
|
||||
return 0;
|
||||
|
||||
if (filter && !_passes_activation_filter(cmd, lv)) {
|
||||
|
||||
@@ -379,8 +379,7 @@ static int _percent_run(struct dev_manager *dm, const char *name,
|
||||
!segtype->ops->target_percent(&dm->target_state, dm->mem,
|
||||
dm->cmd, seg, params,
|
||||
&total_numerator,
|
||||
&total_denominator,
|
||||
percent))
|
||||
&total_denominator))
|
||||
goto_out;
|
||||
|
||||
} while (next);
|
||||
@@ -393,7 +392,7 @@ static int _percent_run(struct dev_manager *dm, const char *name,
|
||||
|
||||
if (total_denominator)
|
||||
*percent = (float) total_numerator *100 / total_denominator;
|
||||
else if (*percent < 0)
|
||||
else
|
||||
*percent = 100;
|
||||
|
||||
log_debug("LV percent: %f", *percent);
|
||||
@@ -928,8 +927,8 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
|
||||
break;
|
||||
if (lv_is_cow(lv) && !layer)
|
||||
break;
|
||||
if (max_stripe_size < seg->stripe_size)
|
||||
max_stripe_size = seg->stripe_size;
|
||||
if (max_stripe_size < seg->stripe_size * seg->area_count)
|
||||
max_stripe_size = seg->stripe_size * seg->area_count;
|
||||
}
|
||||
|
||||
if (read_ahead == DM_READ_AHEAD_AUTO) {
|
||||
|
||||
50
lib/cache/lvmcache.c
vendored
50
lib/cache/lvmcache.c
vendored
@@ -97,9 +97,10 @@ static void _update_cache_info_lock_state(struct lvmcache_info *info,
|
||||
int was_locked = (info->status & CACHE_LOCKED) ? 1 : 0;
|
||||
|
||||
/*
|
||||
* Cache becomes invalid whenever lock state changes
|
||||
* Cache becomes invalid whenever lock state changes unless
|
||||
* exclusive VG_GLOBAL is held (i.e. while scanning).
|
||||
*/
|
||||
if (was_locked != locked) {
|
||||
if (!vgname_is_locked(VG_GLOBAL) && (was_locked != locked)) {
|
||||
info->status |= CACHE_INVALID;
|
||||
*cached_vgmetadata_valid = 0;
|
||||
}
|
||||
@@ -166,7 +167,7 @@ void lvmcache_drop_metadata(const char *vgname)
|
||||
|
||||
/* Indicate that PVs could now be missing from the cache */
|
||||
init_full_scan_done(0);
|
||||
} else
|
||||
} else if (!vgname_is_locked(VG_GLOBAL))
|
||||
_drop_metadata(vgname);
|
||||
}
|
||||
|
||||
@@ -631,11 +632,14 @@ struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid)
|
||||
|
||||
static int _free_vginfo(struct lvmcache_vginfo *vginfo)
|
||||
{
|
||||
struct lvmcache_vginfo *primary_vginfo, *vginfo2;
|
||||
int r = 1;
|
||||
|
||||
_free_cached_vgmetadata(vginfo);
|
||||
|
||||
if (vginfo_from_vgname(vginfo->vgname, NULL) == vginfo) {
|
||||
vginfo2 = primary_vginfo = vginfo_from_vgname(vginfo->vgname, NULL);
|
||||
|
||||
if (vginfo == primary_vginfo) {
|
||||
dm_hash_remove(_vgname_hash, vginfo->vgname);
|
||||
if (vginfo->next && !dm_hash_insert(_vgname_hash, vginfo->vgname,
|
||||
vginfo->next)) {
|
||||
@@ -643,7 +647,12 @@ static int _free_vginfo(struct lvmcache_vginfo *vginfo)
|
||||
vginfo->vgname);
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
} else do
|
||||
if (vginfo2->next == vginfo) {
|
||||
vginfo2->next = vginfo->next;
|
||||
break;
|
||||
}
|
||||
while ((vginfo2 = primary_vginfo->next));
|
||||
|
||||
if (vginfo->vgname)
|
||||
dm_free(vginfo->vgname);
|
||||
@@ -837,6 +846,7 @@ static int _lvmcache_update_vgname(struct lvmcache_info *info,
|
||||
{
|
||||
struct lvmcache_vginfo *vginfo, *primary_vginfo, *orphan_vginfo;
|
||||
struct lvmcache_info *info2, *info3;
|
||||
char mdabuf[32];
|
||||
// struct lvmcache_vginfo *old_vginfo, *next;
|
||||
|
||||
if (!vgname || (info && info->vginfo && !strcmp(info->vginfo->vgname, vgname)))
|
||||
@@ -906,11 +916,16 @@ static int _lvmcache_update_vgname(struct lvmcache_info *info,
|
||||
orphan_vginfo = vginfo_from_vgname(primary_vginfo->fmt->orphan_vg_name, NULL);
|
||||
_drop_vginfo(info2, primary_vginfo);
|
||||
_vginfo_attach_info(orphan_vginfo, info2);
|
||||
log_debug("lvmcache: %s: now in VG %s%s%s%s",
|
||||
if (info2->mdas.n)
|
||||
sprintf(mdabuf, " with %u mdas",
|
||||
list_size(&info2->mdas));
|
||||
else
|
||||
mdabuf[0] = '\0';
|
||||
log_debug("lvmcache: %s: now in VG %s%s%s%s%s",
|
||||
dev_name(info2->dev),
|
||||
vgname, orphan_vginfo->vgid[0] ? " (" : "",
|
||||
orphan_vginfo->vgid[0] ? orphan_vginfo->vgid : "",
|
||||
orphan_vginfo->vgid[0] ? ")" : "");
|
||||
orphan_vginfo->vgid[0] ? ")" : "", mdabuf);
|
||||
}
|
||||
|
||||
if (!_insert_vginfo(vginfo, vgid, vgstatus, creation_host,
|
||||
@@ -939,13 +954,17 @@ static int _lvmcache_update_vgname(struct lvmcache_info *info,
|
||||
/* FIXME Check consistency of list! */
|
||||
vginfo->fmt = fmt;
|
||||
|
||||
if (info)
|
||||
log_debug("lvmcache: %s: now in VG %s%s%s%s",
|
||||
if (info) {
|
||||
if (info->mdas.n)
|
||||
sprintf(mdabuf, " with %u mdas", list_size(&info->mdas));
|
||||
else
|
||||
mdabuf[0] = '\0';
|
||||
log_debug("lvmcache: %s: now in VG %s%s%s%s%s",
|
||||
dev_name(info->dev),
|
||||
vgname, vginfo->vgid[0] ? " (" : "",
|
||||
vginfo->vgid[0] ? vginfo->vgid : "",
|
||||
vginfo->vgid[0] ? ")" : "");
|
||||
else
|
||||
vginfo->vgid[0] ? ")" : "", mdabuf);
|
||||
} else
|
||||
log_debug("lvmcache: initialised VG %s", vgname);
|
||||
|
||||
return 1;
|
||||
@@ -1007,6 +1026,15 @@ int lvmcache_update_vgname_and_id(struct lvmcache_info *info,
|
||||
vgid = vgname;
|
||||
}
|
||||
|
||||
/* If PV without mdas is already in a real VG, don't make it orphan */
|
||||
if (is_orphan_vg(vgname) && info->vginfo && !list_size(&info->mdas) &&
|
||||
!is_orphan_vg(info->vginfo->vgname) && memlock())
|
||||
return 1;
|
||||
|
||||
/* If moving PV from orphan to real VG, always mark it valid */
|
||||
if (!is_orphan_vg(vgname))
|
||||
info->status &= ~CACHE_INVALID;
|
||||
|
||||
if (!_lvmcache_update_vgname(info, vgname, vgid, vgstatus,
|
||||
creation_host, info->fmt) ||
|
||||
!_lvmcache_update_vgid(info, info->vginfo, vgid) ||
|
||||
|
||||
@@ -755,6 +755,11 @@ static int _init_segtypes(struct cmd_context *cmd)
|
||||
segtype->library = NULL;
|
||||
list_add(&cmd->segtypes, &segtype->list);
|
||||
|
||||
if (!(segtype = init_free_segtype(cmd)))
|
||||
return 0;
|
||||
segtype->library = NULL;
|
||||
list_add(&cmd->segtypes, &segtype->list);
|
||||
|
||||
#ifdef SNAPSHOT_INTERNAL
|
||||
if (!(segtype = init_snapshot_segtype(cmd)))
|
||||
return 0;
|
||||
|
||||
@@ -1011,7 +1011,7 @@ float find_config_tree_float(struct cmd_context *cmd, const char *path,
|
||||
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[])
|
||||
static int _str_in_array(const char *str, const char * const values[])
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1024,9 +1024,8 @@ static int _str_in_array(const char *str, const char *values[])
|
||||
|
||||
static int _str_to_bool(const char *str, int fail)
|
||||
{
|
||||
static const char *_true_values[] = { "y", "yes", "on", "true", NULL };
|
||||
static const char *_false_values[] =
|
||||
{ "n", "no", "off", "false", NULL };
|
||||
const char * const _true_values[] = { "y", "yes", "on", "true", NULL };
|
||||
const char * const _false_values[] = { "n", "no", "off", "false", NULL };
|
||||
|
||||
if (_str_in_array(str, _true_values))
|
||||
return 1;
|
||||
@@ -1276,7 +1275,7 @@ unsigned maybe_config_section(const char *str, unsigned len)
|
||||
begin_count = _count_tokens(str, len, TOK_SECTION_B);
|
||||
end_count = _count_tokens(str, len, TOK_SECTION_E);
|
||||
|
||||
if (begin_count && end_count && (begin_count - end_count == 0))
|
||||
if (begin_count && end_count && (begin_count == end_count))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
@@ -101,8 +101,10 @@
|
||||
|
||||
#define DEFAULT_REP_ALIGNED 1
|
||||
#define DEFAULT_REP_BUFFERED 1
|
||||
#define DEFAULT_REP_COLUMNS_AS_ROWS 0
|
||||
#define DEFAULT_REP_HEADINGS 1
|
||||
#define DEFAULT_REP_PREFIXES 0
|
||||
#define DEFAULT_REP_QUOTED 1
|
||||
#define DEFAULT_REP_SEPARATOR " "
|
||||
|
||||
#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,origin,snap_percent,move_pv,mirror_log,copy_percent,convert_lv"
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
/* Define some portable printing types */
|
||||
#define PRIsize_t "zu"
|
||||
#define PRIptrdiff_t "td"
|
||||
#define PRIpid_t PRId32
|
||||
|
||||
struct str_list {
|
||||
struct list list;
|
||||
|
||||
@@ -48,18 +48,26 @@ static int _dev_has_md_magic(struct device *dev, uint64_t sb_offset)
|
||||
* 1: At start of device
|
||||
* 2: 4K from start of device.
|
||||
*/
|
||||
static uint64_t _v1_sb_offset(uint64_t size, unsigned minor_version)
|
||||
typedef enum {
|
||||
MD_MINOR_VERSION_MIN,
|
||||
MD_MINOR_V0 = MD_MINOR_VERSION_MIN,
|
||||
MD_MINOR_V1,
|
||||
MD_MINOR_V2,
|
||||
MD_MINOR_VERSION_MAX = MD_MINOR_V2
|
||||
} md_minor_version_t;
|
||||
|
||||
static uint64_t _v1_sb_offset(uint64_t size, md_minor_version_t minor_version)
|
||||
{
|
||||
uint64_t sb_offset;
|
||||
uint64_t uninitialized_var(sb_offset);
|
||||
|
||||
switch(minor_version) {
|
||||
case 0:
|
||||
case MD_MINOR_V0:
|
||||
sb_offset = (size - 8 * 2) & ~(4 * 2 - 1ULL);
|
||||
break;
|
||||
case 1:
|
||||
case MD_MINOR_V1:
|
||||
sb_offset = 0;
|
||||
break;
|
||||
case 2:
|
||||
case MD_MINOR_V2:
|
||||
sb_offset = 4 * 2;
|
||||
break;
|
||||
}
|
||||
@@ -74,7 +82,7 @@ static uint64_t _v1_sb_offset(uint64_t size, unsigned minor_version)
|
||||
int dev_is_md(struct device *dev, uint64_t *sb)
|
||||
{
|
||||
int ret = 1;
|
||||
unsigned minor = 0;
|
||||
md_minor_version_t minor;
|
||||
uint64_t size, sb_offset;
|
||||
|
||||
if (!dev_get_size(dev, &size)) {
|
||||
@@ -96,12 +104,13 @@ int dev_is_md(struct device *dev, uint64_t *sb)
|
||||
if (_dev_has_md_magic(dev, sb_offset))
|
||||
goto out;
|
||||
|
||||
minor = MD_MINOR_VERSION_MIN;
|
||||
/* Version 1, try v1.0 -> v1.2 */
|
||||
do {
|
||||
sb_offset = _v1_sb_offset(size, minor);
|
||||
if (_dev_has_md_magic(dev, sb_offset))
|
||||
goto out;
|
||||
} while (++minor <= 2);
|
||||
} while (++minor <= MD_MINOR_VERSION_MAX);
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
@@ -94,11 +94,6 @@ const char *dev_name_confirmed(struct device *dev, int quiet);
|
||||
/* Does device contain md superblock? If so, where? */
|
||||
int dev_is_md(struct device *dev, uint64_t *sb);
|
||||
|
||||
/* FIXME Check partition type if appropriate */
|
||||
|
||||
#define is_lvm_partition(a) 1
|
||||
/* int is_lvm_partition(const char *name); */
|
||||
|
||||
int is_partitioned_dev(struct device *dev);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
|
||||
typedef enum { SIZE_LONG = 0, SIZE_SHORT = 1, SIZE_UNIT = 2 } size_len_t;
|
||||
|
||||
static struct {
|
||||
static const struct {
|
||||
alloc_policy_t alloc;
|
||||
const char *str;
|
||||
const char str[12]; /* must be changed when size extends 11 chars */
|
||||
} _policies[] = {
|
||||
{
|
||||
ALLOC_CONTIGUOUS, "contiguous"}, {
|
||||
@@ -36,7 +36,7 @@ static struct {
|
||||
ALLOC_INHERIT, "inherit"}
|
||||
};
|
||||
|
||||
static int _num_policies = sizeof(_policies) / sizeof(*_policies);
|
||||
static const int _num_policies = sizeof(_policies) / sizeof(*_policies);
|
||||
|
||||
uint64_t units_to_bytes(const char *units, char *unit_type)
|
||||
{
|
||||
@@ -155,7 +155,7 @@ static const char *_display_size(const struct cmd_context *cmd,
|
||||
uint64_t byte = UINT64_C(0);
|
||||
uint64_t units = UINT64_C(1024);
|
||||
char *size_buf = NULL;
|
||||
const char *size_str[][3] = {
|
||||
const char * const size_str[][3] = {
|
||||
{" Exabyte", " EB", "E"},
|
||||
{" Petabyte", " PB", "P"},
|
||||
{" Terabyte", " TB", "T"},
|
||||
|
||||
@@ -356,7 +356,7 @@ static struct disk_list *__read_disk(const struct format_type *fmt,
|
||||
list_init(&dl->lvds);
|
||||
|
||||
if (!_read_pvd(dev, &dl->pvd))
|
||||
goto_bad;
|
||||
goto bad;
|
||||
|
||||
/*
|
||||
* is it an orphan ?
|
||||
|
||||
@@ -36,6 +36,7 @@ int import_pool_vg(struct volume_group *vg, struct dm_pool *mem, struct list *pl
|
||||
vg->extent_count +=
|
||||
((pl->pd.pl_blocks) / POOL_PE_SIZE);
|
||||
|
||||
vg->free_count = vg->extent_count;
|
||||
vg->pv_count++;
|
||||
|
||||
if (vg->name)
|
||||
@@ -45,7 +46,6 @@ int import_pool_vg(struct volume_group *vg, struct dm_pool *mem, struct list *pl
|
||||
get_pool_vg_uuid(&vg->id, &pl->pd);
|
||||
vg->extent_size = POOL_PE_SIZE;
|
||||
vg->status |= LVM_READ | LVM_WRITE | CLUSTERED | SHARED;
|
||||
vg->free_count = vg->extent_count;
|
||||
vg->max_lv = 1;
|
||||
vg->max_pv = POOL_MAX_DEVICES;
|
||||
vg->alloc = ALLOC_NORMAL;
|
||||
@@ -165,7 +165,8 @@ int import_pool_pv(const struct format_type *fmt, struct dm_pool *mem,
|
||||
log_error("Unable to duplicate vg_name string");
|
||||
return 0;
|
||||
}
|
||||
memcpy(&pv->vgid, &vg->id, sizeof(vg->id));
|
||||
if (vg != NULL)
|
||||
memcpy(&pv->vgid, &vg->id, sizeof(vg->id));
|
||||
pv->status = 0;
|
||||
pv->size = pd->pl_blocks;
|
||||
pv->pe_size = POOL_PE_SIZE;
|
||||
|
||||
@@ -321,6 +321,20 @@ static int _print_header(struct formatter *f,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _print_flag_config(struct formatter *f, int status, int type)
|
||||
{
|
||||
char buffer[4096];
|
||||
if (!print_flags(status, type | STATUS_FLAG, buffer, sizeof(buffer)))
|
||||
return_0;
|
||||
outf(f, "status = %s", buffer);
|
||||
|
||||
if (!print_flags(status, type, buffer, sizeof(buffer)))
|
||||
return_0;
|
||||
outf(f, "flags = %s", buffer);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _print_vg(struct formatter *f, struct volume_group *vg)
|
||||
{
|
||||
char buffer[4096];
|
||||
@@ -332,9 +346,8 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
|
||||
|
||||
outf(f, "seqno = %u", vg->seqno);
|
||||
|
||||
if (!print_flags(vg->status, VG_FLAGS, buffer, sizeof(buffer)))
|
||||
if (!_print_flag_config(f, vg->status, VG_FLAGS))
|
||||
return_0;
|
||||
outf(f, "status = %s", buffer);
|
||||
|
||||
if (!list_empty(&vg->tags)) {
|
||||
if (!print_tags(&vg->tags, buffer, sizeof(buffer)))
|
||||
@@ -408,9 +421,8 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
|
||||
return_0;
|
||||
outnl(f);
|
||||
|
||||
if (!print_flags(pv->status, PV_FLAGS, buffer, sizeof(buffer)))
|
||||
if (!_print_flag_config(f, pv->status, PV_FLAGS))
|
||||
return_0;
|
||||
outf(f, "status = %s", buffer);
|
||||
|
||||
if (!list_empty(&pv->tags)) {
|
||||
if (!print_tags(&pv->tags, buffer, sizeof(buffer)))
|
||||
@@ -520,9 +532,8 @@ static int _print_lv(struct formatter *f, struct logical_volume *lv)
|
||||
|
||||
outf(f, "id = \"%s\"", buffer);
|
||||
|
||||
if (!print_flags(lv->status, LV_FLAGS, buffer, sizeof(buffer)))
|
||||
if (!_print_flag_config(f, lv->status, LV_FLAGS))
|
||||
return_0;
|
||||
outf(f, "status = %s", buffer);
|
||||
|
||||
if (!list_empty(&lv->tags)) {
|
||||
if (!print_tags(&lv->tags, buffer, sizeof(buffer)))
|
||||
|
||||
@@ -25,48 +25,49 @@
|
||||
struct flag {
|
||||
const int mask;
|
||||
const char *description;
|
||||
int kind;
|
||||
};
|
||||
|
||||
static struct flag _vg_flags[] = {
|
||||
{EXPORTED_VG, "EXPORTED"},
|
||||
{RESIZEABLE_VG, "RESIZEABLE"},
|
||||
{PARTIAL_VG, "PARTIAL"},
|
||||
{PVMOVE, "PVMOVE"},
|
||||
{LVM_READ, "READ"},
|
||||
{LVM_WRITE, "WRITE"},
|
||||
{CLUSTERED, "CLUSTERED"},
|
||||
{SHARED, "SHARED"},
|
||||
{PRECOMMITTED, NULL},
|
||||
{0, NULL}
|
||||
{EXPORTED_VG, "EXPORTED", STATUS_FLAG},
|
||||
{RESIZEABLE_VG, "RESIZEABLE", STATUS_FLAG},
|
||||
{PARTIAL_VG, "PARTIAL", STATUS_FLAG},
|
||||
{PVMOVE, "PVMOVE", STATUS_FLAG},
|
||||
{LVM_READ, "READ", STATUS_FLAG},
|
||||
{LVM_WRITE, "WRITE", STATUS_FLAG},
|
||||
{CLUSTERED, "CLUSTERED", STATUS_FLAG},
|
||||
{SHARED, "SHARED", STATUS_FLAG},
|
||||
{PRECOMMITTED, NULL, 0},
|
||||
{0, NULL, 0}
|
||||
};
|
||||
|
||||
static struct flag _pv_flags[] = {
|
||||
{ALLOCATABLE_PV, "ALLOCATABLE"},
|
||||
{EXPORTED_VG, "EXPORTED"},
|
||||
{0, NULL}
|
||||
{ALLOCATABLE_PV, "ALLOCATABLE", STATUS_FLAG},
|
||||
{EXPORTED_VG, "EXPORTED", STATUS_FLAG},
|
||||
{0, NULL, 0}
|
||||
};
|
||||
|
||||
static struct flag _lv_flags[] = {
|
||||
{LVM_READ, "READ"},
|
||||
{LVM_WRITE, "WRITE"},
|
||||
{FIXED_MINOR, "FIXED_MINOR"},
|
||||
{VISIBLE_LV, "VISIBLE"},
|
||||
{PVMOVE, "PVMOVE"},
|
||||
{LOCKED, "LOCKED"},
|
||||
{MIRROR_NOTSYNCED, "NOTSYNCED"},
|
||||
{MIRROR_IMAGE, NULL},
|
||||
{MIRROR_LOG, NULL},
|
||||
{MIRRORED, NULL},
|
||||
{VIRTUAL, NULL},
|
||||
{SNAPSHOT, NULL},
|
||||
{ACTIVATE_EXCL, NULL},
|
||||
{CONVERTING, NULL},
|
||||
{0, NULL}
|
||||
{LVM_READ, "READ", STATUS_FLAG},
|
||||
{LVM_WRITE, "WRITE", STATUS_FLAG},
|
||||
{FIXED_MINOR, "FIXED_MINOR", STATUS_FLAG},
|
||||
{VISIBLE_LV, "VISIBLE", STATUS_FLAG},
|
||||
{PVMOVE, "PVMOVE", STATUS_FLAG},
|
||||
{LOCKED, "LOCKED", STATUS_FLAG},
|
||||
{MIRROR_NOTSYNCED, "NOTSYNCED", STATUS_FLAG},
|
||||
{MIRROR_IMAGE, NULL, 0},
|
||||
{MIRROR_LOG, NULL, 0},
|
||||
{MIRRORED, NULL, 0},
|
||||
{VIRTUAL, NULL, 0},
|
||||
{SNAPSHOT, NULL, 0},
|
||||
{ACTIVATE_EXCL, NULL, 0},
|
||||
{CONVERTING, NULL, 0},
|
||||
{0, NULL, 0}
|
||||
};
|
||||
|
||||
static struct flag *_get_flags(int type)
|
||||
{
|
||||
switch (type) {
|
||||
switch (type & ~STATUS_FLAG) {
|
||||
case VG_FLAGS:
|
||||
return _vg_flags;
|
||||
|
||||
@@ -101,6 +102,9 @@ int print_flags(uint32_t status, int type, char *buffer, size_t size)
|
||||
if (status & flags[f].mask) {
|
||||
status &= ~flags[f].mask;
|
||||
|
||||
if ((type & STATUS_FLAG) != flags[f].kind)
|
||||
continue;
|
||||
|
||||
/* Internal-only flag? */
|
||||
if (!flags[f].description)
|
||||
continue;
|
||||
@@ -151,7 +155,7 @@ int read_flags(uint32_t *status, int type, struct config_value *cv)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!flags[f].description) {
|
||||
if (!flags[f].description && (type & STATUS_FLAG)) {
|
||||
log_err("Unknown status flag '%s'.", cv->v.str);
|
||||
return 0;
|
||||
}
|
||||
@@ -160,6 +164,6 @@ int read_flags(uint32_t *status, int type, struct config_value *cv)
|
||||
}
|
||||
|
||||
out:
|
||||
*status = s;
|
||||
*status |= s;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
|
||||
struct raw_locn *rlocn;
|
||||
uint64_t area_start;
|
||||
uint64_t area_size;
|
||||
uint64_t prev_sector;
|
||||
uint64_t prev_sector, prev_sector2;
|
||||
uint64_t latest_mrec_offset;
|
||||
int i;
|
||||
uint64_t offset;
|
||||
@@ -184,8 +184,11 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
|
||||
offset2 = size2 = 0;
|
||||
i = 0;
|
||||
while (prev_sector != latest_mrec_offset) {
|
||||
prev_sector2 = prev_sector;
|
||||
prev_sector = _get_prev_sector_circular(area_start, area_size,
|
||||
prev_sector);
|
||||
if (prev_sector > prev_sector2)
|
||||
goto_out;
|
||||
/*
|
||||
* FIXME: for some reason, the whole metadata region from
|
||||
* area->start to area->start+area->size is not used.
|
||||
@@ -343,10 +346,8 @@ static int _raw_write_mda_header(const struct format_type *fmt,
|
||||
MDA_HEADER_SIZE -
|
||||
sizeof(mdah->checksum_xl)));
|
||||
|
||||
if (!dev_write(dev, start_byte, MDA_HEADER_SIZE, mdah)) {
|
||||
dm_pool_free(fmt->cmd->mem, mdah);
|
||||
if (!dev_write(dev, start_byte, MDA_HEADER_SIZE, mdah))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -667,6 +668,7 @@ static int _vg_commit_raw_rlocn(struct format_instance *fid,
|
||||
|
||||
if (!_raw_write_mda_header(fid->fmt, mdac->area.dev, mdac->area.start,
|
||||
mdah)) {
|
||||
dm_pool_free(fid->fmt->cmd->mem, mdah);
|
||||
log_error("Failed to write metadata area header");
|
||||
goto out;
|
||||
}
|
||||
@@ -749,6 +751,7 @@ static int _vg_remove_raw(struct format_instance *fid, struct volume_group *vg,
|
||||
|
||||
if (!_raw_write_mda_header(fid->fmt, mdac->area.dev, mdac->area.start,
|
||||
mdah)) {
|
||||
dm_pool_free(fid->fmt->cmd->mem, mdah);
|
||||
log_error("Failed to write metadata area header");
|
||||
goto out;
|
||||
}
|
||||
@@ -1363,7 +1366,10 @@ static int _text_pv_write(const struct format_type *fmt, struct physical_volume
|
||||
}
|
||||
}
|
||||
|
||||
label_write(pv->dev, label);
|
||||
if (!label_write(pv->dev, label)) {
|
||||
dev_close(pv->dev);
|
||||
return_0;
|
||||
}
|
||||
|
||||
if (!dev_close(pv->dev))
|
||||
return_0;
|
||||
@@ -1393,43 +1399,33 @@ static int _add_raw(struct list *raw_list, struct device_area *dev_area)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
struct physical_volume *pv, struct list *mdas)
|
||||
static int _get_pv_if_in_vg(struct lvmcache_info *info,
|
||||
struct physical_volume *pv)
|
||||
{
|
||||
struct label *label;
|
||||
struct device *dev;
|
||||
struct lvmcache_info *info;
|
||||
struct metadata_area *mda, *mda_new;
|
||||
struct mda_context *mdac, *mdac_new;
|
||||
struct data_area_list *da;
|
||||
|
||||
if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter)))
|
||||
return_0;
|
||||
|
||||
/* FIXME Optimise out repeated reading when cache lock held */
|
||||
if (!(label_read(dev, &label, UINT64_C(0))))
|
||||
return_0;
|
||||
info = (struct lvmcache_info *) label->info;
|
||||
|
||||
/* Have we already cached vgname? */
|
||||
if (info->vginfo && info->vginfo->vgname &&
|
||||
!is_orphan_vg(info->vginfo->vgname) &&
|
||||
get_pv_from_vg_by_id(info->fmt, info->vginfo->vgname,
|
||||
info->vginfo->vgid, info->dev->pvid, pv)) {
|
||||
info->vginfo->vgid, info->dev->pvid, pv))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _populate_pv_fields(struct lvmcache_info *info,
|
||||
struct physical_volume *pv)
|
||||
{
|
||||
struct data_area_list *da;
|
||||
|
||||
/* Have we already cached vgname? */
|
||||
if (_get_pv_if_in_vg(info, pv))
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Perform full scan (just the first time) and try again */
|
||||
if (!memlock() && !full_scan_done()) {
|
||||
lvmcache_label_scan(fmt->cmd, 2);
|
||||
lvmcache_label_scan(info->fmt->cmd, 2);
|
||||
|
||||
if (info->vginfo && info->vginfo->vgname &&
|
||||
!is_orphan_vg(info->vginfo->vgname) &&
|
||||
get_pv_from_vg_by_id(info->fmt, info->vginfo->vgname,
|
||||
info->vginfo->vgid,
|
||||
info->dev->pvid, pv)) {
|
||||
if (_get_pv_if_in_vg(info, pv))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Orphan */
|
||||
@@ -1442,13 +1438,35 @@ static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
/* Currently only support exactly one data area */
|
||||
if (list_size(&info->das) != 1) {
|
||||
log_error("Must be exactly one data area (found %d) on PV %s",
|
||||
list_size(&info->das), dev_name(dev));
|
||||
list_size(&info->das), dev_name(info->dev));
|
||||
return 0;
|
||||
}
|
||||
|
||||
list_iterate_items(da, &info->das)
|
||||
pv->pe_start = da->disk_locn.offset >> SECTOR_SHIFT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
struct physical_volume *pv, struct list *mdas)
|
||||
{
|
||||
struct label *label;
|
||||
struct device *dev;
|
||||
struct lvmcache_info *info;
|
||||
struct metadata_area *mda, *mda_new;
|
||||
struct mda_context *mdac, *mdac_new;
|
||||
|
||||
if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter)))
|
||||
return_0;
|
||||
|
||||
if (!(label_read(dev, &label, UINT64_C(0))))
|
||||
return_0;
|
||||
info = (struct lvmcache_info *) label->info;
|
||||
|
||||
if (!_populate_pv_fields(info, pv))
|
||||
return 0;
|
||||
|
||||
if (!mdas)
|
||||
return 1;
|
||||
|
||||
|
||||
@@ -36,9 +36,11 @@
|
||||
* common code for reading and writing them.
|
||||
*/
|
||||
enum {
|
||||
COMPATIBLE_FLAG = 0x0,
|
||||
VG_FLAGS,
|
||||
PV_FLAGS,
|
||||
LV_FLAGS
|
||||
LV_FLAGS,
|
||||
STATUS_FLAG = 0x8,
|
||||
};
|
||||
|
||||
struct text_vg_version_ops {
|
||||
|
||||
@@ -125,6 +125,31 @@ static int _read_id(struct id *id, struct config_node *cn, const char *path)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _read_flag_config(struct config_node *n, uint32_t *status, int type)
|
||||
{
|
||||
struct config_node *cn;
|
||||
*status = 0;
|
||||
|
||||
if (!(cn = find_config_node(n, "status"))) {
|
||||
log_error("Could not find status flags.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(read_flags(status, type | STATUS_FLAG, cn->v))) {
|
||||
log_error("Could not read status flags.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((cn = find_config_node(n, "flags"))) {
|
||||
if (!(read_flags(status, type, cn->v))) {
|
||||
log_error("Could not read flags.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
|
||||
struct volume_group *vg, struct config_node *pvn,
|
||||
struct config_node *vgn __attribute((unused)),
|
||||
@@ -181,12 +206,7 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
|
||||
|
||||
memcpy(&pv->vgid, &vg->id, sizeof(vg->id));
|
||||
|
||||
if (!(cn = find_config_node(pvn, "status"))) {
|
||||
log_error("Couldn't find status flags for physical volume.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(read_flags(&pv->status, PV_FLAGS, cn->v))) {
|
||||
if (!_read_flag_config(pvn, &pv->status, PV_FLAGS)) {
|
||||
log_error("Couldn't read status flags for physical volume.");
|
||||
return 0;
|
||||
}
|
||||
@@ -493,13 +513,9 @@ static int _read_lvnames(struct format_instance *fid __attribute((unused)),
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(cn = find_config_node(lvn, "status"))) {
|
||||
log_error("Couldn't find status flags for logical volume.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(read_flags(&lv->status, LV_FLAGS, cn->v))) {
|
||||
log_error("Couldn't read status flags for logical volume.");
|
||||
if (!_read_flag_config(lvn, &lv->status, LV_FLAGS)) {
|
||||
log_error("Couldn't read status flags for logical volume %s.",
|
||||
lv->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -692,14 +708,8 @@ static struct volume_group *_read_vg(struct format_instance *fid,
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!(cn = find_config_node(vgn, "status"))) {
|
||||
log_error("Couldn't find status flags for volume group %s.",
|
||||
vg->name);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!(read_flags(&vg->status, VG_FLAGS, cn->v))) {
|
||||
log_error("Couldn't read status flags for volume group %s.",
|
||||
if (!_read_flag_config(vgn, &vg->status, VG_FLAGS)) {
|
||||
log_error("Error reading flags of volume group %s.",
|
||||
vg->name);
|
||||
goto bad;
|
||||
}
|
||||
@@ -826,7 +836,7 @@ static const char *_read_vgname(const struct format_type *fmt,
|
||||
struct config_tree *cft, struct id *vgid,
|
||||
uint32_t *vgstatus, char **creation_host)
|
||||
{
|
||||
struct config_node *vgn, *cn;
|
||||
struct config_node *vgn;
|
||||
struct dm_pool *mem = fmt->cmd->mem;
|
||||
char *vgname;
|
||||
int old_suppress;
|
||||
@@ -855,18 +865,12 @@ static const char *_read_vgname(const struct format_type *fmt,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(cn = find_config_node(vgn, "status"))) {
|
||||
if (!_read_flag_config(vgn, vgstatus, VG_FLAGS)) {
|
||||
log_error("Couldn't find status flags for volume group %s.",
|
||||
vgname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(read_flags(vgstatus, VG_FLAGS, cn->v))) {
|
||||
log_error("Couldn't read status flags for volume group %s.",
|
||||
vgname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return vgname;
|
||||
}
|
||||
|
||||
|
||||
60
lib/freeseg/freeseg.c
Normal file
60
lib/freeseg/freeseg.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 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 Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "lib.h"
|
||||
#include "toolcontext.h"
|
||||
#include "segtype.h"
|
||||
#include "display.h"
|
||||
#include "text_export.h"
|
||||
#include "text_import.h"
|
||||
#include "config.h"
|
||||
#include "str_list.h"
|
||||
#include "targets.h"
|
||||
#include "lvm-string.h"
|
||||
#include "activate.h"
|
||||
#include "str_list.h"
|
||||
#include "metadata.h"
|
||||
|
||||
static const char *_freeseg_name(const struct lv_segment *seg)
|
||||
{
|
||||
return seg->segtype->name;
|
||||
}
|
||||
|
||||
static void _freeseg_destroy(const struct segment_type *segtype)
|
||||
{
|
||||
dm_free((void *)segtype);
|
||||
}
|
||||
|
||||
static struct segtype_handler _freeseg_ops = {
|
||||
.name = _freeseg_name,
|
||||
.destroy = _freeseg_destroy,
|
||||
};
|
||||
|
||||
struct segment_type *init_free_segtype(struct cmd_context *cmd)
|
||||
{
|
||||
struct segment_type *segtype = dm_malloc(sizeof(*segtype));
|
||||
|
||||
if (!segtype)
|
||||
return_NULL;
|
||||
|
||||
segtype->cmd = cmd;
|
||||
segtype->ops = &_freeseg_ops;
|
||||
segtype->name = "free";
|
||||
segtype->private = NULL;
|
||||
segtype->flags = SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED;
|
||||
|
||||
log_very_verbose("Initialised segtype: %s", segtype->name);
|
||||
|
||||
return segtype;
|
||||
}
|
||||
@@ -284,7 +284,7 @@ int label_read(struct device *dev, struct label **result,
|
||||
}
|
||||
|
||||
if (!(l = _find_labeller(dev, buf, §or, scan_sector)))
|
||||
goto_out;
|
||||
goto out;
|
||||
|
||||
if ((r = (l->ops->read)(l, dev, buf, result)) && result && *result)
|
||||
(*result)->sector = sector;
|
||||
@@ -361,7 +361,7 @@ int label_verify(struct device *dev)
|
||||
}
|
||||
|
||||
if (!(l = _find_labeller(dev, buf, §or, UINT64_C(0))))
|
||||
goto_out;
|
||||
goto out;
|
||||
|
||||
r = l->ops->verify ? l->ops->verify(l, buf, sector) : 1;
|
||||
|
||||
|
||||
@@ -292,6 +292,10 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname)
|
||||
if (is_orphan_vg(vgname))
|
||||
return 1;
|
||||
|
||||
/* LVM1 is only present in 2.4 kernels. */
|
||||
if (strncmp(cmd->kernel_vsn, "2.4.", 4))
|
||||
return 1;
|
||||
|
||||
if (dm_snprintf(path, sizeof(path), "%s/lvm/VGs/%s", cmd->proc_dir,
|
||||
vgname) < 0) {
|
||||
log_error("LVM1 proc VG pathname too long for %s", vgname);
|
||||
|
||||
@@ -51,6 +51,7 @@ static int _already_logging = 0;
|
||||
static int _mirror_in_sync = 0;
|
||||
static int _dmeventd_monitor = DEFAULT_DMEVENTD_MONITOR;
|
||||
static int _ignore_suspended_devices = 0;
|
||||
static int _error_message_produced = 0;
|
||||
|
||||
static lvm2_log_fn_t _lvm2_log_fn = NULL;
|
||||
|
||||
@@ -238,6 +239,16 @@ void init_indent(int indent)
|
||||
_indent = indent;
|
||||
}
|
||||
|
||||
void init_error_message_produced(int value)
|
||||
{
|
||||
_error_message_produced = value;
|
||||
}
|
||||
|
||||
int error_message_produced(void)
|
||||
{
|
||||
return _error_message_produced;
|
||||
}
|
||||
|
||||
int test_mode()
|
||||
{
|
||||
return _test;
|
||||
@@ -322,6 +333,9 @@ void print_log(int level, const char *file, int line, const char *format, ...)
|
||||
if (_log_suppress == 2)
|
||||
return;
|
||||
|
||||
if (level <= _LOG_ERR)
|
||||
_error_message_produced = 1;
|
||||
|
||||
trformat = _(format);
|
||||
|
||||
if (_lvm2_log_fn) {
|
||||
|
||||
@@ -79,6 +79,7 @@ void init_security_level(int level);
|
||||
void init_mirror_in_sync(int in_sync);
|
||||
void init_dmeventd_monitor(int reg);
|
||||
void init_ignore_suspended_devices(int ignore);
|
||||
void init_error_message_produced(int error_message_produced);
|
||||
|
||||
void set_cmd_name(const char *cmd_name);
|
||||
|
||||
@@ -94,6 +95,7 @@ int lockingfailed(void);
|
||||
int security_level(void);
|
||||
int mirror_in_sync(void);
|
||||
int ignore_suspended_devices(void);
|
||||
int error_message_produced(void);
|
||||
|
||||
#define DMEVENTD_MONITOR_IGNORE -1
|
||||
int dmeventd_monitor_mode(void);
|
||||
|
||||
@@ -2048,6 +2048,27 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* remove LVs with its dependencies - LV leaf nodes should be removed first
|
||||
*/
|
||||
int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
const force_t force)
|
||||
{
|
||||
struct list *snh, *snht;
|
||||
|
||||
if (lv_is_origin(lv)) {
|
||||
/* remove snapshot LVs first */
|
||||
list_iterate_safe(snh, snht, &lv->snapshot_segs) {
|
||||
if (!lv_remove_with_dependencies(cmd, list_struct_base(snh, struct lv_segment,
|
||||
origin_list)->cow,
|
||||
force))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return lv_remove_single(cmd, lv, force);
|
||||
}
|
||||
|
||||
/*
|
||||
* insert_layer_for_segments_on_pv() inserts a layer segment for a segment area.
|
||||
* However, layer modification could split the underlying layer segment.
|
||||
|
||||
@@ -347,7 +347,7 @@ vg_t *vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
|
||||
|
||||
/* pe_start and pe_end relate to any existing data so that new metadata
|
||||
* areas can avoid overlap */
|
||||
pv_t *pv_create(const struct format_type *fmt,
|
||||
pv_t *pv_create(const struct cmd_context *cmd,
|
||||
struct device *dev,
|
||||
struct id *id,
|
||||
uint64_t size,
|
||||
@@ -416,6 +416,9 @@ int lv_remove(struct logical_volume *lv);
|
||||
int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
force_t force);
|
||||
|
||||
int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
force_t force);
|
||||
|
||||
int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
const char *new_name);
|
||||
|
||||
@@ -529,6 +532,7 @@ int add_mirror_log(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
int reconfigure_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
|
||||
struct list *removable_pvs, unsigned remove_log);
|
||||
int collapse_mirrored_lv(struct logical_volume *lv);
|
||||
int shift_mirror_images(struct lv_segment *mirrored_seg, unsigned mimage);
|
||||
|
||||
struct logical_volume *find_pvmove_lv(struct volume_group *vg,
|
||||
struct device *dev, uint32_t lv_type);
|
||||
|
||||
@@ -296,11 +296,14 @@ static int remove_lvs_in_vg(struct cmd_context *cmd,
|
||||
struct volume_group *vg,
|
||||
force_t force)
|
||||
{
|
||||
struct list *lst;
|
||||
struct lv_list *lvl;
|
||||
|
||||
list_iterate_items(lvl, &vg->lvs)
|
||||
if (!lv_remove_single(cmd, lvl->lv, force))
|
||||
return 0;
|
||||
while ((lst = list_first(&vg->lvs))) {
|
||||
lvl = list_item(lst, struct lv_list);
|
||||
if (!lv_remove_with_dependencies(cmd, lvl->lv, force))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -747,7 +750,7 @@ int vg_split_mdas(struct cmd_context *cmd __attribute((unused)),
|
||||
* Note:
|
||||
* FIXME - liblvm todo - tidy up arguments for external use (fmt, mdas, etc)
|
||||
*/
|
||||
pv_t *pv_create(const struct format_type *fmt,
|
||||
pv_t *pv_create(const struct cmd_context *cmd,
|
||||
struct device *dev,
|
||||
struct id *id, uint64_t size,
|
||||
uint64_t pe_start,
|
||||
@@ -756,7 +759,7 @@ pv_t *pv_create(const struct format_type *fmt,
|
||||
int pvmetadatacopies,
|
||||
uint64_t pvmetadatasize, struct list *mdas)
|
||||
{
|
||||
return _pv_create(fmt, dev, id, size, pe_start,
|
||||
return _pv_create(cmd->fmt, dev, id, size, pe_start,
|
||||
existing_extent_count,
|
||||
existing_extent_size,
|
||||
pvmetadatacopies,
|
||||
@@ -1213,10 +1216,11 @@ int vg_validate(struct volume_group *vg)
|
||||
|
||||
if ((lv_count = (uint32_t) list_size(&vg->lvs)) !=
|
||||
vg->lv_count + 2 * vg->snapshot_count) {
|
||||
log_debug("Internal error: #internal LVs (%u) != #LVs (%"
|
||||
log_error("Internal error: #internal LVs (%u) != #LVs (%"
|
||||
PRIu32 ") + 2 * #snapshots (%" PRIu32 ") in VG %s",
|
||||
list_size(&vg->lvs), vg->lv_count,
|
||||
vg->snapshot_count, vg->name);
|
||||
r = 0;
|
||||
}
|
||||
|
||||
list_iterate_items(lvl, &vg->lvs) {
|
||||
@@ -1251,6 +1255,13 @@ int vg_validate(struct volume_group *vg)
|
||||
}
|
||||
}
|
||||
|
||||
if (!(vg->fid->fmt->features & FMT_UNLIMITED_VOLS) &&
|
||||
(!vg->max_lv || !vg->max_pv)) {
|
||||
log_error("Internal error: Volume group %s has limited PV/LV count"
|
||||
" but limit is not set.", vg->name);
|
||||
r = 0;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -1487,8 +1498,10 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
|
||||
const struct format_type *fmt;
|
||||
struct volume_group *vg, *correct_vg = NULL;
|
||||
struct metadata_area *mda;
|
||||
struct lvmcache_info *info;
|
||||
int inconsistent = 0;
|
||||
int inconsistent_vgid = 0;
|
||||
int inconsistent_pvs = 0;
|
||||
unsigned use_precommitted = precommitted;
|
||||
struct list *pvids;
|
||||
struct pv_list *pvl, *pvl2;
|
||||
@@ -1530,16 +1543,16 @@ 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)))
|
||||
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");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Store pvids for later so we can check if any are missing */
|
||||
if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid)))
|
||||
return_NULL;
|
||||
|
||||
/* Ensure contents of all metadata areas match - else do recovery */
|
||||
list_iterate_items(mda, &fid->metadata_areas) {
|
||||
if ((use_precommitted &&
|
||||
@@ -1563,6 +1576,44 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
|
||||
|
||||
/* Ensure every PV in the VG was in the cache */
|
||||
if (correct_vg) {
|
||||
/*
|
||||
* If the VG has PVs without mdas, they may still be
|
||||
* orphans in the cache: update the cache state here.
|
||||
*/
|
||||
if (!inconsistent &&
|
||||
list_size(&correct_vg->pvs) > list_size(pvids)) {
|
||||
list_iterate_items(pvl, &correct_vg->pvs) {
|
||||
if (!pvl->pv->dev) {
|
||||
inconsistent_pvs = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (str_list_match_item(pvids, pvl->pv->dev->pvid))
|
||||
continue;
|
||||
|
||||
/*
|
||||
* PV not marked as belonging to this VG in cache.
|
||||
* Check it's an orphan without metadata area.
|
||||
*/
|
||||
if (!(info = info_from_pvid(pvl->pv->dev->pvid, 1)) ||
|
||||
!info->vginfo || !is_orphan_vg(info->vginfo->vgname) ||
|
||||
list_size(&info->mdas)) {
|
||||
inconsistent_pvs = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the check passed, let's update VG and recalculate pvids */
|
||||
if (!inconsistent_pvs) {
|
||||
log_debug("Updating cache for PVs without mdas "
|
||||
"in VG %s.", vgname);
|
||||
lvmcache_update_vg(correct_vg, use_precommitted);
|
||||
|
||||
if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid)))
|
||||
return_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (list_size(&correct_vg->pvs) != list_size(pvids)) {
|
||||
log_debug("Cached VG %s had incorrect PV list",
|
||||
vgname);
|
||||
@@ -1919,7 +1970,7 @@ struct list *get_vgids(struct cmd_context *cmd, int full_scan)
|
||||
static int _get_pvs(struct cmd_context *cmd, struct list **pvslist)
|
||||
{
|
||||
struct str_list *strl;
|
||||
struct list *results;
|
||||
struct list * uninitialized_var(results);
|
||||
const char *vgname, *vgid;
|
||||
struct list *pvh, *tmp;
|
||||
struct list *vgids;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
@@ -135,6 +135,53 @@ uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
|
||||
return region_size;
|
||||
}
|
||||
|
||||
/*
|
||||
* shift_mirror_images
|
||||
* @mirrored_seg
|
||||
* @mimage: The position (index) of the image to move to the end
|
||||
*
|
||||
* When dealing with removal of legs, we often move a 'removable leg'
|
||||
* to the back of the 'areas' array. It is critically important not
|
||||
* to simply swap it for the last area in the array. This would have
|
||||
* the affect of reordering the remaining legs - altering position of
|
||||
* the primary. So, we must shuffle all of the areas in the array
|
||||
* to maintain their relative position before moving the 'removable
|
||||
* leg' to the end.
|
||||
*
|
||||
* Short illustration of the problem:
|
||||
* - Mirror consists of legs A, B, C and we want to remove A
|
||||
* - We swap A and C and then remove A, leaving C, B
|
||||
* This scenario is problematic in failure cases where A dies, because
|
||||
* B becomes the primary. If the above happens, we effectively throw
|
||||
* away any changes made between the time of failure and the time of
|
||||
* restructuring the mirror.
|
||||
*
|
||||
* So, any time we want to move areas to the end to be removed, use
|
||||
* this function.
|
||||
*/
|
||||
int shift_mirror_images(struct lv_segment *mirrored_seg, unsigned mimage)
|
||||
{
|
||||
int i;
|
||||
struct lv_segment_area area;
|
||||
|
||||
if (mimage >= mirrored_seg->area_count) {
|
||||
log_error("Invalid index (%u) of mirror image supplied "
|
||||
"to shift_mirror_images()", mimage);
|
||||
return 0;
|
||||
}
|
||||
|
||||
area = mirrored_seg->areas[mimage];
|
||||
|
||||
/* Shift remaining images down to fill the hole */
|
||||
for (i = mimage + 1; i < mirrored_seg->area_count; i++)
|
||||
mirrored_seg->areas[i-1] = mirrored_seg->areas[i];
|
||||
|
||||
/* Place this one at the end */
|
||||
mirrored_seg->areas[i-1] = area;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function writes a new header to the mirror log header to the lv
|
||||
*
|
||||
@@ -469,13 +516,12 @@ static int _remove_mirror_images(struct logical_volume *lv,
|
||||
for (s = 0; s < mirrored_seg->area_count &&
|
||||
old_area_count - new_area_count < num_removed; s++) {
|
||||
sub_lv = seg_lv(mirrored_seg, s);
|
||||
|
||||
if (!is_temporary_mirror_layer(sub_lv) &&
|
||||
_is_mirror_image_removable(sub_lv, removable_pvs)) {
|
||||
/* Swap segment to end */
|
||||
if (!shift_mirror_images(mirrored_seg, s))
|
||||
return_0;
|
||||
new_area_count--;
|
||||
area = mirrored_seg->areas[new_area_count];
|
||||
mirrored_seg->areas[new_area_count] = mirrored_seg->areas[s];
|
||||
mirrored_seg->areas[s] = area;
|
||||
}
|
||||
}
|
||||
if (num_removed && old_area_count == new_area_count)
|
||||
@@ -552,6 +598,17 @@ static int _remove_mirror_images(struct logical_volume *lv,
|
||||
|
||||
log_very_verbose("Updating \"%s\" in kernel", mirrored_seg->lv->name);
|
||||
|
||||
/*
|
||||
* Avoid having same mirror target loaded twice simultaneouly by first
|
||||
* activating the removed LV which now contains an error segment.
|
||||
* As it's now detached from mirrored_seg->lv we must activate it
|
||||
* explicitly.
|
||||
*/
|
||||
if (lv1 && !activate_lv(lv1->vg->cmd, lv1)) {
|
||||
log_error("Problem reactivating removed %s", lv1->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!resume_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) {
|
||||
log_error("Problem reactivating %s", mirrored_seg->lv->name);
|
||||
return 0;
|
||||
@@ -1140,6 +1197,8 @@ int remove_mirror_log(struct cmd_context *cmd,
|
||||
struct list *removable_pvs)
|
||||
{
|
||||
float sync_percent;
|
||||
struct lvinfo info;
|
||||
struct volume_group *vg = lv->vg;
|
||||
|
||||
/* Unimplemented features */
|
||||
if (list_size(&lv->segments) != 1) {
|
||||
@@ -1148,10 +1207,21 @@ int remove_mirror_log(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
/* Had disk log, switch to core. */
|
||||
if (!lv_mirror_percent(cmd, lv, 0, &sync_percent, NULL)) {
|
||||
log_error("Unable to determine mirror sync status.");
|
||||
if (lv_info(cmd, lv, &info, 0, 0) && info.exists) {
|
||||
if (!lv_mirror_percent(cmd, lv, 0, &sync_percent, NULL)) {
|
||||
log_error("Unable to determine mirror sync status.");
|
||||
return 0;
|
||||
}
|
||||
} else if (vg_is_clustered(vg)) {
|
||||
log_error("Unable to convert the log of inactive "
|
||||
"cluster mirror %s", lv->name);
|
||||
return 0;
|
||||
} else if (yes_no_prompt("Full resync required to convert "
|
||||
"inactive mirror %s to core log. "
|
||||
"Proceed? [y/n]: "))
|
||||
sync_percent = 0;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sync_percent >= 100.0)
|
||||
init_mirror_in_sync(1);
|
||||
@@ -1269,12 +1339,9 @@ int attach_mirror_log(struct lv_segment *seg, struct logical_volume *log_lv)
|
||||
return add_seg_to_segs_using_this_lv(log_lv, seg);
|
||||
}
|
||||
|
||||
int add_mirror_log(struct cmd_context *cmd,
|
||||
struct logical_volume *lv,
|
||||
uint32_t log_count,
|
||||
uint32_t region_size,
|
||||
struct list *allocatable_pvs,
|
||||
alloc_policy_t alloc)
|
||||
int add_mirror_log(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
uint32_t log_count, uint32_t region_size,
|
||||
struct list *allocatable_pvs, alloc_policy_t alloc)
|
||||
{
|
||||
struct alloc_handle *ah;
|
||||
const struct segment_type *segtype;
|
||||
@@ -1282,17 +1349,31 @@ int add_mirror_log(struct cmd_context *cmd,
|
||||
float sync_percent;
|
||||
int in_sync;
|
||||
struct logical_volume *log_lv;
|
||||
struct lvinfo info;
|
||||
|
||||
/* Unimplemented features */
|
||||
if (log_count > 1) {
|
||||
log_error("log_count > 1 is not supported");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (list_size(&lv->segments) != 1) {
|
||||
log_error("Multiple-segment mirror is not supported");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* We are unable to convert the log of inactive cluster mirrors
|
||||
* due to the inability to detect whether the mirror is active
|
||||
* on remote nodes (even though it is inactive on this node)
|
||||
*/
|
||||
if (vg_is_clustered(lv->vg) &&
|
||||
!(lv_info(cmd, lv, &info, 0, 0) && info.exists)) {
|
||||
log_error("Unable to convert the log of inactive "
|
||||
"cluster mirror %s", lv->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(parallel_areas = build_parallel_areas_from_lv(cmd, lv)))
|
||||
return_0;
|
||||
|
||||
@@ -1344,7 +1425,8 @@ int add_mirror_images(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
struct alloc_handle *ah;
|
||||
const struct segment_type *segtype;
|
||||
struct list *parallel_areas;
|
||||
struct logical_volume **img_lvs, *log_lv;
|
||||
struct logical_volume **img_lvs;
|
||||
struct logical_volume *log_lv = NULL;
|
||||
|
||||
if (stripes > 1) {
|
||||
log_error("stripes > 1 is not supported");
|
||||
@@ -1416,8 +1498,8 @@ int add_mirror_images(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return 1;
|
||||
|
||||
out_remove_log:
|
||||
if (!lv_remove(log_lv) || !vg_write(log_lv->vg) ||
|
||||
(backup(log_lv->vg), !vg_commit(log_lv->vg)))
|
||||
if (log_lv && (!lv_remove(log_lv) || !vg_write(log_lv->vg) ||
|
||||
(backup(log_lv->vg), !vg_commit(log_lv->vg))))
|
||||
log_error("Manual intervention may be required to remove "
|
||||
"abandoned log LV before retrying.");
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ struct segtype_handler {
|
||||
struct cmd_context *cmd,
|
||||
struct lv_segment *seg, char *params,
|
||||
uint64_t *total_numerator,
|
||||
uint64_t *total_denominator, float *percent);
|
||||
uint64_t *total_denominator);
|
||||
int (*target_present) (const struct lv_segment *seg,
|
||||
unsigned *attributes);
|
||||
int (*modules_needed) (struct dm_pool *mem,
|
||||
@@ -95,6 +95,7 @@ struct segment_type *get_segtype_from_string(struct cmd_context *cmd,
|
||||
struct segment_type *init_striped_segtype(struct cmd_context *cmd);
|
||||
struct segment_type *init_zero_segtype(struct cmd_context *cmd);
|
||||
struct segment_type *init_error_segtype(struct cmd_context *cmd);
|
||||
struct segment_type *init_free_segtype(struct cmd_context *cmd);
|
||||
|
||||
#ifdef SNAPSHOT_INTERNAL
|
||||
struct segment_type *init_snapshot_segtype(struct cmd_context *cmd);
|
||||
|
||||
@@ -176,8 +176,7 @@ static struct mirror_state *_mirrored_init_target(struct dm_pool *mem,
|
||||
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 __attribute((unused)))
|
||||
uint64_t *total_denominator)
|
||||
{
|
||||
struct mirror_state *mirr_state;
|
||||
uint64_t numerator, denominator;
|
||||
@@ -376,7 +375,7 @@ static int _mirrored_target_present(const struct lv_segment *seg __attribute((un
|
||||
* FIXME: Fails incorrectly if cmirror was built into kernel.
|
||||
*/
|
||||
if (attributes) {
|
||||
if (!_mirror_attributes && module_present("cmirror"))
|
||||
if (!_mirror_attributes && module_present("log-clustered"))
|
||||
_mirror_attributes |= MIRROR_LOG_CLUSTERED;
|
||||
*attributes = _mirror_attributes;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,7 @@
|
||||
/* 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'.
|
||||
*/
|
||||
/* Define to 1 if you have the <dirent.h> header file. */
|
||||
#undef HAVE_DIRENT_H
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
@@ -49,6 +48,9 @@
|
||||
/* Define to 1 if you have the `dup2' function. */
|
||||
#undef HAVE_DUP2
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#undef HAVE_ERRNO_H
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
@@ -61,7 +63,7 @@
|
||||
/* Define to 1 if you have the `getmntent' function. */
|
||||
#undef HAVE_GETMNTENT
|
||||
|
||||
/* Define to 1 to if getopt_long is available. */
|
||||
/* Define to 1 if getopt_long is available. */
|
||||
#undef HAVE_GETOPTLONG
|
||||
|
||||
/* Define to 1 if you have the <getopt.h> header file. */
|
||||
@@ -171,6 +173,9 @@
|
||||
/* Define to 1 if you have the <selinux/selinux.h> header file. */
|
||||
#undef HAVE_SELINUX_SELINUX_H
|
||||
|
||||
/* Define to 1 if sepol_check_context is available. */
|
||||
#undef HAVE_SEPOL
|
||||
|
||||
/* Define to 1 if you have the `setlocale' function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
@@ -184,6 +189,9 @@
|
||||
zero-length file name argument. */
|
||||
#undef HAVE_STAT_EMPTY_STRING_BUG
|
||||
|
||||
/* Define to 1 if you have the <stdarg.h> header file. */
|
||||
#undef HAVE_STDARG_H
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#undef HAVE_STDDEF_H
|
||||
|
||||
@@ -270,6 +278,9 @@
|
||||
/* 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/statvfs.h> header file. */
|
||||
#undef HAVE_SYS_STATVFS_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
@@ -291,6 +302,9 @@
|
||||
/* Define to 1 if you have the <sys/wait.h> header file. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define to 1 if you have the <termios.h> header file. */
|
||||
#undef HAVE_TERMIOS_H
|
||||
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#undef HAVE_TIME_H
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
|
||||
static inline char *last_path_component(char const *name)
|
||||
{
|
||||
char const *slash = strrchr (name, '/');
|
||||
char const *slash = strrchr(name, '/');
|
||||
char const *res = slash ? slash + 1 : name;
|
||||
return (char *) res;
|
||||
|
||||
return (char *)res;
|
||||
}
|
||||
|
||||
@@ -25,4 +25,6 @@
|
||||
(void) (&_a == &_b); \
|
||||
_a > _b ? _a : _b; })
|
||||
|
||||
#define uninitialized_var(x) x = x
|
||||
|
||||
#endif
|
||||
|
||||
@@ -303,6 +303,10 @@ static int _lvstatus_disp(struct dm_report *rh __attribute((unused)), struct dm_
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Blank if this is a "free space" LV. */
|
||||
if (!*lv->name)
|
||||
goto out;
|
||||
|
||||
if (lv->status & PVMOVE)
|
||||
repstr[0] = 'p';
|
||||
else if (lv->status & CONVERTING)
|
||||
@@ -332,8 +336,10 @@ static int _lvstatus_disp(struct dm_report *rh __attribute((unused)), struct dm_
|
||||
repstr[1] = '-';
|
||||
else if (lv->status & LVM_WRITE)
|
||||
repstr[1] = 'w';
|
||||
else
|
||||
else if (lv->status & LVM_READ)
|
||||
repstr[1] = 'r';
|
||||
else
|
||||
repstr[1] = '-';
|
||||
|
||||
repstr[2] = _alloc_policy_char(lv->alloc);
|
||||
|
||||
@@ -375,6 +381,7 @@ static int _lvstatus_disp(struct dm_report *rh __attribute((unused)), struct dm_
|
||||
repstr[5] = '-';
|
||||
}
|
||||
|
||||
out:
|
||||
dm_report_field_set_value(field, repstr, NULL);
|
||||
return 1;
|
||||
}
|
||||
@@ -1077,7 +1084,8 @@ static struct dm_report_field_type _fields[] = {
|
||||
|
||||
void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
|
||||
report_type_t *report_type, const char *separator,
|
||||
int aligned, int buffered, int headings, int field_prefixes)
|
||||
int aligned, int buffered, int headings, int field_prefixes,
|
||||
int quoted, int columns_as_rows)
|
||||
{
|
||||
uint32_t report_flags = 0;
|
||||
void *rh;
|
||||
@@ -1091,9 +1099,21 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
|
||||
if (headings)
|
||||
report_flags |= DM_REPORT_OUTPUT_HEADINGS;
|
||||
|
||||
if (field_prefixes)
|
||||
report_flags |= DM_REPORT_OUTPUT_FIELD_NAME_PREFIX;
|
||||
|
||||
if (!quoted)
|
||||
report_flags |= DM_REPORT_OUTPUT_FIELD_UNQUOTED;
|
||||
|
||||
if (columns_as_rows)
|
||||
report_flags |= DM_REPORT_OUTPUT_COLUMNS_AS_ROWS;
|
||||
|
||||
rh = dm_report_init(report_type, _report_types, _fields, format,
|
||||
separator, report_flags, keys, cmd);
|
||||
|
||||
if (field_prefixes)
|
||||
dm_report_set_output_field_name_prefix(rh, "lvm2_");
|
||||
|
||||
return rh;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ typedef int (*field_report_fn) (struct report_handle * dh, struct field * field,
|
||||
|
||||
void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
|
||||
report_type_t *report_type, const char *separator,
|
||||
int aligned, int buffered, int headings, int field_prefixes);
|
||||
int aligned, int buffered, int headings, int field_prefixes,
|
||||
int quoted, int columns_as_rows);
|
||||
void report_free(void *handle);
|
||||
int report_object(void *handle, struct volume_group *vg,
|
||||
struct logical_volume *lv, struct physical_volume *pv,
|
||||
|
||||
@@ -95,20 +95,14 @@ static int _snap_target_percent(void **target_state __attribute((unused)),
|
||||
struct cmd_context *cmd __attribute((unused)),
|
||||
struct lv_segment *seg __attribute((unused)),
|
||||
char *params, uint64_t *total_numerator,
|
||||
uint64_t *total_denominator, float *percent)
|
||||
uint64_t *total_denominator)
|
||||
{
|
||||
float percent2;
|
||||
uint64_t numerator, denominator;
|
||||
|
||||
if (strchr(params, '/')) {
|
||||
if (sscanf(params, "%" PRIu64 "/%" PRIu64,
|
||||
&numerator, &denominator) == 2) {
|
||||
*total_numerator += numerator;
|
||||
*total_denominator += denominator;
|
||||
}
|
||||
} else if (sscanf(params, "%f", &percent2) == 1) {
|
||||
*percent += percent2;
|
||||
*percent /= 2;
|
||||
if (sscanf(params, "%" PRIu64 "/%" PRIu64,
|
||||
&numerator, &denominator) == 2) {
|
||||
*total_numerator += numerator;
|
||||
*total_denominator += denominator;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static char _c[] =
|
||||
static const char _c[] =
|
||||
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#";
|
||||
|
||||
static int _built_inverse;
|
||||
@@ -67,11 +68,29 @@ int lvnum_from_lvid(union lvid *lvid)
|
||||
lv_num *= sizeof(_c) - 1;
|
||||
if ((c = strchr(_c, lvid->id[1].uuid[i])))
|
||||
lv_num += (int) (c - _c);
|
||||
if (lv_num < 0)
|
||||
lv_num = 0;
|
||||
}
|
||||
|
||||
return lv_num;
|
||||
}
|
||||
|
||||
int lvid_in_restricted_range(union lvid *lvid)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ID_LEN - 3; i++)
|
||||
if (lvid->id[1].uuid[i] != '0')
|
||||
return 0;
|
||||
|
||||
for (i = ID_LEN - 3; i < ID_LEN; i++)
|
||||
if (!isdigit(lvid->id[1].uuid[i]))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int id_create(struct id *id)
|
||||
{
|
||||
int randomfile;
|
||||
@@ -110,7 +129,7 @@ int id_create(struct id *id)
|
||||
*/
|
||||
static void _build_inverse(void)
|
||||
{
|
||||
char *ptr;
|
||||
const char *ptr;
|
||||
|
||||
if (_built_inverse)
|
||||
return;
|
||||
|
||||
@@ -34,6 +34,7 @@ union lvid {
|
||||
|
||||
int lvid_from_lvnum(union lvid *lvid, struct id *vgid, uint32_t lv_num);
|
||||
int lvnum_from_lvid(union lvid *lvid);
|
||||
int lvid_in_restricted_range(union lvid *lvid);
|
||||
|
||||
void uuid_from_num(char *uuid, uint32_t num);
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ else
|
||||
endif
|
||||
VERSIONED_SHLIB = libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION)
|
||||
|
||||
DEFS += -DDEVICE_UID=@DEVICE_UID@ -DDEVICE_GID=@DEVICE_GID@ \
|
||||
-DDEVICE_MODE=@DEVICE_MODE@
|
||||
DEFS += -DDM_DEVICE_UID=@DM_DEVICE_UID@ -DDM_DEVICE_GID=@DM_DEVICE_GID@ \
|
||||
-DDM_DEVICE_MODE=@DM_DEVICE_MODE@
|
||||
|
||||
include ../make.tmpl
|
||||
|
||||
|
||||
@@ -1501,6 +1501,11 @@ static int _create_and_load_v4(struct dm_task *dmt)
|
||||
return r;
|
||||
}
|
||||
|
||||
uint64_t dm_task_get_existing_table_size(struct dm_task *dmt)
|
||||
{
|
||||
return dmt->existing_table_size;
|
||||
}
|
||||
|
||||
static int _reload_with_suppression_v4(struct dm_task *dmt)
|
||||
{
|
||||
struct dm_task *task;
|
||||
@@ -1534,6 +1539,12 @@ static int _reload_with_suppression_v4(struct dm_task *dmt)
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Store existing table size */
|
||||
t2 = task->head;
|
||||
while (t2 && t2->next)
|
||||
t2 = t2->next;
|
||||
dmt->existing_table_size = t2 ? t2->start + t2->length : 0;
|
||||
|
||||
if ((task->dmi.v4->flags & DM_READONLY_FLAG) ? 1 : 0 != dmt->read_only)
|
||||
goto no_match;
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ struct dm_task {
|
||||
int no_open_count;
|
||||
int skip_lockfs;
|
||||
int suppress_identical_reload;
|
||||
uint64_t existing_table_size;
|
||||
|
||||
char *uuid;
|
||||
};
|
||||
@@ -69,5 +70,6 @@ struct cmd_data {
|
||||
};
|
||||
|
||||
int dm_check_version(void);
|
||||
uint64_t dm_task_get_existing_table_size(struct dm_task *dmt);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -181,8 +181,9 @@ int dm_task_add_target(struct dm_task *dmt,
|
||||
uint64_t size, const char *ttype, const char *params);
|
||||
|
||||
/*
|
||||
* Format major/minor numbers correctly for input to driver
|
||||
* Format major/minor numbers correctly for input to driver.
|
||||
*/
|
||||
#define DM_FORMAT_DEV_BUFSIZE 13 /* Minimum bufsize to handle worst case. */
|
||||
int dm_format_dev(char *buf, int bufsize, uint32_t dev_major, uint32_t dev_minor);
|
||||
|
||||
/* Use this to retrive target information returned from a STATUS call */
|
||||
@@ -740,6 +741,8 @@ struct dm_report_field_type {
|
||||
#define DM_REPORT_OUTPUT_BUFFERED 0x00000002
|
||||
#define DM_REPORT_OUTPUT_HEADINGS 0x00000004
|
||||
#define DM_REPORT_OUTPUT_FIELD_NAME_PREFIX 0x00000008
|
||||
#define DM_REPORT_OUTPUT_FIELD_UNQUOTED 0x00000010
|
||||
#define DM_REPORT_OUTPUT_COLUMNS_AS_ROWS 0x00000020
|
||||
|
||||
struct dm_report *dm_report_init(uint32_t *report_types,
|
||||
const struct dm_report_object_type *types,
|
||||
|
||||
@@ -120,9 +120,9 @@ struct dm_task *dm_task_create(int type)
|
||||
dmt->type = type;
|
||||
dmt->minor = -1;
|
||||
dmt->major = -1;
|
||||
dmt->uid = DEVICE_UID;
|
||||
dmt->gid = DEVICE_GID;
|
||||
dmt->mode = DEVICE_MODE;
|
||||
dmt->uid = DM_DEVICE_UID;
|
||||
dmt->gid = DM_DEVICE_GID;
|
||||
dmt->mode = DM_DEVICE_MODE;
|
||||
dmt->no_open_count = 0;
|
||||
dmt->read_ahead = DM_READ_AHEAD_AUTO;
|
||||
dmt->read_ahead_flags = 0;
|
||||
|
||||
@@ -99,6 +99,7 @@ struct load_properties {
|
||||
uint32_t read_ahead_flags;
|
||||
|
||||
unsigned segment_count;
|
||||
unsigned size_changed;
|
||||
struct list segs;
|
||||
|
||||
const char *new_name;
|
||||
@@ -603,6 +604,7 @@ struct dm_tree_node *dm_tree_add_new_dev(struct dm_tree *dtree,
|
||||
dnode->props.major = major;
|
||||
dnode->props.minor = minor;
|
||||
dnode->props.new_name = NULL;
|
||||
dnode->props.size_changed = 0;
|
||||
} else if (strcmp(name, dnode->name)) {
|
||||
/* Do we need to rename node? */
|
||||
if (!(dnode->props.new_name = dm_pool_strdup(dtree->mem, name))) {
|
||||
@@ -937,7 +939,7 @@ static int _suspend_node(const char *name, uint32_t major, uint32_t minor,
|
||||
log_verbose("Suspending %s (%" PRIu32 ":%" PRIu32 ")%s%s",
|
||||
name, major, minor,
|
||||
skip_lockfs ? "" : " with filesystem sync",
|
||||
no_flush ? "" : " without device flush");
|
||||
no_flush ? "" : " with device flush");
|
||||
|
||||
if (!(dmt = dm_task_create(DM_DEVICE_SUSPEND))) {
|
||||
log_error("Suspend dm_task creation failed for %s", name);
|
||||
@@ -1243,7 +1245,7 @@ static int _emit_areas_line(struct dm_task *dmt __attribute((unused)),
|
||||
size_t paramsize, int *pos)
|
||||
{
|
||||
struct seg_area *area;
|
||||
char devbuf[10];
|
||||
char devbuf[DM_FORMAT_DEV_BUFSIZE];
|
||||
int tw;
|
||||
const char *prefix = "";
|
||||
|
||||
@@ -1270,7 +1272,8 @@ static int _emit_segment_line(struct dm_task *dmt, struct load_segment *seg, uin
|
||||
int pos = 0;
|
||||
int tw;
|
||||
int r;
|
||||
char originbuf[10], cowbuf[10], logbuf[10];
|
||||
char originbuf[DM_FORMAT_DEV_BUFSIZE], cowbuf[DM_FORMAT_DEV_BUFSIZE];
|
||||
char logbuf[DM_FORMAT_DEV_BUFSIZE];
|
||||
const char *logtype;
|
||||
|
||||
switch(seg->type) {
|
||||
@@ -1493,6 +1496,13 @@ static int _load_node(struct dm_tree_node *dnode)
|
||||
if (r && !dnode->info.inactive_table)
|
||||
log_verbose("Suppressed %s identical table reload.",
|
||||
dnode->name);
|
||||
|
||||
if ((dnode->props.size_changed =
|
||||
(dm_task_get_existing_table_size(dmt) == seg_start) ? 0 : 1))
|
||||
log_debug("Table size changed from %" PRIu64 " to %"
|
||||
PRIu64 " for %s",
|
||||
dm_task_get_existing_table_size(dmt),
|
||||
seg_start, dnode->name);
|
||||
}
|
||||
|
||||
dnode->props.segment_count = 0;
|
||||
@@ -1504,8 +1514,8 @@ out:
|
||||
}
|
||||
|
||||
int dm_tree_preload_children(struct dm_tree_node *dnode,
|
||||
const char *uuid_prefix,
|
||||
size_t uuid_prefix_len)
|
||||
const char *uuid_prefix,
|
||||
size_t uuid_prefix_len)
|
||||
{
|
||||
void *handle = NULL;
|
||||
struct dm_tree_node *child;
|
||||
@@ -1540,8 +1550,8 @@ int dm_tree_preload_children(struct dm_tree_node *dnode,
|
||||
}
|
||||
}
|
||||
|
||||
/* Resume device immediately if it has parents */
|
||||
if (!dm_tree_node_num_children(child, 1))
|
||||
/* Resume device immediately if it has parents and its size changed */
|
||||
if (!dm_tree_node_num_children(child, 1) || !child->props.size_changed)
|
||||
continue;
|
||||
|
||||
if (!child->info.inactive_table && !child->info.suspended)
|
||||
|
||||
@@ -267,8 +267,7 @@ static void _display_fields(struct dm_report *rh)
|
||||
log_warn("%s Fields", desc);
|
||||
log_warn("%*.*s", (int) strlen(desc) + 7,
|
||||
(int) strlen(desc) + 7,
|
||||
"------------------------------------------");
|
||||
|
||||
"-------------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
/* FIXME Add line-wrapping at terminal width (or 80 cols) */
|
||||
@@ -513,6 +512,14 @@ struct dm_report *dm_report_init(uint32_t *report_types,
|
||||
|
||||
rh->flags |= output_flags & DM_REPORT_OUTPUT_MASK;
|
||||
|
||||
/* With columns_as_rows we must buffer and not align. */
|
||||
if (output_flags & DM_REPORT_OUTPUT_COLUMNS_AS_ROWS) {
|
||||
if (!(output_flags & DM_REPORT_OUTPUT_BUFFERED))
|
||||
rh->flags |= DM_REPORT_OUTPUT_BUFFERED;
|
||||
if (output_flags & DM_REPORT_OUTPUT_ALIGNED)
|
||||
rh->flags &= ~DM_REPORT_OUTPUT_ALIGNED;
|
||||
}
|
||||
|
||||
if (output_flags & DM_REPORT_OUTPUT_BUFFERED)
|
||||
rh->flags |= RH_SORT_REQUIRED;
|
||||
|
||||
@@ -793,23 +800,152 @@ static int _sort_rows(struct dm_report *rh)
|
||||
/*
|
||||
* Produce report output
|
||||
*/
|
||||
int dm_report_output(struct dm_report *rh)
|
||||
static int _output_field(struct dm_report *rh, struct dm_report_field *field)
|
||||
{
|
||||
char *field_id;
|
||||
int32_t width;
|
||||
uint32_t align;
|
||||
const char *repstr;
|
||||
char buf[4096];
|
||||
|
||||
if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
|
||||
if (!(field_id = strdup(rh->fields[field->props->field_num].id))) {
|
||||
log_error("dm_report: Failed to copy field name");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!dm_pool_grow_object(rh->mem, rh->output_field_name_prefix, 0)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!dm_pool_grow_object(rh->mem, _toupperstr(field_id), 0)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
return 0;
|
||||
}
|
||||
|
||||
free(field_id);
|
||||
|
||||
if (!dm_pool_grow_object(rh->mem, "=", 1)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED) &&
|
||||
!dm_pool_grow_object(rh->mem, "\'", 1)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
repstr = field->report_string;
|
||||
width = field->props->width;
|
||||
if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) {
|
||||
if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (!(align = field->props->flags & DM_REPORT_FIELD_ALIGN_MASK))
|
||||
align = (field->props->flags & DM_REPORT_FIELD_TYPE_NUMBER) ?
|
||||
DM_REPORT_FIELD_ALIGN_RIGHT : DM_REPORT_FIELD_ALIGN_LEFT;
|
||||
if (align & DM_REPORT_FIELD_ALIGN_LEFT) {
|
||||
if (dm_snprintf(buf, sizeof(buf), "%-*.*s",
|
||||
width, width, repstr) < 0) {
|
||||
log_error("dm_report: left-aligned snprintf() failed");
|
||||
return 0;
|
||||
}
|
||||
if (!dm_pool_grow_object(rh->mem, buf, width)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
return 0;
|
||||
}
|
||||
} else if (align & DM_REPORT_FIELD_ALIGN_RIGHT) {
|
||||
if (dm_snprintf(buf, sizeof(buf), "%*.*s",
|
||||
width, width, repstr) < 0) {
|
||||
log_error("dm_report: right-aligned snprintf() failed");
|
||||
return 0;
|
||||
}
|
||||
if (!dm_pool_grow_object(rh->mem, buf, width)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) &&
|
||||
!(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED))
|
||||
if (!dm_pool_grow_object(rh->mem, "\'", 1)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _output_as_rows(struct dm_report *rh)
|
||||
{
|
||||
struct field_properties *fp;
|
||||
struct dm_report_field *field;
|
||||
struct row *row;
|
||||
|
||||
if (!dm_pool_begin_object(rh->mem, 512)) {
|
||||
log_error("dm_report: Unable to allocate output line");
|
||||
return 0;
|
||||
}
|
||||
|
||||
list_iterate_items(fp, &rh->field_props) {
|
||||
if (fp->flags & FLD_HIDDEN) {
|
||||
list_iterate_items(row, &rh->rows) {
|
||||
field = list_item(list_first(&row->fields), struct dm_report_field);
|
||||
list_del(&field->list);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((rh->flags & DM_REPORT_OUTPUT_HEADINGS)) {
|
||||
if (!dm_pool_grow_object(rh->mem, rh->fields[fp->field_num].heading, 0)) {
|
||||
log_error("dm_report: Failed to extend row for field name");
|
||||
goto bad;
|
||||
}
|
||||
if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
|
||||
log_error("dm_report: Failed to extend row with separator");
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
|
||||
list_iterate_items(row, &rh->rows) {
|
||||
if ((field = list_item(list_first(&row->fields), struct dm_report_field))) {
|
||||
if (!_output_field(rh, field))
|
||||
goto bad;
|
||||
list_del(&field->list);
|
||||
}
|
||||
|
||||
if (!list_end(&rh->rows, &row->list))
|
||||
if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dm_pool_grow_object(rh->mem, "\0", 1)) {
|
||||
log_error("dm_report: Failed to terminate row");
|
||||
goto bad;
|
||||
}
|
||||
log_print("%s", (char *) dm_pool_end_object(rh->mem));
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
bad:
|
||||
dm_pool_abandon_object(rh->mem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _output_as_columns(struct dm_report *rh)
|
||||
{
|
||||
struct list *fh, *rowh, *ftmp, *rtmp;
|
||||
struct row *row = NULL;
|
||||
struct dm_report_field *field;
|
||||
const char *repstr;
|
||||
char *field_id;
|
||||
char buf[4096];
|
||||
int32_t width;
|
||||
uint32_t align;
|
||||
|
||||
if (list_empty(&rh->rows))
|
||||
return 1;
|
||||
|
||||
/* Sort rows */
|
||||
if ((rh->flags & RH_SORT_REQUIRED))
|
||||
_sort_rows(rh);
|
||||
|
||||
/* If headings not printed yet, calculate field widths and print them */
|
||||
if (!(rh->flags & RH_HEADINGS_PRINTED))
|
||||
@@ -827,75 +963,15 @@ int dm_report_output(struct dm_report *rh)
|
||||
if (field->props->flags & FLD_HIDDEN)
|
||||
continue;
|
||||
|
||||
if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
|
||||
if (!(field_id = strdup(rh->fields[field->props->field_num].id))) {
|
||||
log_error("dm_report: Failed to copy field name");
|
||||
goto bad;
|
||||
}
|
||||
if (!_output_field(rh, field))
|
||||
goto bad;
|
||||
|
||||
if (!dm_pool_grow_object(rh->mem, rh->output_field_name_prefix, 0)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!dm_pool_grow_object(rh->mem, _toupperstr(field_id), 0)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
free(field_id);
|
||||
|
||||
if (!dm_pool_grow_object(rh->mem, "=\"", 2)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
|
||||
repstr = field->report_string;
|
||||
width = field->props->width;
|
||||
if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) {
|
||||
if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
goto bad;
|
||||
}
|
||||
} else {
|
||||
if (!(align = field->props->flags & DM_REPORT_FIELD_ALIGN_MASK))
|
||||
align = (field->props->flags & DM_REPORT_FIELD_TYPE_NUMBER) ?
|
||||
DM_REPORT_FIELD_ALIGN_RIGHT : DM_REPORT_FIELD_ALIGN_LEFT;
|
||||
if (align & DM_REPORT_FIELD_ALIGN_LEFT) {
|
||||
if (dm_snprintf(buf, sizeof(buf), "%-*.*s",
|
||||
width, width, repstr) < 0) {
|
||||
log_error("dm_report: left-aligned snprintf() failed");
|
||||
goto bad;
|
||||
}
|
||||
if (!dm_pool_grow_object(rh->mem, buf, width)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
goto bad;
|
||||
}
|
||||
} else if (align & DM_REPORT_FIELD_ALIGN_RIGHT) {
|
||||
if (dm_snprintf(buf, sizeof(buf), "%*.*s",
|
||||
width, width, repstr) < 0) {
|
||||
log_error("dm_report: right-aligned snprintf() failed");
|
||||
goto bad;
|
||||
}
|
||||
if (!dm_pool_grow_object(rh->mem, buf, width)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX)
|
||||
if (!dm_pool_grow_object(rh->mem, "\"", 1)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!list_end(&row->fields, fh))
|
||||
if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
|
||||
log_error("dm_report: Unable to extend output line");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
list_del(&field->list);
|
||||
}
|
||||
if (!dm_pool_grow_object(rh->mem, "\0", 1)) {
|
||||
@@ -915,3 +991,17 @@ int dm_report_output(struct dm_report *rh)
|
||||
dm_pool_abandon_object(rh->mem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dm_report_output(struct dm_report *rh)
|
||||
{
|
||||
if (list_empty(&rh->rows))
|
||||
return 1;
|
||||
|
||||
if ((rh->flags & RH_SORT_REQUIRED))
|
||||
_sort_rows(rh);
|
||||
|
||||
if ((rh->flags & DM_REPORT_OUTPUT_COLUMNS_AS_ROWS))
|
||||
return _output_as_rows(rh);
|
||||
else
|
||||
return _output_as_columns(rh);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ struct memblock {
|
||||
const char *file; /* File that allocated */
|
||||
int line; /* Line that allocated */
|
||||
void *magic; /* Address of this block */
|
||||
};
|
||||
} __attribute__((aligned(8)));
|
||||
|
||||
static struct {
|
||||
unsigned block_serialno;/* Non-decreasing serialno of block */
|
||||
|
||||
15
make.tmpl.in
15
make.tmpl.in
@@ -1,7 +1,7 @@
|
||||
# @configure_input@
|
||||
#
|
||||
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
# Copyright (C) 2004, 2008 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
@@ -21,7 +21,10 @@ CC = @CC@
|
||||
RANLIB = @RANLIB@
|
||||
SHELL = /bin/sh
|
||||
INSTALL = @INSTALL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
MSGFMT = @MSGFMT@
|
||||
LCOV = @LCOV@
|
||||
GENHTML = @GENHTML@
|
||||
LN_S = @LN_S@
|
||||
LIBS = @LIBS@
|
||||
DEFS += @DEFS@
|
||||
@@ -204,11 +207,15 @@ $(LIB_STATIC): $(OBJECTS)
|
||||
|
||||
clean: $(SUBDIRS.clean)
|
||||
$(RM) $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(SOURCES:%.c=%.d) \
|
||||
$(SOURCES:%.c=%.pot) $(LDDEPS)
|
||||
$(SOURCES:%.c=%.pot) $(SOURCES:%.c=%.gcno) \
|
||||
$(SOURCES:%.c=%.gcda) $(LDDEPS)
|
||||
|
||||
distclean: $(SUBDIRS.distclean)
|
||||
$(RM) $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(DISTCLEAN_TARGETS) \
|
||||
$(SOURCES:%.c=%.d) $(SOURCES:%.c=%.pot) $(LDDEPS) \
|
||||
$(RM) -rf $(DISTCLEAN_DIRS)
|
||||
$(RM) $(DISTCLEAN_TARGETS) \
|
||||
$(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(SOURCES:%.c=%.d) \
|
||||
$(SOURCES:%.c=%.pot) $(SOURCES:%.c=%.gcno) \
|
||||
$(SOURCES:%.c=%.gcda) $(LDDEPS) \
|
||||
config.cache config.log config.status \
|
||||
Makefile make.tmpl core \
|
||||
version.h lvm2.po
|
||||
|
||||
@@ -11,7 +11,7 @@ lvcreate \- create a logical volume in an existing volume group
|
||||
{\-l/\-\-extents LogicalExtentsNumber[%{VG|PVS|FREE}] |
|
||||
\-L/\-\-size LogicalVolumeSize[kKmMgGtT]}
|
||||
[\-M/\-\-persistent y/n] [\-\-minor minor]
|
||||
[\-m/\-\-mirrors Mirrors [\-\-nosync] [\-\-mirrorlog {disk|log}] [\-\-corelog]
|
||||
[\-m/\-\-mirrors Mirrors [\-\-nosync] [\-\-mirrorlog {disk|core}] [\-\-corelog]
|
||||
[\-R/\-\-regionsize MirrorLogRegionSize]]
|
||||
[\-n/\-\-name LogicalVolumeName]
|
||||
[\-p/\-\-permission r/rw] [\-r/\-\-readahead ReadAheadSectors|auto|none]
|
||||
|
||||
@@ -126,5 +126,5 @@ SCSI disk for later use by LVM:
|
||||
.sp
|
||||
.SH SEE ALSO
|
||||
.BR lvm "(8), " vgcreate "(8), " vgextend "(8), " lvcreate "(8), "
|
||||
.BR cfdisk "(8), " fdisk "(8), " losetup "(8), " mdadd "(8), "
|
||||
.BR cfdisk "(8), " fdisk "(8), " losetup "(8), " mdadm "(8), "
|
||||
.BR vgcfgrestore "(8), " vgconvert "(8)"
|
||||
|
||||
@@ -206,7 +206,7 @@ if (( $metadata )); then
|
||||
|
||||
pvs="$("$LVM" pvs --separator , --noheadings --units s --nosuffix -o \
|
||||
name,pe_start 2>> "$log" | $SED -e 's/^ *//')"
|
||||
for line in "$pvs"
|
||||
for line in $pvs
|
||||
do
|
||||
test -z "$line" && continue
|
||||
pv="$(echo $line | $CUT -d, -f1)"
|
||||
|
||||
@@ -48,7 +48,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
|
||||
$(T): init.sh
|
||||
@echo "*** $@ ***"; '$(SHELL_PATH_SQ)' \
|
||||
$(TESTS_ENVIRONMENT) $@ $(GIT_TEST_OPTS)
|
||||
$(TESTS_ENVIRONMENT) $@ $(LVM_TEST_OPTS)
|
||||
|
||||
.bin-dir-stamp: lvm-wrapper
|
||||
rm -rf bin
|
||||
@@ -63,7 +63,7 @@ lvm-wrapper: Makefile
|
||||
rm -f $@-t $@
|
||||
echo '#!/bin/sh' > $@-t
|
||||
test -n "@DMDIR@" \
|
||||
&& echo 'export LD_LIBRARY_PATH="@DMDIR@/lib"' >> $@-t
|
||||
&& echo 'export LD_LIBRARY_PATH="@DMDIR@/lib:@DMDIR@/dmeventd"' >> $@-t
|
||||
echo 'cmd=$$(echo ./$$0|sed "s,.*/,,")' >> $@-t
|
||||
echo 'test "$$cmd" = lvm &&' >> $@-t
|
||||
echo 'exec "$(abs_top_builddir)/tools/lvm" "$$@"' >> $@-t
|
||||
@@ -74,6 +74,8 @@ lvm-wrapper: Makefile
|
||||
clean:
|
||||
rm -rf init.sh lvm-wrapper bin .bin-dir-stamp
|
||||
|
||||
distclean: clean
|
||||
|
||||
all: $(T)
|
||||
.PHONY: $(T) clean
|
||||
.PHONY: $(T) clean distclean
|
||||
.NOTPARALLEL:
|
||||
|
||||
@@ -52,38 +52,64 @@ loop_setup_()
|
||||
|
||||
compare_vg_field_()
|
||||
{
|
||||
local vg1=$1;
|
||||
local vg2=$2;
|
||||
local field=$3;
|
||||
local val1;
|
||||
local val2;
|
||||
|
||||
val1=$(vgs --noheadings -o $field $vg1)
|
||||
val2=$(vgs --noheadings -o $field $vg2)
|
||||
if test "$verbose" = "t"
|
||||
then
|
||||
echo "compare_vg_field_ VG1: `vgs --noheadings -o $3 $1` VG2: `vgs --noheadings -o $3 $2`"
|
||||
echo "compare_vg_field_ VG1: $val1 VG2: $val2"
|
||||
fi
|
||||
return $(test $(vgs --noheadings -o $3 $1) == $(vgs --noheadings -o $3 $2) )
|
||||
return $(test $val1 == $val2 )
|
||||
}
|
||||
|
||||
check_vg_field_()
|
||||
{
|
||||
local vg=$1;
|
||||
local field=$2;
|
||||
local expected=$3;
|
||||
local actual;
|
||||
|
||||
actual=$(vgs --noheadings -o $field $vg)
|
||||
if test "$verbose" = "t"
|
||||
then
|
||||
echo "check_vg_field_ VG=$1, field=$2, actual=`vgs --noheadings -o $2 $1`, expected=$3"
|
||||
echo "check_vg_field_ VG=$vg, field=$field, actual=$actual, expected=$expected"
|
||||
fi
|
||||
return $(test $(vgs --noheadings -o $2 $1) == $3)
|
||||
return $(test $actual == $expected)
|
||||
}
|
||||
|
||||
check_pv_field_()
|
||||
{
|
||||
local pv=$1;
|
||||
local field=$2;
|
||||
local expected=$3;
|
||||
local actual;
|
||||
|
||||
actual=$(pvs --noheadings -o $field $pv)
|
||||
if test "$verbose" = "t"
|
||||
then
|
||||
echo "check_pv_field_ PV=$1, field=$2, actual=`pvs --noheadings -o $2 $1`, expected=$3"
|
||||
echo "check_pv_field_ PV=$pv, field=$field, actual=$actual, expected=$expected"
|
||||
fi
|
||||
return $(test $(pvs --noheadings -o $2 $1) == $3)
|
||||
return $(test $actual == $expected)
|
||||
}
|
||||
|
||||
check_lv_field_()
|
||||
{
|
||||
local lv=$1;
|
||||
local field=$2;
|
||||
local expected=$3;
|
||||
local actual;
|
||||
|
||||
actual=$(lvs --noheadings -o $field $lv)
|
||||
if test "$verbose" = "t"
|
||||
then
|
||||
echo "check_lv_field_ LV=$1, field=$2, actual=`lvs --noheadings -o $2 $1`, expected=$3"
|
||||
echo "check_lv_field_ LV=$lv, field=$field, actual=$actual, expected=$expected"
|
||||
fi
|
||||
return $(test $(lvs --noheadings -o $2 $1) == $3)
|
||||
return $(test $actual == $expected)
|
||||
}
|
||||
|
||||
vg_validate_pvlv_counts_()
|
||||
@@ -122,10 +148,20 @@ init_root_dir_()
|
||||
export DM_DEV_DIR=$G_dev_
|
||||
|
||||
# Only the first caller does anything.
|
||||
mkdir -p $G_root_/etc $G_dev_ $G_dev_/mapper
|
||||
mkdir -p $G_root_/etc $G_dev_ $G_dev_/mapper $G_root_/lib
|
||||
for i in 0 1 2 3 4 5 6 7; do
|
||||
mknod $G_root_/dev/loop$i b 7 $i
|
||||
done
|
||||
for i in $abs_top_builddir/dmeventd/mirror/*.so $abs_top_builddir/dmeventd/snapshot/*.so
|
||||
do
|
||||
# NOTE: This check is necessary because the loop above will give us the value
|
||||
# "$abs_top_builddir/dmeventd/mirror/*.so" if no files ending in 'so' exist.
|
||||
# This is the best way I could quickly determine to skip over this bogus value.
|
||||
if [ -f $i ]; then
|
||||
echo Setting up symlink from $i to $G_root_/lib
|
||||
ln -s $i $G_root_/lib
|
||||
fi
|
||||
done
|
||||
cat > $G_root_/etc/lvm.conf <<-EOF
|
||||
devices {
|
||||
dir = "$G_dev_"
|
||||
@@ -134,6 +170,18 @@ init_root_dir_()
|
||||
cache_dir = "$G_root_/etc"
|
||||
sysfs_scan = 0
|
||||
}
|
||||
log {
|
||||
verbose = $verboselevel
|
||||
syslog = 0
|
||||
indent = 1
|
||||
}
|
||||
backup {
|
||||
backup = 0
|
||||
archive = 0
|
||||
}
|
||||
global {
|
||||
library_dir = "$G_root_/lib"
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
@@ -32,4 +32,9 @@ test_expect_success \
|
||||
'ensure they are the same' \
|
||||
'diff -u actual expected'
|
||||
|
||||
# Need mdadm for some pvcreate tests
|
||||
test_expect_success \
|
||||
'verify mdadm is installed and in path (needed for pvcreate tests)' \
|
||||
'which mdadm'
|
||||
|
||||
test_done
|
||||
|
||||
99
test/t-covercmd.sh
Executable file
99
test/t-covercmd.sh
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
#
|
||||
# tests basic functionality of read-ahead and ra regressions
|
||||
#
|
||||
|
||||
test_description='Test coverage'
|
||||
privileges_required_=1
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
cleanup_()
|
||||
{
|
||||
vgremove -f "$vg" 2>/dev/null || true
|
||||
test -n "$d1" && losetup -d "$d1"
|
||||
test -n "$d2" && losetup -d "$d2"
|
||||
test -n "$d3" && losetup -d "$d3"
|
||||
test -n "$d4" && losetup -d "$d4"
|
||||
test -n "$d5" && losetup -d "$d5"
|
||||
rm -f "$f1" "$f2" "$f3" "$f4" "$f5"
|
||||
}
|
||||
|
||||
get_lvs_()
|
||||
{
|
||||
case $(lvs --units s --nosuffix --noheadings -o $1_read_ahead "$vg"/"$lv") in
|
||||
*$2) true ;;
|
||||
*) false ;;
|
||||
esac
|
||||
}
|
||||
|
||||
test_expect_success "set up temp files, loopback devices" \
|
||||
'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
|
||||
f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
|
||||
f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
|
||||
f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") &&
|
||||
f5=$(pwd)/5 && d5=$(loop_setup_ "$f5") &&
|
||||
vg=$(this_test_)-test-vg-$$ &&
|
||||
lv=$(this_test_)-test-lv-$$
|
||||
pvcreate "$d1" &&
|
||||
pvcreate --metadatacopies 0 "$d2" &&
|
||||
pvcreate --metadatacopies 0 "$d3" &&
|
||||
pvcreate "$d4" &&
|
||||
pvcreate --metadatacopies 0 "$d5" &&
|
||||
vgcreate -c n "$vg" "$d1" "$d2" "$d3" "$d4" "$d5" &&
|
||||
lvcreate -n "$lv" -l 1%FREE -i5 -I256 "$vg"'
|
||||
|
||||
test_expect_success "test *scan and *display tools" \
|
||||
'pvscan &&
|
||||
vgscan &&
|
||||
lvscan &&
|
||||
lvmdiskscan &&
|
||||
vgdisplay --units k &&
|
||||
lvdisplay --units g &&
|
||||
for i in b k m g t p e H B K M G T P E ; do \
|
||||
pvdisplay --units "$i" "$d1" || return $? ; done'
|
||||
|
||||
test_expect_success "test vgexport vgimport tools" \
|
||||
'vgchange -an "$vg" &&
|
||||
vgexport "$vg" &&
|
||||
vgimport "$vg" &&
|
||||
vgchange -ay "$vg"'
|
||||
|
||||
# "-persistent y --major 254 --minor 20"
|
||||
# "-persistent n"
|
||||
test_expect_success "test various lvm utils" \
|
||||
'for i in dumpconfig formats segtypes
|
||||
do lvm "$i" || return $? ; done &&
|
||||
for i in pr "p rw" an ay "-monitor y" "-monitor n" \
|
||||
-resync -refresh "-addtag MYTAG" "-deltag MYETAG"
|
||||
do lvchange -$i "$vg"/"$lv" || return $? ; done &&
|
||||
pvck "$d1" &&
|
||||
vgck "$vg" &&
|
||||
lvrename "$vg" "$lv" "$lv-rename" &&
|
||||
vgcfgbackup -f "$(pwd)/backup.$$" "$vg" &&
|
||||
vgchange -an "$vg" &&
|
||||
vgcfgrestore -f "$(pwd)/backup.$$" "$vg" &&
|
||||
vgremove -f "$vg" &&
|
||||
pvresize --setphysicalvolumesize 10M "$d1"'
|
||||
|
||||
test_expect_failure "test various errors and obsoleted tools" \
|
||||
'lvmchange ||
|
||||
lvrename "$vg" ||
|
||||
lvrename "$vg-xxx" ||
|
||||
lvrename "$vg" "$vg"/"$lv-rename" "$vg"/"$lv"'
|
||||
|
||||
test_done
|
||||
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
@@ -36,6 +36,15 @@ test_expect_success \
|
||||
|
||||
lv=lvcreate-usage-$$
|
||||
|
||||
test_expect_success \
|
||||
"lvcreate rejects repeated invocation (run 2 times)" '
|
||||
lvcreate -n $lv -l 4 $vg &&
|
||||
{ lvcreate -n $lv -l 4 $vg;
|
||||
status=$?; echo status=$status; test $status = 5 &&
|
||||
lvremove -ff $vg/$lv
|
||||
}
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
'lvcreate rejects a negative stripe_size' \
|
||||
'lvcreate -L 64M -n $lv -i2 --stripesize -4 $vg 2>err;
|
||||
|
||||
61
test/t-lvmcache-exercise.sh
Executable file
61
test/t-lvmcache-exercise.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
test_description='Test lvmcache operation'
|
||||
privileges_required_=1
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
cleanup_()
|
||||
{
|
||||
test -n "$d1" && losetup -d "$d1"
|
||||
test -n "$d2" && losetup -d "$d2"
|
||||
test -n "$d3" && losetup -d "$d3"
|
||||
test -n "$d4" && losetup -d "$d4"
|
||||
test -n "$d5" && losetup -d "$d5"
|
||||
rm -f "$f1" "$f2" "$f3" "$f4" "$f5"
|
||||
}
|
||||
|
||||
# FIXME: paramaterize lvm1 vs lvm2 metadata; most of these tests should run
|
||||
# fine with lvm1 metadata as well; for now, just add disks 5 and 6 as lvm1
|
||||
# metadata
|
||||
test_expect_success \
|
||||
'set up temp files, loopback devices, PVs, vgnames' \
|
||||
'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
|
||||
f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
|
||||
f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
|
||||
f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") &&
|
||||
f5=$(pwd)/5 && d5=$(loop_setup_ "$f5") &&
|
||||
vg1=$(this_test_)-test-vg1-$$ &&
|
||||
vg2=$(this_test_)-test-vg2-$$ &&
|
||||
lv1=$(this_test_)-test-lv1-$$ &&
|
||||
lv2=$(this_test_)-test-lv2-$$ &&
|
||||
lv3=$(this_test_)-test-lv3-$$ &&
|
||||
pvcreate $d1 $d2 $d3 $d4 $d5'
|
||||
|
||||
#
|
||||
# Duplicate vg name should cause warnings (but not segfault!)
|
||||
#
|
||||
test_expect_success \
|
||||
"Duplicate vg name might cause warnings but should succeed" \
|
||||
'vgcreate $vg1 $d1 &&
|
||||
vgcreate $vg2 $d3 &&
|
||||
losetup -d $d1 &&
|
||||
vgcreate $vg1 $d2 &&
|
||||
losetup $d1 $f1 &&
|
||||
pvs &&
|
||||
pvs'
|
||||
|
||||
test_done
|
||||
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
68
test/t-metadata.sh
Executable file
68
test/t-metadata.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
#
|
||||
# tests basic functionality of read-ahead and ra regressions
|
||||
#
|
||||
|
||||
test_description='Test --metadatatype 1'
|
||||
privileges_required_=1
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
cleanup_()
|
||||
{
|
||||
vgremove -f "$vg"
|
||||
test -n "$d1" && losetup -d "$d1"
|
||||
test -n "$d2" && losetup -d "$d2"
|
||||
test -n "$d3" && losetup -d "$d3"
|
||||
test -n "$d4" && losetup -d "$d4"
|
||||
test -n "$d5" && losetup -d "$d5"
|
||||
rm -f "$f1" "$f2" "$f3" "$f4" "$f5"
|
||||
}
|
||||
|
||||
test_expect_success "set up temp files, loopback devices" \
|
||||
'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
|
||||
f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
|
||||
f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
|
||||
f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") &&
|
||||
f5=$(pwd)/5 && d5=$(loop_setup_ "$f5") &&
|
||||
vg=$(this_test_)-test-vg-$$ &&
|
||||
lv=$(this_test_)-test-lv-$$
|
||||
pvcreate "$d1" &&
|
||||
pvcreate --metadatacopies 0 "$d2" &&
|
||||
pvcreate --metadatacopies 0 "$d3" &&
|
||||
pvcreate "$d4" &&
|
||||
pvcreate --metadatacopies 0 "$d5" &&
|
||||
vgcreate -c n "$vg" "$d1" "$d2" "$d3" "$d4" "$d5" &&
|
||||
lvcreate -n "$lv" -l 1%FREE -i5 -I256 "$vg"'
|
||||
|
||||
test_expect_success "test medatasize 0" \
|
||||
'pvchange -x n "$d1" &&
|
||||
pvchange -x y "$d1" &&
|
||||
vgchange -a n "$vg" &&
|
||||
pvchange --uuid "$d1" &&
|
||||
pvchange --uuid "$d2" &&
|
||||
vgremove -f "$vg"'
|
||||
|
||||
|
||||
test_expect_success "test metadatatype 1" \
|
||||
'pvcreate -M1 "$d1" &&
|
||||
pvcreate -M1 "$d2" &&
|
||||
pvcreate -M1 "$d3" &&
|
||||
vgcreate -M1 "$vg" "$d1" "$d2" "$d3" &&
|
||||
pvchange --uuid "$d1"'
|
||||
|
||||
test_done
|
||||
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
49
test/t-pool-labels.sh
Executable file
49
test/t-pool-labels.sh
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
test_description='Test lvm functionality with GFS pool labels'
|
||||
privileges_required_=1
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
cleanup_()
|
||||
{
|
||||
test -n "$d1" && losetup -d "$d1"
|
||||
rm -f "$f1" "$f2"
|
||||
}
|
||||
|
||||
# create the old GFS pool labeled linear devices
|
||||
create_pool_label_()
|
||||
{
|
||||
echo -en "\x01\x16\x70\x06\x5f\xcf\xff\xb9\xf8\x24\x8apool1" | dd of=$2 bs=5 seek=1 conv=notrunc
|
||||
echo -en "\x04\x01\x03\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x0$1\x68\x01\x16\x70\x00\x00\x00\x00\x00\x06\x5f\xd0" | dd of=$2 bs=273 seek=1 conv=notrunc
|
||||
}
|
||||
|
||||
test_expect_success "set up temp files, loopback devices, pool labels" \
|
||||
'f1=$(pwd)/0 && d1=$(loop_setup_ "$f1") &&
|
||||
f2=$(pwd)/1 && d2=$(loop_setup_ "$f2") &&
|
||||
create_pool_label_ 0 "$d1" &&
|
||||
create_pool_label_ 1 "$d2"'
|
||||
|
||||
test_expect_failure "check that pvcreate fails without -ff on the pool device" \
|
||||
'pvcreate "$d1"'
|
||||
|
||||
test_expect_success "check that vgdisplay and pvcreate -ff works with the pool device" \
|
||||
'vgdisplay &&
|
||||
test -n "$d2" && losetup -d "$d2" &&
|
||||
vgdisplay &&
|
||||
pvcreate -ff -y "$d1"'
|
||||
|
||||
test_done
|
||||
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
104
test/t-pvchange-usage.sh
Executable file
104
test/t-pvchange-usage.sh
Executable file
@@ -0,0 +1,104 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2008 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
test_description='Test pvchange option values'
|
||||
privileges_required_=1
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
cleanup_()
|
||||
{
|
||||
test -n "$d1" && losetup -d "$d1"
|
||||
test -n "$d2" && losetup -d "$d2"
|
||||
test -n "$d3" && losetup -d "$d3"
|
||||
test -n "$d4" && losetup -d "$d4"
|
||||
rm -f "$f1" "$f2" "$f3" "$f4"
|
||||
}
|
||||
|
||||
test_expect_success \
|
||||
'set up temp files, loopback devices, PVs, vgname' \
|
||||
'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
|
||||
f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
|
||||
f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
|
||||
f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") &&
|
||||
vg1=$(this_test_)-test-vg1-$$ &&
|
||||
lv=$(this_test_)-test-lv-$$'
|
||||
|
||||
for mda in 0 1 2
|
||||
do
|
||||
test_expect_success \
|
||||
"setup pv with metadatacopies = $mda" '
|
||||
pvcreate $d4 &&
|
||||
pvcreate --metadatacopies $mda $d1 &&
|
||||
vgcreate $vg1 $d1 $d4
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
"pvchange adds/dels tag to pvs with metadatacopies = $mda " '
|
||||
pvchange $d1 --addtag test$mda &&
|
||||
check_pv_field_ $d1 pv_tags test$mda &&
|
||||
pvchange $d1 --deltag test$mda &&
|
||||
check_pv_field_ $d1 pv_tags " "
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
"vgchange disable/enable allocation for pvs with metadatacopies = $mda (bz452982)" '
|
||||
pvchange $d1 -x n &&
|
||||
check_pv_field_ $d1 pv_attr -- &&
|
||||
pvchange $d1 -x y &&
|
||||
check_pv_field_ $d1 pv_attr a-
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
'remove pv' '
|
||||
vgremove $vg1 &&
|
||||
pvremove $d1 $d4
|
||||
'
|
||||
done
|
||||
|
||||
test_expect_success \
|
||||
"pvchange uuid" "
|
||||
pvcreate --metadatacopies 0 $d1 &&
|
||||
pvcreate --metadatacopies 2 $d2 &&
|
||||
vgcreate $vg1 $d1 $d2 &&
|
||||
pvchange -u $d1 &&
|
||||
pvchange -u $d2 &&
|
||||
vg_validate_pvlv_counts_ $vg1 2 0 0
|
||||
"
|
||||
test_expect_success \
|
||||
"pvchange rejects uuid change under an active lv" '
|
||||
lvcreate -l 16 -i 2 -n $lv --alloc anywhere $vg1 &&
|
||||
vg_validate_pvlv_counts_ $vg1 2 1 0 &&
|
||||
{ pvchange -u $d1;
|
||||
status=$?; echo status=$status; test $status = 5 &&
|
||||
lvchange -an "$vg1"/"$lv" &&
|
||||
pvchange -u $d1
|
||||
}
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
"cleanup" '
|
||||
lvremove -f "$vg1"/"$lv" &&
|
||||
vgremove $vg1
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
"pvchange reject --addtag to lvm1 pv" '
|
||||
pvcreate -M1 $d1 &&
|
||||
{ pvchange $d1 --addtag test;
|
||||
status=$?; echo status=$status; test $status != 0
|
||||
}
|
||||
'
|
||||
|
||||
test_done
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
49
test/t-pvcreate-metadata0.sh
Executable file
49
test/t-pvcreate-metadata0.sh
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
#
|
||||
# Testcase for bugzilla #450651
|
||||
# also checks that vgremove properly removes all lv devices in the right order
|
||||
#
|
||||
test_description='Test pvcreate without metadata on all pvs'
|
||||
privileges_required_=1
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
cleanup_()
|
||||
{
|
||||
test -n "$d1" && losetup -d "$d1"
|
||||
test -n "$d2" && losetup -d "$d2"
|
||||
rm -f "$f1" "$f2"
|
||||
}
|
||||
|
||||
test_expect_success "set up temp files, loopback devices" \
|
||||
'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
|
||||
f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
|
||||
vg=$(this_test_)-test-vg-$$ &&
|
||||
lv=$(this_test_)-test-lv-$$ &&
|
||||
lv_snap=$(this_test_)-test-lv-snap-$$ &&
|
||||
pvcreate "$d1" &&
|
||||
pvcreate --metadatacopies 0 "$d2"'
|
||||
|
||||
test_expect_success "check lv snapshot" \
|
||||
'vgcreate -c n "$vg" "$d1" "$d2" &&
|
||||
lvcreate -n "$lv" -l 60%FREE "$vg" &&
|
||||
lvcreate -s -n "$lv_snap" -l 10%FREE "$vg"/"$lv" &&
|
||||
pvdisplay &&
|
||||
lvdisplay &&
|
||||
vgremove -f "$vg"'
|
||||
|
||||
test_done
|
||||
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
142
test/t-pvcreate-operation.sh
Executable file
142
test/t-pvcreate-operation.sh
Executable file
@@ -0,0 +1,142 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
test_description='Test pvcreate logic operation'
|
||||
privileges_required_=1
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
cleanup_()
|
||||
{
|
||||
test -n "$d1" && losetup -d "$d1"
|
||||
test -n "$d2" && losetup -d "$d2"
|
||||
test -n "$d3" && losetup -d "$d3"
|
||||
test -n "$d4" && losetup -d "$d4"
|
||||
rm -f "$f1" "$f2" "$f3" "$f4"
|
||||
}
|
||||
|
||||
test_expect_success \
|
||||
'set up temp files, loopback devices, PVs, vgname' \
|
||||
'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
|
||||
f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
|
||||
f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
|
||||
f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") &&
|
||||
vg1=$(this_test_)-test-vg1-$$'
|
||||
|
||||
for mdatype in 1 2
|
||||
do
|
||||
|
||||
test_expect_success \
|
||||
"pvcreate (lvm$mdatype) succeeds when run repeatedly (pv not in a vg)" '
|
||||
pvcreate -M$mdatype $d1 &&
|
||||
pvcreate -M$mdatype $d1 &&
|
||||
pvremove -f $d1
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
"pvcreate (lvm$mdatype) fails when PV belongs to VG" \
|
||||
'pvcreate -M$mdatype $d1 &&
|
||||
vgcreate -M$mdatype $vg1 $d1 &&
|
||||
pvcreate -M$mdatype $d1;
|
||||
status=$?; echo status=$status; test $status != 0 &&
|
||||
vgremove -f $vg1 &&
|
||||
pvremove -f $d1'
|
||||
|
||||
test_expect_success \
|
||||
"pvcreate (lvm$mdatype) fails when PV1 does and PV2 does not belong to VG" \
|
||||
'pvcreate -M$mdatype $d1 &&
|
||||
pvcreate -M$mdatype $d2 &&
|
||||
vgcreate -M$mdatype $vg1 $d1 &&
|
||||
echo pvcreate a second time on $d2 and $d1 &&
|
||||
pvcreate -M$mdatype $d2 $d1;
|
||||
status=$?; echo status=$status; test $status != 0 &&
|
||||
vgremove -f $vg1 &&
|
||||
pvremove -f $d2 &&
|
||||
pvremove -f $d1'
|
||||
|
||||
# NOTE: Force pvcreate after test completion to ensure clean device
|
||||
#test_expect_success \
|
||||
# "pvcreate (lvm$mdatype) fails on md component device" \
|
||||
# 'mdadm -C -l raid0 -n 2 /dev/md0 $d1 $d2 &&
|
||||
# pvcreate -M$mdatype $d1;
|
||||
# status=$?; echo status=$status; test $status != 0 &&
|
||||
# mdadm --stop /dev/md0 &&
|
||||
# pvcreate -ff -y -M$mdatype $d1 $d2 &&
|
||||
# pvremove -f $d1 $d2'
|
||||
done
|
||||
|
||||
test_expect_success \
|
||||
'pvcreate (lvm2) fails without -ff when PV with metadatacopies=0 belongs to VG' \
|
||||
'pvcreate --metadatacopies 0 $d1 &&
|
||||
pvcreate --metadatacopies 1 $d2 &&
|
||||
vgcreate $vg1 $d1 $d2 &&
|
||||
pvcreate $d1;
|
||||
status=$?; echo status=$status; test $status != 0 &&
|
||||
vgremove -f $vg1 &&
|
||||
pvremove -f $d2 &&
|
||||
pvremove -f $d1'
|
||||
|
||||
test_expect_success \
|
||||
'pvcreate (lvm2) succeeds with -ff when PV with metadatacopies=0 belongs to VG' \
|
||||
'pvcreate --metadatacopies 0 $d1 &&
|
||||
pvcreate --metadatacopies 1 $d2 &&
|
||||
vgcreate $vg1 $d1 $d2 &&
|
||||
pvcreate -ff -y $d1 &&
|
||||
vgreduce --removemissing $vg1 &&
|
||||
vgremove -ff $vg1 &&
|
||||
pvremove -f $d2 &&
|
||||
pvremove -f $d1'
|
||||
|
||||
for i in 0 1 2 3
|
||||
do
|
||||
test_expect_success \
|
||||
"pvcreate (lvm2) succeeds writing LVM label at sector $i" \
|
||||
'pvcreate --labelsector $i $d1 &&
|
||||
dd if=$d1 bs=512 skip=$i count=1 status=noxfer 2>&1 | strings | grep -q LABELONE;
|
||||
test $? == 0 &&
|
||||
pvremove -f $d1'
|
||||
done
|
||||
|
||||
test_expect_failure \
|
||||
"pvcreate (lvm2) fails writing LVM label at sector 4" \
|
||||
'pvcreate --labelsector 4 $d1'
|
||||
|
||||
backupfile=mybackupfile-$(this_test_)
|
||||
uuid1=freddy-fred-fred-fred-fred-fred-freddy
|
||||
uuid2=freddy-fred-fred-fred-fred-fred-fredie
|
||||
bogusuuid=fred
|
||||
|
||||
test_expect_failure \
|
||||
'pvcreate rejects uuid option with less than 32 characters' \
|
||||
'pvcreate --uuid $bogusuuid $d1'
|
||||
|
||||
test_expect_success \
|
||||
'pvcreate rejects uuid already in use' \
|
||||
'pvcreate --uuid $uuid1 $d1 &&
|
||||
pvcreate --uuid $uuid1 $d2;
|
||||
status=$?; echo status=$status; test $status != 0'
|
||||
|
||||
test_expect_success \
|
||||
'pvcreate rejects non-existent file given with restorefile' \
|
||||
'pvcreate --uuid $uuid1 --restorefile $backupfile $d1;
|
||||
status=$?; echo status=$status; test $status != 0'
|
||||
|
||||
test_expect_success \
|
||||
'pvcreate rejects restorefile with uuid not found in file' \
|
||||
'pvcreate --uuid $uuid1 $d1 &&
|
||||
vgcfgbackup -f $backupfile &&
|
||||
pvcreate --uuid $uuid2 --restorefile $backupfile $d2;
|
||||
status=$?; echo status=$status; test $status != 0'
|
||||
|
||||
test_done
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
110
test/t-pvcreate-usage.sh
Executable file
110
test/t-pvcreate-usage.sh
Executable file
@@ -0,0 +1,110 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
test_description='Test pvcreate option values'
|
||||
privileges_required_=1
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
cleanup_()
|
||||
{
|
||||
test -n "$d1" && losetup -d "$d1"
|
||||
test -n "$d2" && losetup -d "$d2"
|
||||
test -n "$d3" && losetup -d "$d3"
|
||||
test -n "$d4" && losetup -d "$d4"
|
||||
rm -f "$f1" "$f2" "$f3" "$f4"
|
||||
}
|
||||
|
||||
test_expect_success \
|
||||
'set up temp files, loopback devices, PVs, vgname' \
|
||||
'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
|
||||
f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
|
||||
f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
|
||||
f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") &&
|
||||
vg1=$(this_test_)-test-vg1-$$'
|
||||
|
||||
test_expect_success \
|
||||
'pvcreate rejects negative setphysicalvolumesize' \
|
||||
'pvcreate --setphysicalvolumesize -1024 $d1;
|
||||
status=$?; echo status=$status; test $status != 0'
|
||||
|
||||
test_expect_success \
|
||||
'pvcreate rejects negative metadatasize' \
|
||||
'pvcreate --metadatasize -1024 $d1;
|
||||
status=$?; echo status=$status; test $status != 0'
|
||||
|
||||
# x. metadatasize 0, defaults to 255
|
||||
# FIXME: unable to check default value, not in reporting cmds
|
||||
# should default to 255 according to code
|
||||
# check_pv_field_ pv_mda_size 255 &&
|
||||
test_expect_success \
|
||||
'pvcreate accepts metadatasize 0' \
|
||||
'pvcreate --metadatasize 0 $d1 &&
|
||||
pvremove $d1'
|
||||
|
||||
# x. metadatasize too large
|
||||
# For some reason we allow this, even though there's no room for data?
|
||||
#test_expect_success \
|
||||
# 'pvcreate rejects metadatasize too large' \
|
||||
# 'pvcreate --metadatasize 100000000000000 $d1;
|
||||
# status=$?; echo status=$status; test $status != 0'
|
||||
|
||||
test_expect_success \
|
||||
'pvcreate rejects metadatacopies < 0' \
|
||||
'pvcreate --metadatacopies -1 $d1;
|
||||
status=$?; echo status=$status; test $status != 0'
|
||||
|
||||
test_expect_success \
|
||||
'pvcreate accepts metadatacopies = 0, 1, 2' \
|
||||
'pvcreate --metadatacopies 0 $d1 &&
|
||||
pvcreate --metadatacopies 1 $d2 &&
|
||||
pvcreate --metadatacopies 2 $d3 &&
|
||||
check_pv_field_ $d1 pv_mda_count 0 &&
|
||||
check_pv_field_ $d2 pv_mda_count 1 &&
|
||||
check_pv_field_ $d3 pv_mda_count 2 &&
|
||||
pvremove $d1 &&
|
||||
pvremove $d2 &&
|
||||
pvremove $d3'
|
||||
|
||||
test_expect_success \
|
||||
'pvcreate rejects metadatacopies > 2' \
|
||||
'pvcreate --metadatacopies 3 $d1;
|
||||
status=$?; echo status=$status; test $status != 0'
|
||||
|
||||
test_expect_success \
|
||||
'pvcreate rejects invalid device' \
|
||||
'pvcreate $d1bogus;
|
||||
status=$?; echo status=$status; test $status != 0'
|
||||
|
||||
test_expect_success \
|
||||
'pvcreate rejects labelsector < 0' \
|
||||
'pvcreate --labelsector -1 $d1;
|
||||
status=$?; echo status=$status; test $status != 0'
|
||||
|
||||
test_expect_success \
|
||||
'pvcreate rejects labelsector > 1000000000000' \
|
||||
'pvcreate --labelsector 1000000000000 $d1;
|
||||
status=$?; echo status=$status; test $status != 0'
|
||||
|
||||
# other possibilites based on code inspection (not sure how hard)
|
||||
# x. device too small (min of 512 * 1024 KB)
|
||||
# x. device filtered out
|
||||
# x. unable to open /dev/urandom RDONLY
|
||||
# x. device too large (pe_count > UINT32_MAX)
|
||||
# x. device read-only
|
||||
# x. unable to open device readonly
|
||||
# x. BLKGETSIZE64 fails
|
||||
# x. set size to value inconsistent with device / PE size
|
||||
|
||||
test_done
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
111
test/t-pvremove-usage.sh
Executable file
111
test/t-pvremove-usage.sh
Executable file
@@ -0,0 +1,111 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2008 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
test_description='Test pvremove'
|
||||
privileges_required_=1
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
cleanup_()
|
||||
{
|
||||
test -n "$d1" && losetup -d "$d1"
|
||||
test -n "$d2" && losetup -d "$d2"
|
||||
test -n "$d3" && losetup -d "$d3"
|
||||
rm -f "$f1" "$f2"
|
||||
}
|
||||
|
||||
test_expect_success "set up temp files, loopback devices" \
|
||||
'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
|
||||
f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
|
||||
f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
|
||||
vg=$(this_test_)-test-vg-$$ &&
|
||||
pvcreate "$d1" &&
|
||||
pvcreate --metadatacopies 0 "$d2" &&
|
||||
pvcreate --metadatacopies 2 "$d3"
|
||||
'
|
||||
|
||||
test_expect_success "check pvremove fails when bogus pv given" '
|
||||
pvremove "$d2" bogus;
|
||||
status=$?; echo $status; test $status != 0
|
||||
'
|
||||
|
||||
#failing, but still removing everything what can be removed
|
||||
#is somewhat odd as default, what do we have -f for?
|
||||
test_expect_failure "but still removes the valid pv that was given too :-/" '
|
||||
pvs | grep "$d2"; status=$?;
|
||||
pvcreate --metadatacopies 0 "$d2";
|
||||
echo $status; test $status = 0
|
||||
'
|
||||
|
||||
test_expect_success "check pvremove refuses to remove pv in a vg" '
|
||||
vgcreate -c n "$vg" "$d1" "$d2" &&
|
||||
{ pvremove "$d2" "$d3";
|
||||
status=$?; echo $status; test $status != 0
|
||||
}
|
||||
'
|
||||
|
||||
for mdacp in 0 1 2; do
|
||||
test_expect_success \
|
||||
"check pvremove truly wipes the label (pvscan wont find) (---metadatacopies $mdacp)" '
|
||||
pvcreate --metadatacopies $mdacp "$d3" &&
|
||||
pvremove "$d3" &&
|
||||
{ pvscan |grep "$d3";
|
||||
status=$?; echo $status; test $status != 0
|
||||
}
|
||||
'
|
||||
|
||||
test_expect_success "reset setup" '
|
||||
vgremove -ff $vg &&
|
||||
pvcreate --metadatacopies $mdacp "$d1" &&
|
||||
pvcreate "$d2" &&
|
||||
vgcreate $vg $d1 $d2
|
||||
'
|
||||
test_expect_success "pvremove -f fails when pv in a vg (---metadatacopies $mdacp)" '
|
||||
pvremove -f $d1;
|
||||
status=$?; echo $status; test $status != 0 &&
|
||||
pvs $d1
|
||||
'
|
||||
test_expect_success \
|
||||
"pvremove -ff fails without confirmation when pv in a vg (---metadatacopies $mdacp)" '
|
||||
echo n|eval pvremove -ff $d1;
|
||||
status=$?; echo $status; test $status != 0
|
||||
'
|
||||
test_expect_success \
|
||||
"pvremove -ff succeds with confirmation when pv in a vg (---metadatacopies $mdacp)" '
|
||||
yes | pvremove -ff $d1 &&
|
||||
pvs $d1;
|
||||
status=$?; echo $status; test $status != 0
|
||||
'
|
||||
test_expect_success "cleanup & setup" '
|
||||
vgreduce --removemissing $vg &&
|
||||
pvcreate --metadatacopies $mdacp "$d1" &&
|
||||
vgextend $vg $d1
|
||||
'
|
||||
test_expect_success \
|
||||
"pvremove -ff -y is sufficient when pv in a vg (---metadatacopies $mdacp)" '
|
||||
echo n | pvremove -ff -y $d1
|
||||
'
|
||||
test_expect_success "cleanup & setup" '
|
||||
vgreduce --removemissing $vg &&
|
||||
pvcreate --metadatacopies $mdacp "$d1" &&
|
||||
vgextend $vg $d1
|
||||
'
|
||||
done
|
||||
|
||||
test_expect_success "cleanup" '
|
||||
vgremove -ff "$vg"
|
||||
'
|
||||
|
||||
test_done
|
||||
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
68
test/t-read-ahead.sh
Executable file
68
test/t-read-ahead.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
#
|
||||
# tests basic functionality of read-ahead and ra regressions
|
||||
#
|
||||
|
||||
test_description='Test read-ahead functionality'
|
||||
privileges_required_=1
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
cleanup_()
|
||||
{
|
||||
test -n "$d1" && losetup -d "$d1"
|
||||
test -n "$d2" && losetup -d "$d2"
|
||||
test -n "$d3" && losetup -d "$d3"
|
||||
test -n "$d4" && losetup -d "$d4"
|
||||
test -n "$d5" && losetup -d "$d5"
|
||||
rm -f "$f1" "$f2" "$f3" "$f4" "$f5"
|
||||
}
|
||||
|
||||
get_lvs_()
|
||||
{
|
||||
case $(lvs --units s --nosuffix --noheadings -o $1_read_ahead "$vg"/"$lv") in
|
||||
*$2) true ;;
|
||||
*) false ;;
|
||||
esac
|
||||
}
|
||||
|
||||
test_expect_success "set up temp files, loopback devices" \
|
||||
'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
|
||||
f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
|
||||
f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
|
||||
f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") &&
|
||||
f5=$(pwd)/5 && d5=$(loop_setup_ "$f5") &&
|
||||
vg=$(this_test_)-test-vg-$$ &&
|
||||
lv=$(this_test_)-test-lv-$$'
|
||||
|
||||
test_expect_success "test various read ahead settings" \
|
||||
'pvcreate "$d1" &&
|
||||
pvcreate "$d2" &&
|
||||
pvcreate "$d3" &&
|
||||
pvcreate "$d4" &&
|
||||
pvcreate "$d5" &&
|
||||
vgcreate -c n "$vg" "$d1" "$d2" "$d3" "$d4" "$d5" &&
|
||||
lvcreate -n "$lv" -l 100%FREE -i5 -I256 "$vg" &&
|
||||
lvdisplay "$vg"/"$lv" &&
|
||||
lvchange -r auto "$vg"/"$lv" 2>&1 | grep auto &&
|
||||
get_lvs_ lv auto &&
|
||||
get_lvs_ lv_kernel 5120 &&
|
||||
lvchange -r 400 "$vg/$lv" &&
|
||||
get_lvs_ lv 400 &&
|
||||
vgremove -f "$vg"'
|
||||
|
||||
test_done
|
||||
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
@@ -18,15 +18,19 @@ cleanup_()
|
||||
{
|
||||
test -n "$d1" && losetup -d "$d1"
|
||||
test -n "$d2" && losetup -d "$d2"
|
||||
rm -f "$f1" "$f2"
|
||||
test -n "$d3" && losetup -d "$d3"
|
||||
rm -f "$f1" "$f2" "$f3"
|
||||
}
|
||||
|
||||
test_expect_success \
|
||||
'set up temp files, loopback devices, PVs, vgname' \
|
||||
'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
|
||||
f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
|
||||
f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
|
||||
vg=$(this_test_)-test-vg-$$ &&
|
||||
pvcreate $d1 $d2'
|
||||
pvcreate $d1 $d2 &&
|
||||
pvcreate --metadatacopies 0 $d3
|
||||
'
|
||||
|
||||
lv=vgcreate-usage-$$
|
||||
|
||||
@@ -79,13 +83,31 @@ test_expect_success \
|
||||
status=$?; echo status=$status; test $status = 3 &&
|
||||
grep "New volume group name \"$vg\" is invalid\$" err'
|
||||
|
||||
# FIXME: Not sure why this fails
|
||||
#test_expect_success \
|
||||
# 'vgcreate rejects MaxLogicalVolumes > 255' \
|
||||
# 'vgcreate --metadatatype 1 --maxlogicalvolumes 1024 $vg $d1 $d2 2>err;
|
||||
# cp err save;
|
||||
# status=$?; echo status=$status; test $status = 3 &&
|
||||
# grep "^ Number of volumes may not exceed 255\$" err'
|
||||
test_expect_success \
|
||||
'cleanup vg name' '
|
||||
vg=$(this_test_)-test-vg-$$
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
"vgcreate rejects repeated invocation (run 2 times)" '
|
||||
vgcreate $vg $d1 $d2 && {
|
||||
vgcreate $vg $d1 $d2;
|
||||
status=$?; echo status=$status; test $status = 5 &&
|
||||
vgremove -ff $vg
|
||||
}
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
'vgcreate rejects MaxLogicalVolumes > 255' \
|
||||
'vgcreate --metadatatype 1 --maxlogicalvolumes 1024 $vg $d1 $d2 2>err;
|
||||
status=$?; echo status=$status; test $status = 3 &&
|
||||
grep "^ Number of volumes may not exceed 255\$" err'
|
||||
|
||||
test_expect_success \
|
||||
"vgcreate fails when the only pv has --metadatacopies 0" '
|
||||
vgcreate $vg $d3;
|
||||
status=$?; echo status=$status; test $status = 5
|
||||
'
|
||||
|
||||
test_done
|
||||
# Local Variables:
|
||||
|
||||
101
test/t-vgreduce-usage.sh
Executable file
101
test/t-vgreduce-usage.sh
Executable file
@@ -0,0 +1,101 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2008 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
|
||||
test_description='Test vgreduce command options for validity'
|
||||
privileges_required_=1
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
cleanup_()
|
||||
{
|
||||
test -n "$d1" && losetup -d "$d1"
|
||||
test -n "$d2" && losetup -d "$d2"
|
||||
test -n "$d3" && losetup -d "$d3"
|
||||
test -n "$d4" && losetup -d "$d4"
|
||||
rm -f "$f1" "$f2" "$f3" "$f4"
|
||||
}
|
||||
|
||||
test_expect_success \
|
||||
'set up temp files, loopback devices, PVs, vgnames' \
|
||||
'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
|
||||
f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
|
||||
f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
|
||||
f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") &&
|
||||
vg1=$(this_test_)-test-vg1-$$ &&
|
||||
vg2=$(this_test_)-test-vg2-$$ &&
|
||||
lv1=$(this_test_)-test-lv1-$$ &&
|
||||
lv2=$(this_test_)-test-lv2-$$ &&
|
||||
lv3=$(this_test_)-test-lv3-$$'
|
||||
|
||||
#TODO --removemissing (+ -- mirrorsonly)
|
||||
|
||||
for mdatype in 1 2
|
||||
do
|
||||
test_expect_success \
|
||||
"(lvm$mdatype) setup PVs" '
|
||||
pvcreate -M$mdatype $d1 $d2
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
"(lvm$mdatype) vgreduce removes only the specified pv from vg (bz427382)" '
|
||||
vgcreate -M$mdatype $vg1 $d1 $d2 &&
|
||||
vgreduce $vg1 $d1 &&
|
||||
check_pv_field_ $d2 vg_name $vg1 &&
|
||||
vgremove -f $vg1
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
"(lvm$mdatype) vgreduce rejects removing the last pv (--all)" '
|
||||
vgcreate -M$mdatype $vg1 $d1 $d2 &&
|
||||
{ vgreduce --all $vg1;
|
||||
status=$?; echo status=$status; test $status != 0 &&
|
||||
vgremove -f $vg1
|
||||
}
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
"(lvm$mdatype) vgreduce rejects removing the last pv" '
|
||||
vgcreate -M$mdatype $vg1 $d1 $d2 &&
|
||||
{ vgreduce $vg1 $d1 $d2;
|
||||
status=$?; echo status=$status; test $status = 5 &&
|
||||
vgremove -f $vg1
|
||||
}
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
"(lvm$mdatype) remove PVs " '
|
||||
pvremove -ff $d1 $d2
|
||||
'
|
||||
done
|
||||
|
||||
for mdatype in 2
|
||||
do
|
||||
test_expect_success \
|
||||
"(lvm$mdatype) setup PVs (--metadatacopies 0)" '
|
||||
pvcreate -M$mdatype $d1 $d2 &&
|
||||
pvcreate --metadatacopies 0 -M$mdatype $d3 $d4
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
"(lvm$mdatype) vgreduce rejects removing pv with the last mda copy" '
|
||||
vgcreate -M$mdatype $vg1 $d1 $d3 &&
|
||||
{ vgreduce $vg1 $d1;
|
||||
status=$?; echo status=$status; test $status != 0 &&
|
||||
vgremove -f $vg1
|
||||
}
|
||||
'
|
||||
done
|
||||
|
||||
|
||||
test_done
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
@@ -31,7 +31,8 @@ test_expect_success \
|
||||
f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") &&
|
||||
vg1=$(this_test_)-1-$$ &&
|
||||
vg2=$(this_test_)-2-$$ &&
|
||||
pvcreate $d1 $d2 $d3 $d4'
|
||||
pvcreate $d1 $d2 &&
|
||||
pvcreate --metadatacopies 0 $d3 $d4'
|
||||
|
||||
test_expect_success \
|
||||
'vgrename normal operation - rename vg1 to vg2' \
|
||||
@@ -40,6 +41,16 @@ test_expect_success \
|
||||
check_vg_field_ $vg2 vg_name $vg2 &&
|
||||
vgremove $vg2'
|
||||
|
||||
test_expect_success \
|
||||
"vgrename by uuid (bz231187)" '
|
||||
vgcreate $vg1 $d1 $d3 &&
|
||||
UUID=$(vgs --noheading -o vg_uuid $vg1) &&
|
||||
check_vg_field_ $vg1 vg_uuid $UUID &&
|
||||
vgrename $UUID $vg2 &&
|
||||
check_vg_field_ $vg2 vg_name $vg2 &&
|
||||
vgremove $vg2
|
||||
'
|
||||
|
||||
test_done
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: nil
|
||||
|
||||
@@ -20,7 +20,8 @@ cleanup_()
|
||||
test -n "$d2" && losetup -d "$d2"
|
||||
test -n "$d3" && losetup -d "$d3"
|
||||
test -n "$d4" && losetup -d "$d4"
|
||||
rm -f "$f1" "$f2" "$f3" "$f4"
|
||||
test -n "$d5" && losetup -d "$d5"
|
||||
rm -f "$f1" "$f2" "$f3" "$f4" "$f5"
|
||||
}
|
||||
|
||||
# FIXME: paramaterize lvm1 vs lvm2 metadata; most of these tests should run
|
||||
@@ -32,16 +33,22 @@ test_expect_success \
|
||||
f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
|
||||
f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
|
||||
f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") &&
|
||||
f5=$(pwd)/5 && d5=$(loop_setup_ "$f5") &&
|
||||
vg1=$(this_test_)-test-vg1-$$ &&
|
||||
vg2=$(this_test_)-test-vg2-$$ &&
|
||||
lv1=$(this_test_)-test-lv1-$$ &&
|
||||
lv2=$(this_test_)-test-lv2-$$ &&
|
||||
lv3=$(this_test_)-test-lv3-$$ &&
|
||||
pvcreate $d1 $d2 $d3 $d4'
|
||||
lv3=$(this_test_)-test-lv3-$$'
|
||||
|
||||
for mdatype in 1 2
|
||||
do
|
||||
test_expect_success \
|
||||
"(lvm$mdatype) setup PVs" \
|
||||
'pvcreate -M$mdatype $d1 $d2 $d3 $d4'
|
||||
|
||||
test_expect_success \
|
||||
'vgsplit accepts new vg as destination of split' \
|
||||
'vgcreate $vg1 $d1 $d2 &&
|
||||
"(lvm$mdatype) vgsplit accepts new vg as destination of split" \
|
||||
'vgcreate -M$mdatype $vg1 $d1 $d2 &&
|
||||
vgsplit $vg1 $vg2 $d1 1>err;
|
||||
status=$?; echo status=$status; test $status = 0 &&
|
||||
grep "New volume group \"$vg2\" successfully split from \"$vg1\"" err &&
|
||||
@@ -49,9 +56,9 @@ test_expect_success \
|
||||
vgremove $vg2'
|
||||
|
||||
test_expect_success \
|
||||
'vgsplit accepts existing vg as destination of split' \
|
||||
'vgcreate $vg1 $d1 $d2 &&
|
||||
vgcreate $vg2 $d3 $d4 &&
|
||||
"(lvm$mdatype) vgsplit accepts existing vg as destination of split" \
|
||||
'vgcreate -M$mdatype $vg1 $d1 $d2 &&
|
||||
vgcreate -M$mdatype $vg2 $d3 $d4 &&
|
||||
vgsplit $vg1 $vg2 $d1 1>err;
|
||||
status=$?; echo status=$status; test $status = 0 &&
|
||||
grep "Existing volume group \"$vg2\" successfully split from \"$vg1\"" err &&
|
||||
@@ -59,25 +66,25 @@ test_expect_success \
|
||||
vgremove $vg2'
|
||||
|
||||
test_expect_success \
|
||||
'vgsplit accepts --maxphysicalvolumes 128 on new VG' \
|
||||
'vgcreate $vg1 $d1 $d2 &&
|
||||
"(lvm$mdatype) vgsplit accepts --maxphysicalvolumes 128 on new VG" \
|
||||
'vgcreate -M$mdatype $vg1 $d1 $d2 &&
|
||||
vgsplit --maxphysicalvolumes 128 $vg1 $vg2 $d1 &&
|
||||
check_vg_field_ $vg2 max_pv 128 &&
|
||||
vgremove $vg1 &&
|
||||
vgremove $vg2'
|
||||
|
||||
test_expect_success \
|
||||
'vgsplit accepts --maxlogicalvolumes 128 on new VG' \
|
||||
'vgcreate $vg1 $d1 $d2 &&
|
||||
"(lvm$mdatype) vgsplit accepts --maxlogicalvolumes 128 on new VG" \
|
||||
'vgcreate -M$mdatype $vg1 $d1 $d2 &&
|
||||
vgsplit --maxlogicalvolumes 128 $vg1 $vg2 $d1 &&
|
||||
check_vg_field_ $vg2 max_lv 128 &&
|
||||
vgremove $vg1 &&
|
||||
vgremove $vg2'
|
||||
|
||||
test_expect_success \
|
||||
'vgsplit rejects split because max_pv of destination would be exceeded' \
|
||||
'vgcreate --maxphysicalvolumes 2 $vg1 $d1 $d2 &&
|
||||
vgcreate --maxphysicalvolumes 2 $vg2 $d3 $d4 &&
|
||||
"(lvm$mdatype) vgsplit rejects split because max_pv of destination would be exceeded" \
|
||||
'vgcreate -M$mdatype --maxphysicalvolumes 2 $vg1 $d1 $d2 &&
|
||||
vgcreate -M$mdatype --maxphysicalvolumes 2 $vg2 $d3 $d4 &&
|
||||
vgsplit $vg1 $vg2 $d1 2>err;
|
||||
status=$?; echo status=$status; test $status = 5 &&
|
||||
grep "^ Maximum number of physical volumes (2) exceeded" err &&
|
||||
@@ -85,9 +92,9 @@ test_expect_success \
|
||||
vgremove $vg1'
|
||||
|
||||
test_expect_success \
|
||||
'vgsplit rejects split because maxphysicalvolumes given with existing vg' \
|
||||
'vgcreate --maxphysicalvolumes 2 $vg1 $d1 $d2 &&
|
||||
vgcreate --maxphysicalvolumes 2 $vg2 $d3 $d4 &&
|
||||
"(lvm$mdatype) vgsplit rejects split because maxphysicalvolumes given with existing vg" \
|
||||
'vgcreate -M$mdatype --maxphysicalvolumes 2 $vg1 $d1 $d2 &&
|
||||
vgcreate -M$mdatype --maxphysicalvolumes 2 $vg2 $d3 $d4 &&
|
||||
vgsplit --maxphysicalvolumes 2 $vg1 $vg2 $d1 2>err;
|
||||
status=$?; echo status=$status; test $status = 5 &&
|
||||
grep "^ Volume group \"$vg2\" exists, but new VG option specified" err &&
|
||||
@@ -95,9 +102,9 @@ test_expect_success \
|
||||
vgremove $vg1'
|
||||
|
||||
test_expect_success \
|
||||
'vgsplit rejects split because maxlogicalvolumes given with existing vg' \
|
||||
'vgcreate --maxlogicalvolumes 2 $vg1 $d1 $d2 &&
|
||||
vgcreate --maxlogicalvolumes 2 $vg2 $d3 $d4 &&
|
||||
"(lvm$mdatype) vgsplit rejects split because maxlogicalvolumes given with existing vg" \
|
||||
'vgcreate -M$mdatype --maxlogicalvolumes 2 $vg1 $d1 $d2 &&
|
||||
vgcreate -M$mdatype --maxlogicalvolumes 2 $vg2 $d3 $d4 &&
|
||||
vgsplit --maxlogicalvolumes 2 $vg1 $vg2 $d1 2>err;
|
||||
status=$?; echo status=$status; test $status = 5 &&
|
||||
grep "^ Volume group \"$vg2\" exists, but new VG option specified" err &&
|
||||
@@ -105,9 +112,9 @@ test_expect_success \
|
||||
vgremove $vg1'
|
||||
|
||||
test_expect_success \
|
||||
'vgsplit rejects split because alloc given with existing vg' \
|
||||
'vgcreate --alloc cling $vg1 $d1 $d2 &&
|
||||
vgcreate --alloc cling $vg2 $d3 $d4 &&
|
||||
"(lvm$mdatype) vgsplit rejects split because alloc given with existing vg" \
|
||||
'vgcreate -M$mdatype --alloc cling $vg1 $d1 $d2 &&
|
||||
vgcreate -M$mdatype --alloc cling $vg2 $d3 $d4 &&
|
||||
vgsplit --alloc cling $vg1 $vg2 $d1 2>err;
|
||||
status=$?; echo status=$status; test $status = 5 &&
|
||||
grep "^ Volume group \"$vg2\" exists, but new VG option specified" err &&
|
||||
@@ -115,9 +122,9 @@ test_expect_success \
|
||||
vgremove $vg1'
|
||||
|
||||
test_expect_success \
|
||||
'vgsplit rejects split because clustered given with existing vg' \
|
||||
'vgcreate --clustered n $vg1 $d1 $d2 &&
|
||||
vgcreate --clustered n $vg2 $d3 $d4 &&
|
||||
"(lvm$mdatype) vgsplit rejects split because clustered given with existing vg" \
|
||||
'vgcreate -M$mdatype --clustered n $vg1 $d1 $d2 &&
|
||||
vgcreate -M$mdatype --clustered n $vg2 $d3 $d4 &&
|
||||
vgsplit --clustered n $vg1 $vg2 $d1 2>err;
|
||||
status=$?; echo status=$status; test $status = 5 &&
|
||||
grep "^ Volume group \"$vg2\" exists, but new VG option specified" err &&
|
||||
@@ -125,22 +132,10 @@ test_expect_success \
|
||||
vgremove $vg1'
|
||||
|
||||
test_expect_success \
|
||||
'vgsplit rejects split because metadata types differ' \
|
||||
'pvcreate -ff -M1 $d3 $d4 &&
|
||||
pvcreate -ff -M2 $d1 $d2 &&
|
||||
vgcreate -M1 $vg1 $d3 $d4 &&
|
||||
vgcreate -M2 $vg2 $d1 $d2 &&
|
||||
vgsplit $vg1 $vg2 $d3 2>err;
|
||||
status=$?; echo status=$status; test $status = 5 &&
|
||||
grep "^ Metadata types differ" err &&
|
||||
vgremove $vg2 &&
|
||||
vgremove $vg1'
|
||||
|
||||
test_expect_success \
|
||||
'vgsplit rejects vg with active lv' \
|
||||
'pvcreate -ff -M2 $d3 $d4 &&
|
||||
vgcreate $vg1 $d1 $d2 &&
|
||||
vgcreate $vg2 $d3 $d4 &&
|
||||
"(lvm$mdatype) vgsplit rejects vg with active lv" \
|
||||
'pvcreate -ff -M$mdatype $d3 $d4 &&
|
||||
vgcreate -M$mdatype $vg1 $d1 $d2 &&
|
||||
vgcreate -M$mdatype $vg2 $d3 $d4 &&
|
||||
lvcreate -l 4 -n $lv1 $vg1 &&
|
||||
vgsplit $vg1 $vg2 $d1 2>err;
|
||||
status=$?; echo status=$status; test $status = 5 &&
|
||||
@@ -149,9 +144,9 @@ test_expect_success \
|
||||
vgremove -f $vg1'
|
||||
|
||||
test_expect_success \
|
||||
'vgsplit rejects split because max_lv is exceeded' \
|
||||
'vgcreate --maxlogicalvolumes 2 $vg1 $d1 $d2 &&
|
||||
vgcreate --maxlogicalvolumes 2 $vg2 $d3 $d4 &&
|
||||
"(lvm$mdatype) vgsplit rejects split because max_lv is exceeded" \
|
||||
'vgcreate -M$mdatype --maxlogicalvolumes 2 $vg1 $d1 $d2 &&
|
||||
vgcreate -M$mdatype --maxlogicalvolumes 2 $vg2 $d3 $d4 &&
|
||||
lvcreate -l 4 -n $lv1 $vg1 &&
|
||||
lvcreate -l 4 -n $lv2 $vg1 &&
|
||||
lvcreate -l 4 -n $lv3 $vg2 &&
|
||||
@@ -164,8 +159,8 @@ test_expect_success \
|
||||
vgremove -f $vg1'
|
||||
|
||||
test_expect_success \
|
||||
'verify default - max_lv attribute from new VG is same as source VG' \
|
||||
'vgcreate $vg1 $d1 $d2 &&
|
||||
"(lvm$mdatype) vgsplit verify default - max_lv attribute from new VG is same as source VG" \
|
||||
'vgcreate -M$mdatype $vg1 $d1 $d2 &&
|
||||
lvcreate -l 4 -n $lv1 $vg1 &&
|
||||
vgchange -an $vg1 &&
|
||||
vgsplit $vg1 $vg2 $d1 &&
|
||||
@@ -174,8 +169,8 @@ test_expect_success \
|
||||
vgremove -f $vg1'
|
||||
|
||||
test_expect_success \
|
||||
'verify default - max_pv attribute from new VG is same as source VG' \
|
||||
'vgcreate $vg1 $d1 $d2 &&
|
||||
"(lvm$mdatype) vgsplit verify default - max_pv attribute from new VG is same as source VG" \
|
||||
'vgcreate -M$mdatype $vg1 $d1 $d2 &&
|
||||
lvcreate -l 4 -n $lv1 $vg1 &&
|
||||
vgchange -an $vg1 &&
|
||||
vgsplit $vg1 $vg2 $d1 &&
|
||||
@@ -184,8 +179,8 @@ test_expect_success \
|
||||
vgremove -f $vg1'
|
||||
|
||||
test_expect_success \
|
||||
'verify default - vg_fmt attribute from new VG is same as source VG' \
|
||||
'vgcreate $vg1 $d1 $d2 &&
|
||||
"(lvm$mdatype) vgsplit verify default - vg_fmt attribute from new VG is same as source VG" \
|
||||
'vgcreate -M$mdatype $vg1 $d1 $d2 &&
|
||||
lvcreate -l 4 -n $lv1 $vg1 &&
|
||||
vgchange -an $vg1 &&
|
||||
vgsplit $vg1 $vg2 $d1 &&
|
||||
@@ -194,9 +189,9 @@ test_expect_success \
|
||||
vgremove -f $vg1'
|
||||
|
||||
test_expect_success \
|
||||
'vgsplit rejects split because PV not in VG' \
|
||||
'vgcreate $vg1 $d1 $d2 &&
|
||||
vgcreate $vg2 $d3 $d4 &&
|
||||
"(lvm$mdatype) vgsplit rejects split because PV not in VG" \
|
||||
'vgcreate -M$mdatype $vg1 $d1 $d2 &&
|
||||
vgcreate -M$mdatype $vg2 $d3 $d4 &&
|
||||
lvcreate -l 4 -n $lv1 $vg1 &&
|
||||
lvcreate -l 4 -n $lv2 $vg1 &&
|
||||
vgchange -an $vg1 &&
|
||||
@@ -204,6 +199,36 @@ test_expect_success \
|
||||
status=$?; echo status=$status; test $status = 5 &&
|
||||
vgremove -f $vg2 &&
|
||||
vgremove -f $vg1'
|
||||
done
|
||||
|
||||
test_expect_success \
|
||||
"(lvm2) setup PVs" '
|
||||
pvcreate -M$mdatype --metadatacopies 0 $d5'
|
||||
|
||||
test_expect_success \
|
||||
"(lvm2) vgsplit rejects to give away pv with the last mda copy" '
|
||||
vgcreate -M2 $vg1 $d5 $d2 &&
|
||||
lvcreate -l 10 -n $lv1 $vg1 &&
|
||||
lvchange -an $vg1/$lv1 &&
|
||||
vg_validate_pvlv_counts_ $vg1 2 1 0 &&
|
||||
{ vgsplit $vg1 $vg2 $d5;
|
||||
status=$?; echo status=$status; test $status != 0 &&
|
||||
vg_validate_pvlv_counts_ $vg1 2 1 0 &&
|
||||
vgremove -ff $vg1
|
||||
}
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
'(lvm2) vgsplit rejects split because metadata types differ' \
|
||||
'pvcreate -ff -M1 $d3 $d4 &&
|
||||
pvcreate -ff -M2 $d1 $d2 &&
|
||||
vgcreate -M1 $vg1 $d3 $d4 &&
|
||||
vgcreate -M2 $vg2 $d1 $d2 &&
|
||||
vgsplit $vg1 $vg2 $d3 2>err;
|
||||
status=$?; echo status=$status; test $status = 5 &&
|
||||
grep "^ Metadata types differ" err &&
|
||||
vgremove $vg2 &&
|
||||
vgremove $vg1'
|
||||
|
||||
test_done
|
||||
# Local Variables:
|
||||
|
||||
@@ -42,19 +42,28 @@ this_test_() { expr "./$0" : '.*/t-\([^/]*\)\.sh$'; }
|
||||
test "${test_description}" != "" ||
|
||||
error "Test script did not set test_description."
|
||||
|
||||
verboselevel=0
|
||||
while test "$#" -ne 0
|
||||
do
|
||||
case "$1" in
|
||||
-d|--d|--de|--deb|--debu|--debug)
|
||||
debug=t; shift ;;
|
||||
debug=t ;;
|
||||
-i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate)
|
||||
immediate=t; shift ;;
|
||||
immediate=t ;;
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "$test_description"
|
||||
exit 0 ;;
|
||||
-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
|
||||
verbose=t; shift ;;
|
||||
verbose=t ;;
|
||||
-vv|-vvv|-vvvv)
|
||||
verboselevel=${#1}
|
||||
verboselevel=$(($verboselevel - 1))
|
||||
verbose=t ;;
|
||||
*)
|
||||
echo "$0: unsupported option $1"
|
||||
exit 0 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
exec 5>&1
|
||||
|
||||
@@ -53,7 +53,9 @@ arg(monitor_ARG, '\0', "monitor", yes_no_arg, 0)
|
||||
arg(config_ARG, '\0', "config", string_arg, 0)
|
||||
arg(trustcache_ARG, '\0', "trustcache", NULL, 0)
|
||||
arg(ignoremonitoring_ARG, '\0', "ignoremonitoring", NULL, 0)
|
||||
arg(prefixes_ARG, '\0', "prefixes", NULL, 0)
|
||||
arg(nameprefixes_ARG, '\0', "nameprefixes", NULL, 0)
|
||||
arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
|
||||
arg(rows_ARG, '\0', "rows", NULL, 0)
|
||||
|
||||
/* Allow some variations */
|
||||
arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
|
||||
|
||||
@@ -217,6 +217,7 @@ xx(lvextend,
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[--alloc AllocationPolicy]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-f|--force]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
|
||||
"\t{-l|--extents [+]LogicalExtentsNumber[%{VG|PVS|FREE}] |\n"
|
||||
@@ -230,9 +231,9 @@ xx(lvextend,
|
||||
"\t[--version]" "\n"
|
||||
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
|
||||
|
||||
alloc_ARG, autobackup_ARG, extents_ARG, mirrors_ARG, nofsck_ARG,
|
||||
resizefs_ARG, size_ARG, stripes_ARG, stripesize_ARG, test_ARG,
|
||||
type_ARG)
|
||||
alloc_ARG, autobackup_ARG, extents_ARG, force_ARG, mirrors_ARG,
|
||||
nofsck_ARG, resizefs_ARG, size_ARG, stripes_ARG, stripesize_ARG,
|
||||
test_ARG, type_ARG)
|
||||
|
||||
xx(lvmchange,
|
||||
"With the device mapper, this is obsolete and does nothing.",
|
||||
@@ -339,6 +340,7 @@ xx(lvresize,
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[--alloc AllocationPolicy]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-f|--force]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
|
||||
"\t{-l|--extents [+|-]LogicalExtentsNumber[%{VG|LV|PVS|FREE}] |\n"
|
||||
@@ -351,8 +353,9 @@ xx(lvresize,
|
||||
"\t[--version]" "\n"
|
||||
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
|
||||
|
||||
alloc_ARG, autobackup_ARG, extents_ARG, nofsck_ARG, resizefs_ARG,
|
||||
size_ARG, stripes_ARG, stripesize_ARG, test_ARG, type_ARG)
|
||||
alloc_ARG, autobackup_ARG, extents_ARG, force_ARG, nofsck_ARG,
|
||||
resizefs_ARG, size_ARG, stripes_ARG, stripesize_ARG, test_ARG,
|
||||
type_ARG)
|
||||
|
||||
xx(lvs,
|
||||
"Display information about logical volumes",
|
||||
@@ -363,24 +366,27 @@ xx(lvs,
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[--nameprefixes]\n"
|
||||
"\t[--noheadings]\n"
|
||||
"\t[--nosuffix]\n"
|
||||
"\t[-o|--options [+]Field[,Field]]\n"
|
||||
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[--rows]\n"
|
||||
"\t[--segments]\n"
|
||||
"\t[--separator Separator]\n"
|
||||
"\t[--trustcache]\n"
|
||||
"\t[--unbuffered]\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[--unquoted]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n",
|
||||
|
||||
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
|
||||
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG,
|
||||
segments_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG,
|
||||
units_ARG)
|
||||
aligned_ARG, all_ARG, ignorelockingfailure_ARG, nameprefixes_ARG,
|
||||
noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG,
|
||||
rows_ARG, segments_ARG, separator_ARG, sort_ARG, trustcache_ARG,
|
||||
unbuffered_ARG, units_ARG, unquoted_ARG)
|
||||
|
||||
xx(lvscan,
|
||||
"List all logical volumes in all volume groups",
|
||||
@@ -570,25 +576,28 @@ xx(pvs,
|
||||
"\t[-a|--all]\n"
|
||||
"\t[-d|--debug]" "\n"
|
||||
"\t[-h|-?|--help] " "\n"
|
||||
"\t[--noheadings]\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[--nameprefixes]\n"
|
||||
"\t[--noheadings]\n"
|
||||
"\t[--nosuffix]\n"
|
||||
"\t[-o|--options [+]Field[,Field]]\n"
|
||||
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[--rows]\n"
|
||||
"\t[--segments]\n"
|
||||
"\t[--separator Separator]\n"
|
||||
"\t[--trustcache]\n"
|
||||
"\t[--unbuffered]\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[--unquoted]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]\n"
|
||||
"\t[PhysicalVolume [PhysicalVolume...]]\n",
|
||||
|
||||
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
|
||||
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG,
|
||||
segments_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG,
|
||||
units_ARG)
|
||||
aligned_ARG, all_ARG, ignorelockingfailure_ARG, nameprefixes_ARG,
|
||||
noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG,
|
||||
rows_ARG, segments_ARG, separator_ARG, sort_ARG, trustcache_ARG,
|
||||
unbuffered_ARG, units_ARG, unquoted_ARG)
|
||||
|
||||
xx(pvscan,
|
||||
"List all physical volumes",
|
||||
@@ -887,22 +896,26 @@ xx(vgs,
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[--nameprefixes]\n"
|
||||
"\t[--noheadings]\n"
|
||||
"\t[--nosuffix]\n"
|
||||
"\t[-o|--options [+]Field[,Field]]\n"
|
||||
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[--rows]\n"
|
||||
"\t[--separator Separator]\n"
|
||||
"\t[--trustcache]\n"
|
||||
"\t[--unbuffered]\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[--unquoted]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]\n"
|
||||
"\t[VolumeGroupName [VolumeGroupName...]]\n",
|
||||
|
||||
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
|
||||
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG,
|
||||
separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG)
|
||||
aligned_ARG, all_ARG, ignorelockingfailure_ARG, nameprefixes_ARG,
|
||||
noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG,
|
||||
rows_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG,
|
||||
unquoted_ARG)
|
||||
|
||||
xx(vgscan,
|
||||
"Search for all volume groups",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2005-2007 NEC Corporation
|
||||
*
|
||||
* This file is part of the device-mapper userspace tools.
|
||||
@@ -114,14 +114,15 @@ enum {
|
||||
MAJOR_ARG,
|
||||
MINOR_ARG,
|
||||
MODE_ARG,
|
||||
NAMEPREFIXES_ARG,
|
||||
NOFLUSH_ARG,
|
||||
NOHEADINGS_ARG,
|
||||
NOLOCKFS_ARG,
|
||||
NOOPENCOUNT_ARG,
|
||||
NOTABLE_ARG,
|
||||
OPTIONS_ARG,
|
||||
PREFIXES_ARG,
|
||||
READAHEAD_ARG,
|
||||
ROWS_ARG,
|
||||
SEPARATOR_ARG,
|
||||
SHOWKEYS_ARG,
|
||||
SORT_ARG,
|
||||
@@ -130,6 +131,7 @@ enum {
|
||||
TREE_ARG,
|
||||
UID_ARG,
|
||||
UNBUFFERED_ARG,
|
||||
UNQUOTED_ARG,
|
||||
UUID_ARG,
|
||||
VERBOSE_ARG,
|
||||
VERSION_ARG,
|
||||
@@ -1927,7 +1929,7 @@ static const struct dm_report_object_type _report_types[] = {
|
||||
};
|
||||
|
||||
/* Column definitions */
|
||||
#define OFFSET_OF(strct, field) ((unsigned int) &((struct strct *)NULL)->field)
|
||||
#define OFFSET_OF(strct, field) (((char*)&((struct strct*)0)->field) - (char*)0)
|
||||
#define STR (DM_REPORT_FIELD_TYPE_STRING)
|
||||
#define NUM (DM_REPORT_FIELD_TYPE_NUMBER)
|
||||
#define FIELD_O(type, strct, sorttype, head, field, width, func, id, desc) {DR_ ## type, sorttype, OFFSET_OF(strct, field), width, id, head, &_ ## func ## _disp, desc},
|
||||
@@ -1976,6 +1978,7 @@ static int _report_init(struct command *c)
|
||||
const char *keys = "";
|
||||
const char *separator = " ";
|
||||
int aligned = 1, headings = 1, buffered = 1, field_prefixes = 0;
|
||||
int quoted = 1, columns_as_rows = 0;
|
||||
uint32_t flags = 0;
|
||||
size_t len = 0;
|
||||
int r = 0;
|
||||
@@ -1990,7 +1993,13 @@ static int _report_init(struct command *c)
|
||||
if (_switches[UNBUFFERED_ARG])
|
||||
buffered = 0;
|
||||
|
||||
if (_switches[PREFIXES_ARG]) {
|
||||
if (_switches[ROWS_ARG])
|
||||
columns_as_rows = 1;
|
||||
|
||||
if (_switches[UNQUOTED_ARG])
|
||||
quoted = 0;
|
||||
|
||||
if (_switches[NAMEPREFIXES_ARG]) {
|
||||
aligned = 0;
|
||||
field_prefixes = 1;
|
||||
}
|
||||
@@ -2040,6 +2049,12 @@ static int _report_init(struct command *c)
|
||||
if (field_prefixes)
|
||||
flags |= DM_REPORT_OUTPUT_FIELD_NAME_PREFIX;
|
||||
|
||||
if (!quoted)
|
||||
flags |= DM_REPORT_OUTPUT_FIELD_UNQUOTED;
|
||||
|
||||
if (columns_as_rows)
|
||||
flags |= DM_REPORT_OUTPUT_COLUMNS_AS_ROWS;
|
||||
|
||||
if (!(_report = dm_report_init(&_report_type,
|
||||
_report_types, _report_fields,
|
||||
options, separator, flags, keys, NULL)))
|
||||
@@ -2119,7 +2134,7 @@ static void _usage(FILE *out)
|
||||
" [-r|--readonly] [--noopencount] [--nolockfs]\n"
|
||||
" [--readahead [+]<sectors>|auto|none]\n"
|
||||
" [-c|-C|--columns] [-o <fields>] [-O|--sort <sort_fields>]\n"
|
||||
" [--noheadings] [--prefixes] [--separator <separator>]\n\n");
|
||||
" [--nameprefixes] [--noheadings] [--separator <separator>]\n\n");
|
||||
for (i = 0; _commands[i].name; i++)
|
||||
fprintf(out, "\t%s %s\n", _commands[i].name, _commands[i].help);
|
||||
fprintf(out, "\n<device> may be device name or -u <uuid> or "
|
||||
@@ -2475,14 +2490,15 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
|
||||
{"major", 1, &ind, MAJOR_ARG},
|
||||
{"minor", 1, &ind, MINOR_ARG},
|
||||
{"mode", 1, &ind, MODE_ARG},
|
||||
{"nameprefixes", 0, &ind, NAMEPREFIXES_ARG},
|
||||
{"noflush", 0, &ind, NOFLUSH_ARG},
|
||||
{"noheadings", 0, &ind, NOHEADINGS_ARG},
|
||||
{"nolockfs", 0, &ind, NOLOCKFS_ARG},
|
||||
{"noopencount", 0, &ind, NOOPENCOUNT_ARG},
|
||||
{"notable", 0, &ind, NOTABLE_ARG},
|
||||
{"options", 1, &ind, OPTIONS_ARG},
|
||||
{"prefixes", 0, &ind, PREFIXES_ARG},
|
||||
{"readahead", 1, &ind, READAHEAD_ARG},
|
||||
{"rows", 0, &ind, ROWS_ARG},
|
||||
{"separator", 1, &ind, SEPARATOR_ARG},
|
||||
{"showkeys", 0, &ind, SHOWKEYS_ARG},
|
||||
{"sort", 1, &ind, SORT_ARG},
|
||||
@@ -2492,6 +2508,7 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
|
||||
{"uid", 1, &ind, UID_ARG},
|
||||
{"uuid", 1, &ind, UUID_ARG},
|
||||
{"unbuffered", 0, &ind, UNBUFFERED_ARG},
|
||||
{"unquoted", 0, &ind, UNQUOTED_ARG},
|
||||
{"verbose", 1, &ind, VERBOSE_ARG},
|
||||
{"version", 0, &ind, VERSION_ARG},
|
||||
{0, 0, 0, 0}
|
||||
@@ -2608,6 +2625,8 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
|
||||
_switches[TARGET_ARG]++;
|
||||
_target = optarg;
|
||||
}
|
||||
if ((ind == NAMEPREFIXES_ARG))
|
||||
_switches[NAMEPREFIXES_ARG]++;
|
||||
if ((ind == NOFLUSH_ARG))
|
||||
_switches[NOFLUSH_ARG]++;
|
||||
if ((ind == NOHEADINGS_ARG))
|
||||
@@ -2616,8 +2635,6 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
|
||||
_switches[NOLOCKFS_ARG]++;
|
||||
if ((ind == NOOPENCOUNT_ARG))
|
||||
_switches[NOOPENCOUNT_ARG]++;
|
||||
if ((ind == PREFIXES_ARG))
|
||||
_switches[PREFIXES_ARG]++;
|
||||
if ((ind == READAHEAD_ARG)) {
|
||||
_switches[READAHEAD_ARG]++;
|
||||
if (!strcasecmp(optarg, "auto"))
|
||||
@@ -2638,6 +2655,8 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((ind == ROWS_ARG))
|
||||
_switches[ROWS_ARG]++;
|
||||
if ((ind == SHOWKEYS_ARG))
|
||||
_switches[SHOWKEYS_ARG]++;
|
||||
if ((ind == TABLE_ARG)) {
|
||||
@@ -2646,8 +2665,8 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
|
||||
}
|
||||
if ((ind == TREE_ARG))
|
||||
_switches[TREE_ARG]++;
|
||||
if ((ind == UNBUFFERED_ARG))
|
||||
_switches[UNBUFFERED_ARG]++;
|
||||
if ((ind == UNQUOTED_ARG))
|
||||
_switches[UNQUOTED_ARG]++;
|
||||
if ((ind == VERSION_ARG))
|
||||
_switches[VERSION_ARG]++;
|
||||
}
|
||||
|
||||
@@ -387,8 +387,11 @@ static int lvchange_readahead(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
if (lv->read_ahead == read_ahead) {
|
||||
log_error("Read ahead is already %u for \"%s\"",
|
||||
read_ahead, lv->name);
|
||||
if (read_ahead == DM_READ_AHEAD_AUTO)
|
||||
log_error("Read ahead is already auto for \"%s\"", lv->name);
|
||||
else
|
||||
log_error("Read ahead is already %u for \"%s\"",
|
||||
read_ahead, lv->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -542,7 +545,7 @@ static int lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
void *handle __attribute((unused)))
|
||||
{
|
||||
int doit = 0;
|
||||
int doit = 0, docmds = 0;
|
||||
int archived = 0;
|
||||
|
||||
if (!(lv->vg->status & LVM_WRITE) &&
|
||||
@@ -603,6 +606,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
archived = 1;
|
||||
doit += lvchange_permission(cmd, lv);
|
||||
docmds++;
|
||||
}
|
||||
|
||||
/* allocation policy change */
|
||||
@@ -611,6 +615,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
archived = 1;
|
||||
doit += lvchange_alloc(cmd, lv);
|
||||
docmds++;
|
||||
}
|
||||
|
||||
/* read ahead sector change */
|
||||
@@ -619,6 +624,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
archived = 1;
|
||||
doit += lvchange_readahead(cmd, lv);
|
||||
docmds++;
|
||||
}
|
||||
|
||||
/* read ahead sector change */
|
||||
@@ -627,6 +633,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
archived = 1;
|
||||
doit += lvchange_persistent(cmd, lv);
|
||||
docmds++;
|
||||
if (sigint_caught())
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
@@ -637,6 +644,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
archived = 1;
|
||||
doit += lvchange_tag(cmd, lv, addtag_ARG);
|
||||
docmds++;
|
||||
}
|
||||
|
||||
/* del tag */
|
||||
@@ -645,6 +653,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
archived = 1;
|
||||
doit += lvchange_tag(cmd, lv, deltag_ARG);
|
||||
docmds++;
|
||||
}
|
||||
|
||||
if (doit)
|
||||
@@ -671,6 +680,9 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (doit != docmds)
|
||||
return ECMD_FAILED;
|
||||
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
|
||||
@@ -508,6 +508,9 @@ static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * l
|
||||
}
|
||||
|
||||
if (lp->mirrors == existing_mirrors) {
|
||||
/*
|
||||
* Convert Mirror log type
|
||||
*/
|
||||
original_lv = _original_lv(lv);
|
||||
if (!first_seg(original_lv)->log_lv && !corelog) {
|
||||
if (!add_mirror_log(cmd, original_lv, 1,
|
||||
@@ -629,10 +632,12 @@ static int lvconvert_snapshot(struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (org->status & (LOCKED|PVMOVE) || lv_is_cow(org)) {
|
||||
if (org->status & (LOCKED|PVMOVE|MIRRORED) || lv_is_cow(org)) {
|
||||
log_error("Unable to create a snapshot of a %s LV.",
|
||||
org->status & LOCKED ? "locked" :
|
||||
org->status & PVMOVE ? "pvmove" : "snapshot");
|
||||
org->status & PVMOVE ? "pvmove" :
|
||||
org->status & MIRRORED ? "mirrored" :
|
||||
"snapshot");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -707,16 +712,20 @@ static int lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, mirrors_ARG) || (lv->status & MIRRORED)) {
|
||||
if (!archive(lv->vg))
|
||||
if (lp->snapshot) {
|
||||
if (lv->status & MIRRORED) {
|
||||
log_error("Unable to convert mirrored LV \"%s\" into a snapshot.", lv->name);
|
||||
return ECMD_FAILED;
|
||||
if (!lvconvert_mirrors(cmd, lv, lp))
|
||||
return ECMD_FAILED;
|
||||
} else if (lp->snapshot) {
|
||||
}
|
||||
if (!archive(lv->vg))
|
||||
return ECMD_FAILED;
|
||||
if (!lvconvert_snapshot(cmd, lv, lp))
|
||||
return ECMD_FAILED;
|
||||
} else if (arg_count(cmd, mirrors_ARG) || (lv->status & MIRRORED)) {
|
||||
if (!archive(lv->vg))
|
||||
return ECMD_FAILED;
|
||||
if (!lvconvert_mirrors(cmd, lv, lp))
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
@@ -523,8 +523,6 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct lvinfo info;
|
||||
uint32_t pv_extent_count;
|
||||
|
||||
status |= lp->permission | VISIBLE_LV;
|
||||
|
||||
if (lp->lv_name && find_lv_in_vg(vg, lp->lv_name)) {
|
||||
log_error("Logical volume \"%s\" already exists in "
|
||||
"volume group \"%s\"", lp->lv_name, lp->vg_name);
|
||||
@@ -544,16 +542,6 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the pv list.
|
||||
*/
|
||||
if (lp->pv_count) {
|
||||
if (!(pvh = create_pv_list(cmd->mem, vg,
|
||||
lp->pv_count, lp->pvs, 1)))
|
||||
return_0;
|
||||
} else
|
||||
pvh = &vg->pvs;
|
||||
|
||||
if (lp->stripe_size > vg->extent_size) {
|
||||
log_error("Reducing requested stripe size %s to maximum, "
|
||||
"physical extent size %s",
|
||||
@@ -594,6 +582,16 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
|
||||
lp->extents = (uint64_t) tmp_size / vg->extent_size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the pv list.
|
||||
*/
|
||||
if (lp->pv_count) {
|
||||
if (!(pvh = create_pv_list(cmd->mem, vg,
|
||||
lp->pv_count, lp->pvs, 1)))
|
||||
return_0;
|
||||
} else
|
||||
pvh = &vg->pvs;
|
||||
|
||||
switch(lp->percent) {
|
||||
case PERCENT_VG:
|
||||
lp->extents = lp->extents * vg->extent_count / 100;
|
||||
@@ -631,6 +629,8 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
status |= lp->permission | VISIBLE_LV;
|
||||
|
||||
if (lp->snapshot) {
|
||||
if (!activation()) {
|
||||
log_error("Can't create snapshot without using "
|
||||
|
||||
@@ -236,6 +236,10 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline)
|
||||
log_error("No such command '%s'. Try 'help'.",
|
||||
argv[0]);
|
||||
|
||||
if ((ret != ECMD_PROCESSED) && !error_message_produced()) {
|
||||
log_debug("Internal error: Failed command did not use log_error");
|
||||
log_error("Command failed with status code %d.", ret);
|
||||
}
|
||||
_write_history();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
@@ -79,9 +79,10 @@ int lvm2_run(void *handle, const char *cmdline)
|
||||
}
|
||||
|
||||
/* FIXME Temporary - move to libdevmapper */
|
||||
ret = ECMD_PROCESSED;
|
||||
if (!strcmp(cmdline, "_memlock_inc"))
|
||||
memlock_inc();
|
||||
if (!strcmp(cmdline, "_memlock_dec"))
|
||||
else if (!strcmp(cmdline, "_memlock_dec"))
|
||||
memlock_dec();
|
||||
else
|
||||
ret = lvm_run_command(cmd, argc, argv);
|
||||
|
||||
@@ -875,6 +875,8 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
|
||||
int ret = 0;
|
||||
int locking_type;
|
||||
|
||||
init_error_message_produced(0);
|
||||
|
||||
/* each command should start out with sigint flag cleared */
|
||||
sigint_clear();
|
||||
|
||||
@@ -999,11 +1001,76 @@ static void _init_rand(void)
|
||||
srand((unsigned) time(NULL) + (unsigned) getpid());
|
||||
}
|
||||
|
||||
static void _close_stray_fds(void)
|
||||
static const char *_get_cmdline(pid_t pid)
|
||||
{
|
||||
static char _proc_cmdline[32];
|
||||
char buf[256];
|
||||
int fd;
|
||||
|
||||
snprintf(buf, sizeof(buf), DEFAULT_PROC_DIR "/%u/cmdline", pid);
|
||||
if ((fd = open(buf, O_RDONLY)) > 0) {
|
||||
read(fd, _proc_cmdline, sizeof(_proc_cmdline) - 1);
|
||||
_proc_cmdline[sizeof(_proc_cmdline) - 1] = '\0';
|
||||
close(fd);
|
||||
} else
|
||||
_proc_cmdline[0] = '\0';
|
||||
|
||||
return _proc_cmdline;
|
||||
}
|
||||
|
||||
static const char *_get_filename(int fd)
|
||||
{
|
||||
static char filename[PATH_MAX];
|
||||
char buf[32]; /* Assumes short DEFAULT_PROC_DIR */
|
||||
int size;
|
||||
|
||||
snprintf(buf, sizeof(buf), DEFAULT_PROC_DIR "/self/fd/%u", fd);
|
||||
|
||||
if ((size = readlink(buf, filename, sizeof(filename) - 1)) == -1)
|
||||
filename[0] = '\0';
|
||||
else
|
||||
filename[size] = '\0';
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
static void _close_descriptor(int fd, unsigned suppress_warnings,
|
||||
const char *command, pid_t ppid,
|
||||
const char *parent_cmdline)
|
||||
{
|
||||
int r;
|
||||
const char *filename;
|
||||
|
||||
/* Ignore bad file descriptors */
|
||||
if (fcntl(fd, F_GETFD) == -1 && errno == EBADF)
|
||||
return;
|
||||
|
||||
if (!suppress_warnings)
|
||||
filename = _get_filename(fd);
|
||||
|
||||
r = close(fd);
|
||||
if (suppress_warnings)
|
||||
return;
|
||||
|
||||
if (!r)
|
||||
fprintf(stderr, "File descriptor %d (%s) leaked on "
|
||||
"%s invocation.", fd, filename, command);
|
||||
else if (errno == EBADF)
|
||||
return;
|
||||
else
|
||||
fprintf(stderr, "Close failed on stray file descriptor "
|
||||
"%d (%s): %s", fd, filename, strerror(errno));
|
||||
|
||||
fprintf(stderr, " Parent PID %" PRIpid_t ": %s\n", ppid, parent_cmdline);
|
||||
}
|
||||
|
||||
static void _close_stray_fds(const char *command)
|
||||
{
|
||||
struct rlimit rlim;
|
||||
int fd;
|
||||
int suppress_warnings = 0;
|
||||
unsigned suppress_warnings = 0;
|
||||
pid_t ppid = getppid();
|
||||
const char *parent_cmdline = _get_cmdline(ppid);
|
||||
|
||||
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
|
||||
fprintf(stderr, "getrlimit(RLIMIT_NOFILE) failed: %s\n",
|
||||
@@ -1014,15 +1081,9 @@ static void _close_stray_fds(void)
|
||||
if (getenv("LVM_SUPPRESS_FD_WARNINGS"))
|
||||
suppress_warnings = 1;
|
||||
|
||||
for (fd = 3; fd < rlim.rlim_cur; fd++) {
|
||||
if (suppress_warnings)
|
||||
close(fd);
|
||||
else if (!close(fd))
|
||||
fprintf(stderr, "File descriptor %d left open\n", fd);
|
||||
else if (errno != EBADF)
|
||||
fprintf(stderr, "Close failed on stray file "
|
||||
"descriptor %d: %s\n", fd, strerror(errno));
|
||||
}
|
||||
for (fd = 3; fd < rlim.rlim_cur; fd++)
|
||||
_close_descriptor(fd, suppress_warnings, command, ppid,
|
||||
parent_cmdline);
|
||||
}
|
||||
|
||||
struct cmd_context *init_lvm(unsigned is_static)
|
||||
@@ -1096,7 +1157,14 @@ static int _run_script(struct cmd_context *cmd, int argc, char **argv)
|
||||
continue;
|
||||
if (!strcmp(argv[0], "quit") || !strcmp(argv[0], "exit"))
|
||||
break;
|
||||
lvm_run_command(cmd, argc, argv);
|
||||
ret = lvm_run_command(cmd, argc, argv);
|
||||
if (ret != ECMD_PROCESSED) {
|
||||
if (!error_message_produced()) {
|
||||
log_debug("Internal error: Failed command did not use log_error");
|
||||
log_error("Command failed with status code %d.", ret);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fclose(script))
|
||||
@@ -1153,15 +1221,13 @@ int lvm2_main(int argc, char **argv, unsigned is_static)
|
||||
int ret, alias = 0;
|
||||
struct cmd_context *cmd;
|
||||
|
||||
_close_stray_fds();
|
||||
|
||||
base = last_path_component(argv[0]);
|
||||
while (*base == '/')
|
||||
base++;
|
||||
if (strcmp(base, "lvm") && strcmp(base, "lvm.static") &&
|
||||
strcmp(base, "initrd-lvm"))
|
||||
alias = 1;
|
||||
|
||||
_close_stray_fds(base);
|
||||
|
||||
if (is_static && strcmp(base, "lvm.static") &&
|
||||
path_exists(LVM_SHARED_PATH) &&
|
||||
!getenv("LVM_DID_EXEC")) {
|
||||
@@ -1218,6 +1284,11 @@ int lvm2_main(int argc, char **argv, unsigned is_static)
|
||||
if (ret == ENO_SUCH_CMD)
|
||||
log_error("No such command. Try 'help'.");
|
||||
|
||||
if ((ret != ECMD_PROCESSED) && !error_message_produced()) {
|
||||
log_debug("Internal error: Failed command did not use log_error");
|
||||
log_error("Command failed with status code %d.", ret);
|
||||
}
|
||||
|
||||
out:
|
||||
lvm_fin(cmd);
|
||||
if (ret == ECMD_PROCESSED)
|
||||
|
||||
@@ -308,6 +308,11 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (lv->status & CONVERTING) {
|
||||
log_error("Can't resize %s while lvconvert in progress", lv->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
alloc = arg_uint_value(cmd, alloc_ARG, lv->alloc);
|
||||
|
||||
if (lp->size) {
|
||||
|
||||
@@ -23,9 +23,11 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
struct volume_group *vg = NULL;
|
||||
const char *vg_name = NULL;
|
||||
struct pv_list *pvl;
|
||||
struct list mdas;
|
||||
uint64_t sector;
|
||||
uint32_t orig_pe_alloc_count;
|
||||
/* FIXME Next three only required for format1. */
|
||||
uint32_t orig_pe_count, orig_pe_size;
|
||||
uint64_t orig_pe_start;
|
||||
|
||||
const char *pv_name = pv_dev_name(pv);
|
||||
const char *tag = NULL;
|
||||
@@ -35,8 +37,6 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
int allocatable = 0;
|
||||
int tagarg = 0;
|
||||
|
||||
list_init(&mdas);
|
||||
|
||||
if (arg_count(cmd, addtag_ARG))
|
||||
tagarg = addtag_ARG;
|
||||
else if (arg_count(cmd, deltag_ARG))
|
||||
@@ -51,7 +51,6 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
}
|
||||
|
||||
/* If in a VG, must change using volume group. */
|
||||
/* FIXME: handle PVs with no MDAs */
|
||||
if (!is_orphan(pv)) {
|
||||
vg_name = pv_vg_name(pv);
|
||||
|
||||
@@ -98,7 +97,7 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(pv = pv_read(cmd, pv_name, &mdas, §or, 1))) {
|
||||
if (!(pv = pv_read(cmd, pv_name, NULL, §or, 1))) {
|
||||
unlock_vg(cmd, vg_name);
|
||||
log_error("Unable to read PV \"%s\"", pv_name);
|
||||
return 0;
|
||||
@@ -171,6 +170,12 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
if (!is_orphan(pv)) {
|
||||
orig_vg_name = pv_vg_name(pv);
|
||||
orig_pe_alloc_count = pv_pe_alloc_count(pv);
|
||||
|
||||
/* FIXME format1 pv_write doesn't preserve these. */
|
||||
orig_pe_size = pv_pe_size(pv);
|
||||
orig_pe_start = pv_pe_start(pv);
|
||||
orig_pe_count = pv_pe_count(pv);
|
||||
|
||||
pv->vg_name = pv->fmt->orphan_vg_name;
|
||||
pv->pe_alloc_count = 0;
|
||||
if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
|
||||
@@ -181,6 +186,10 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
}
|
||||
pv->vg_name = orig_vg_name;
|
||||
pv->pe_alloc_count = orig_pe_alloc_count;
|
||||
|
||||
pv->pe_size = orig_pe_size;
|
||||
pv->pe_start = orig_pe_start;
|
||||
pv->pe_count = orig_pe_count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,8 +229,6 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
struct list *pvslist;
|
||||
struct list mdas;
|
||||
|
||||
list_init(&mdas);
|
||||
|
||||
if (arg_count(cmd, allocatable_ARG) + arg_count(cmd, addtag_ARG) +
|
||||
arg_count(cmd, deltag_ARG) + arg_count(cmd, uuid_ARG) != 1) {
|
||||
log_error("Please give exactly one option of -x, -uuid, "
|
||||
@@ -243,12 +250,34 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
log_verbose("Using physical volume(s) on command line");
|
||||
for (; opt < argc; opt++) {
|
||||
pv_name = argv[opt];
|
||||
/* FIXME Read VG instead - pv_read will fail */
|
||||
list_init(&mdas);
|
||||
if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1))) {
|
||||
log_error("Failed to read physical volume %s",
|
||||
pv_name);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* If a PV has no MDAs it may appear to be an
|
||||
* orphan until the metadata is read off
|
||||
* another PV in the same VG. Detecting this
|
||||
* means checking every VG by scanning every
|
||||
* PV on the system.
|
||||
*/
|
||||
if (is_orphan(pv) && !list_size(&mdas)) {
|
||||
if (!scan_vgs_for_pvs(cmd)) {
|
||||
log_error("Rescan for PVs without "
|
||||
"metadata areas failed.");
|
||||
continue;
|
||||
}
|
||||
if (!(pv = pv_read(cmd, pv_name,
|
||||
NULL, NULL, 1))) {
|
||||
log_error("Failed to read "
|
||||
"physical volume %s",
|
||||
pv_name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
total++;
|
||||
done += _pvchange_single(cmd, pv, NULL);
|
||||
}
|
||||
|
||||
236
tools/pvcreate.c
236
tools/pvcreate.c
@@ -18,6 +18,18 @@
|
||||
|
||||
struct pvcreate_params {
|
||||
int zero;
|
||||
uint64_t size;
|
||||
int pvmetadatacopies;
|
||||
uint64_t pvmetadatasize;
|
||||
int64_t labelsector;
|
||||
struct id id; /* FIXME: redundant */
|
||||
struct id *idp; /* 0 if no --uuid option */
|
||||
uint64_t pe_start;
|
||||
uint32_t extent_count;
|
||||
uint32_t extent_size;
|
||||
const char *restorefile; /* 0 if no --restorefile option */
|
||||
force_t force;
|
||||
unsigned yes;
|
||||
};
|
||||
|
||||
const char _really_init[] =
|
||||
@@ -27,18 +39,14 @@ const char _really_init[] =
|
||||
* See if we may pvcreate on this device.
|
||||
* 0 indicates we may not.
|
||||
*/
|
||||
static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
static int pvcreate_check(struct cmd_context *cmd, const char *name,
|
||||
struct pvcreate_params *pp)
|
||||
{
|
||||
struct physical_volume *pv;
|
||||
struct device *dev;
|
||||
uint64_t md_superblock;
|
||||
|
||||
/* is the partition type set correctly ? */
|
||||
if ((arg_count(cmd, force_ARG) < 1) && !is_lvm_partition(name)) {
|
||||
log_error("%s: Not LVM partition type: use -f to override",
|
||||
name);
|
||||
return 0;
|
||||
}
|
||||
/* FIXME Check partition type is LVM unless --force is given */
|
||||
|
||||
/* Is there a pv here already? */
|
||||
/* FIXME Use partial mode here? */
|
||||
@@ -58,14 +66,14 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
|
||||
/* Allow partial & exported VGs to be destroyed. */
|
||||
/* We must have -ff to overwrite a non orphan */
|
||||
if (pv && !is_orphan(pv) && arg_count(cmd, force_ARG) != 2) {
|
||||
if (pv && !is_orphan(pv) && pp->force != DONT_PROMPT_OVERRIDE) {
|
||||
log_error("Can't initialize physical volume \"%s\" of "
|
||||
"volume group \"%s\" without -ff", name, pv_vg_name(pv));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* prompt */
|
||||
if (pv && !is_orphan(pv) && !arg_count(cmd, yes_ARG) &&
|
||||
if (pv && !is_orphan(pv) && !pp->yes &&
|
||||
yes_no_prompt(_really_init, name, pv_vg_name(pv)) == 'n') {
|
||||
log_print("%s: physical volume not initialized", name);
|
||||
return 0;
|
||||
@@ -98,6 +106,9 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This test will fail if the device belongs to an MD array.
|
||||
*/
|
||||
if (!dev_test_excl(dev)) {
|
||||
/* FIXME Detect whether device-mapper itself is still using it */
|
||||
log_error("Can't open %s exclusively. Mounted filesystem?",
|
||||
@@ -107,9 +118,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
|
||||
/* Wipe superblock? */
|
||||
if (dev_is_md(dev, &md_superblock) &&
|
||||
((!arg_count(cmd, uuidstr_ARG) &&
|
||||
!arg_count(cmd, restorefile_ARG)) ||
|
||||
arg_count(cmd, yes_ARG) ||
|
||||
((!pp->idp && !pp->restorefile) || pp->yes ||
|
||||
(yes_no_prompt("Software RAID md superblock "
|
||||
"detected on %s. Wipe it? [y/n] ", name) == 'y'))) {
|
||||
log_print("Wiping software RAID md superblock on %s", name);
|
||||
@@ -123,7 +132,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
if (sigint_caught())
|
||||
return 0;
|
||||
|
||||
if (pv && !is_orphan(pv) && arg_count(cmd, force_ARG)) {
|
||||
if (pv && !is_orphan(pv) && pp->force) {
|
||||
log_warn("WARNING: Forcing physical volume creation on "
|
||||
"%s%s%s%s", name,
|
||||
!is_orphan(pv) ? " of volume group \"" : "",
|
||||
@@ -139,85 +148,29 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
{
|
||||
struct pvcreate_params *pp = (struct pvcreate_params *) handle;
|
||||
void *pv;
|
||||
void *existing_pv;
|
||||
struct id id, *idp = NULL;
|
||||
const char *uuid = NULL;
|
||||
uint64_t size = 0;
|
||||
struct device *dev;
|
||||
struct list mdas;
|
||||
int pvmetadatacopies;
|
||||
uint64_t pvmetadatasize;
|
||||
struct volume_group *vg;
|
||||
const char *restorefile;
|
||||
uint64_t pe_start = 0;
|
||||
uint32_t extent_count = 0, extent_size = 0;
|
||||
|
||||
if (arg_count(cmd, uuidstr_ARG)) {
|
||||
uuid = arg_str_value(cmd, uuidstr_ARG, "");
|
||||
if (!id_read_format(&id, uuid))
|
||||
return EINVALID_CMD_LINE;
|
||||
if ((dev = device_from_pvid(cmd, &id)) &&
|
||||
if (pp->idp) {
|
||||
if ((dev = device_from_pvid(cmd, pp->idp)) &&
|
||||
(dev != dev_cache_get(pv_name, cmd->filter))) {
|
||||
log_error("uuid %s already in use on \"%s\"", uuid,
|
||||
dev_name(dev));
|
||||
return ECMD_FAILED;
|
||||
log_error("uuid %s already in use on \"%s\"",
|
||||
pp->idp->uuid, dev_name(dev));
|
||||
return 0;
|
||||
}
|
||||
idp = &id;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, restorefile_ARG)) {
|
||||
restorefile = arg_str_value(cmd, restorefile_ARG, "");
|
||||
/* The uuid won't already exist */
|
||||
init_partial(1);
|
||||
if (!(vg = backup_read_vg(cmd, NULL, restorefile))) {
|
||||
log_error("Unable to read volume group from %s",
|
||||
restorefile);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
init_partial(0);
|
||||
if (!(existing_pv = find_pv_in_vg_by_uuid(vg, idp))) {
|
||||
log_error("Can't find uuid %s in backup file %s",
|
||||
uuid, restorefile);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
pe_start = pv_pe_start(existing_pv);
|
||||
extent_size = pv_pe_size(existing_pv);
|
||||
extent_count = pv_pe_count(existing_pv);
|
||||
}
|
||||
|
||||
if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
|
||||
log_error("Can't get lock for orphan PVs");
|
||||
return ECMD_FAILED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!pvcreate_check(cmd, pv_name))
|
||||
if (!pvcreate_check(cmd, pv_name, pp))
|
||||
goto error;
|
||||
|
||||
if (sigint_caught())
|
||||
goto error;
|
||||
|
||||
if (arg_sign_value(cmd, physicalvolumesize_ARG, 0) == SIGN_MINUS) {
|
||||
log_error("Physical volume size may not be negative");
|
||||
goto error;
|
||||
}
|
||||
size = arg_uint64_value(cmd, physicalvolumesize_ARG, UINT64_C(0));
|
||||
|
||||
if (arg_sign_value(cmd, metadatasize_ARG, 0) == SIGN_MINUS) {
|
||||
log_error("Metadata size may not be negative");
|
||||
goto error;
|
||||
}
|
||||
pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0));
|
||||
if (!pvmetadatasize)
|
||||
pvmetadatasize = find_config_tree_int(cmd,
|
||||
"metadata/pvmetadatasize",
|
||||
DEFAULT_PVMETADATASIZE);
|
||||
|
||||
pvmetadatacopies = arg_int_value(cmd, metadatacopies_ARG, -1);
|
||||
if (pvmetadatacopies < 0)
|
||||
pvmetadatacopies = find_config_tree_int(cmd,
|
||||
"metadata/pvmetadatacopies",
|
||||
DEFAULT_PVMETADATACOPIES);
|
||||
|
||||
if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
|
||||
log_error("%s: Couldn't find device. Check your filters?",
|
||||
pv_name);
|
||||
@@ -225,9 +178,10 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
}
|
||||
|
||||
list_init(&mdas);
|
||||
if (!(pv = pv_create(cmd->fmt, dev, idp, size, pe_start,
|
||||
extent_count, extent_size,
|
||||
pvmetadatacopies, pvmetadatasize, &mdas))) {
|
||||
if (!(pv = pv_create(cmd, dev, pp->idp, pp->size, pp->pe_start,
|
||||
pp->extent_count, pp->extent_size,
|
||||
pp->pvmetadatacopies,
|
||||
pp->pvmetadatasize,&mdas))) {
|
||||
log_error("Failed to setup physical volume \"%s\"", pv_name);
|
||||
goto error;
|
||||
}
|
||||
@@ -259,8 +213,7 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
log_very_verbose("Writing physical volume data to disk \"%s\"",
|
||||
pv_name);
|
||||
if (!(pv_write(cmd, (struct physical_volume *)pv, &mdas,
|
||||
arg_int64_value(cmd, labelsector_ARG,
|
||||
DEFAULT_LABELSECTOR)))) {
|
||||
pp->labelsector))) {
|
||||
log_error("Failed to write physical volume \"%s\"", pv_name);
|
||||
goto error;
|
||||
}
|
||||
@@ -268,69 +221,152 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
log_print("Physical volume \"%s\" successfully created", pv_name);
|
||||
|
||||
unlock_vg(cmd, VG_ORPHANS);
|
||||
return ECMD_PROCESSED;
|
||||
return 1;
|
||||
|
||||
error:
|
||||
unlock_vg(cmd, VG_ORPHANS);
|
||||
return ECMD_FAILED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pvcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
/*
|
||||
* Intial sanity checking of command-line arguments and fill in 'pp' fields.
|
||||
*
|
||||
* Input arguments:
|
||||
* cmd, argc, argv
|
||||
*
|
||||
* Output arguments:
|
||||
* pp: structure allocated by caller, fields written / validated here
|
||||
*/
|
||||
static int pvcreate_validate_params(struct cmd_context *cmd,
|
||||
int argc, char **argv,
|
||||
struct pvcreate_params *pp)
|
||||
{
|
||||
int i, r;
|
||||
int ret = ECMD_PROCESSED;
|
||||
struct pvcreate_params pp;
|
||||
const char *uuid = NULL;
|
||||
void *existing_pv;
|
||||
struct volume_group *vg;
|
||||
|
||||
memset(pp, 0, sizeof(*pp));
|
||||
|
||||
if (!argc) {
|
||||
log_error("Please enter a physical volume path");
|
||||
return EINVALID_CMD_LINE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, restorefile_ARG) && !arg_count(cmd, uuidstr_ARG)) {
|
||||
log_error("--uuid is required with --restorefile");
|
||||
return EINVALID_CMD_LINE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, uuidstr_ARG) && argc != 1) {
|
||||
log_error("Can only set uuid on one volume at once");
|
||||
return EINVALID_CMD_LINE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, uuidstr_ARG)) {
|
||||
uuid = arg_str_value(cmd, uuidstr_ARG, "");
|
||||
if (!id_read_format(&pp->id, uuid))
|
||||
return 0;
|
||||
pp->idp = &pp->id;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, restorefile_ARG)) {
|
||||
pp->restorefile = arg_str_value(cmd, restorefile_ARG, "");
|
||||
/* The uuid won't already exist */
|
||||
init_partial(1);
|
||||
if (!(vg = backup_read_vg(cmd, NULL, pp->restorefile))) {
|
||||
log_error("Unable to read volume group from %s",
|
||||
pp->restorefile);
|
||||
return 0;
|
||||
}
|
||||
init_partial(0);
|
||||
if (!(existing_pv = find_pv_in_vg_by_uuid(vg, pp->idp))) {
|
||||
log_error("Can't find uuid %s in backup file %s",
|
||||
uuid, pp->restorefile);
|
||||
return 0;
|
||||
}
|
||||
pp->pe_start = pv_pe_start(existing_pv);
|
||||
pp->extent_size = pv_pe_size(existing_pv);
|
||||
pp->extent_count = pv_pe_count(existing_pv);
|
||||
}
|
||||
|
||||
if (arg_count(cmd, yes_ARG) && !arg_count(cmd, force_ARG)) {
|
||||
log_error("Option y can only be given with option f");
|
||||
return EINVALID_CMD_LINE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp->yes = arg_count(cmd, yes_ARG);
|
||||
pp->force = arg_count(cmd, force_ARG);
|
||||
|
||||
if (arg_int_value(cmd, labelsector_ARG, 0) >= LABEL_SCAN_SECTORS) {
|
||||
log_error("labelsector must be less than %lu",
|
||||
LABEL_SCAN_SECTORS);
|
||||
return EINVALID_CMD_LINE;
|
||||
return 0;
|
||||
} else {
|
||||
pp->labelsector = arg_int64_value(cmd, labelsector_ARG,
|
||||
DEFAULT_LABELSECTOR);
|
||||
}
|
||||
|
||||
if (!(cmd->fmt->features & FMT_MDAS) &&
|
||||
(arg_count(cmd, metadatacopies_ARG) ||
|
||||
arg_count(cmd, metadatasize_ARG))) {
|
||||
log_error("Metadata parameters only apply to text format");
|
||||
return EINVALID_CMD_LINE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, metadatacopies_ARG) &&
|
||||
arg_int_value(cmd, metadatacopies_ARG, -1) > 2) {
|
||||
log_error("Metadatacopies may only be 0, 1 or 2");
|
||||
return EINVALID_CMD_LINE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, zero_ARG))
|
||||
pp.zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
|
||||
pp->zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
|
||||
else if (arg_count(cmd, restorefile_ARG) || arg_count(cmd, uuidstr_ARG))
|
||||
pp.zero = 0;
|
||||
pp->zero = 0;
|
||||
else
|
||||
pp.zero = 1;
|
||||
pp->zero = 1;
|
||||
|
||||
if (arg_sign_value(cmd, physicalvolumesize_ARG, 0) == SIGN_MINUS) {
|
||||
log_error("Physical volume size may not be negative");
|
||||
return 0;
|
||||
}
|
||||
pp->size = arg_uint64_value(cmd, physicalvolumesize_ARG, UINT64_C(0));
|
||||
|
||||
if (arg_sign_value(cmd, metadatasize_ARG, 0) == SIGN_MINUS) {
|
||||
log_error("Metadata size may not be negative");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pp->pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0));
|
||||
if (!pp->pvmetadatasize)
|
||||
pp->pvmetadatasize = find_config_tree_int(cmd,
|
||||
"metadata/pvmetadatasize",
|
||||
DEFAULT_PVMETADATASIZE);
|
||||
|
||||
pp->pvmetadatacopies = arg_int_value(cmd, metadatacopies_ARG, -1);
|
||||
if (pp->pvmetadatacopies < 0)
|
||||
pp->pvmetadatacopies = find_config_tree_int(cmd,
|
||||
"metadata/pvmetadatacopies",
|
||||
DEFAULT_PVMETADATACOPIES);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int pvcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int ret = ECMD_PROCESSED;
|
||||
struct pvcreate_params pp;
|
||||
|
||||
if (!pvcreate_validate_params(cmd, argc, argv, &pp)) {
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
r = pvcreate_single(cmd, argv[i], &pp);
|
||||
if (r > ret)
|
||||
ret = r;
|
||||
if (!pvcreate_single(cmd, argv[i], &pp))
|
||||
ret = ECMD_FAILED;
|
||||
|
||||
if (sigint_caught())
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -25,23 +25,40 @@ const char _really_wipe[] =
|
||||
static int pvremove_check(struct cmd_context *cmd, const char *name)
|
||||
{
|
||||
struct physical_volume *pv;
|
||||
struct list mdas;
|
||||
|
||||
/* is the partition type set correctly ? */
|
||||
if ((arg_count(cmd, force_ARG) < 1) && !is_lvm_partition(name)) {
|
||||
log_error("%s: Not LVM partition type: use -f to override",
|
||||
name);
|
||||
return 0;
|
||||
}
|
||||
list_init(&mdas);
|
||||
|
||||
/* FIXME Check partition type is LVM unless --force is given */
|
||||
|
||||
/* Is there a pv here already? */
|
||||
/* If not, this is an error unless you used -f. */
|
||||
if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) {
|
||||
if (!(pv = pv_read(cmd, name, &mdas, NULL, 1))) {
|
||||
if (arg_count(cmd, force_ARG))
|
||||
return 1;
|
||||
log_error("Physical Volume %s not found", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* If a PV has no MDAs it may appear to be an
|
||||
* orphan until the metadata is read off
|
||||
* another PV in the same VG. Detecting this
|
||||
* means checking every VG by scanning every
|
||||
* PV on the system.
|
||||
*/
|
||||
if (is_orphan(pv) && !list_size(&mdas)) {
|
||||
if (!scan_vgs_for_pvs(cmd)) {
|
||||
log_error("Rescan for PVs without metadata areas "
|
||||
"failed.");
|
||||
return 0;
|
||||
}
|
||||
if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) {
|
||||
log_error("Failed to read physical volume %s", name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* orphan ? */
|
||||
if (is_orphan(pv))
|
||||
return 1;
|
||||
|
||||
@@ -35,6 +35,8 @@ static int _pv_resize_single(struct cmd_context *cmd,
|
||||
struct list mdas;
|
||||
const char *pv_name = pv_dev_name(pv);
|
||||
const char *vg_name;
|
||||
struct lvmcache_info *info;
|
||||
int mda_count = 0;
|
||||
|
||||
list_init(&mdas);
|
||||
|
||||
@@ -51,13 +53,7 @@ static int _pv_resize_single(struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME Create function to test compatibility properly */
|
||||
if (list_size(&mdas) > 1) {
|
||||
log_error("%s: too many metadata areas for pvresize",
|
||||
pv_name);
|
||||
unlock_vg(cmd, vg_name);
|
||||
return 0;
|
||||
}
|
||||
mda_count = list_size(&mdas);
|
||||
} else {
|
||||
vg_name = pv_vg_name(pv);
|
||||
|
||||
@@ -87,10 +83,26 @@ static int _pv_resize_single(struct cmd_context *cmd,
|
||||
|
||||
pv = pvl->pv;
|
||||
|
||||
if (!(info = info_from_pvid(pv->dev->pvid, 0))) {
|
||||
unlock_vg(cmd, vg_name);
|
||||
log_error("Can't get info for PV %s in volume group %s",
|
||||
pv_name, vg->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
mda_count = list_size(&info->mdas);
|
||||
|
||||
if (!archive(vg))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME Create function to test compatibility properly */
|
||||
if (mda_count > 1) {
|
||||
log_error("%s: too many metadata areas for pvresize", pv_name);
|
||||
unlock_vg(cmd, vg_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(pv->fmt->features & FMT_RESIZE_PV)) {
|
||||
log_error("Physical volume %s format does not support resizing.",
|
||||
pv_name);
|
||||
|
||||
@@ -61,8 +61,39 @@ static int _pvsegs_sub_single(struct cmd_context *cmd __attribute((unused)),
|
||||
int ret = ECMD_PROCESSED;
|
||||
struct lv_segment *seg = pvseg->lvseg;
|
||||
|
||||
if (!report_object(handle, vg, seg ? seg->lv : NULL, pvseg->pv, seg,
|
||||
pvseg))
|
||||
struct logical_volume _free_logical_volume = {
|
||||
.vg = vg,
|
||||
.name = (char *) "",
|
||||
.snapshot = NULL,
|
||||
.status = VISIBLE_LV,
|
||||
.major = -1,
|
||||
.minor = -1,
|
||||
};
|
||||
|
||||
struct lv_segment _free_lv_segment = {
|
||||
.lv = &_free_logical_volume,
|
||||
.le = 0,
|
||||
.status = 0,
|
||||
.stripe_size = 0,
|
||||
.area_count = 0,
|
||||
.area_len = 0,
|
||||
.origin = NULL,
|
||||
.cow = NULL,
|
||||
.chunk_size = 0,
|
||||
.region_size = 0,
|
||||
.extents_copied = 0,
|
||||
.log_lv = NULL,
|
||||
.areas = NULL,
|
||||
};
|
||||
|
||||
_free_lv_segment.segtype = get_segtype_from_string(cmd, "free");
|
||||
_free_lv_segment.len = pvseg->len;
|
||||
list_init(&_free_logical_volume.tags);
|
||||
list_init(&_free_logical_volume.segments);
|
||||
list_init(&_free_logical_volume.segs_using_this_lv);
|
||||
|
||||
if (!report_object(handle, vg, seg ? seg->lv : &_free_logical_volume, pvseg->pv,
|
||||
seg ? : &_free_lv_segment, pvseg))
|
||||
ret = ECMD_FAILED;
|
||||
|
||||
return ret;
|
||||
@@ -158,7 +189,8 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
char *str;
|
||||
const char *keys = NULL, *options = NULL, *separator;
|
||||
int r = ECMD_PROCESSED;
|
||||
int aligned, buffered, headings, field_prefixes;
|
||||
int aligned, buffered, headings, field_prefixes, quoted;
|
||||
int columns_as_rows;
|
||||
unsigned args_are_pvs;
|
||||
|
||||
aligned = find_config_tree_int(cmd, "report/aligned",
|
||||
@@ -171,6 +203,10 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
DEFAULT_REP_SEPARATOR);
|
||||
field_prefixes = find_config_tree_int(cmd, "report/prefixes",
|
||||
DEFAULT_REP_PREFIXES);
|
||||
quoted = find_config_tree_int(cmd, "report/quoted",
|
||||
DEFAULT_REP_QUOTED);
|
||||
columns_as_rows = find_config_tree_int(cmd, "report/columns_as_rows",
|
||||
DEFAULT_REP_COLUMNS_AS_ROWS);
|
||||
|
||||
args_are_pvs = (report_type == PVS || report_type == PVSEGS) ? 1 : 0;
|
||||
|
||||
@@ -272,14 +308,19 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
buffered = 0;
|
||||
if (arg_count(cmd, noheadings_ARG))
|
||||
headings = 0;
|
||||
if (arg_count(cmd, prefixes_ARG)) {
|
||||
if (arg_count(cmd, nameprefixes_ARG)) {
|
||||
aligned = 0;
|
||||
field_prefixes = 1;
|
||||
}
|
||||
if (arg_count(cmd, unquoted_ARG))
|
||||
quoted = 0;
|
||||
if (arg_count(cmd, rows_ARG))
|
||||
columns_as_rows = 1;
|
||||
|
||||
if (!(report_handle = report_init(cmd, options, keys, &report_type,
|
||||
separator, aligned, buffered,
|
||||
headings, field_prefixes))) {
|
||||
headings, field_prefixes, quoted,
|
||||
columns_as_rows))) {
|
||||
stack;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user