cluster/cman qdisk/score.c qdisk/disk.h qdisk/ ...
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL4
Changes by: lhh at sourceware.org 2007-01-22 22:50:38
Modified files:
cman/qdisk : score.c disk.h score.h clulog.c main.c Makefile
gettid.c
cman/man : qdisk.5 mkqdisk.8
Added files:
cman/qdisk : daemon_init.c
Log message:
Resolves bugzillas: #213533, #216092, #220211, #223002, #223234/#223240
Detailed comments:
* Lock in memory to prevent being swapped out
* Turn on RR scheduling for main + score threads
* Let qdiskd wait for CMAN to start
* Add option to qdiskd to stop CMAN if qdisk device is not available
* Make qdisk interval timings more accurate
* Add option to reboot node if qdiskd detects internal hang > failure time (e.g. interval*tko, in seconds)
* Add per-heuristic tko counts for unreliable heuristics (e.g. ping packets)
* Remove nodes from quorate mask immediately on eviction
* Update man pages with better examples
* Don't let >1 instance of qdiskd be started
* Clarify logging output.
* Improve data in status_file.
* Allow qdiskd to run with no defined heuristics (master-always-wins mode).
* Make fencing of nodes optional (default = on).
* Make sure CMAN is running before we try to talk to it at each point.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/qdisk/daemon_init.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.1.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/qdisk/score.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.1&r2=1.1.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/qdisk/disk.h.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.3&r2=1.1.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/qdisk/score.h.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.1&r2=1.1.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/qdisk/clulog.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.1&r2=1.1.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/qdisk/main.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.4&r2=1.1.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/qdisk/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/qdisk/gettid.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/man/qdisk.5.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.1&r2=1.1.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/man/mkqdisk.8.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.1&r2=1.1.2.2
cman/qdisk/score.c +83 -10
@@ -32,14 +32,20 @@#include <string.h> #include <ccs.h> #include <clulog.h> +#include <sched.h> +#include <sys/mman.h> +#include "disk.h" #include "score.h" static pthread_mutex_t sc_lock =PTHREAD_MUTEX_INITIALIZER ;static int _score =0 , _maxscore =0 , _score_thread_running =0 ;static pthread_t score_thread = (pthread_t )0 ; +void set_priority (int ,int );struct h_arg {struct h_data *h; +int sched_queue; +int sched_prio;int count; };
@@ -97,6 +103,20 @@ h->childpid = pid;return 0 ; } + +/* +* always use SCHED_OTHER for the child processes +* nice -1 is fine; but we don't know what the child process +* might do, so leaving it (potentially) in SCHED_RR or SCHED_FIFO +* is out of the question +* +* XXX if you set SCHED_OTHER in the conf file and nice 20, the below +* will make the heuristics a higher prio than qdiskd. This should be +* fine in practice, because running qdiskd at nice 20 will cause all +* sorts of problems on a busy system. +*/ +set_priority (SCHED_OTHER ,-1 ); +munlockall (); argv[0 ] ="/bin/sh" ; argv[1 ] ="-c" ;
@@ -122,6 +142,12 @@ *score =0 ; *maxscore =0 ; + +/* Allow operation w/o any heuristics */ +if (!max) { + *score = *maxscore =1 ; +return ; + }for (x =0 ; x < max; x++) { *maxscore += h[x].score;
@@ -141,22 +167,51 @@int status;if (h->childpid ==0 ) +/* No child to check */ return 0 ; ret =waitpid (h->childpid, &status, block?0 :WNOHANG );if (!block && ret ==0 ) +/* No children exited */ return 0 ; h->childpid =0 ; - h->available =0 ;if (ret <0 && errno ==ECHILD ) -return -1 ; -if (!WIFEXITED (status)) -return 0 ; -if (WEXITSTATUS (status) !=0 ) -return 0 ; - h->available =1 ; +/* wrong child? */ + goto miss; +if (!WIFEXITED (status)) { + ret =0 ; + goto miss; + } +if (WEXITSTATUS (status) !=0 ) { + ret =0 ; + goto miss; + } + +/* Returned 0 and was not killed */ +if (!h->available) { + h->available =1 ; +clulog (LOG_INFO ,"Heuristic: '%s' UP\n" , h->program); + } + h->misses =0 ;return 0 ; + +miss: +if (h->available) { + h->misses++; +if (h->misses >= h->tko) { +clulog (LOG_INFO , +"Heuristic: '%s' DOWN (%d/%d)\n" , + h->program, h->misses, h->tko); + h->available =0 ; + }else { +clulog (LOG_DEBUG , +"Heuristic: '%s' missed (%d/%d)\n" , + h->program, h->misses, h->tko); + } + } + +return ret; }
@@ -204,7 +259,9 @@ do { h[x].program = NULL; h[x].available = 0; + h[x].misses = 0; h[x].interval = 2; + h[x].tko = 1; h[x].score = 1; h[x].childpid = 0; h[x].nextrun = 0;
@@ -236,9 +293,20 @@if (h[x].interval <=0 ) h[x].interval =2 ; } + +/* Get tko for this heuristic */ +snprintf (query,sizeof (query), +"/cluster/quorumd/heuristic[%d]/@tko" , x+1 ); +if (ccs_get (ccsfd, query, &val) ==0 ) { + h[x].tko=atoi (val); +free (val); +if (h[x].tko <=0 ) + h[x].tko =1 ; + } -clulog (LOG_DEBUG ,"Heuristic: '%s' score=%d interval=%d\n" , - h[x].program, h[x].score, h[x].interval); +clulog (LOG_DEBUG , +"Heuristic: '%s' score=%d interval=%d tko=%d\n" , + h[x].program, h[x].score, h[x].interval, h[x].tko); }while (++x < max);
@@ -271,6 +339,8 @@ {struct h_arg *args = (struct h_arg *)arg;int score, maxscore; + +set_priority (args->sched_queue, args->sched_prio);while (_score_thread_running) {fork_heuristics (args->h, args->count);
@@ -317,7 +387,7 @@to pass in h if it was allocated on the stack. */ int -start_score_thread (struct h_data *h,int count) +start_score_thread (qd_ctx *ctx,struct h_data *h,int count) {pthread_attr_t attrs;struct h_arg *args;
@@ -337,8 +407,11 @@memcpy (args->h, h, (sizeof (struct h_data ) * count)); args->count = count; + args->sched_queue = ctx->qc_sched; + args->sched_prio = ctx->qc_sched_prio; _score_thread_running =1 ; +pthread_attr_init (&attrs);pthread_attr_setinheritsched (&attrs,PTHREAD_INHERIT_SCHED );pthread_create (&score_thread, &attrs, score_thread_main, args);
cman/qdisk/disk.h +7 -1
@@ -67,7 +67,11 @@typedef enum { -RF_REBOOT =0x1 /* Reboot if we go from master->none */ +RF_REBOOT =0x1 ,/* Reboot if we go from master->none */ +RF_STOP_CMAN =0x2 , +RF_DEBUG =0x4 , +RF_PARANOID =0x8 , +RF_ALLOW_KILL =0x10 }run_flag_t ;
@@ -237,6 +241,8 @@int qc_tko;int qc_votes;int qc_scoremin; +int qc_sched; +int qc_sched_prio;disk_node_state_t qc_disk_status;disk_node_state_t qc_status;int qc_master;/* Master?! */
cman/qdisk/score.h +3 -1
@@ -32,7 +32,9 @@char * program;int score;int available; +int tko;int interval; +int misses;pid_t childpid;time_t nextrun; };
@@ -50,7 +52,7 @@/* Start the thread which runs the scoring applets */ -int start_score_thread (struct h_data *h,int count); +int start_score_thread (qd_ctx *ctx,struct h_data *h,int count);/* Get our score + maxscore
cman/qdisk/clulog.c +1 -6
@@ -20,8 +20,6 @@/** @file * Library routines for communicating with the logging daemon. * -* $Id: clulog.c,v 1.1.2.1 2006/05/18 14:52:49 lhh Exp $ -* * Author: Jeff Moyer <[email protected]> */ #include <stdio.h>
@@ -50,8 +48,6 @@#include <string.h> -static const char *version __attribute__ ((unused)) = "$Revision: 1.1.2.1 $"; -#ifdef DEBUG #include <assert.h> #define Dprintf(fmt,args...) printf(fmt,##args)
@@ -135,7 +131,7 @@ }pthread_mutex_unlock (&log_mutex); -return "local4" ; +return "daemon" ; }
@@ -156,7 +152,6 @@for (; facilitynames[x].c_name; x++) {if (strcmp (facilityname, facilitynames[x].c_name))continue ; - syslog_facility = facilitynames[x].c_val;break ; }
cman/qdisk/main.c +421 -47
736 lines not on this page · raw message
cman/qdisk/Makefile +11 -1
@@ -19,6 +19,16 @@ CFLAGS +=-I${incdir} -I${top_srcdir}/config \ -Wall -Werror -Wstrict-prototypes -Wshadow -D_GNU_SOURCE -g +ifneq (${KERNEL_SRC}, ) +# Use the kernel tree if patched, otherwise, look where cluster headers +# should be installed +CFLAGS += $(shell if [ -d ${KERNEL_SRC}/include/cluster ]; then \ + echo '-I${KERNEL_SRC}/include/cluster'; else \ + echo '-I${incdir}/cluster'; fi) +else +CFLAGS += -I${incdir}/cluster +endif + TARGET=qdiskd mkqdisk all: ${TARGET}
@@ -31,7 +41,7 @@ install ${TARGET} ${sbindir} qdiskd: disk.o crc32.o disk_util.o main.o score.o bitmap.o clulog.o \ - gettid.o proc.o ../lib/libcman.a + gettid.o proc.o daemon_init.o ../lib/libcman.a gcc -o $@ $^ -lpthread -L../lib -lccs mkqdisk: disk.o crc32.o disk_util.o \
cman/qdisk/gettid.c +1 -1
@@ -2,8 +2,8 @@#include <sys/syscall.h> #include <linux/unistd.h> #include <gettid.h> -#include <errno.h> #include <unistd.h> +#include <errno.h> /* Patch from Adam Conrad / Ubuntu: Don't use _syscall macro */
cman/man/qdisk.5 +123 -17
208 lines not on this page · raw message
cman/man/mkqdisk.8 +8 -3
@@ -13,11 +13,16 @@ .IP "\-c device \-l label" Initialize a new cluster quorum disk. This will destroy all data on the given device. If a cluster is currently using that device as a quorum disk, the -entire cluster will malfunction. Do not ru +entire cluster will malfunction. Do not run this on an active cluster when +qdiskd is running. Only one device on the SAN should ever have the given +label; using multiple different devices is currently not supported (it is +expected a RAID array is used for quorum disk redundancy). The label can be +any textual string up to 127 characters - and is therefore enough space to hold +a UUID created with uuidgen(1). .IP "\-f label" -Find the cluster quorum disk with the given label and display information about it.. +Find the cluster quorum disk with the given label and display information about it. .IP "\-L" Display information on all accessible cluster quorum disks. .SH "SEE ALSO" -qdisk(5) qdiskd(8) +qdisk(5), qdiskd(8), uuidgen(1)