• R/O
  • SSH

pm_diskd: Commit

※ リポジトリは、pm-diskd ブランチが https://github.com/linux-ha-japan/pm_diskd-1.0 へ、pm-diskd-2.0ブランチが https://github.com/linux-ha-japan/pm_diskd へ移行しました。

Pacemaker 対応ディスク故障監視機能。

Pacemaker-1.0公式リポジトリのクローンに対し、パッチ作成用のブランチを作成して管理する。
ブランチ名: pm-diskd

初回 hg clone 実行後は、hg update -r pm-diskd を実行すること。

Heartbeat-2.1.4 用 hb-diskd(*) のPacemaker対応版
(*) http://sourceforge.jp/projects/linux-ha/releases/?package_id=10555


Commit MetaInfo

Revisionc0120717ece7a045c5a9edb048743a014eaa1f9e (tree)
Time2013-02-19 14:33:39
AuthorYuusuke Iida <iidayuus@inte...>
CommiterYuusuke Iida

Log Message

The code was corrected in order to make it cooperate with pacemaker-1.1.

Change Summary

Incremental Difference

diff -r 29333ad8879e -r c0120717ece7 Makefile.am
--- a/Makefile.am Thu Feb 14 10:47:27 2013 +0900
+++ b/Makefile.am Tue Feb 19 14:33:39 2013 +0900
@@ -5,7 +5,7 @@
55 MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure
66
77 SUBDIRS = tools resources
8-doc_DATA = README
8+doc_DATA = README
99
1010 SPEC = $(PACKAGE_NAME).spec
1111 TARFILE = $(PACKAGE_NAME)-$(VERSION).tar.gz
diff -r 29333ad8879e -r c0120717ece7 configure.ac
--- a/configure.ac Thu Feb 14 10:47:27 2013 +0900
+++ b/configure.ac Tue Feb 19 14:33:39 2013 +0900
@@ -2,7 +2,7 @@
22 # Process this file with autoconf to produce a configure script.
33
44 AC_PREREQ([2.53])
5-AC_INIT([pm_diskd], [1.2], BUG-REPORT-ADDRESS)
5+AC_INIT([pm_diskd], [2.0], BUG-REPORT-ADDRESS)
66 AM_INIT_AUTOMAKE
77
88 # Checks for programs.
@@ -28,8 +28,6 @@
2828 }
2929
3030
31-# Checks for libraries.
32-
3331 # Checks for typedefs, structures, and compiler characteristics.
3432 dnl Fix default variables - "prefix" variable if not specified
3533 if test "$prefix" = "NONE"; then
@@ -53,51 +51,56 @@
5351 fi
5452 fi
5553
56-# Checks for header files.
57-CFLAGS="$CFLAGS -I${prefix}/include/heartbeat"
58-CFLAGS="$CFLAGS -I${prefix}/include/pacemaker"
54+dnl ===============================================
55+dnl Libraries
56+dnl ===============================================
5957
60-AC_CHECK_HEADERS([hb_config.h])
61-AC_CHECK_HEADERS([glue_config.h])
62-AC_CHECK_HEADERS([agent_config.h])
58+dnl check for pacemaker
59+PKG_CHECK_MODULES(CRM, pacemaker-cluster)
60+LIBS="$LIBS $CRM_LIBS"
6361
64-GLUE_HEADER=none
65-if test "$ac_cv_header_glue_config_h" = "yes"; then
66- GLUE_HEADER=glue_config.h
67-elif test "$ac_cv_header_hb_config_h" = "yes"; then
68- GLUE_HEADER=hb_config.h
69-else
70- AC_MSG_FAILURE(Core development headers were not found)
62+dnl check for gthread
63+PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.0, have_gthread=yes, have_gthread=no)
64+AM_CONDITIONAL(HAVE_GTHREAD, test x$have_gthread = xyes)
65+if test x"$have_gthread" = xyes; then
66+ CFLAGS="$CFLAGS $GTHREAD_CFLAGS"
67+ LIBS="$LIBS $GTHREAD_LIBS"
7168 fi
7269
73-OCF_RA_DIR=`extract_header_define $GLUE_HEADER OCF_RA_DIR`
74-AC_DEFINE_UNQUOTED(OCF_RA_DIR,"$OCF_RA_DIR", ocf resource directory)
75-AC_SUBST(OCF_RA_DIR)
70+dnl ========================================================================
71+dnl Headers
72+dnl ========================================================================
73+
74+AC_CHECK_HEADER([pacemaker/crm_config.h])
75+
76+AC_PATH_PROGS(XML2CONFIG, xml2-config)
77+AC_MSG_CHECKING(for special libxml2 includes)
78+if test "x$XML2CONFIG" = "x"; then
79+ AC_MSG_ERROR(libxml2 config not found)
80+else
81+ XML2HEAD="`$XML2CONFIG --cflags`"
82+ AC_MSG_RESULT($XML2HEAD)
83+fi
84+CPPFLAGS="$CPPFLAGS $XML2HEAD"
85+
86+
87+#CFLAGS="$CFLAGS -I${prefix}/include/glib-2.0"
88+#CFLAGS="$CFLAGS -I${prefix}/lib64/glib-2.0/include"
89+
90+if test "$ac_cv_header_pacemaker_crm_config_h" = "yes"; then
91+ CFLAGS="$CFLAGS -I${prefix}/include/pacemaker"
92+fi
93+
94+OCF_ROOT_DIR=`extract_header_define crm/services.h OCF_ROOT_DIR`
95+#AC_DEFINE_UNQUOTED(OCF_ROOT_DIR,"$OCF_ROOT_DIR", ocf resource directory)
96+AC_SUBST(OCF_ROOT_DIR)
7697
7798 CRM_DAEMON_DIR=`extract_header_define crm_config.h CRM_DAEMON_DIR`
78-AC_DEFINE_UNQUOTED(CRM_DAEMON_DIR,"$CRM_DAEMON_DIR", crm daemon directory)
99+#AC_DEFINE_UNQUOTED(CRM_DAEMON_DIR,"$CRM_DAEMON_DIR", crm daemon directory)
79100 AC_SUBST(CRM_DAEMON_DIR)
80101
81-CRM_DAEMON_GROUP=`extract_header_define $GLUE_HEADER HA_APIGROUP`
82-AC_DEFINE_UNQUOTED(CRM_DAEMON_GROUP,"$CRM_DAEMON_GROUP", Group to run Pacemaker daemons as)
83-AC_SUBST(CRM_DAEMON_GROUP)
84-
85-CRM_DAEMON_USER=`extract_header_define $GLUE_HEADER HA_CCMUSER`
86-AC_DEFINE_UNQUOTED(CRM_DAEMON_USER,"$CRM_DAEMON_USER", User to run Pacemaker daemons as)
87-AC_SUBST(CRM_DAEMON_USER)
88102
89-#
90-grep "release 6" /etc/redhat-release -q
91-if test $? = 0; then
92- rhelver=6
93-else
94- rhelver=5
95-fi
96-RHEL_VER="$rhelver"
97-AC_SUBST(RHEL_VER)
98-
99-# Checks for library functions.
100-
103+dnl The Makefiles and shell scripts we output
101104 AC_CONFIG_FILES(Makefile \
102105 resources/Makefile \
103106 tools/Makefile \
@@ -136,10 +139,11 @@
136139 AC_MSG_RESULT([ State information = ${localstatedir}])
137140 AC_MSG_RESULT([ System configuration = ${sysconfdir}])
138141 AC_MSG_RESULT([ Document directory = ${docdir}])
139-AC_MSG_RESULT([ Ocf RA dir = ${OCF_RA_DIR}])
142+AC_MSG_RESULT([ Ocf RA dir = ${OCF_ROOT_DIR}])
140143 AC_MSG_RESULT([])
141144 AC_MSG_RESULT([ HA group name = ${CRM_DAEMON_GROUP}])
142145 AC_MSG_RESULT([ HA user name = ${CRM_DAEMON_USER}])
143146 AC_MSG_RESULT([])
144147 AC_MSG_RESULT([ CFLAGS = ${CFLAGS}])
148+AC_MSG_RESULT([ Libraries = ${LIBS}])
145149
diff -r 29333ad8879e -r c0120717ece7 pm_diskd.spec.in
--- a/pm_diskd.spec.in Thu Feb 14 10:47:27 2013 +0900
+++ b/pm_diskd.spec.in Tue Feb 19 14:33:39 2013 +0900
@@ -3,8 +3,8 @@
33 ########################################
44 %define __check_files %{nil}
55 %define name pm_diskd
6-%define version 1.2
7-%define release 1.el@RHEL_VER@
6+%define version 2.0
7+%define release 1%{?dist}
88 %define prefix /usr
99 %define libdir %{_libdir}
1010 %define orgarch pm_diskd-%{version}
@@ -21,17 +21,16 @@
2121 License: GPL/LGPL
2222 Vendor: NIPPON TELEGRAPH AND TELEPHONE CORPORATION
2323 BuildRoot: %{_tmppath}/%{name}-%{version}
24-BuildRequires: autoconf, automake, pacemaker-libs-devel >= 1.0.9, heartbeat-devel >= 3.0.3, cluster-glue-libs-devel >= 1.0.6
25-Requires: pacemaker >= 1.0.9, resource-agents >= 1.0.3, cluster-glue >= 1.0.6, heartbeat >= 3.0.3
24+BuildRequires: autoconf, automake
25+BuildRequires: pacemaker-libs-devel >= 1.1.8
26+Requires: pacemaker-libs >= 1.1.8
2627
2728 ########################################
2829 %description
2930 pacemaker diskcheck service
30- for pacemaker 1.0.9
31+ for pacemaker 1.1.8
3132 and
32- resoucr-agent 1.0.3
33- and
34- cluster-glue 1.0.6
33+ cluster-glue 1.0.11
3534
3635 ########################################
3736 %prep
@@ -93,10 +92,10 @@
9392 %files
9493 ########################################
9594 %defattr(-,root,root)
96-
95+%doc README
9796 %dir %{ocfdir}
9897 %attr (755, root, root) %{ocfdir}/diskd
99-%attr (755, root, root) %{_libdir}/heartbeat/diskd
98+%attr (755, root, root) %{_libexecdir}/pacemaker/diskd
10099
101100 ########################################
102101 %changelog
diff -r 29333ad8879e -r c0120717ece7 resources/Makefile.am
--- a/resources/Makefile.am Thu Feb 14 10:47:27 2013 +0900
+++ b/resources/Makefile.am Tue Feb 19 14:33:39 2013 +0900
@@ -2,5 +2,5 @@
22
33 EXTRA_DIST = $(ocf_SCRIPTS)
44
5-ocfdir = $(OCF_RA_DIR)/pacemaker
5+ocfdir = $(OCF_ROOT_DIR)/resource.d/pacemaker
66 ocf_SCRIPTS = diskd
diff -r 29333ad8879e -r c0120717ece7 tools/Makefile.am
--- a/tools/Makefile.am Thu Feb 14 10:47:27 2013 +0900
+++ b/tools/Makefile.am Tue Feb 19 14:33:39 2013 +0900
@@ -1,19 +1,16 @@
11 MAINTAINERCLEANFILES = Makefile.in
22
3-INCLUDES = -I/usr/include/pacemaker \
4- -I/usr/include/glib-2.0 \
5- -I$(libdir)/glib-2.0/include \
6- -I/usr/include/libxml2
7-
83 halibdir = $(CRM_DAEMON_DIR)
94 halib_PROGRAMS = diskd
105
116 # BUILD
127
138 diskd_SOURCES = diskd.c
14-diskd_LDADD = -lcrmcommon \
15- -lgthread-2.0 \
16- -lcrmcluster
9+#diskd_LDADD = -lgthread-2.0
10+
11+#diskd_LDADD = -lcrmcommon \
12+# -lgthread-2.0 \
13+# -lcrmcluster
1714
1815
1916 AM_CFLAGS = -Wall -Werror
diff -r 29333ad8879e -r c0120717ece7 tools/diskd.c
--- a/tools/diskd.c Thu Feb 14 10:47:27 2013 +0900
+++ b/tools/diskd.c Tue Feb 19 14:33:39 2013 +0900
@@ -40,19 +40,13 @@
4040 #include <time.h>
4141 #include <string.h>
4242
43-#include <clplumbing/Gmain_timeout.h>
44-#include <clplumbing/lsb_exitcodes.h>
45-
46-#include <crm/crm.h>
47-#include <crm/common/util.h>
48-#include <crm/common/ipc.h>
43+#include <crm/attrd.h>
44+#include <crm/common/mainloop.h>
4945
5046 #ifdef HAVE_GETOPT_H
5147 # include <getopt.h>
5248 #endif
5349
54-#include <glib.h>
55-
5650 #define MIN_INTERVAL 1
5751 #define MAX_INTERVAL 3600
5852 #define MIN_TIMEOUT 1
@@ -114,14 +108,15 @@
114108 static void diskd_thread_condsend(void);
115109 static void diskd_thread_timer_end(void);
116110 void send_update(void);
111+void crm_make_daemon(const char *name, gboolean daemonize, const char *pidfile);
117112
118-static gboolean
119-diskd_shutdown(int nsig, gpointer unused)
113+static void
114+diskd_shutdown(int nsig)
120115 {
121116 crm_info("Exiting");
122117
123118 if (timer_id != -1) {
124- Gmain_timeout_remove(timer_id);
119+ g_source_remove(timer_id);
125120 timer_id = -1;
126121 }
127122
@@ -130,17 +125,16 @@
130125 if (mainloop != NULL && g_main_is_running(mainloop)) {
131126 g_main_quit(mainloop);
132127 } else {
133- exit(0);
128+ crm_exit(EX_OK);
134129 }
135- return FALSE;
136130 }
137131
138132 static void
139-usage(const char *cmd, int exit_status)
133+usage(const char *cmd, int crm_exit_status)
140134 {
141135 FILE *stream;
142136
143- stream = exit_status ? stderr : stdout;
137+ stream = crm_exit_status ? stderr : stdout;
144138
145139 fprintf(stream, "usage: %s (-N|-w) [-daipDV?trIoe]\n", cmd);
146140 fprintf(stream, " Basic options\n");
@@ -174,7 +168,7 @@
174168
175169 fflush(stream);
176170
177- exit(exit_status);
171+ crm_exit(crm_exit_status);
178172 }
179173
180174 static gboolean
@@ -275,7 +269,7 @@
275269
276270 if (th_timer != NULL) {
277271 ret_thread = g_thread_join(th_timer);
278- crm_debug_2("thread_join -> %d", GPOINTER_TO_INT (ret_thread));
272+ crm_trace("thread_join -> %d", GPOINTER_TO_INT (ret_thread));
279273 th_timer = NULL;
280274 }
281275 } else {
@@ -312,7 +306,7 @@
312306 g_thread_exit(GINT_TO_POINTER(ERROR));
313307 }
314308
315- crm_debug_2("Received Cond from Main().");
309+ crm_trace("Received Cond from Main().");
316310 g_thread_exit(GINT_TO_POINTER(normal));
317311 }
318312
@@ -349,7 +343,7 @@
349343 struct timeval timeout_tv;
350344 fd_set write_fd_set;
351345
352- crm_debug_2("diskcheck_wt start");
346+ crm_trace("diskcheck_wt start");
353347
354348 diskd_thread_create();
355349
@@ -363,14 +357,14 @@
363357
364358 if (fd == -1) {
365359 crm_err("Could not open %s", wfile);
366- cl_perror("%s", wfile);
360+ crm_perror(LOG_ERR, "%s", wfile);
367361 continue; /* failed to open file. try re-open */
368362 }
369363
370364 while( 1 ) {
371365 err = write(fd, buf, WRITE_DATA); /* data write */
372366 if (err == WRITE_DATA) {
373- crm_debug_2("data writing is OK");
367+ crm_trace("data writing is OK");
374368 close(fd);
375369 if (-1 == remove((const char *)wfile)) {
376370 crm_warn("failed to remove file %s", wfile);
@@ -406,7 +400,7 @@
406400 }
407401 } else {
408402 crm_err("Could not write to file %s", wfile);
409- cl_perror("%s", wfile);
403+ crm_perror(LOG_ERR, "%s", wfile);
410404 close(fd);
411405 if (-1 == remove((const char *)wfile)) {
412406 crm_warn("failed to remove file %s", wfile);
@@ -436,7 +430,7 @@
436430 struct timeval timeout_tv;
437431 fd_set read_fd_set;
438432
439- crm_debug_2("diskcheck start");
433+ crm_trace("diskcheck start");
440434
441435 diskd_thread_create();
442436
@@ -461,7 +455,7 @@
461455 while( 1 ) {
462456 err = read(fd, buf, pagesize);
463457 if (err == pagesize) {
464- crm_debug_2("reading form data is OK");
458+ crm_trace("reading form data is OK");
465459 close(fd);
466460 diskd_thread_condsend();
467461 check_status(normal);
@@ -504,23 +498,23 @@
504498
505499 if ( wflag ) { /* writer */
506500 if (wfile == NULL) {
507- wdir = crm_strdup(WRITE_DIR);
508- crm_malloc0(wfile, PATH_MAX);
501+ wdir = strdup(WRITE_DIR);
502+ wfile = calloc(1, PATH_MAX);
509503 g_snprintf(wfile, PATH_MAX, "%s/%s", WRITE_DIR, WRITE_FILE);
510504 }
511505 buf = (void *)malloc(WRITE_DATA);
512506 if (buf == NULL) {
513507 crm_err("Could not allocate memory");
514- exit(LSB_EXIT_GENERIC);
508+ crm_exit(1);
515509 }
516510 rc = diskcheck_wt(NULL);
517- crm_free(wfile);
511+ free(wfile);
518512 } else { /* reader */
519513 pagesize = getpagesize();
520514 ptr = (void *)malloc(2 * pagesize);
521515 if (ptr == NULL) {
522516 crm_err("Could not allocate memory");
523- exit(LSB_EXIT_GENERIC);
517+ crm_exit(1);
524518 }
525519 buf = (void *)(((u_long)ptr + pagesize) & ~(pagesize-1));
526520 rc = diskcheck(NULL);
@@ -565,19 +559,18 @@
565559 {0, 0, 0, 0}
566560 };
567561 #endif
568- pid_file = crm_strdup(PID_FILE);
562+ pid_file = strdup(PID_FILE);
569563 crm_system_name = basename(argv[0]);
570564
571- G_main_add_SignalHandler(
572- G_PRIORITY_HIGH, SIGTERM, diskd_shutdown, NULL, NULL);
565+ mainloop_add_signal(SIGTERM, diskd_shutdown);
573566
574- crm_log_init(basename(argv[0]), LOG_INFO, TRUE, FALSE, argc, argv);
567+ crm_log_init(basename(argv[0]), LOG_INFO, TRUE, FALSE, argc, argv, FALSE);
575568
576569 /* check user. user shuld be root.*/
577570 if (strcmp("root", (const gchar *)g_get_user_name()) != 0) {
578571 crm_err("permission denied. diskd should be executed by root.\n");
579572 printf ("permission denied. diskd should be executed by root.\n");
580- exit(LSB_EXIT_GENERIC);
573+ crm_exit(1);
581574 }
582575
583576 while (1) {
@@ -592,15 +585,14 @@
592585
593586 switch(flag) {
594587 case 'V':
595- cl_log_enable_stderr(TRUE);
596- alter_debug(DEBUG_INC);
588+ crm_bump_log_level(argc, argv);
597589 break;
598590 case 'p':
599- crm_free(pid_file);
600- pid_file = crm_strdup(optarg);
591+ free(pid_file);
592+ pid_file = strdup(optarg);
601593 break;
602594 case 'a':
603- diskd_attr = crm_strdup(optarg);
595+ diskd_attr = strdup(optarg);
604596 break;
605597 case 'r':
606598 retry = crm_parse_int(optarg, "1");
@@ -627,7 +619,7 @@
627619 ++argerr;
628620 break;
629621 case 'N':
630- device = crm_strdup(optarg);
622+ device = strdup(optarg);
631623 optflag++; /* add 2008.20.24 */
632624 break;
633625 case 'D':
@@ -638,8 +630,8 @@
638630 optflag++;
639631 break;
640632 case 'd': /* add option 2009.4.17 */
641- wdir = crm_strdup(optarg);
642- crm_malloc0(wfile, PATH_MAX);
633+ wdir = strdup(optarg);
634+ wfile = calloc(1, PATH_MAX);
643635 g_snprintf(wfile, PATH_MAX, "%s/%s", optarg, WRITE_FILE);
644636 break;
645637 case 'o': /* add option 2009.10.01 */
@@ -649,7 +641,7 @@
649641 exec_thread_flag =1;
650642 break;
651643 case '?':
652- usage(crm_system_name, LSB_EXIT_GENERIC);
644+ usage(crm_system_name, 1);
653645 break;
654646 default:
655647 printf ("Argument code 0%o (%c) is not (?yet?) supported\n", flag, flag);
@@ -673,7 +665,7 @@
673665 }
674666 if ((argerr) || (optflag >= 2) || (device == NULL && wflag == FALSE)) { /* add optflag 2008.10.24 */
675667 /* "-N" + "-w" pattern and not "-N" + not "-w"*/
676- usage(crm_system_name, LSB_EXIT_GENERIC);
668+ usage(crm_system_name, 1);
677669 }
678670 if ((device != NULL) && (wfile != NULL)) {
679671 /* "-N" + "-d" pattern */
@@ -683,9 +675,9 @@
683675 if (oneshot_flag) {
684676 int rc = 0;
685677
686- crm_free(pid_file);
678+ free(pid_file);
687679 rc = oneshot();
688- exit (rc);
680+ crm_exit (rc);
689681 }
690682
691683 crm_make_daemon(crm_system_name, daemonize, pid_file);
@@ -693,29 +685,29 @@
693685
694686 if ( wflag ) { /* writer */
695687 if (wfile == NULL) {
696- wdir = crm_strdup(WRITE_DIR);
697- crm_malloc0(wfile, PATH_MAX);
688+ wdir = strdup(WRITE_DIR);
689+ wfile = calloc(1, PATH_MAX);
698690 g_snprintf(wfile, PATH_MAX, "%s/%s", WRITE_DIR, WRITE_FILE);
699691 }
700692 buf = (void *)malloc(WRITE_DATA);
701693 if (buf == NULL) {
702694 crm_err("Could not allocate memory");
703695 check_status(ERROR);
704- exit(LSB_EXIT_GENERIC);
696+ crm_exit(1);
705697 }
706698 diskcheck_wt(NULL);
707- timer_id = Gmain_timeout_add(interval*1000, diskcheck_wt, NULL);
699+ timer_id = g_timeout_add(interval*1000, diskcheck_wt, NULL);
708700 } else { /* reader */
709701 pagesize = getpagesize();
710702 ptr = (void *)malloc(2 * pagesize);
711703 if (ptr == NULL) {
712704 crm_err("Could not allocate memory");
713705 check_status(ERROR);
714- exit(LSB_EXIT_GENERIC);
706+ crm_exit(1);
715707 }
716708 buf = (void *)(((u_long)ptr + pagesize) & ~(pagesize-1));
717709 diskcheck(NULL);
718- timer_id = Gmain_timeout_add(interval*1000, diskcheck, NULL);
710+ timer_id = g_timeout_add(interval*1000, diskcheck, NULL);
719711 }
720712
721713 crm_info("Starting %s", crm_system_name);
@@ -723,9 +715,9 @@
723715 g_main_run(mainloop);
724716
725717 free(ptr);
726- crm_free(pid_file);
718+ free(pid_file);
727719 if (wfile != NULL) {
728- crm_free(wfile);
720+ free(wfile);
729721 }
730722
731723 diskd_thread_timer_end();
@@ -737,7 +729,10 @@
737729 void
738730 send_update(void)
739731 {
740- attrd_lazy_update('U', NULL, diskd_attr, diskcheck_value, attr_section, attr_set, "0");
732+ if(FALSE == attrd_update_delegate(
733+ NULL, 'U', NULL, diskd_attr, diskcheck_value, attr_section, attr_set, "0", NULL)) {
734+ crm_err("Could not update %s=%s", diskd_attr, diskcheck_value);
735+ }
741736 }
742737
743738
Show on old repository browser