OBS User unknown 2008-09-13 03:05:30 +00:00 committed by Git OBS Bridge
parent 9de402f2b3
commit 772bf0f4a7
8 changed files with 499 additions and 11 deletions

22
64-lvm2.rules Normal file
View File

@ -0,0 +1,22 @@
# This file causes block devices with LVM signatures to be automatically
# added to their volume group.
# See udev(8) for syntax
SUBSYSTEM!="block", GOTO="lvm_end"
ACTION!="add|change", GOTO="lvm_end"
IMPORT{PROGRAM}="vol_id $tempnode"
ENV{ID_FS_TYPE}!="LVM2_member", GOTO="lvm_end"
ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-id/lvm2-pvuuid-$env{ID_FS_UUID_ENC}"
IMPORT{PROGRAM}="collect_lvm $tempnode"
ENV{VGUUID}!="?*", GOTO="lvm_end"
ENV{VGNAME}!="?*", GOTO="lvm_end"
# If all related PV's available already, active all LVs inside.
ENV{COLLECT}=="0", RUN+="/sbin/vgchange -a y $env{VGNAME}"
LABEL="lvm_end"

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2eb48e5ee80662aa122948da996576beb8f2b28c7fb4473163c568543d865b9a
size 577326

3
LVM2.2.02.39.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4eeb6a82b496be4ebbad5b6350698469c7de4fcc5d1372edd16d856dc49fac8c
size 455011

37
collect_lvm Normal file
View File

@ -0,0 +1,37 @@
#!/bin/sh
PVNAME=$1
/sbin/lvm pvs --config "devices {filter = [ \"a|$PVNAME|\", \"r/.*/\" ]}" --partial -o vg_name,vg_attr,pv_uuid,vg_uuid --ignorelockingfailure --noheadings $PVNAME 2>/dev/null | while read vgname vgattr pvuuid vguuid; do
if [[ $vgattr =~ mode. ]]; then
continue
fi
if [[ $vgattr =~ .....c ]]; then
exit 1
fi
pvlist=$(/sbin/lvm vgdisplay --config "devices {filter = [ \"a|$PVNAME|\", \"r/.*/\" ]}" --partial -v $vgname 2>/dev/null | while read str1 str2 val; do
if [[ $str1 =~ PV && $str2 =~ UUID ]]; then
echo $val
fi
done)
echo PVUUID=$pvuuid
echo VGUUID=$vguuid
echo VGNAME=$vgname
collected=0
for pv in $pvlist; do
if [[ ! -h /dev/disk/by-id/lvm2-pvuuid-$pv ]]; then
echo COLLECT=1
collected=1
break
fi
done
if [[ $collected == 0 ]]; then
echo COLLECT=0
fi
# /lib/udev/collect $vguuid $pvuuid $pvlist
# echo COLLECT=$?
done

352
lvm-pv-create-link.diff Normal file
View File

