cluster: RHEL6 - resource-agents: fix incorrect link resolution in fs-lib
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 56e843fbbce29a4e821f32ebcd271ac0455a4203
Parent: 1f423c3a2d0de6960955fe17dcc5f61f3a709016
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Jun 30 12:22:00 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed Jun 30 12:22:00 2010 -0400
resource-agents: fix incorrect link resolution in fs-lib
Fs-lib.sh was not resolving symbolic links prior to
checking [ -b ], meaning that we would end up with
a potential mismatch if what is in /proc/mounts did not
match what was in cluster.conf, causing a service failure
Resolves: rhnz#609579
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/utils/fs-lib.sh | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/rgmanager/src/resources/utils/fs-lib.sh b/rgmanager/src/resources/utils/fs-lib.sh
index bc3877e..32667ed 100644
--- a/rgmanager/src/resources/utils/fs-lib.sh
+++ b/rgmanager/src/resources/utils/fs-lib.sh
@@ -116,12 +116,6 @@ real_device()
[ -z "$dev" ] && return $OCF_ERR_ARGS
- # If our provided blockdev is a device, we are done
- if [ -b "$dev" ]; then
- REAL_DEVICE="$dev"
- return $OCF_SUCCESS
- fi
-
# Oops, we have a link. Sorry, this is going to fork.
if [ -h "$dev" ]; then
realdev=$(readlink -f $dev)
@@ -132,6 +126,12 @@ real_device()
return $OCF_SUCCESS
fi
+ # If our provided blockdev is a device, we are done
+ if [ -b "$dev" ]; then
+ REAL_DEVICE="$dev"
+ return $OCF_SUCCESS
+ fi
+
# It's not a link, it's not a block device. If it also
# does not match UUID= or LABEL=, then findfs is not
# going to find anything useful, so we should quit now.
13 years, 10 months
cluster: STABLE3 - resource-agents: fix incorrect link resolution in fs-lib
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 4d24a40f7d0b19d145d03c365a9505fe0927b886
Parent: dbe5e99513b5c6e26aeb70baea075e16084f84ec
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Jun 30 12:22:00 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed Jun 30 12:23:42 2010 -0400
resource-agents: fix incorrect link resolution in fs-lib
Fs-lib.sh was not resolving symbolic links prior to
checking [ -b ], meaning that we would end up with
a potential mismatch if what is in /proc/mounts did not
match what was in cluster.conf, causing a service failure
Resolves: rhnz#609579
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/utils/fs-lib.sh | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/rgmanager/src/resources/utils/fs-lib.sh b/rgmanager/src/resources/utils/fs-lib.sh
index bc3877e..32667ed 100644
--- a/rgmanager/src/resources/utils/fs-lib.sh
+++ b/rgmanager/src/resources/utils/fs-lib.sh
@@ -116,12 +116,6 @@ real_device()
[ -z "$dev" ] && return $OCF_ERR_ARGS
- # If our provided blockdev is a device, we are done
- if [ -b "$dev" ]; then
- REAL_DEVICE="$dev"
- return $OCF_SUCCESS
- fi
-
# Oops, we have a link. Sorry, this is going to fork.
if [ -h "$dev" ]; then
realdev=$(readlink -f $dev)
@@ -132,6 +126,12 @@ real_device()
return $OCF_SUCCESS
fi
+ # If our provided blockdev is a device, we are done
+ if [ -b "$dev" ]; then
+ REAL_DEVICE="$dev"
+ return $OCF_SUCCESS
+ fi
+
# It's not a link, it's not a block device. If it also
# does not match UUID= or LABEL=, then findfs is not
# going to find anything useful, so we should quit now.
13 years, 10 months
cluster: RHEL6 - rgmanager: fix staged upgrade compatibility
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 1f423c3a2d0de6960955fe17dcc5f61f3a709016
Parent: 58da98dd5214da252fac892fe53b03676e46c13b
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Jun 30 11:11:43 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed Jun 30 12:12:27 2010 -0400
rgmanager: fix staged upgrade compatibility
This breaks rolling upgrade compatibility for
STABLE3 and should not be ported to that branch.
Resolves: rhbz#609550
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/include/platform.h | 3 +++
rgmanager/include/resgroup.h | 22 ++++++++--------------
2 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/rgmanager/include/platform.h b/rgmanager/include/platform.h
index 7681b50..c5dc66e 100644
--- a/rgmanager/include/platform.h
+++ b/rgmanager/include/platform.h
@@ -47,6 +47,9 @@ Configure is gone...
#define swab32(x) x=be_swap32(x)
#define swab64(x) x=be_swap64(x)
+#define lswab16(x) x=le_swap16(x)
+#define lswab32(x) x=le_swap32(x)
+#define lswab64(x) x=le_swap64(x)
#if defined(__sparc__)
#define ALIGNED __attribute__((aligned))
diff --git a/rgmanager/include/resgroup.h b/rgmanager/include/resgroup.h
index 3afbce2..c639315 100644
--- a/rgmanager/include/resgroup.h
+++ b/rgmanager/include/resgroup.h
@@ -28,7 +28,7 @@
typedef struct {
char rs_name[64]; /**< Service name */
/* 64 */
- uint32_t rs_id; /**< Service ID */
+ uint32_t rs_flags; /**< Service ID */
uint32_t rs_magic; /**< Magic ID */
uint32_t rs_owner; /**< Member ID running service. */
uint32_t rs_last_owner; /**< Last member to run the service. */
@@ -38,23 +38,17 @@ typedef struct {
restarts */
uint64_t rs_transition; /**< Last service transition time */
/* 96 */
- uint32_t rs_flags; /**< User setted flags */
- /* 100 */
- uint8_t rs_version; /**< State version */
- uint8_t _pad_[3];
- /* 104 */
} rg_state_t;
#define swab_rg_state_t(ptr) \
{\
- swab32((ptr)->rs_id);\
- swab32((ptr)->rs_magic);\
- swab32((ptr)->rs_owner);\
- swab32((ptr)->rs_last_owner);\
- swab32((ptr)->rs_state);\
- swab32((ptr)->rs_restarts);\
- swab64((ptr)->rs_transition);\
- swab32((ptr)->rs_flags);\
+ lswab32((ptr)->rs_magic);\
+ lswab32((ptr)->rs_owner);\
+ lswab32((ptr)->rs_last_owner);\
+ lswab32((ptr)->rs_state);\
+ lswab32((ptr)->rs_restarts);\
+ lswab64((ptr)->rs_transition);\
+ lswab32((ptr)->rs_flags);\
}
#if 0
13 years, 10 months
cluster: RHEL6 - resource-agents: Make vm.sh use stop/start timeouts
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 58da98dd5214da252fac892fe53b03676e46c13b
Parent: d6aaa9cc1e5de3d472c6c9169cf980cf2c0bea34
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Mon Jun 21 12:22:23 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed Jun 30 06:57:48 2010 -0400
resource-agents: Make vm.sh use stop/start timeouts
Startup timeouts are handled by calling the status_program
(if specified) every few seconds until either the timeout is
reached or the status program returns a successful result.
Because the combined VM boot + application time was the
basis for the 5 minute check interval for depth=10 (where
the status_program is called), it has been reduced to 1
minute intervals.
The startup timeout, since it may now be waiting for
services within the VM, has been increased to 5 minutes
from 20 seconds to match the previous status check timing
functionality.
This patch fixes the previous patch's inadequate
handling of start timeouts.
Resolves: bz606754
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/vm.sh | 77 ++++++++++++++++++++++++++++++++++++++---
1 files changed, 72 insertions(+), 5 deletions(-)
diff --git a/rgmanager/src/resources/vm.sh b/rgmanager/src/resources/vm.sh
index 08fd097..b3cbc2e 100644
--- a/rgmanager/src/resources/vm.sh
+++ b/rgmanager/src/resources/vm.sh
@@ -261,15 +261,15 @@ meta_data()
</parameters>
<actions>
- <action name="start" timeout="20"/>
+ <action name="start" timeout="300"/>
<action name="stop" timeout="120"/>
<action name="status" timeout="10" interval="30"/>
<action name="monitor" timeout="10" interval="30"/>
<!-- depth 10 calls the status_program -->
- <action name="status" depth="10" timeout="10" interval="300"/>
- <action name="monitor" depth="10" timeout="10" interval="300"/>
+ <action name="status" depth="10" timeout="20" interval="60"/>
+ <action name="monitor" depth="10" timeout="20" interval="60"/>
<!-- reconfigure - reconfigure with new OCF parameters.
NOT OCF COMPATIBLE AT ALL -->
@@ -351,6 +351,31 @@ do_xm_start()
}
+get_timeout()
+{
+ declare -i default_timeout=60
+ declare -i tout=60
+
+ if [ -n "$OCF_RESKEY_RGMANAGER_meta_timeout" ]; then
+ tout=$OCF_RESKEY_RGMANAGER_meta_timeout
+ elif [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
+ tout=$OCF_RESKEY_CRM_meta_timeout
+ fi
+
+ if [ $tout -eq 0 ]; then
+ echo $default_timeout
+ return 0
+ fi
+ if [ $tout -lt 0 ]; then
+ echo $default_timeout
+ return 0
+ fi
+
+ echo $tout
+ return 0
+}
+
+
#
# Start a virtual machine given the parameters from
# the environment.
@@ -428,7 +453,7 @@ do_xm_stop()
#
do_virsh_stop()
{
- declare -i timeout=60
+ declare -i timeout=$(get_timeout)
declare -i ret=1
declare state
@@ -443,7 +468,7 @@ do_virsh_stop()
echo virsh $op $OCF_RESKEY_name ...
virsh $op $OCF_RESKEY_name
- timeout=60
+ timeout=$(get_timeout)
while [ $timeout -gt 0 ]; do
sleep 5
((timeout -= 5))
@@ -913,6 +938,42 @@ migrate()
return $rv
}
+
+wait_start()
+{
+ declare -i timeout_remaining=$(get_timeout)
+ declare -i start_time
+ declare -i end_time
+ declare -i delta
+ declare -i sleep_time
+
+ if [ -z "$OCF_RESKEY_status_program" ]; then
+ return 0
+ fi
+
+ while [ $timeout_remaining -gt 0 ]; do
+ start_time=$(date +%s)
+ bash -c "$OCF_RESKEY_status_program"
+ if [ $? -eq 0 ]; then
+ return 0
+ fi
+ end_time=$(date +%s)
+ delta=$(((end_time - start_time)))
+ sleep_time=$(((5 - delta)))
+
+ ((timeout_remaining -= $delta))
+ if [ $sleep_time -gt 0 ]; then
+ sleep $sleep_time
+ ((timeout_remaining -= $sleep_time))
+ fi
+ done
+
+ ocf_log err "Start of $OCF_RESOURCE_INSTANCE has failed"
+ ocf_log err "Timeout exceeded while waiting for \"$OCF_RESKEY_status_program\""
+
+ return 1
+}
+
#
#
#
@@ -921,6 +982,12 @@ case $1 in
start)
validate_all || exit $OCF_ERR_ARGS
do_start
+ rv=$?
+ if [ $rv -ne 0 ]; then
+ exit $rv
+ fi
+
+ wait_start
exit $?
;;
stop)
13 years, 10 months
cluster: STABLE3 - resource-agents: Make vm.sh use stop/start timeouts
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: dbe5e99513b5c6e26aeb70baea075e16084f84ec
Parent: b8235f4200def1297703b3da7721fb05821eb7d9
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Mon Jun 21 12:22:23 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed Jun 30 06:53:30 2010 -0400
resource-agents: Make vm.sh use stop/start timeouts
Startup timeouts are handled by calling the status_program
(if specified) every few seconds until either the timeout is
reached or the status program returns a successful result.
Because the combined VM boot + application time was the
basis for the 5 minute check interval for depth=10 (where
the status_program is called), it has been reduced to 1
minute intervals.
The startup timeout, since it may now be waiting for
services within the VM, has been increased to 5 minutes
from 20 seconds to match the previous status check timing
functionality.
This patch fixes the previous patch's inadequate
handling of start timeouts.
Resolves: bz606754
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/vm.sh | 77 ++++++++++++++++++++++++++++++++++++++---
1 files changed, 72 insertions(+), 5 deletions(-)
diff --git a/rgmanager/src/resources/vm.sh b/rgmanager/src/resources/vm.sh
index 08fd097..b3cbc2e 100644
--- a/rgmanager/src/resources/vm.sh
+++ b/rgmanager/src/resources/vm.sh
@@ -261,15 +261,15 @@ meta_data()
</parameters>
<actions>
- <action name="start" timeout="20"/>
+ <action name="start" timeout="300"/>
<action name="stop" timeout="120"/>
<action name="status" timeout="10" interval="30"/>
<action name="monitor" timeout="10" interval="30"/>
<!-- depth 10 calls the status_program -->
- <action name="status" depth="10" timeout="10" interval="300"/>
- <action name="monitor" depth="10" timeout="10" interval="300"/>
+ <action name="status" depth="10" timeout="20" interval="60"/>
+ <action name="monitor" depth="10" timeout="20" interval="60"/>
<!-- reconfigure - reconfigure with new OCF parameters.
NOT OCF COMPATIBLE AT ALL -->
@@ -351,6 +351,31 @@ do_xm_start()
}
+get_timeout()
+{
+ declare -i default_timeout=60
+ declare -i tout=60
+
+ if [ -n "$OCF_RESKEY_RGMANAGER_meta_timeout" ]; then
+ tout=$OCF_RESKEY_RGMANAGER_meta_timeout
+ elif [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
+ tout=$OCF_RESKEY_CRM_meta_timeout
+ fi
+
+ if [ $tout -eq 0 ]; then
+ echo $default_timeout
+ return 0
+ fi
+ if [ $tout -lt 0 ]; then
+ echo $default_timeout
+ return 0
+ fi
+
+ echo $tout
+ return 0
+}
+
+
#
# Start a virtual machine given the parameters from
# the environment.
@@ -428,7 +453,7 @@ do_xm_stop()
#
do_virsh_stop()
{
- declare -i timeout=60
+ declare -i timeout=$(get_timeout)
declare -i ret=1
declare state
@@ -443,7 +468,7 @@ do_virsh_stop()
echo virsh $op $OCF_RESKEY_name ...
virsh $op $OCF_RESKEY_name
- timeout=60
+ timeout=$(get_timeout)
while [ $timeout -gt 0 ]; do
sleep 5
((timeout -= 5))
@@ -913,6 +938,42 @@ migrate()
return $rv
}
+
+wait_start()
+{
+ declare -i timeout_remaining=$(get_timeout)
+ declare -i start_time
+ declare -i end_time
+ declare -i delta
+ declare -i sleep_time
+
+ if [ -z "$OCF_RESKEY_status_program" ]; then
+ return 0
+ fi
+
+ while [ $timeout_remaining -gt 0 ]; do
+ start_time=$(date +%s)
+ bash -c "$OCF_RESKEY_status_program"
+ if [ $? -eq 0 ]; then
+ return 0
+ fi
+ end_time=$(date +%s)
+ delta=$(((end_time - start_time)))
+ sleep_time=$(((5 - delta)))
+
+ ((timeout_remaining -= $delta))
+ if [ $sleep_time -gt 0 ]; then
+ sleep $sleep_time
+ ((timeout_remaining -= $sleep_time))
+ fi
+ done
+
+ ocf_log err "Start of $OCF_RESOURCE_INSTANCE has failed"
+ ocf_log err "Timeout exceeded while waiting for \"$OCF_RESKEY_status_program\""
+
+ return 1
+}
+
#
#
#
@@ -921,6 +982,12 @@ case $1 in
start)
validate_all || exit $OCF_ERR_ARGS
do_start
+ rv=$?
+ if [ $rv -ne 0 ]; then
+ exit $rv
+ fi
+
+ wait_start
exit $?
;;
stop)
13 years, 10 months
cluster: STABLE3 - Revert "resource-agents: Make vm.sh use stop/start timeouts"
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: b8235f4200def1297703b3da7721fb05821eb7d9
Parent: 9e5a1dafc93894612bc6436ac867c333b97c6181
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Tue Jun 29 11:09:40 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed Jun 30 06:53:30 2010 -0400
Revert "resource-agents: Make vm.sh use stop/start timeouts"
This reverts commit c9bbf4f12402c5e38e51e21d38682712c18ab5ee.
---
rgmanager/src/resources/vm.sh | 65 +++-------------------------------------
1 files changed, 5 insertions(+), 60 deletions(-)
diff --git a/rgmanager/src/resources/vm.sh b/rgmanager/src/resources/vm.sh
index dee7564..08fd097 100644
--- a/rgmanager/src/resources/vm.sh
+++ b/rgmanager/src/resources/vm.sh
@@ -261,15 +261,15 @@ meta_data()
</parameters>
<actions>
- <action name="start" timeout="300"/>
+ <action name="start" timeout="20"/>
<action name="stop" timeout="120"/>
<action name="status" timeout="10" interval="30"/>
<action name="monitor" timeout="10" interval="30"/>
<!-- depth 10 calls the status_program -->
- <action name="status" depth="10" timeout="20" interval="60"/>
- <action name="monitor" depth="10" timeout="20" interval="60"/>
+ <action name="status" depth="10" timeout="10" interval="300"/>
+ <action name="monitor" depth="10" timeout="10" interval="300"/>
<!-- reconfigure - reconfigure with new OCF parameters.
NOT OCF COMPATIBLE AT ALL -->
@@ -351,31 +351,6 @@ do_xm_start()
}
-get_timeout()
-{
- declare -i default_timeout=60
- declare -i tout
-
- if [ -n "$OCF_RESKEY_RGMANAGER_meta_timeout" ]; then
- tout=$OCF_RESKEY_RGMANAGER_meta_timeout
- elif [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
- tout=$OCF_RESKEY_CRM_meta_timeout
- fi
-
- if [ "$tout" -eq "0" ]; then
- echo $default_timeout
- return 0
- fi
- if [ $tout -lt 0 ]; then
- echo $default_timeout
- return 0
- fi
-
- echo $tout
- return 0
-}
-
-
#
# Start a virtual machine given the parameters from
# the environment.
@@ -453,7 +428,7 @@ do_xm_stop()
#
do_virsh_stop()
{
- declare -i timeout=$(get_timeout)
+ declare -i timeout=60
declare -i ret=1
declare state
@@ -468,7 +443,7 @@ do_virsh_stop()
echo virsh $op $OCF_RESKEY_name ...
virsh $op $OCF_RESKEY_name
- timeout=$(get_timeout)
+ timeout=60
while [ $timeout -gt 0 ]; do
sleep 5
((timeout -= 5))
@@ -938,30 +913,6 @@ migrate()
return $rv
}
-
-wait_start()
-{
- declare -i timeout_remaining=$(get_timeout)
-
- if [ -z "$OCF_RESKEY_status_program" ]; then
- return 0
- fi
-
- while [ $timeout_remaining -gt 0 ]; do
- bash -c "$OCF_RESKEY_status_program" &> /dev/null
- if [ $? -eq 0 ]; then
- return 0
- fi
- sleep 5
- ((timeout_remaining -= 5))
- done
-
- ocf_log err "Start of $OCF_RESOURCE_INSTANCE has failed"
- ocf_log err "Timeout exceeded while waiting for \"$OCF_RESKEY_status_program\""
-
- return 1
-}
-
#
#
#
@@ -970,12 +921,6 @@ case $1 in
start)
validate_all || exit $OCF_ERR_ARGS
do_start
- rv=$?
- if [ $rv -ne 0 ]; then
- exit $rv
- fi
-
- wait_start
exit $?
;;
stop)
13 years, 10 months
cluster: RHEL6 - rgmanager: Use sysrq-b to reboot
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: d6aaa9cc1e5de3d472c6c9169cf980cf2c0bea34
Parent: 4d6b610339b27a30deac7d9e29dc4236824b58ad
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Mon Jun 28 16:28:06 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Tue Jun 29 14:29:02 2010 -0400
rgmanager: Use sysrq-b to reboot
This resolves an issue where the reboot() syscall
does not complete in rebooting the system, delaying
recovery if the main rgmanager process dies.
Resolves: rhbz#609181
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/daemons/watchdog.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/rgmanager/src/daemons/watchdog.c b/rgmanager/src/daemons/watchdog.c
index 6efd655..dfecab1 100644
--- a/rgmanager/src/daemons/watchdog.c
+++ b/rgmanager/src/daemons/watchdog.c
@@ -4,6 +4,7 @@
#include <sys/reboot.h>
#include <stdlib.h>
#include <sys/mman.h>
+#include <fcntl.h>
#include <signals.h>
#include <logging.h>
@@ -39,6 +40,24 @@ redirect_signals(void)
}
+static int
+sysrq_reboot(void)
+{
+ int fd;
+
+ fd = open("/proc/sysrq-trigger", O_WRONLY|O_SYNC);
+ if (fd < 0)
+ return fd;
+
+ write(fd, "b\n", 2);
+ fsync(fd);
+ fdatasync(fd);
+ close(fd);
+
+ return 0;
+}
+
+
/**
return watchdog's pid, or 0 on failure
*/
@@ -80,6 +99,7 @@ watchdog_init(void)
#else
logt_print(LOG_CRIT, "Watchdog: Daemon died, rebooting...\n");
sync();
+ sysrq_reboot();
reboot(RB_AUTOBOOT);
#endif
exit(255);
13 years, 10 months
cluster: STABLE3 - rgmanager: Use sysrq-b to reboot
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 9e5a1dafc93894612bc6436ac867c333b97c6181
Parent: d76d382f7452d8a6c6e2585d7f4bfe4f446c115c
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Mon Jun 28 16:28:06 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Tue Jun 29 14:27:41 2010 -0400
rgmanager: Use sysrq-b to reboot
This resolves an issue where the reboot() syscall
does not complete in rebooting the system, delaying
recovery if the main rgmanager process dies.
Resolves: rhbz#609181
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/daemons/watchdog.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/rgmanager/src/daemons/watchdog.c b/rgmanager/src/daemons/watchdog.c
index 6efd655..dfecab1 100644
--- a/rgmanager/src/daemons/watchdog.c
+++ b/rgmanager/src/daemons/watchdog.c
@@ -4,6 +4,7 @@
#include <sys/reboot.h>
#include <stdlib.h>
#include <sys/mman.h>
+#include <fcntl.h>
#include <signals.h>
#include <logging.h>
@@ -39,6 +40,24 @@ redirect_signals(void)
}
+static int
+sysrq_reboot(void)
+{
+ int fd;
+
+ fd = open("/proc/sysrq-trigger", O_WRONLY|O_SYNC);
+ if (fd < 0)
+ return fd;
+
+ write(fd, "b\n", 2);
+ fsync(fd);
+ fdatasync(fd);
+ close(fd);
+
+ return 0;
+}
+
+
/**
return watchdog's pid, or 0 on failure
*/
@@ -80,6 +99,7 @@ watchdog_init(void)
#else
logt_print(LOG_CRIT, "Watchdog: Daemon died, rebooting...\n");
sync();
+ sysrq_reboot();
reboot(RB_AUTOBOOT);
#endif
exit(255);
13 years, 10 months
cluster: RHEL56 - GFS: genesis w/flocks on NFS over GFS causes corruption
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: c0d08ea227d2c502519abff654b6b2881f7891b6
Parent: 08fd6f0c99e97b74db27643f93f70fd65b686e9f
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Tue Sep 22 16:17:39 2009 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Tue Jun 29 11:47:38 2010 -0500
GFS: genesis w/flocks on NFS over GFS causes corruption
This patch does a few things to avoid the NFS over GFS corruption on
small (stuffed) files:
1. kmap_atomic is used in place of kmap in stuffed_readpage and
gfs_commit_write.
2. Function stuffed_readpage now flushes the dcache page after
the page is updated in both of those functions as well.
3. In gfs_get_name there was a typo in an if clause.
4. In do_write_buf the new size is written into the incore inode
if the file size has increased.
rhbz#245024
---
gfs-kernel/src/gfs/ops_address.c | 25 +++++++++++++------------
gfs-kernel/src/gfs/ops_export.c | 2 +-
gfs-kernel/src/gfs/ops_file.c | 5 +++++
3 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/gfs-kernel/src/gfs/ops_address.c b/gfs-kernel/src/gfs/ops_address.c
index c9ce4e5..7f5538d 100644
--- a/gfs-kernel/src/gfs/ops_address.c
+++ b/gfs-kernel/src/gfs/ops_address.c
@@ -204,20 +204,20 @@ static int
stuffed_readpage(struct gfs_inode *ip, struct page *page)
{
struct buffer_head *dibh;
- void *kaddr;
+ char *kaddr;
int error;
error = gfs_get_inode_buffer(ip, &dibh);
if (!error) {
- kaddr = kmap(page);
- memcpy((char *)kaddr,
+ kaddr = (char *)kmap_atomic(page, KM_USER0);
+ memcpy(kaddr,
dibh->b_data + sizeof(struct gfs_dinode),
ip->i_di.di_size);
- memset((char *)kaddr + ip->i_di.di_size,
+ memset(kaddr + ip->i_di.di_size,
0,
PAGE_CACHE_SIZE - ip->i_di.di_size);
- kunmap(page);
-
+ kunmap_atomic(kaddr, KM_USER0);
+ flush_dcache_page(page);
brelse(dibh);
SetPageUptodate(page);
@@ -379,18 +379,19 @@ gfs_commit_write(struct file *file, struct page *page,
gfs_trans_add_bh(ip->i_gl, dibh);
- kaddr = kmap(page);
+ kaddr = kmap_atomic(page, KM_USER0);
memcpy(dibh->b_data + sizeof(struct gfs_dinode) + from,
(char *)kaddr + from,
to - from);
- kunmap(page);
-
- brelse(dibh);
+ flush_dcache_page(page);
+ kunmap_atomic(kaddr, KM_USER0);
SetPageUptodate(page);
-
- if (inode->i_size < file_size)
+ if (inode->i_size < file_size) {
i_size_write(inode, file_size);
+ mark_inode_dirty(inode);
+ }
+ brelse(dibh);
} else {
error = generic_commit_write(file, page, from, to);
if (error)
diff --git a/gfs-kernel/src/gfs/ops_export.c b/gfs-kernel/src/gfs/ops_export.c
index 2e8b5c4..e721c58 100644
--- a/gfs-kernel/src/gfs/ops_export.c
+++ b/gfs-kernel/src/gfs/ops_export.c
@@ -213,7 +213,7 @@ int gfs_get_name(struct dentry *parent, char *name,
gfs_glock_dq_uninit(&gh);
- if (!error & !*name)
+ if (!error && !*name)
error = -ENOENT;
return error;
diff --git a/gfs-kernel/src/gfs/ops_file.c b/gfs-kernel/src/gfs/ops_file.c
index 150f328..455debb 100644
--- a/gfs-kernel/src/gfs/ops_file.c
+++ b/gfs-kernel/src/gfs/ops_file.c
@@ -976,6 +976,7 @@ do_write_buf(struct file *file,
size_t s;
ssize_t count = 0;
int error;
+ struct inode *inode = file->f_mapping->host;
gfs_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ghs[num_gh]);
@@ -1022,6 +1023,10 @@ do_write_buf(struct file *file,
}
error = 0;
+ if (inode->i_size < ip->i_di.di_size) {
+ i_size_write(inode, ip->i_di.di_size);
+ mark_inode_dirty(inode);
+ }
out_gunlock:
gfs_glock_dq_m(num_gh + 1, ghs);
13 years, 10 months
cluster: RHEL56 - fsck.gfs2: unaligned access on ia64
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 08fd6f0c99e97b74db27643f93f70fd65b686e9f
Parent: 6468ae5d37c4571c13cadda3d4f4be2b439d6f35
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Tue Jun 29 10:54:50 2010 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Tue Jun 29 10:54:50 2010 -0500
fsck.gfs2: unaligned access on ia64
This patch ports the kernel version of the latest gfs2_bitfit function
back to user space. This is more efficient and avoids the unaligned
access errors on ia64.
rhbz#608158
---
gfs2/fsck/fs_bits.h | 11 -----
gfs2/fsck/pass5.c | 1 -
gfs2/libgfs2/fs_bits.c | 114 +++++++++++++++++++++++++++---------------------
gfs2/libgfs2/libgfs2.h | 4 +-
4 files changed, 66 insertions(+), 64 deletions(-)
diff --git a/gfs2/fsck/fs_bits.h b/gfs2/fsck/fs_bits.h
index 15d6679..2838785 100644
--- a/gfs2/fsck/fs_bits.h
+++ b/gfs2/fsck/fs_bits.h
@@ -28,15 +28,4 @@ struct fs_bitmap
};
typedef struct fs_bitmap fs_bitmap_t;
-/* functions with blk #'s that are buffer relative */
-uint32_t gfs2_bitcount(unsigned char *buffer, unsigned int buflen,
- unsigned char state);
-uint32_t gfs2_bitfit(unsigned char *buffer, unsigned int buflen,
- uint32_t goal, unsigned char old_state);
-
-/* functions with blk #'s that are rgrp relative */
-uint32_t gfs2_blkalloc_internal(struct rgrp_list *rgd, uint32_t goal,
- unsigned char old_state,
- unsigned char new_state, int do_it);
-
#endif /* __FS_BITS_H__ */
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
index f76b9dd..e483ade 100644
--- a/gfs2/fsck/pass5.c
+++ b/gfs2/fsck/pass5.c
@@ -20,7 +20,6 @@
#include "libgfs2.h"
#include "fsck.h"
-#include "fs_bits.h"
#include "util.h"
static int convert_mark(uint8_t q, uint32_t *count)
diff --git a/gfs2/libgfs2/fs_bits.c b/gfs2/libgfs2/fs_bits.c
index aae2958..ee9dfa7 100644
--- a/gfs2/libgfs2/fs_bits.c
+++ b/gfs2/libgfs2/fs_bits.c
@@ -31,6 +31,41 @@
#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
/**
+ * gfs2_bit_search
+ * @ptr: Pointer to bitmap data
+ * @mask: Mask to use (normally 0x55555.... but adjusted for search start)
+ * @state: The state we are searching for
+ *
+ * We xor the bitmap data with a patter which is the bitwise opposite
+ * of what we are looking for, this gives rise to a pattern of ones
+ * wherever there is a match. Since we have two bits per entry, we
+ * take this pattern, shift it down by one place and then and it with
+ * the original. All the even bit positions (0,2,4, etc) then represent
+ * successful matches, so we mask with 0x55555..... to remove the unwanted
+ * odd bit positions.
+ *
+ * This allows searching of a whole u64 at once (32 blocks) with a
+ * single test (on 64 bit arches).
+ */
+
+static inline uint64_t gfs2_bit_search(const unsigned long long *ptr,
+ unsigned long long mask,
+ uint8_t state)
+{
+ unsigned long long tmp;
+ static const unsigned long long search[] = {
+ [0] = 0xffffffffffffffffULL,
+ [1] = 0xaaaaaaaaaaaaaaaaULL,
+ [2] = 0x5555555555555555ULL,
+ [3] = 0x0000000000000000ULL,
+ };
+ tmp = le64_to_cpu(*ptr) ^ search[state];
+ tmp &= (tmp >> 1);
+ tmp &= mask;
+ return tmp;
+}
+
+/**
* gfs2_bitfit - Find a free block in the bitmaps
* @buffer: the buffer that holds the bitmaps
* @buflen: the length (in bytes) of the buffer
@@ -39,60 +74,39 @@
*
* Return: the block number that was allocated
*/
-uint32_t gfs2_bitfit(unsigned char *buffer, unsigned int buflen,
- uint32_t goal, unsigned char old_state)
+unsigned long gfs2_bitfit(const unsigned char *buf, const unsigned int len,
+ unsigned long goal, unsigned char state)
{
- const uint8_t *byte, *start, *end;
- int bit, startbit;
- uint32_t g1, g2, misaligned;
- unsigned long *plong;
- unsigned long lskipval;
-
- lskipval = (old_state & GFS2_BLKST_USED) ? LBITSKIP00 : LBITSKIP55;
- g1 = (goal / GFS2_NBBY);
- start = buffer + g1;
- byte = start;
- end = buffer + buflen;
- g2 = ALIGN(g1, sizeof(unsigned long));
- plong = (unsigned long *)(buffer + g2);
- startbit = bit = (goal % GFS2_NBBY) * GFS2_BIT_SIZE;
- misaligned = g2 - g1;
- if (!misaligned)
- goto ulong_aligned;
-/* parse the bitmap a byte at a time */
-misaligned:
- while (byte < end) {
- if (((*byte >> bit) & GFS2_BIT_MASK) == old_state) {
- return goal +
- (((byte - start) * GFS2_NBBY) +
- ((bit - startbit) >> 1));
- }
- bit += GFS2_BIT_SIZE;
- if (bit >= GFS2_NBBY * GFS2_BIT_SIZE) {
- bit = 0;
- byte++;
- misaligned--;
- if (!misaligned) {
- plong = (unsigned long *)byte;
- goto ulong_aligned;
- }
- }
- }
- return BFITNOENT;
-
-/* parse the bitmap a unsigned long at a time */
-ulong_aligned:
- while ((unsigned char *)plong < end) {
- if (((*plong) & LBITMASK) != lskipval)
- break;
- plong++;
- }
- if ((unsigned char *)plong < end) {
- byte = (const uint8_t *)plong;
- misaligned += sizeof(unsigned long) - 1;
- goto misaligned;
+ unsigned long spoint = (goal << 1) & ((8 * sizeof(unsigned long)) - 1);
+ const unsigned long long *ptr = ((unsigned long long *)buf) + (goal >> 5);
+ const unsigned long long *end = (unsigned long long *)
+ (buf + ALIGN(len, sizeof(unsigned long long)));
+ unsigned long long tmp;
+ unsigned long long mask = 0x5555555555555555ULL;
+ unsigned long bit;
+
+ if (state > 3)
+ return 0;
+
+ /* Mask off bits we don't care about at the start of the search */
+ mask <<= spoint;
+ tmp = gfs2_bit_search(ptr, mask, state);
+ ptr++;
+ while(tmp == 0 && ptr < end) {
+ tmp = gfs2_bit_search(ptr, 0x5555555555555555ULL, state);
+ ptr++;
}
- return BFITNOENT;
+ /* Mask off any bits which are more than len bytes from the start */
+ if (ptr == end && (len & (sizeof(unsigned long long) - 1)))
+ tmp &= (((unsigned long long)~0) >>
+ (64 - 8 * (len & (sizeof(unsigned long long) - 1))));
+ /* Didn't find anything, so return */
+ if (tmp == 0)
+ return BFITNOENT;
+ ptr--;
+ bit = ffsll(tmp);
+ bit /= 2; /* two bits per entry in the bitmap */
+ return (((const unsigned char *)ptr - buf) * GFS2_NBBY) + bit;
}
/**
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index c8cb958..8b4a135 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -385,8 +385,8 @@ void fix_device_geometry(struct gfs2_sbd *sdp);
/* functions with blk #'s that are buffer relative */
uint32_t gfs2_bitcount(unsigned char *buffer, unsigned int buflen,
unsigned char state);
-uint32_t gfs2_bitfit(unsigned char *buffer, unsigned int buflen,
- uint32_t goal, unsigned char old_state);
+unsigned long gfs2_bitfit(const unsigned char *buf, const unsigned int len,
+ unsigned long goal, unsigned char state);
/* functions with blk #'s that are rgrp relative */
uint32_t gfs2_blkalloc_internal(struct rgrp_list *rgd, uint32_t goal,
13 years, 10 months