diff --git a/boot.lvm b/boot.lvm index c51c563..752994e 100644 --- a/boot.lvm +++ b/boot.lvm @@ -7,7 +7,7 @@ ### BEGIN INIT INFO # Provides: boot.lvm # Required-Start: boot.device-mapper boot.udev boot.rootfsck -# X-UnitedLinux-Should-Start: boot.multipath boot.md boot.scsidev boot.dmraid +# Should-Start: boot.multipath boot.md boot.dmraid # Required-Stop: # Default-Start: B # Default-Stop: @@ -42,22 +42,12 @@ case "$1" in echo "Activating LVM volume groups..." /sbin/vgchange -a y $LVM_VGS_ACTIVATED_ON_BOOT - # currently unavailable with lvm2 - #if test -s /etc/pvpath.cfg -a -x /sbin/pvpathrestore; then - # /sbin/pvpathrestore - #fi rc_status -v -r fi ;; stop) - if test -d /etc/lvmtab.d -a -x /sbin/vgchange ; then + if test -d /etc/lvm -a -x /sbin/vgchange ; then /sbin/vgchange -a n - - # currently unavailable with lvm2 - #if test -s /etc/pvpath.cfg -a -x /sbin/pvpathsave; then - # /sbin/pvpathsave - #fi - fi rc_status -v ;; @@ -65,8 +55,11 @@ case "$1" in rc_failed 4 rc_status -v ;; + reload) + $0 start + ;; *) - echo "Usage: $0 {start|stop|status}" + echo "Usage: $0 {start|stop|status|reload}" exit 1 ;; esac diff --git a/clvmd-fix-node-hash.diff b/clvmd-fix-node-hash.diff new file mode 100644 index 0000000..aee1d6f --- /dev/null +++ b/clvmd-fix-node-hash.diff @@ -0,0 +1,82 @@ +--- daemons/clvmd/clvmd-openais.c ++++ daemons/clvmd/clvmd-openais.c +@@ -100,13 +100,6 @@ + SaNameT lock_name; + }; + +-struct lock_wait +-{ +- pthread_cond_t cond; +- pthread_mutex_t mutex; +- int status; +-}; +- + /* Set errno to something approximating the right value and return 0 or -1 */ + static int ais_to_errno(SaAisErrorT err) + { +@@ -245,12 +238,15 @@ + + memcpy(&target_nodeid, msg, OPENAIS_CSID_LEN); + +- DEBUGLOG("Got message from nodeid %d for %d. len %d\n", +- nodeid, target_nodeid, msg_len-4); ++ DEBUGLOG("%u got message from nodeid %d for %d. len %d\n", ++ our_nodeid, nodeid, target_nodeid, msg_len-4); + +- if (target_nodeid == our_nodeid) +- process_message(cluster_client, (char *)msg+OPENAIS_CSID_LEN, +- msg_len-OPENAIS_CSID_LEN, (char*)&nodeid); ++ if (nodeid != our_nodeid) //Not send by myself ++ if (target_nodeid == our_nodeid || target_nodeid == 0) ++ process_message(cluster_client, ++ (char *)msg+OPENAIS_CSID_LEN, ++ msg_len-OPENAIS_CSID_LEN, ++ (char*)&nodeid); + } + + static void cpg_confchg_callback(cpg_handle_t handle, +@@ -292,7 +288,44 @@ + ninfo->state = NODE_DOWN; + } + ++ for (i=0; inodeid = member_list[i].nodeid; ++ dm_hash_insert_binary(node_hash, ++ (char *)&ninfo->nodeid, ++ OPENAIS_CSID_LEN, ninfo); ++ } ++ } ++ ninfo->state = NODE_CLVMD; ++ } ++ + num_nodes = joined_list_entries; ++ ++ //Verbose on node_hash, helpful to debug ++ struct dm_hash_node *hn; ++ DEBUGLOG("Iterate node_hash\n"); ++ dm_hash_iterate(hn, node_hash) ++ { ++ ninfo = dm_hash_get_data(node_hash, hn); ++ if (ninfo->state == NODE_CLVMD) { ++ DEBUGLOG("%u:%s\n", ninfo->nodeid, "CLVMD"); ++ } ++ else { ++ if (ninfo->state == NODE_DOWN) ++ DEBUGLOG("%u:%s\n", ninfo->nodeid, "DOWN"); ++ } ++ } ++ DEBUGLOG("Iterate node_hash done\n"); ++ + } + + diff --git a/clvmd-node-number-fix.diff b/clvmd-node-number-fix.diff new file mode 100644 index 0000000..e695a83 --- /dev/null +++ b/clvmd-node-number-fix.diff @@ -0,0 +1,11 @@ +--- daemons/clvmd/clvmd-openais.c ++++ daemons/clvmd/clvmd-openais.c +@@ -308,7 +308,7 @@ + ninfo->state = NODE_CLVMD; + } + +- num_nodes = joined_list_entries; ++ num_nodes = member_list_entries; + + //Verbose on node_hash, helpful to debug + struct dm_hash_node *hn; diff --git a/clvmd-openais-sync.diff b/clvmd-openais-sync.diff new file mode 100644 index 0000000..e78f53e --- /dev/null +++ b/clvmd-openais-sync.diff @@ -0,0 +1,168 @@ +--- daemons/clvmd/clvmd-openais.c ++++ daemons/clvmd/clvmd-openais.c +@@ -50,11 +50,6 @@ + /* Timeout value for several openais calls */ + #define TIMEOUT 10 + +-static void lck_lock_callback(SaInvocationT invocation, +- SaLckLockStatusT lockStatus, +- SaAisErrorT error); +-static void lck_unlock_callback(SaInvocationT invocation, +- SaAisErrorT error); + static void cpg_deliver_callback (cpg_handle_t handle, + struct cpg_name *groupName, + uint32_t nodeid, +@@ -92,11 +87,6 @@ + .cpg_confchg_fn = cpg_confchg_callback, + }; + +-SaLckCallbacksT lck_callbacks = { +- .saLckLockGrantCallback = lck_lock_callback, +- .saLckResourceUnlockCallback = lck_unlock_callback +-}; +- + struct node_info + { + enum {NODE_UNKNOWN, NODE_DOWN, NODE_UP, NODE_CLVMD} state; +@@ -305,32 +295,6 @@ + num_nodes = joined_list_entries; + } + +-static void lck_lock_callback(SaInvocationT invocation, +- SaLckLockStatusT lockStatus, +- SaAisErrorT error) +-{ +- struct lock_wait *lwait = (struct lock_wait *)(long)invocation; +- +- DEBUGLOG("lck_lock_callback, error = %d\n", error); +- +- lwait->status = error; +- pthread_mutex_lock(&lwait->mutex); +- pthread_cond_signal(&lwait->cond); +- pthread_mutex_unlock(&lwait->mutex); +-} +- +-static void lck_unlock_callback(SaInvocationT invocation, +- SaAisErrorT error) +-{ +- struct lock_wait *lwait = (struct lock_wait *)(long)invocation; +- +- DEBUGLOG("lck_unlock_callback\n"); +- +- lwait->status = SA_AIS_OK; +- pthread_mutex_lock(&lwait->mutex); +- pthread_cond_signal(&lwait->cond); +- pthread_mutex_unlock(&lwait->mutex); +-} + + static int lck_dispatch(struct local_client *client, char *buf, int len, + const char *csid, struct local_client **new_client) +@@ -359,7 +323,7 @@ + } + + err = saLckInitialize(&lck_handle, +- &lck_callbacks, ++ NULL, + &ver); + if (err != SA_AIS_OK) { + cpg_initialize(&cpg_handle, &cpg_callbacks); +@@ -495,15 +459,11 @@ + /* Real locking */ + static int _lock_resource(char *resource, int mode, int flags, int *lockid) + { +- struct lock_wait lwait; + struct lock_info *linfo; + SaLckResourceHandleT res_handle; + SaAisErrorT err; + SaLckLockIdT lock_id; +- +- pthread_cond_init(&lwait.cond, NULL); +- pthread_mutex_init(&lwait.mutex, NULL); +- pthread_mutex_lock(&lwait.mutex); ++ SaLckLockStatusT lockStatus; + + /* This needs to be converted from DLM/LVM2 value for OpenAIS LCK */ + if (flags & LCK_NONBLOCK) flags = SA_LCK_LOCK_NO_QUEUE; +@@ -526,24 +486,24 @@ + return ais_to_errno(err); + } + +- err = saLckResourceLockAsync(res_handle, +- (SaInvocationT)(long)&lwait, +- &lock_id, +- mode, +- flags, +- 0); +- if (err != SA_AIS_OK) ++ err = saLckResourceLock( ++ res_handle, ++ &lock_id, ++ mode, ++ flags, ++ 0, ++ SA_TIME_END, ++ &lockStatus); ++ if (err != SA_AIS_OK && lockStatus != SA_LCK_LOCK_GRANTED) + { + free(linfo); + saLckResourceClose(res_handle); + return ais_to_errno(err); + } +- ++ + /* Wait for it to complete */ +- pthread_cond_wait(&lwait.cond, &lwait.mutex); +- pthread_mutex_unlock(&lwait.mutex); + +- DEBUGLOG("lock_resource returning %d, lock_id=%llx\n", lwait.status, ++ DEBUGLOG("lock_resource returning %d, lock_id=%llx\n", err, + lock_id); + + linfo->lock_id = lock_id; +@@ -551,43 +511,34 @@ + + dm_hash_insert(lock_hash, resource, linfo); + +- return ais_to_errno(lwait.status); ++ return ais_to_errno(err); + } + + + static int _unlock_resource(char *resource, int lockid) + { +- struct lock_wait lwait; + SaAisErrorT err; + struct lock_info *linfo; + +- pthread_cond_init(&lwait.cond, NULL); +- pthread_mutex_init(&lwait.mutex, NULL); +- pthread_mutex_lock(&lwait.mutex); +- + DEBUGLOG("unlock_resource %s\n", resource); + linfo = dm_hash_lookup(lock_hash, resource); + if (!linfo) + return 0; + + DEBUGLOG("unlock_resource: lockid: %llx\n", linfo->lock_id); +- err = saLckResourceUnlockAsync((SaInvocationT)(long)&lwait, linfo->lock_id); ++ err = saLckResourceUnlock(linfo->lock_id, SA_TIME_END); + if (err != SA_AIS_OK) + { + DEBUGLOG("Unlock returned %d\n", err); + return ais_to_errno(err); + } + +- /* Wait for it to complete */ +- pthread_cond_wait(&lwait.cond, &lwait.mutex); +- pthread_mutex_unlock(&lwait.mutex); +- + /* Release the resource */ + dm_hash_remove(lock_hash, resource); + saLckResourceClose(linfo->res_handle); + free(linfo); + +- return ais_to_errno(lwait.status); ++ return ais_to_errno(err); + } + + static int _sync_lock(const char *resource, int mode, int flags, int *lockid) diff --git a/lvm2.changes b/lvm2.changes index 252b74a..3a7e399 100644 --- a/lvm2.changes +++ b/lvm2.changes @@ -1,3 +1,19 @@ +------------------------------------------------------------------- +Wed Apr 30 12:17:29 CEST 2008 - hare@suse.de + +- Fixup build errors + +------------------------------------------------------------------- +Wed Apr 30 09:22:55 CEST 2008 - xwhu@suse.de + +- Cleanup clvmd code on openais stack to make it work +- Split clvmd into a separate package (bnc#384708) + +------------------------------------------------------------------- +Wed Apr 23 12:16:22 CEST 2008 - xwhu@suse.de + +- Change async lock primitives to sync + ------------------------------------------------------------------- Wed Apr 23 07:29:12 CEST 2008 - xwhu@suse.de diff --git a/lvm2.spec b/lvm2.spec index bd0a831..faa46b6 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -11,18 +11,16 @@ Name: lvm2 -BuildRequires: device-mapper-devel module-init-tools openais-devel +BuildRequires: device-mapper-devel openais-devel License: GPL v2 or later; LGPL v2.1 or later Group: System/Base Requires: device-mapper >= 1.02.23 Provides: lvm Obsoletes: lvm -%if %suse_version > 800 PreReq: %fillup_prereq %insserv_prereq -%endif AutoReqProv: on Version: 2.02.33 -Release: 17 +Release: 19 Summary: LVM2 Tools Source: LVM2.%{version}.tar.bz2 Source1: lvm.conf @@ -38,6 +36,9 @@ Patch10: lvm-no_chown.diff Patch11: cmdline_large_minor.diff Patch12: enable-clvmd.patch Patch13: pipe_buff-definition.diff +Patch14: clvmd-openais-sync.diff +Patch15: clvmd-fix-node-hash.diff +Patch16: clvmd-node-number-fix.diff BuildRoot: %{_tmppath}/%{name}-%{version}-build %description @@ -46,6 +47,17 @@ Volume Manager. +%package clvm +License: GPL v2 or later; LGPL v2.1 or later +Requires: %{name}-%{version} openais +Summary: Clustered LVM2 +Group: System/Base + +%description clvm +A daemon for using LVM2 Logival Volumes in a clustered environment. + + + %prep %setup -n LVM2.%{version} %patch @@ -55,8 +67,12 @@ Volume Manager. %patch5 %patch6 %patch10 +%patch11 %patch12 %patch13 +%patch14 +%patch15 +%patch16 %build CFLAGS="$RPM_OPT_FLAGS" MODPROBE_CMD=/sbin/modprobe \ @@ -65,7 +81,7 @@ LDFLAGS="-L /usr/%_lib/openais" \ --mandir=%{_mandir} \ --includedir=/usr/include \ --libdir=/%_lib --enable-dmeventd --enable-cmdlib \ - --with-clvmd=openais --with-cluster=shared + --with-clvmd=openais make %install @@ -77,11 +93,14 @@ 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 744 %{SOURCE2} $RPM_BUILD_ROOT/etc/init.d +install -m 755 %{SOURCE2} $RPM_BUILD_ROOT/etc/init.d mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates -install -m 755 %{SOURCE3} $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 %clean @@ -89,13 +108,22 @@ rm -rf $RPM_BUILD_ROOT %post %{fillup_and_insserv -n lvm -py boot.lvm} +/sbin/ldconfig + +%preun +%{stop_on_removal boot.lvm} %postun %{insserv_cleanup} +/sbin/ldconfig + +%files clvm +%defattr(-,root,root) +/usr/sbin/clvmd %files %defattr(-,root,root) -%doc INSTALL COPYING COPYING.LIB README WHATS_NEW doc/* +%doc INSTALL README WHATS_NEW doc/* %dir /etc/lvm %dir /etc/lvm/backup %dir /etc/lvm/archive @@ -104,7 +132,6 @@ rm -rf $RPM_BUILD_ROOT %config /etc/lvm/lvm.conf %config /etc/init.d/boot.lvm /var/adm/fillup-templates/sysconfig.lvm -/usr/sbin/clvmd /sbin/fsadm /sbin/lvchange /sbin/lvconvert @@ -150,14 +177,9 @@ rm -rf $RPM_BUILD_ROOT /sbin/vgs /sbin/vgscan /sbin/vgsplit -/%_lib/libdevmapper-event-lvm2mirror.so /%_lib/libdevmapper-event-lvm2mirror.so.2.02 -/%_lib/libdevmapper-event-lvm2snapshot.so /%_lib/libdevmapper-event-lvm2snapshot.so.2.02 -/%_lib/liblvm2cmd.so /%_lib/liblvm2cmd.so.2.02 -/%_lib/liblvm2clusterlock.so -/%_lib/liblvm2clusterlock.so.2.02 %{_mandir}/man8/clvmd.8.gz %{_mandir}/man5/lvm.conf.5.gz %{_mandir}/man8/lvchange.8.gz @@ -204,6 +226,13 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man8/vgsplit.8.gz %changelog +* Wed Apr 30 2008 hare@suse.de +- Fixup build errors +* Wed Apr 30 2008 xwhu@suse.de +- Cleanup clvmd code on openais stack to make it work +- Split clvmd into a separate package (bnc#384708) +* Wed Apr 23 2008 xwhu@suse.de +- Change async lock primitives to sync * Wed Apr 23 2008 xwhu@suse.de - Fix build aginst beta definition of PIPE_BUF is missing