@ -0,0 +1,352 @@
Index: LVM2.2.02.39/tools/pvremove.c
===================================================================
--- LVM2.2.02.39.orig/tools/pvremove.c 2007-11-22 02:25:06.000000000 +0100
+++ LVM2.2.02.39/tools/pvremove.c 2008-09-11 16:10:31.000000000 +0200
@@ -18,6 +18,32 @@
const char _really_wipe[] =
"Really WIPE LABELS from physical volume \"%s\" of volume group \"%s\" [y/n]? ";
+static const char* pv_remove_symlink(struct cmd_context* cmd, const char* name)
+{
+ struct physical_volume *pv;
+ char *pvuuid;
+ char pvuuid_link[70];
+
+ init_partial(1);
+ if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) {
+ return NULL;
+ }
+ init_partial(0);
+
+ pvuuid = malloc(sizeof(char)*40);
+ if (pvuuid == NULL) {
+ return NULL;
+ }
+
+ id_write_format(&pv->id, pvuuid, 40);
+
+ snprintf(pvuuid_link, 70, "/dev/disk/by-id/lvm2-pvuuid-%s", pvuuid);
+ unlink(pvuuid_link); //we really don't care if it successed or not.
+
+ free(pvuuid);
+ return pvuuid;
+}
+
/*
* Decide whether it is "safe" to wipe the labels on this device.
* 0 indicates we may not.
@@ -108,6 +134,8 @@
log_print("Labels on physical volume \"%s\" successfully wiped",
pv_name);
+ pv_remove_symlink(cmd, pv_name);
+
ret = ECMD_PROCESSED;
error:
Index: LVM2.2.02.39/tools/pvcreate.c
===================================================================
--- LVM2.2.02.39.orig/tools/pvcreate.c 2008-06-24 22:10:32.000000000 +0200
+++ LVM2.2.02.39/tools/pvcreate.c 2008-09-11 16:11:04.000000000 +0200
@@ -23,6 +23,95 @@
const char _really_init[] =
"Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? ";
+static const char* pv_follow_if_link (const char* path)
+{
+ int r;
+ int len = 60;
+ char *fpath = NULL;
+ char *npath = NULL;
+ struct stat st;
+
+ r = lstat(path, &st);
+ if (r == -1) return NULL; //shouldn't happen
+
+ if (S_ISLNK(st.st_mode)) {
+ while (1) {
+ npath = realloc(fpath, sizeof(char)*len);
+ if (npath == NULL) {
+ if (fpath != NULL) free(fpath);
+ return NULL;
+ }
+ fpath = npath;
+
+ memset(fpath, 0, sizeof(char)*len);
+ r = readlink(path, fpath, len);
+ if (r != -1 && fpath[len-1] == 0) break;
+ if (r == -1) {
+ free(fpath);
+ return NULL;
+ } else {
+ len = len * 2;
+ }
+ }
+ }
+ else {
+ fpath = strdup(path);
+ }
+ return fpath;
+}
+
+
+static const char* pv_symlink_handle(struct cmd_context* cmd, const char* name, int create)
+{
+ struct physical_volume *pv;
+ char *pvuuid;
+ char *pvuuid_link;
+ int old_partial;
+
+ pvuuid_link = malloc(70);
+ if (pvuuid_link == NULL) return NULL;
+
+ old_partial = partial_mode();
+
+ init_partial(1);
+ if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) {
+ free(pvuuid_link);
+ init_partial(old_partial);
+ return NULL;
+ }
+ init_partial(old_partial);
+
+ pvuuid = malloc(sizeof(char)*40);
+ if (pvuuid == NULL) {
+ free(pvuuid_link);
+ return NULL;
+ }
+
+ id_write_format(&pv->id, pvuuid, 40);
+
+ snprintf(pvuuid_link, 70, "/dev/disk/by-id/lvm2-pvuuid-%s", pvuuid);
+
+ //we really don't care if it successed or not.
+ if (create) {
+ const char* tname = NULL;
+ int r;
+ tname = pv_follow_if_link(name);
+ if (tname != NULL) {
+ r = symlink(tname, pvuuid_link);
+ free(tname);
+ }
+ else {
+ symlink(name, pvuuid_link);
+ }
+ } else {
+ //pvuuid_link is saved for future unlink
+ //unlink(pvuuid_link);
+ }
+
+ free(pvuuid);
+ return pvuuid_link;
+}
+
/*
* See if we may pvcreate on this device.
* 0 indicates we may not.
@@ -42,6 +131,7 @@
/* Is there a pv here already? */
/* FIXME Use partial mode here? */
+ init_partial(1);
pv = pv_read(cmd, name, NULL, NULL, 0);
/*
@@ -55,6 +145,7 @@
return_0;
pv = pv_read(cmd, name, NULL, NULL, 0);
}
+ init_partial(0);
/* Allow partial & exported VGs to be destroyed. */
/* We must have -ff to overwrite a non orphan */
@@ -151,6 +242,7 @@
const char *restorefile;
uint64_t pe_start = 0;
uint32_t extent_count = 0, extent_size = 0;
+ const char *oldsymlink;
if (arg_count(cmd, uuidstr_ARG)) {
uuid = arg_str_value(cmd, uuidstr_ARG, "");
@@ -258,13 +350,23 @@
log_very_verbose("Writing physical volume data to disk \"%s\"",
pv_name);
+
+ oldsymlink = pv_symlink_handle(cmd, pv_name, 0);
+
if (!(pv_write(cmd, (struct physical_volume *)pv, &mdas,
arg_int64_value(cmd, labelsector_ARG,
DEFAULT_LABELSECTOR)))) {
log_error("Failed to write physical volume \"%s\"", pv_name);
+ if (oldsymlink) free(oldsymlink);
goto error;
}
+ pv_symlink_handle(cmd, pv_name, 1);
+ if (oldsymlink) {
+ unlink(oldsymlink);
+ free(oldsymlink);
+ }
+
log_print("Physical volume \"%s\" successfully created", pv_name);
unlock_vg(cmd, VG_ORPHANS);
Index: LVM2.2.02.39/tools/pvchange.c
===================================================================
--- LVM2.2.02.39.orig/tools/pvchange.c 2008-02-06 16:47:28.000000000 +0100
+++ LVM2.2.02.39/tools/pvchange.c 2008-09-11 16:11:27.000000000 +0200
@@ -15,6 +15,95 @@
#include "tools.h"
+static const char* pv_follow_if_link (const char* path)
+{
+ int r;
+ int len = 60;
+ char *fpath = NULL;
+ char *npath = NULL;
+ struct stat st;
+
+ r = lstat(path, &st);
+ if (r == -1) return NULL; //shouldn't happen
+
+ if (S_ISLNK(st.st_mode)) {
+ while (1) {
+ npath = realloc(fpath, sizeof(char)*len);
+ if (npath == NULL) {
+ if (fpath != NULL) free(fpath);
+ return NULL;
+ }
+ fpath = npath;
+
+ memset(fpath, 0, sizeof(char)*len);
+ r = readlink(path, fpath, len);
+ if (r != -1 && fpath[len-1] == 0) break;
+ if (r == -1) {
+ free(fpath);
+ return NULL;
+ } else {
+ len = len * 2;
+ }
+ }
+ }
+ else {
+ fpath = strdup(path);
+ }
+ return fpath;
+}
+
+static const char* pv_symlink_handle(struct cmd_context* cmd, const char* name, int create)
+{
+ struct physical_volume *pv;
+ char *pvuuid;
+ char *pvuuid_link;
+ int old_partial;
+
+ pvuuid_link = malloc(70);
+ if (pvuuid_link == NULL) return NULL;
+
+ old_partial = partial_mode();
+
+ init_partial(1);
+ if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) {
+ free(pvuuid_link);
+ init_partial(old_partial);
+ return NULL;
+ }
+ init_partial(old_partial);
+
+ pvuuid = malloc(sizeof(char)*40);
+ if (pvuuid == NULL) {
+ free(pvuuid_link);
+ return NULL;
+ }
+
+ id_write_format(&pv->id, pvuuid, 40);
+
+ snprintf(pvuuid_link, 70, "/dev/disk/by-id/lvm2-pvuuid-%s", pvuuid);
+
+ //we really don't care if it successed or not.
+ if (create) {
+ const char* tname = NULL;
+ int r;
+ tname = pv_follow_if_link(name);
+ if (tname != NULL) {
+ r = symlink(tname, pvuuid_link);
+ free(tname);
+ }
+ else {
+ symlink(name, pvuuid_link);
+ }
+ } else {
+ //pvuuid_link is saved for future unlink
+ //unlink(pvuuid_link);
+ }
+
+ free(pvuuid);
+ return pvuuid_link;
+}
+
+
/* FIXME Locking. PVs in VG. */
static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
@@ -169,16 +258,28 @@
}
log_verbose("Changing uuid of %s to %s.", pv_name, uuid);
if (!is_orphan(pv)) {
+ const char* oldsymlink;
+
orig_vg_name = pv_vg_name(pv);
orig_pe_alloc_count = pv_pe_alloc_count(pv);
pv->vg_name = pv->fmt->orphan_vg_name;
pv->pe_alloc_count = 0;
+ oldsymlink = pv_symlink_handle(cmd, pv_name, 0);
+
if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
log_error("pv_write with new uuid failed "
"for %s.", pv_name);
+ if (oldsymlink) free(oldsymlink);
unlock_vg(cmd, vg_name);
return 0;
}
+
+ pv_symlink_handle(cmd, pv_name, 1);
+ if (oldsymlink) {
+ unlink(oldsymlink);
+ free(oldsymlink);
+ }
+
pv->vg_name = orig_vg_name;
pv->pe_alloc_count = orig_pe_alloc_count;
}
@@ -193,11 +294,23 @@
return 0;
}
backup(vg);
- } else if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
- unlock_vg(cmd, vg_name);
- log_error("Failed to store physical volume \"%s\"",
- pv_name);
- return 0;
+ } else {
+ const char* oldsymlink;
+ oldsymlink = pv_symlink_handle(cmd, pv_name, 0);
+
+ if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
+ unlock_vg(cmd, vg_name);
+ log_error("Failed to store physical volume \"%s\"",
+ pv_name);
+ if (oldsymlink) free(oldsymlink);
+ return 0;
+ }
+ pv_symlink_handle(cmd, pv_name, 1);
+ if (oldsymlink) {
+ unlink(oldsymlink);
+ free(oldsymlink);
+ }
+
}
unlock_vg(cmd, vg_name);

View File

@ -280,4 +280,23 @@ activation {
# dirs = [ "/etc/lvm/metadata", "/mnt/disk2/lvm/metadata2" ]
#}
dmeventd {
# mirror_library is the library used when monitoring a mirror device.
#
# "libdevmapper-event-lvm2mirror.so" attempts to recover from
# failures. It removes failed devices from a volume group and
# reconfigures a mirror as necessary. If no mirror library is
# provided, mirrors are not monitored through dmeventd.
mirror_library = "libdevmapper-event-lvm2mirror.so.2.02"
# snapshot_library is the library used when monitoring a snapshot device.
#
# "libdevmapper-event-lvm2snapshot.so" monitors the filling of
# snapshots and emits a warning through syslog, when the use of
# snapshot exceedes 80%. The warning is repeated when 85%, 90% and
# 95% of the snapshot are filled.
snapshot_library = "libdevmapper-event-lvm2snapshot.so.2.02"
}

View File

@ -1,3 +1,25 @@
Wed Sep 10 13:43:17 CEST 2008 - xwhu@novell.com
-------------------------------------------------------------------
- Upgrade to 2.0.39
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.
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.
Fix ambiguous use of identifier error_message_produced.
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 to not activate mirror leg and log volumes directly.
Fix test directory clean up in make distclean.
- pvcreate/pvremove/pvchange will create symlinks in /dev/disk/by-id/
to the device file
-------------------------------------------------------------------
Wed Sep 3 11:09:34 CEST 2008 - hare@suse.de
@ -29,6 +51,11 @@ Wed Aug 13 06:18:44 CEST 2008 - xwhu@suse.de
- Add Should-Stop to boot.lvm
-------------------------------------------------------------------
Thu Jul 31 16:13:59 CST 2008 - xwhu@suse.de
- repack LVM2.2.02.38.tar.bz2 into bz2 format
-------------------------------------------------------------------
Wed Jul 23 15:38:13 CEST 2008 - hare@suse.de

View File

@ -1,5 +1,5 @@
#
# spec file for package lvm2 (Version 2.02.38)
# spec file for package lvm2 (Version 2.02.39)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@ -18,7 +18,7 @@
Name: lvm2
BuildRequires: device-mapper-devel openais-devel
BuildRequires: device-mapper-devel openais-devel readline-devel
BuildRequires: libselinux-devel
License: GPL v2 or later; LGPL v2.1 or later
Group: System/Base
@ -27,8 +27,8 @@ Provides: lvm
Obsoletes: lvm
PreReq: %fillup_prereq %insserv_prereq
AutoReqProv: on
Version: 2.02.38
Release: 26
Version: 2.02.39
Release: 1
Summary: LVM2 Tools
Source: LVM2.%{version}.tar.bz2
Source1: lvm.conf
@ -36,6 +36,8 @@ Source2: boot.lvm
Source3: sysconfig.lvm
Source4: mkinitrd-setup.sh
Source5: mkinitrd-boot.sh
Source6: 64-lvm2.rules
Source7: collect_lvm
Patch: improve_probing.diff
Patch2: no-inc-audit.diff
Patch3: no_buildroot_shared.diff
@ -46,6 +48,7 @@ Patch10: lvm-no_chown.diff
Patch11: cmdline_large_minor.diff
Patch12: enable-clvmd.patch
Patch13: pipe_buff-definition.diff
Patch14: lvm-pv-create-link.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# Not a real replacement but we drop evms
Provides: evms = 2.5.5 evms-gui = 2.5.5 evms-devel = 2.5.5 evms-ha = 2.5.5
@ -80,6 +83,7 @@ A daemon for using LVM2 Logival Volumes in a clustered environment.
%patch11
%patch12
%patch13
%patch14 -p1
%build
CFLAGS="$RPM_OPT_FLAGS" MODPROBE_CMD=/sbin/modprobe \
@ -101,9 +105,6 @@ install -d -m 755 $RPM_BUILD_ROOT/etc/lvm/metadata
install -d -m 755 $RPM_BUILD_ROOT/var/lock/lvm
install -D -m 755 $RPM_BUILD_ROOT/sbin/clvmd $RPM_BUILD_ROOT/usr/sbin/clvmd
rm $RPM_BUILD_ROOT/sbin/clvmd
rm $RPM_BUILD_ROOT/%_lib/libdevmapper-event-lvm2mirror.so
rm $RPM_BUILD_ROOT/%_lib/libdevmapper-event-lvm2snapshot.so
rm $RPM_BUILD_ROOT/%_lib/liblvm2cmd.so
install -m 644 %{SOURCE1} $RPM_BUILD_ROOT/etc/lvm
mkdir -p $RPM_BUILD_ROOT/etc/init.d
install -m 755 %{SOURCE2} $RPM_BUILD_ROOT/etc/init.d
@ -113,6 +114,9 @@ install -m 755 %{SOURCE5} $RPM_BUILD_ROOT/lib/mkinitrd/scripts/boot-lvm2.sh
mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT/var/adm/fillup-templates
rm $RPM_BUILD_ROOT/usr/include/lvm2cmd.h
# install 64-lvm2.rules and collect_lvm
install -m644 -D %{S:6} $RPM_BUILD_ROOT/lib/udev/rules.d/64-lvm2.rules
install -m755 -D %{S:7} $RPM_BUILD_ROOT/lib/udev/collect_lvm
%clean
rm -rf $RPM_BUILD_ROOT
@ -133,6 +137,7 @@ rm -rf $RPM_BUILD_ROOT
%files clvm
%defattr(-,root,root)
/usr/sbin/clvmd
%{_mandir}/man8/clvmd.8.gz
%files
%defattr(-,root,root)
@ -146,6 +151,8 @@ rm -rf $RPM_BUILD_ROOT
%config /etc/init.d/boot.lvm
%dir /lib/mkinitrd
%dir /lib/mkinitrd/scripts
/lib/udev/rules.d/64-lvm2.rules
/lib/udev/collect_lvm
/lib/mkinitrd/scripts/setup-lvm2.sh
/lib/mkinitrd/scripts/boot-lvm2.sh
/var/adm/fillup-templates/sysconfig.lvm
@ -194,10 +201,12 @@ rm -rf $RPM_BUILD_ROOT
/sbin/vgs
/sbin/vgscan
/sbin/vgsplit
/%_lib/libdevmapper-event-lvm2mirror.so
/%_lib/libdevmapper-event-lvm2snapshot.so
/%_lib/liblvm2cmd.so
/%_lib/libdevmapper-event-lvm2mirror.so.2.02
/%_lib/libdevmapper-event-lvm2snapshot.so.2.02
/%_lib/liblvm2cmd.so.2.02
%{_mandir}/man8/clvmd.8.gz
%{_mandir}/man5/lvm.conf.5.gz
%{_mandir}/man8/lvchange.8.gz
%{_mandir}/man8/lvcreate.8.gz
@ -243,6 +252,26 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man8/vgsplit.8.gz
%changelog
* Wed Sep 10 2008 xwhu@novell.com
- Upgrade to 2.0.39
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.
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.
Fix ambiguous use of identifier error_message_produced.
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 to not activate mirror leg and log volumes directly.
Fix test directory clean up in make distclean.
- pvcreate/pvremove/pvchange will create symlinks in /dev/disk/by-id/
to the device file
* Wed Sep 03 2008 hare@suse.de
- Call mkinitrd_setup during %%post and %%postun (bnc#413709)
* Tue Sep 02 2008 hare@suse.de
@ -256,6 +285,8 @@ rm -rf $RPM_BUILD_ROOT
- Remove the -p option for fillup_and_insserv
* Wed Aug 13 2008 xwhu@suse.de
- Add Should-Stop to boot.lvm
* Fri Aug 01 2008 xwhu@suse.de
- repack LVM2.2.02.38.tar.bz2 into bz2 format
* Wed Jul 23 2008 hare@suse.de
- Include mkinitrd scriptlets.
* Fri Jun 27 2008 xwhu@suse.de