Changes to 'refs/tags/sanlock-2.6'
by David Teigland
Changes since the dawn of time:
Daniel P. Berrange (15):
Fix const-ness of many APIs.
Fix warnings in watchdog module
Fix function prototypes for no-arg methods
Remove use of 'index' as a variable name
Make many functions static
Fix missing include in logging file
Annotate many unused parameters to avoid warnings
Remove redundant redeclaration of 'to' variable
Fix args to execv()
Remove redundant arg to 'run_command'
Rename optarg to optionarg to avoid clashing with getopt.h
Disable the read_request method since it is unused
Add many more compiler warning flags & safety checks
Hard code a sector size of 512 if the lease volume is a regular file
Ensure libsanlock.so is built with debug/warning flags
David Teigland (393):
sync_manager: initial commit
sync_manager: misc updates
sync_manager: misc updates
sync_manager: misc updates
sync_manager: misc updates
sync_manager: add more logging
sync_manager: misc updates
sync_manager: misc updates
sync_manager: num_hosts/MAX_HOSTS stuff
daemon: reworking notions of resource_id/token_name
sync_manager: resource lockfiles
sync_manager: lease arg processing
sync_manager: Began multiple lease support
sync_manager: use first command line arg as action
sync_manager: leader record changes and verify
sync_manager: clean up released leases
sync_manager: move functions around
sync_manager: add more tool actions
sync_manager: naming changes
sync_manager: separate token index and id
sync_manager: fix index usage and other misc
sync_manager: use pthread cond in acquire
sync_manager: write all log entries
sync_manager: simplify polling
sync_manager: fix waitpid use
sync_manager: acquire can fail early
sync_manager: write log entries at exit
sync_manager: add test program
sync_manager: move secondary pid check
sync_manager: fix disk paxos contention
devcount: fix verify checks
sync_manager: add GPL license file
sync_manager: fix leader block offsets
sync_manager: increase COMMAND_MAX
sync_manager: renewal should verify
sync_manager: use sector size from libblkid
sync_manager: use a real checksum function
sync_manager: add libblkid to spec file
sync_manager: print status info
sync_manager: one watchdog file per lease
sync_manager: lease_threads handle watchdog files
sync_manager: fix/add some text/comments
sync_manager: refactor read/write
sync_manager: move disk io functions
sync_manager: remove token arg
sync_manager: rename paxos_disk sync_disk
sync_manager: add aio read/write
sync_manager: make io_timeout_seconds a diskio arg
sync_manager: forgot to add new files
sync_manager: use log thread
sync_manager: client connections
sync_manager: connection processing
sync_manager: send/recv pid
sync_manager: add write_sectors
sync_manager: restructuring
sync_manager: write_sectors code factoring
sync_manager: daemonize
sync_manager: releasing leases
sync_manager: async releasing
sync_manager: release fixes
sync_manager: add direct and indirect acquire/release
sync_manager: reacquire resources
sync_manager: move code
sync_manager: same pid may reacquire resource
sync_manager: lease migration
sync_manager: handle client errors
sync_manager: improve error handling
sync_manager: host_id leases
sync_manager: remove empty files
sync_manager: print initialization info
sync_manager: rename files
sync_manager: clean up header org
sync_manager: delta_lease implementation
sync_manager: accept offset units
sync_manager: fix up init output
sync_manager: put back watchdog calls
sync_manager: fix start_host_id error paths
sync_manager: add log_error's for watchdog file errors
sync_manager: actual timeouts
sync_manager: change timeouts on cmd line
sanlock: create new external api
sanlock: build libsanlock
sanlock: use MAX_LEASES everywhere
sanlock: add libvirt plugin
sanlock plugin: couple minor fixes
sanlock: clean up /var file names
sanlock plugin: fix symbol needed by libvirt
sanlock: add some debug output
sanlock plugin: fix uuid copy
sanlock plugin: fix names
sanlock: add "owner_name"
sanlock: fix renewal checks
sanlock: clean up host_id types
sanlock: set_host_id command
sanlock: fix killing pids
sanlock: add status command
sanlock: set version to 1.0
sanlock: delta_lease cleanup
sanlock: changing num_hosts
sanlock: add dump command
sanlock: renewal timings
sanlock: add direct option
sanlock: check for watchdog file
sanlock: recovery fixes
lock_driver_sanlock: fix compile problems
sanlock: improve command options
sanlock: tidying help text
sanlock: move binary to /usr/sbin
sanlock: add init script
sanlock: fix sigterm shutdown
sanlock: init stop
sanlock: add wdtest command
sanlock.spec: new url
lock_driver_sanlock: remove close
sanlock: introduce lockspaces
lock_driver_sanlock: remove files
sanlock: better logging functions
sanlock: misc log message
sanlock.spec: sbin not libexec
sanlock init: remove watchdog reference
wdmd: watchdog multiplexing daemon
sanlock: add code to use wdmd
sanlock/wdmd: use wdmd in sanlock
sanlock/wdmd: add copyright header to source files
sanlock: rename sanlock source dir
sanlock: move tests dir
move COPYING file
wdmd: use signalfd for signal handling
Fix Makefile comments
wdmd: fix daemon debug option
wdmd: add init script
sanlock.spec: updates
sanlock.spec: src dir
sanlock: build with uninstalled libwdmd
sanlock: version 1.1
sanlock: high priority options
wdmd: high priority options
sanlock: return migration state
sanlock: migration.txt describes libvirt/sanlock steps
libsanlock: include admin functions
sanlock: fix host_id expiration check
sanlock: migration working
devcount: migrate test
sanlock: setowner improvements
sanlock: migrate to target fix
sanlock: fix wdmd stop order
sanlock: various fixes
sanlock: remove wdtest
sanlock: remove migration
sanlock: clean up command return data
sanlock: add resource string conversion functions
sanlock: rework internal structs
devcount: add relock test
sanlock: fix release and inquire
sanlock: add_lockspace EEXIST
sanlock: rework client handling
sanlock: clean up warnings
sanlock: debug message changes
sanlock: add lockspace checks
wdmd: enable test scripts
sanlock: add str_to_lockspace to lib
WIP devcount migrate
devcount: new migrate test
sanlock: read_id and live_id commands
sanlock: check lockspace name and host_id
sanlock: remove remaining cluster_mode
sanlock: add libsanlock_direct
devcountn: start multiple devcount tests
devcount: small changes
sanlock: new return values
sanlock: misc changes and fix
sanlock: log error of full bad block
sanlock: interval between renewal checks
sanlock: renewal changes
sanlock: fix log_dump
sanlock: fix find_client_pid
sanlock: fix host_id reads from paxos_acquire
sanlock: init with one write
devcount: improve output
devcount: new pause/resume
devcount: add expire test
sanlock: correct paxos usage
sanlock: direct read_leader
sanlock: paxos delays
sanlock: use thread pool
sanlock: client status output format changes
sanlock: fix inquire of dead pid
sanlock: use native linux aio
sanlock: i/o changes
sanlock: aio changes
sanlock: reduce paxos acquire read ops
sanlock: quiet error case
sanlock: don't free aio buf until event completes
sanlock: io timeout related changes
sanlock: read dblocks in single aligned io
sanlock: add sanlock_restrict api
sanlock: add sanlock_direct_sector_size api
sanlock: add checksum to dblocks
sanlock: fix init restart
sanlock: don't release tokens in dead lockspace
sanlock: fix adding lockspace
sanlock: official 1MB/8MB alignment
devcount: use aio in init
libsanlock: link with LDFLAGS
sanlock: increase version to 1.3
sanlock/wdmd: shut up warnings
sanlock: fix libwdmd linking
remove spec file
sanlock: use a completed read after renewal timeout
sanlock: use unique host name in delta leases
sanlock: remove sector_size api
sanlock: abort delta wait on shutdown
sanlock: fix add_lockspace failure
sanlk_load: add new test
sanlock: fix recv and inquire
sanlock: initial pid_dead check in acquire
sanlock: release 1.4
sanlock: generate a uuid for host id
sanlock: return -EINPROGRESS from add_lockspace
sanlk_load: periodically kill and replace a pid
sanlock: zero num_hosts uses DEFAULT_MAX_HOSTS
tests: misc changes
sanlock: break paxos_acquire wait loop
sanlock: increase log line to 512 bytes
sanlock: change a log_error to log_debug
sanlock: fail host_id when corrupted
sanlock: release 1.5
sanlock: release 1.6
sanlock: handle colon escaping in path strings
wdmd: add option for high priority
wdmd: use accept4 with SOCK_NONBLOCK
wdmd: tidy sun_addr snprintf
wdmd: pid and sock file changes
wdmd: add man page
wdmd: disable test scripts
sanlock: use accept4 with SOCK_NONBLOCK
sanlock: tidy sun_addr snprintf
sanlock: add explicit -luuid
sanlock: pid and sock file changes
sanlock: add man page
sanlock/wdmd: improve mkdir of run dir
wdmd: new build flags
sanlock: new build flags
sanlock/wdmd: use monotonic time
sanlock: build with pie
sanlock/wdmd: nonblocking listening/accept
sanlock: add missing monotime files
sanlock: update man page
sanlock: man page update
sanlock: update man page and help text
sanlock: print connections limit
release: sanlock 1.7
makefile: install mode for man pages
sanlock: read align_size in renewal
sanlock: check other host_id leases
sanlock: minor fixes and cleanups
sanlock: add request api/cmd
sanlock: crc code tidying
sanlock/wdmd: add license header to files
sanlock: create libsanlock_client
sanlock: move client code
remove COPYING file
sanlock: remove internal header from sanlock_sock
libsanlock_client: use LGPLv2+
libwdmd: use LGPLv2+
sanlock_rv.h: switch to LGPLv2+
README.license: document licenses
sanlock: client align and init
sanlock: write request record
sanlock: request struct magic and version numbers
sanlock: set bitmap for requests
sanlock: examine resource requests
sanlock: update man page
sanlock: remove old comment
sanlock: renaming functions
sanlock: optimize paxos wait
sanlock: use flags in struct resource
sanlock: restructure lockspace checks
sanlock: remove BLOCK_WD force mode
libsanlock: fix function stubs
sanlock: new status and host_status
sanlock: improve status output
sanlock: status output sorting
sanlock: SIGTERM and SIGKILL for REQ_KILL_PID
sanlock: add flag RESTRICT_SIGKILL
sanlock: setup fewer aio events
sanlock: move cmd processing
sanlock: suppress log messages
sanlock: rename source files
sanlock: improve killing pids
sanlock: fix log_dump
version 1.8
sanlock: quick host_id reacquire
sanlock: add force option to shutdown command
simpler copyright line
default to GPLv2+ for our original files
sanlock: improve daemon permission errors
add systemd files
fixing up init stuff
release 1.9
sanlock: setmode
Revert "sanlock: setmode"
sanlock: fix error exit
sanlock: fix debug line
init scripts: fix path to restorecon
sanlock: shared mode for leases
sanlock: fix missing close_disks
sanlock: fix problem in paxos
sanlock: add paxos sanity check
sanlock: fix leaking fd
sanlock: change to paxos algorithm
sanlock: change ondisk version
sanlock: remove log noise
sanlock: ignore SIGTERM if lockspaces exist
sanlock: quiet more error messages
sanlk_load: munging variable names
sanlk_load: add shared locks
sanlock: kill client connection on recv error
sanlk_load: ignore release errors
sanlock: set sector_size in shared tokens
sanlock man page: mention SH
release 2.0
sanlock: clean up warnings
sanlock: fix inquire state string
sanlock: retry transient sh failures
sanlock: status for all shared tokens
sanlock: add a logrotate file
release 2.1
python: fix path strncpy
sanlock: remove physical sector size requirement
sanlock: add sample sysconfig file
sanlock: ASYNC flag for lockspace add and rem
sanlock: UNUSED flag for lockspace rem
release 2.2
sanlock.log: empty file to install from rpm
Revert "sanlock.log: empty file to install from rpm"
sanlock: remove limits.conf
sysconfig: remove user option
init: root user
release 2.3
latest spec file
sanlock.spec: fix exclusive arch
sanlock/wdmd: use /var/log/subsys/file
daemon: skip setup_groups when no -U or -G
sanlock.spec: require useradd and groupadd
sanlock.spec updated
daemon: don't put struct space on stack
daemon: fix add_lockspace that has been removed
daemon: fix inquire lver
daemon: graceful pid handling
Revert "init: make explicit to run sanlock as root"
remove spec file
release 2.4
daemon: include resource.h
daemon: fix lockfile ownership
wdmd: use lockfile mode 644
sanlock: use lockfile mode 644
wdmd: use shm_open to prevent restart
sanlock: remove umask 0
sanlock/wdmd: remove global connection
daemon: extend grace time
wdmd: close device when test fails
wdmd: preemptive close before test fails
wdmd: pet after reopen and use 1 sec interval after failure
sanlock: base kill sig on last renewal
clientn: add tests
tests: add test-recovery script
sanlock: fix paxos acquire host_id check
daemon: use helper for examine request kill
sanlock: show host_status for all lockspaces
sanlock: fix status of lockspaces in add and rem
sanlock: adjustable io timeouts
sanlock: add direct next_free command
sanlock: request force_mode 2 is SIGUSR1
sanlock: print escape chars in path from status
release 2.5
sanlock: configurable mlockall level
sanlock: change log level for startup and io timeouts
sanlock: update man page
sanlock: fix aborted command clearing
sanlock: client add_lockspace with timeout
sanlock: print command output to stdout
wdmd: new script handling
fence_sanlock: new code
fence_sanlock: various fixes and changes
fence_sanlock: variable alignment
fence_sanlockd: use init script
fence_sanlock: add man pages
fence_sanlock: use SIGHUP for shutdown
fence_sanlock: handle two node fence duel
sanlock/wdmd: get version from common file
wdmd: show option values in start message
release 2.6
David Weber (3):
Fix order of linking
Install another symlink to shared library
Replace restrict field name with restricted
Fabio M. Di Nitto (15):
build: sanlock should link with libsanlock
build: install shared lib header files and fix DESTDIR usage
build: drop rpm target
spec file: do first cut for total spec file
build: fix linking with libsanlock and install target
fence_sanlock: add install bits
fence_sanlockd: add missing \n
fence_sanlock: cleanup shell usage
fence_sanlock: don't restart fence_sanlockd if it's already running
fence_sanlock: add basic metadata to integrate with ccs_config_validate
fence_sanlock: improve action_on error checking and report
fence_sanlock: unify code and silence some operations
fence_sanlockd init: cleanup, remove hardcoded paths and use system service
fence_sanlock: fix build to be selfcontained
systemd: add fence_sanlockd service file
Federico Simoncelli (58):
rpm: sync specfile with fedora
rpm: add sanlock_admin.h header
rpm: add the lib package, install the initscripts
python: remove unused python code
python: add python binding
python: release the gil during sanlock operations
python: wrap sanlock extension with a module
rpm: add python binding package
python: pass a lockspace copy to str_to_lockspace
makefile: fix install typo
rpm: add sanlock_direct header
python: add sanlock init functions and exception
direct: close disks after initialization
python: register process only once
daemon: configurable socket permissions
rpm: add sanlock user and group
python: exceptions must contain the errno
rpm: add missing libaio-devel dependency
rpm: add daemon options in the init file
python: add missing aio library
python: add get_alignment function
libs: include libsanlock_direct into libsanlock
python: align num_hosts and max_hosts defaults
python: expose sanlock file descriptor
python: improve error reporting
python: parse lockspaces and resources natively
python: add usage example
python: initial support for sanlock errors
python: document the sanlock module
python: module cleanup
build: fix documentation install path
client: return appropriate errno on failure
python: expose errno in the exception
python: acquire leases for other processes
sanlock: implement the inq_lockspace command
python: add the inq_lockspace command binding
misc: run sanlock daemon as sanlock user
wdmd: use getopt to parse the command line
wdmd: make socket group ownership configurable
python: add shared resource parameter to acquire
python: release leases for other processes
python: ASYNC flag for lockspace add and rem
python: UNUSED flag for lockspace rem
log: add full time and date to the log messages
sanlock: set the supplementary groups at startup
log: add the thread id in the log messages
sanlock: fix an rv check typo in setup_groups
init: add a stop timeout for the sanlock service
build: add a generic rpm spec file
init: make explicit to run sanlock as root
wdmd: load the softdog module when needed
sanlock: WAIT flag for sanlock_inq_lockspace
daemon: drop root privileges and use the helper
init: use checkpid when stopping the services
sanlock: expose sanlock path import and export utils
sanlock: configuring the core dump output
python: fix the tuple parsing for py_add_lockspace
sanlock: use signal handler for all terminating signals
Saggi Mizrahi (21):
Added the begining of the testing and debugging tools
Better handling of max hosts
sync_manager: Updated tests to work with new lease struct
sync_manager: fixed skipping first arg in command
sync_manager: acquire and release actions
sync_manager: minor fixes
sync_manager: renamed stuff
sync_manager: made acquire synchronous again
sync_manager: added set_host_id action
sync_manager: use kill(0) for secondary pid check
sync_manager: make rpm and install
sync_manager: spec file update
sync_manager: Allow longer resource names
sync_manager: allow repeated set_host_id
sync_manager: Added escaping for the leases arg
sync_manager: Created the python bindings for sync_manager
sync_manager: listener socket permissions
sync_manager: Updated python binding and tests
sync_manager: Made 'token' a const in log_level
sync_manager: refactor messaging system
sync_manager: use getsockopt PEERCRED
11 years, 1 month
VERSION
by David Teigland
VERSION | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 4ed1fb4f0c553608160a7108d212441a022339c4
Author: David Teigland <teigland(a)redhat.com>
Date: Tue Oct 9 10:55:14 2012 -0500
release 2.6
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/VERSION b/VERSION
index 95e3ba8..5154b3f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.5
+2.6
11 years, 1 month
wdmd/main.c
by David Teigland
wdmd/main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 0c43ce84b720f6087e68f4df87f63f6e9145aaa5
Author: David Teigland <teigland(a)redhat.com>
Date: Tue Oct 9 10:54:26 2012 -0500
wdmd: show option values in start message
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/wdmd/main.c b/wdmd/main.c
index 9d7ac7d..482ab29 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -1403,7 +1403,8 @@ int main(int argc, char *argv[])
openlog("wdmd", LOG_CONS | LOG_PID, LOG_DAEMON);
- log_error("wdmd started allow_scripts %d", allow_scripts);
+ log_error("wdmd started S%d H%d G%d", allow_scripts, high_priority,
+ socket_gid);
setup_priority();
11 years, 1 month
VERSION src/Makefile src/main.c wdmd/Makefile wdmd/main.c
by David Teigland
VERSION | 2 +-
src/Makefile | 4 +++-
src/main.c | 6 ++----
wdmd/Makefile | 3 +++
wdmd/main.c | 4 +---
5 files changed, 10 insertions(+), 9 deletions(-)
New commits:
commit 55de01b481813cc1f94dd4f7dd9ad4139e875d1a
Author: David Teigland <teigland(a)redhat.com>
Date: Mon Oct 8 11:42:30 2012 -0500
sanlock/wdmd: get version from common file
use top level VERSION file for all
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/VERSION b/VERSION
index 6b4950e..95e3ba8 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.4
+2.5
diff --git a/src/Makefile b/src/Makefile
index 81c57f9..2fb2dee 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -73,6 +73,9 @@ CFLAGS += -D_GNU_SOURCE -g \
-fasynchronous-unwind-tables \
-fdiagnostics-show-option
+VER=$(shell cat ../VERSION)
+CFLAGS += -DVERSION=\"$(VER)\"
+
CMD_CFLAGS = $(CFLAGS) -fPIE -DPIE
CMD_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
@@ -83,7 +86,6 @@ LIB_ENTIRE_LDFLAGS += -Wl,-z,relro -pie
LIB_CLIENT_LDFLAGS += -Wl,-z,relro -pie
-
all: $(LIBSO_ENTIRE_TARGET) $(LIBSO_CLIENT_TARGET) $(CMD_TARGET)
$(LIBSO_ENTIRE_TARGET): $(LIB_ENTIRE_SOURCE)
diff --git a/src/main.c b/src/main.c
index 87c784d..17c37a4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,8 +54,6 @@
#include "helper.h"
#include "timeouts.h"
-#define RELEASE_VERSION "2.5"
-
#define SIGRUNPATH 100 /* anything that's not SIGTERM/SIGKILL */
struct thread_pool {
@@ -1637,7 +1635,7 @@ static int do_daemon(void)
setup_groups();
log_level(0, 0, NULL, LOG_WARNING, "sanlock daemon started %s host %s",
- RELEASE_VERSION, our_host_name_global);
+ VERSION, our_host_name_global);
setup_priority();
@@ -1840,7 +1838,7 @@ static int read_command_line(int argc, char *argv[])
if (!strcmp(arg1, "version") || !strcmp(arg1, "--version") ||
!strcmp(arg1, "-V")) {
printf("%s %s (built %s %s)\n",
- argv[0], RELEASE_VERSION, __DATE__, __TIME__);
+ argv[0], VERSION, __DATE__, __TIME__);
exit(EXIT_SUCCESS);
}
diff --git a/wdmd/Makefile b/wdmd/Makefile
index 205245b..de6b035 100644
--- a/wdmd/Makefile
+++ b/wdmd/Makefile
@@ -42,6 +42,9 @@ CFLAGS += -D_GNU_SOURCE -g \
-fdiagnostics-show-option \
-fPIE -DPIE
+VER=$(shell cat ../VERSION)
+CFLAGS += -DVERSION=\"$(VER)\"
+
CMD_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
CMD_LDADD += -lwdmd -lrt
diff --git a/wdmd/main.c b/wdmd/main.c
index 90e32c6..9d7ac7d 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -41,8 +41,6 @@
#define GNUC_UNUSED __attribute__((__unused__))
#endif
-#define RELEASE_VERSION "2.5"
-
#define DEFAULT_TEST_INTERVAL 10
#define RECOVER_TEST_INTERVAL 1
#define DEFAULT_FIRE_TIMEOUT 60
@@ -1333,7 +1331,7 @@ static void print_usage_and_exit(int status)
static void print_version_and_exit(void)
{
- printf("wdmd version %s\n", RELEASE_VERSION);
+ printf("wdmd version %s\n", VERSION);
exit(0);
}
11 years, 1 month
wdmd/main.c wdmd/sysconfig.wdmd wdmd/wdmd.8 wdmd/wdmd_sock.h
by David Teigland
wdmd/main.c | 517 +++++++++++++++++++++++++++++++++++++++-------------
wdmd/sysconfig.wdmd | 8
wdmd/wdmd.8 | 52 ++++-
wdmd/wdmd_sock.h | 1
4 files changed, 441 insertions(+), 137 deletions(-)
New commits:
commit 8257d7b732c91bdd0825d90d36cda69a8acfad8c
Author: David Teigland <teigland(a)redhat.com>
Date: Wed Sep 19 15:15:05 2012 -0500
wdmd: new script handling
Rewrite the code for using test scripts,
enabled by -S 1. Also added dumping
daemon state by wdmd --dump.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/wdmd/main.c b/wdmd/main.c
index ce6579c..90e32c6 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Red Hat, Inc.
+ * Copyright 2011-2012 Red Hat, Inc.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
@@ -63,21 +63,24 @@ static char lockfile_path[PATH_MAX];
static int dev_fd = -1;
static int shm_fd;
+static int allow_scripts;
+static int kill_script_sec;
+static char *scripts_dir = (char *)"/etc/wdmd.d";
+
struct script_status {
+ uint64_t start;
int pid;
- char path[PATH_MAX];
+ int last_result;
+ unsigned int run_count;
+ unsigned int fail_count;
+ unsigned int good_count;
+ unsigned int kill_count;
+ unsigned int long_count;
+ char name[PATH_MAX];
};
-/* The relationship between SCRIPT_WAIT_SECONDS/MAX_SCRIPTS/test_interval
- is not very sophisticated, but it's simple. If we wait up to 2 seconds
- for each script to exit, and have 5 scripts, that's up to 10 seconds we
- spend in test_scripts, and it's simplest if the max time in test_scripts
- does not excede the test_interval (10). FIXME: this is not entirely
- true since the test_interval was changed to 1 after a failure. */
-
-#define SCRIPT_WAIT_SECONDS 2
-#define MAX_SCRIPTS 4
-struct script_status scripts[MAX_SCRIPTS];
+#define MAX_SCRIPTS 8
+static struct script_status scripts[MAX_SCRIPTS];
struct client {
int used;
@@ -97,7 +100,6 @@ static int client_maxi;
static int client_size = 0;
static struct client *client = NULL;
static struct pollfd *pollfd = NULL;
-const char *client_built = " client";
#define log_debug(fmt, args...) \
@@ -112,6 +114,14 @@ do { \
syslog(LOG_ERR, fmt, ##args); \
} while (0)
+#define log_script(i) \
+ log_error("script %.64s last_result %d start %llu run %u fail %u good %u kill %u long %u", \
+ scripts[i].name, scripts[i].last_result, \
+ (unsigned long long)scripts[i].start, \
+ scripts[i].run_count, scripts[i].fail_count, \
+ scripts[i].good_count, scripts[i].kill_count, \
+ scripts[i].long_count);
+
static uint64_t monotime(void)
{
@@ -240,6 +250,81 @@ static int get_peer_pid(int fd, int *pid)
return 0;
}
+#define DEBUG_SIZE (1024 * 1024)
+#define LINE_SIZE 256
+
+char debug_buf[DEBUG_SIZE];
+
+static void dump_debug(int fd)
+{
+ char line[LINE_SIZE];
+ uint64_t now;
+ int line_len;
+ int debug_len = 0;
+ int i;
+
+ memset(debug_buf, 0, DEBUG_SIZE);
+
+ now = monotime();
+
+ memset(line, 0, sizeof(line));
+ snprintf(line, 255, "wdmd %d socket_gid %d high_priority %d now %llu last_keepalive %llu last_closeunclean %llu allow_scripts %d kill_script_sec %d\n",
+ getpid(), socket_gid, high_priority,
+ (unsigned long long)now,
+ (unsigned long long)last_keepalive,
+ (unsigned long long)last_closeunclean,
+ allow_scripts, kill_script_sec);
+
+ line_len = strlen(line);
+ strncat(debug_buf, line, LINE_SIZE);
+ debug_len += line_len;
+
+ for (i = 0; i < MAX_SCRIPTS; i++) {
+ if (!scripts[i].name[0])
+ continue;
+ memset(line, 0, sizeof(line));
+ snprintf(line, 255, "script %d name %.64s pid %d now %llu start %llu last_result %d run %u fail %u good %u kill %u long %u\n",
+ i, scripts[i].name, scripts[i].pid,
+ (unsigned long long)now,
+ (unsigned long long)scripts[i].start,
+ scripts[i].last_result,
+ scripts[i].run_count,
+ scripts[i].fail_count,
+ scripts[i].good_count,
+ scripts[i].kill_count,
+ scripts[i].long_count);
+
+ line_len = strlen(line);
+
+ if (debug_len + line_len >= DEBUG_SIZE - 1)
+ goto out;
+
+ strncat(debug_buf, line, LINE_SIZE);
+ debug_len += line_len;
+ }
+
+ for (i = 0; i < client_size; i++) {
+ if (!client[i].used)
+ continue;
+ memset(line, 0, sizeof(line));
+ snprintf(line, 255, "client %d name %.64s pid %d fd %d dead %d ref %d now %llu renewal %llu expire %llu\n",
+ i, client[i].name, client[i].pid, client[i].fd, client[i].pid_dead, client[i].refcount,
+ (unsigned long long)now,
+ (unsigned long long)client[i].renewal,
+ (unsigned long long)client[i].expire);
+
+ line_len = strlen(line);
+
+ if (debug_len + line_len >= DEBUG_SIZE - 1)
+ goto out;
+
+ strncat(debug_buf, line, LINE_SIZE);
+ debug_len += line_len;
+ }
+ out:
+ send(fd, debug_buf, debug_len, MSG_NOSIGNAL);
+}
+
static void process_connection(int ci)
{
struct wdmd_header h;
@@ -299,6 +384,11 @@ static void process_connection(int ci)
h_ret.last_keepalive = last_keepalive;
send(client[ci].fd, &h_ret, sizeof(h_ret), MSG_NOSIGNAL);
break;
+
+ case CMD_DUMP_DEBUG:
+ strncpy(client[ci].name, "dump", WDMD_NAME_SIZE);
+ dump_debug(client[ci].fd);
+ break;
};
return;
@@ -384,6 +474,7 @@ static int setup_clients(void)
return rv;
ci = client_add(fd, process_listener, client_pid_dead);
+ strncpy(client[ci].name, "listen", WDMD_NAME_SIZE);
return 0;
}
@@ -546,159 +637,286 @@ static int test_files(void)
#else
-const char *files_built = NULL;
static void close_files(void) { }
static int setup_files(void) { return 0; }
static int test_files(void) { return 0; }
#endif /* TEST_FILES */
+static int find_script(char *name)
+{
+ int i;
-#ifdef TEST_SCRIPTS
-#define SCRIPTS_DIR "/etc/wdmd/test_scripts"
-static DIR *scripts_dir;
-const char *scripts_built = " scripts";
+ for (i = 0; i < MAX_SCRIPTS; i++) {
+ if (!strncmp(scripts[i].name, name, PATH_MAX))
+ return i;
+ }
+ return -1;
+}
-static void close_scripts(void)
+static int add_script(char *name)
{
- closedir(scripts_dir);
+ int i;
+
+ for (i = 0; i < MAX_SCRIPTS; i++) {
+ if (scripts[i].name[0])
+ continue;
+
+ log_debug("add_script %d %s", i, name);
+ strncpy(scripts[i].name, name, PATH_MAX);
+ return i;
+ }
+ log_debug("script %s no space", name);
+ return -1;
}
-static int setup_scripts(void)
+static int check_path(char *path)
{
- mode_t old_umask;
+ struct stat st;
int rv;
- old_umask = umask(0022);
- rv = mkdir(SCRIPTS_DIR, 0777);
- if (rv < 0 && errno != EEXIST)
- goto out;
+ rv = stat(path, &st);
- scripts_dir = opendir(SCRIPTS_DIR);
- if (!scripts_dir)
- rv = -errno;
- else
- rv = 0;
- out:
- umask(old_umask);
- return rv;
+ if (rv < 0)
+ return -errno;
+
+ if (!(S_ISREG(st.st_mode)))
+ return -1;
+
+ if (!(st.st_mode & S_IXUSR))
+ return -1;
+
+ return 0;
}
-static int run_script(char *name, int i)
+static int run_script(int i)
{
- int pid;
+ char path[PATH_MAX];
+ int pid, rv;
- if (i >= MAX_SCRIPTS) {
- log_error("max scripts %d, ignore %s", MAX_SCRIPTS, name);
- return -1;
- }
+ memset(path, 0, sizeof(path));
+ snprintf(path, PATH_MAX-1, "%s/%s", scripts_dir, scripts[i].name);
- snprintf(scripts[i].path, PATH_MAX-1, "%s/%s", SCRIPTS_DIR, name);
+ rv = check_path(path);
+ if (rv < 0)
+ return rv;
pid = fork();
if (pid < 0)
return -errno;
if (pid) {
- log_debug("run_script %d %s", pid, name);
- scripts[i].pid = pid;
- return 0;
+ log_debug("script %s pid %d", scripts[i].name, pid);
+ return pid;
} else {
- execlp(scripts[i].path, scripts[i].path, NULL);
+ execlp(path, path, NULL);
exit(EXIT_FAILURE);
}
}
-static int check_script(int i)
+static void close_scripts(void)
{
- time_t begin;
- int status;
- int rv;
+}
- if (!scripts[i].pid)
- return 0;
+static int setup_scripts(void)
+{
+ char path[PATH_MAX];
+ struct dirent **namelist;
+ int i, s, rv, de_count;
- begin = monotime();
+ if (!allow_scripts)
+ return 0;
- while (1) {
- rv = waitpid(scripts[i].pid, &status, WNOHANG);
+ de_count = scandir(scripts_dir, &namelist, 0, alphasort);
+ if (de_count < 0)
+ return 0;
- if (rv < 0) {
- goto out;
+ for (i = 0; i < de_count; i++) {
+ if (namelist[i]->d_name[0] == '.')
+ goto next;
- } else if (!rv) {
- /* pid still running */
- if (monotime() - begin >= SCRIPT_WAIT_SECONDS) {
- rv = -ETIMEDOUT;
- goto out;
- }
- sleep(1);
-
- } else if (WIFEXITED(status)) {
- /* pid exited */
- if (!WEXITSTATUS(status))
- rv = 0;
- else
- rv = -1;
- goto out;
+ memset(path, 0, sizeof(path));
+ snprintf(path, PATH_MAX-1, "%s/%s", scripts_dir, namelist[i]->d_name);
- } else {
- /* pid state changed but still running */
- if (monotime() - begin >= 2) {
- rv = -ETIMEDOUT;
- goto out;
- }
- sleep(1);
+ rv = check_path(path);
+ if (rv < 0) {
+ log_debug("script %s ignore %d", namelist[i]->d_name, rv);
+ goto next;
}
+
+ s = find_script(namelist[i]->d_name);
+ if (s < 0)
+ add_script(namelist[i]->d_name);
+ next:
+ free(namelist[i]);
}
- out:
- log_debug("check_script %d rv %d begin %llu",
- scripts[i].pid, rv, (unsigned long long)begin);
+ free(namelist);
- scripts[i].pid = 0;
- return rv;
+ return 0;
}
static int test_scripts(void)
{
- struct dirent *de;
- int fail_count = 0;
- int run_count = 0;
- int i, rv;
+ int i, rv, pid, result, running, fail_count, status;
+ uint64_t begin, now;
- memset(scripts, 0, sizeof(scripts));
+ if (!allow_scripts)
+ return 0;
- rewinddir(scripts_dir);
+ fail_count = 0;
- while ((de = readdir(scripts_dir))) {
- if (de->d_name[0] == '.')
+ begin = monotime();
+
+ for (i = 0; i < MAX_SCRIPTS; i++) {
+ if (!scripts[i].name[0])
+ continue;
+
+ /* pid didn't exit in previous cycle */
+ if (scripts[i].pid)
continue;
- rv = run_script(de->d_name, run_count);
- if (!rv)
- run_count++;
+ /*
+ * after a script reports success, don't call it again before
+ * the normal test interval; this is needed because the test
+ * interval becomes shorter when failures occur
+ */
+
+ if (!scripts[i].last_result &&
+ ((begin - scripts[i].start) < (DEFAULT_TEST_INTERVAL - 1)))
+ continue;
+
+ pid = run_script(i);
+
+ if (pid <= 0) {
+ log_error("script %s removed %d", scripts[i].name, pid);
+ memset(&scripts[i], 0, sizeof(struct script_status));
+ } else {
+ scripts[i].pid = pid;
+ scripts[i].start = begin;
+ scripts[i].run_count++;
+ }
}
- for (i = 0; i < run_count; i++) {
- rv = check_script(i);
- if (rv < 0) {
- log_error("test failed script %s", scripts[i].path);
- fail_count++;
+ /* wait up to DEFAULT_TEST_INTERVAL-1 for the pids to finish */
+
+ while (1) {
+ running = 0;
+
+ for (i = 0; i < MAX_SCRIPTS; i++) {
+ if (!scripts[i].name[0])
+ continue;
+
+ if (!scripts[i].pid)
+ continue;
+
+ rv = waitpid(scripts[i].pid, &status, WNOHANG);
+
+ if (rv < 0) {
+ /* shouldn't happen */
+ log_error("script %s pid %d waitpid error %d %d",
+ scripts[i].name, scripts[i].pid, rv, errno);
+ log_script(i);
+ running++;
+
+ } else if (!rv) {
+ /* pid still running, has not changed state */
+ running++;
+
+ } else if (rv == scripts[i].pid) {
+ /* pid state has changed */
+
+ if (WIFEXITED(status)) {
+ /* pid exited with an exit code */
+ result = WEXITSTATUS(status);
+
+ if (result) {
+ log_error("script %s pid %d exit status %d",
+ scripts[i].name, scripts[i].pid,
+ result);
+
+ scripts[i].fail_count++;
+ scripts[i].last_result = result;
+ scripts[i].pid = 0;
+ fail_count++;
+
+ log_script(i);
+ } else {
+ scripts[i].good_count++;
+ scripts[i].last_result = 0;
+ scripts[i].pid = 0;
+ }
+
+ } else if (WIFSIGNALED(status)) {
+ /* pid terminated due to a signal */
+
+ log_error("script %s pid %d term signal %d",
+ scripts[i].name, scripts[i].pid,
+ WTERMSIG(status));
+
+ scripts[i].kill_count++;
+ scripts[i].last_result = EINTR;
+ scripts[i].pid = 0;
+ fail_count++;
+
+ log_script(i);
+ } else {
+ /* pid state changed but still running */
+ running++;
+ }
+
+ } else {
+ /* shouldn't happen */
+ log_error("script %s pid %d waitpid rv %d",
+ scripts[i].name, scripts[i].pid, rv);
+ log_script(i);
+
+ running++;
+ }
+
+ /* option to kill script after it's run for kill_script_sec */
+
+ if (scripts[i].pid && kill_script_sec &&
+ (monotime() - scripts[i].start >= kill_script_sec)) {
+ kill(scripts[i].pid, SIGKILL);
+ }
}
+
+ if (!running)
+ break;
+
+ if (monotime() - begin >= DEFAULT_TEST_INTERVAL - 1)
+ break;
+
+ sleep(1);
}
- return fail_count;
-}
+ if (!running)
+ goto out;
-#else
+ /* any pids that have not exited count as a failed for this cycle */
-const char *scripts_built = NULL;
-static void close_scripts(void) { }
-static int setup_scripts(void) { return 0; }
-static int test_scripts(void) { return 0; }
+ now = monotime();
-#endif /* TEST_SCRIPTS */
+ for (i = 0; i < MAX_SCRIPTS; i++) {
+ if (!scripts[i].name[0])
+ continue;
+
+ if (!scripts[i].pid)
+ continue;
+ scripts[i].long_count++;
+ fail_count++;
+
+ log_error("script %s pid %d start %llu now %llu taking too long",
+ scripts[i].name, scripts[i].pid,
+ (unsigned long long)scripts[i].start,
+ (unsigned long long)now);
+ log_script(i);
+ }
+
+ out:
+ return fail_count;
+}
static int open_dev(void)
{
@@ -817,15 +1035,20 @@ static void process_signals(int ci)
if (!active_clients())
daemon_quit = 1;
}
+
+ if (fdsi.ssi_signo == SIGHUP) {
+ setup_scripts();
+ }
}
static int setup_signals(void)
{
sigset_t mask;
- int fd, rv;
+ int fd, rv, ci;
sigemptyset(&mask);
sigaddset(&mask, SIGTERM);
+ sigaddset(&mask, SIGHUP);
rv = sigprocmask(SIG_BLOCK, &mask, NULL);
if (rv < 0)
@@ -835,7 +1058,8 @@ static int setup_signals(void)
if (fd < 0)
return -errno;
- client_add(fd, process_signals, client_pid_dead);
+ ci = client_add(fd, process_signals, client_pid_dead);
+ strncpy(client[ci].name, "signal", WDMD_NAME_SIZE);
return 0;
}
@@ -1055,25 +1279,61 @@ static int group_to_gid(char *arg)
return gr->gr_gid;
}
+static void print_debug_and_exit(void)
+{
+ struct sockaddr_un addr;
+ struct wdmd_header h;
+ int rv, s;
+
+ s = socket(AF_LOCAL, SOCK_STREAM, 0);
+ if (s < 0)
+ exit(1);
+
+ rv = wdmd_socket_address(&addr);
+ if (rv < 0)
+ exit(1);
+
+ rv = connect(s, (struct sockaddr *) &addr, sizeof(struct sockaddr_un));
+ if (rv < 0)
+ exit(1);
+
+ memset(&h, 0, sizeof(h));
+ h.cmd = CMD_DUMP_DEBUG;
+
+ rv = send(s, (void *)&h, sizeof(struct wdmd_header), 0);
+ if (rv < 0)
+ exit(1);
+
+ rv = recv(s, &debug_buf, DEBUG_SIZE, 0);
+ if (rv < 0)
+ exit(1);
+
+ write(STDOUT_FILENO, debug_buf, strlen(debug_buf));
+
+ exit(0);
+}
+
static void print_usage_and_exit(int status)
{
printf("Usage:\n");
printf("wdmd [options]\n\n");
printf("--version, -V print version\n");
printf("--help, -h print usage\n");
+ printf("--dump, -d print debug from daemon\n");
printf("-D debug: no fork and print all logging to stderr\n");
- printf("-H <num> use high priority features (1 yes, 0 no, default %d)\n",
+ printf("-H 0|1 use high priority features (1 yes, 0 no, default %d)\n",
DEFAULT_HIGH_PRIORITY);
- printf("-G <groupname> group ownership for the socket\n");
+ printf("-G <name> group ownership for the socket\n");
+ printf("-S 0|1 allow script tests (default %d)\n", allow_scripts);
+ printf("-s <path> path to scripts dir (default %s)\n", scripts_dir);
+ printf("-k <num> kill unfinished scripts after num seconds (default %d)\n",
+ kill_script_sec);
exit(status);
}
static void print_version_and_exit(void)
{
- printf("wdmd version %s tests_built%s%s%s\n", RELEASE_VERSION,
- scripts_built ? scripts_built : "",
- client_built ? client_built : "",
- files_built ? files_built : "");
+ printf("wdmd version %s\n", RELEASE_VERSION);
exit(0);
}
@@ -1089,24 +1349,18 @@ int main(int argc, char *argv[])
{
int rv;
- /*
- * TODO:
- * -c <num> enable test clients (1 yes, 0 no, default ...)
- * -s <num> enable test scripts (1 yes, 0 no, default ...)
- * -f <num> enable test files (1 yes, 0 no, default ...)
- */
-
while (1) {
int c;
int option_index = 0;
static struct option long_options[] = {
{"help", no_argument, 0, 'h' },
+ {"dump", no_argument, 0, 'd' },
{"version", no_argument, 0, 'V' },
{0, 0, 0, 0 }
};
- c = getopt_long(argc, argv, "hVDH:G:",
+ c = getopt_long(argc, argv, "hdVDH:G:S:s:k:",
long_options, &option_index);
if (c == -1)
break;
@@ -1115,6 +1369,9 @@ int main(int argc, char *argv[])
case 'h':
print_usage_and_exit(0);
break;
+ case 'd':
+ print_debug_and_exit();
+ break;
case 'V':
print_version_and_exit();
break;
@@ -1127,6 +1384,15 @@ int main(int argc, char *argv[])
case 'H':
high_priority = atoi(optarg);
break;
+ case 'S':
+ allow_scripts = atoi(optarg);
+ break;
+ case 's':
+ scripts_dir = strdup(optarg);
+ break;
+ case 'k':
+ kill_script_sec = atoi(optarg);
+ break;
}
}
@@ -1139,10 +1405,7 @@ int main(int argc, char *argv[])
openlog("wdmd", LOG_CONS | LOG_PID, LOG_DAEMON);
- log_error("wdmd started tests_built%s%s%s\n",
- scripts_built ? scripts_built : "",
- client_built ? client_built : "",
- files_built ? files_built : "");
+ log_error("wdmd started allow_scripts %d", allow_scripts);
setup_priority();
diff --git a/wdmd/sysconfig.wdmd b/wdmd/sysconfig.wdmd
new file mode 100644
index 0000000..06a13db
--- /dev/null
+++ b/wdmd/sysconfig.wdmd
@@ -0,0 +1,8 @@
+# WDMDOPTS -- set the command line options for the wdmd daemon
+# See wdmd man page for full list of command line options.
+#
+# Include "-G sanlock" in the option string.
+#
+# To enable use of test scripts
+#WDMDOPTS="-G sanlock -S 1"
+
diff --git a/wdmd/wdmd.8 b/wdmd/wdmd.8
index 2df7297..7e11562 100644
--- a/wdmd/wdmd.8
+++ b/wdmd/wdmd.8
@@ -14,7 +14,7 @@ detmermine whether each KEEPALIVE is done. Every test interval (10
seconds), the daemon tests each source. If any test fails, the KEEPALIVE
is not done. In a standard configuration, the watchdog timer will reset
the system if no KEEPALIVE is done for 60 seconds ("fire timeout"). This
-means that if single test fails 5-6 times in row, the watchdog will fire
+means that if a single test fails 5-6 times in row, the watchdog will fire
and reset the system. With multiple test sources, fewer separate failures
back to back can also cause a reset, e.g.
@@ -45,7 +45,8 @@ guaranteed to fire, regardless of whether other sources on the system have
passed or failed. A spurious reset due to the combined effects of
multiple failing tests as shown above, is an accepted side effect.
-wdmd will exit if a watchdog driver is not loaded.
+The wdmd init script will load the softdog module if no other watchdog
+module has been loaded.
wdmd cannot be used on the system with any other program that needs to
open /dev/watchdog, e.g. watchdog(8).
@@ -57,18 +58,49 @@ regular messages to wdmd to update an expiry time for their connection.
Every test interval, wdmd will check if the expiry time for a connection
has been reached. If so, the test for that client fails.
-(Other test sources such as scripts executed each test interval may be
-added in the future.)
+.SS Test Source: scripts
+
+wdmd will run scripts from a designated directory every test interval.
+If a script exits with 0, the test is considered a success, otherwise
+a failure. If a script does not exit by the end of the test interval,
+it is considered a failure.
.SH OPTIONS
.TP
+.B \-\-version, \-V
+ Print version.
+
+.TP
+.B \-\-help, \-h
+ Print usage.
+
+.TP
+.B \-\-dump, \-d
+ Print debug information from the daemon.
+
+.TP
.B \-D
-Enable debugging to stderr and don't fork.
+ Enable debugging to stderr and don't fork.
.TP
-.BI \-H " num"
-Enable (1) or disable (0) high priority features such as realtime
-scheduling priority and mlockall.
-.br
-Default 1.
+.BI \-H " 0|1"
+ Enable (1) or disable (0) high priority features such as realtime
+ scheduling priority and mlockall.
+
+.TP
+.BI \-G " name"
+ Group ownership for the socket.
+
+.TP
+.BI \-S " 0|1"
+ Enable (1) or disable (0) script tests.
+
+.TP
+.BI \-s " path"
+ Path to scripts dir.
+
+.TP
+.BI \-k " num"
+ Kill unfinished scripts after num seconds.
+
diff --git a/wdmd/wdmd_sock.h b/wdmd/wdmd_sock.h
index 7834f6c..6818683 100644
--- a/wdmd/wdmd_sock.h
+++ b/wdmd/wdmd_sock.h
@@ -19,6 +19,7 @@ enum {
CMD_REFCOUNT_CLEAR,
CMD_TEST_LIVE,
CMD_STATUS,
+ CMD_DUMP_DEBUG,
};
struct wdmd_header {
11 years, 1 month
10 commits - python/sanlock.c src/cmd.c src/diskio.c src/log.h src/main.c src/sanlock.8 src/sanlock_internal.h
by David Teigland
python/sanlock.c | 2
src/cmd.c | 8 +-
src/diskio.c | 18 +++---
src/log.h | 18 +++++-
src/main.c | 139 ++++++++++++++++++++++++++++++++++---------------
src/sanlock.8 | 14 +++-
src/sanlock_internal.h | 6 +-
7 files changed, 144 insertions(+), 61 deletions(-)
New commits:
commit acfa6febfd0eec904fd379a1bc4bbcaa6f0d3176
Author: David Weber <wb(a)munzinger.de>
Date: Mon Oct 8 10:25:16 2012 -0500
Replace restrict field name with restricted
"restrict" is a keyword in C99 so it mustn't be used.
diff --git a/src/cmd.c b/src/cmd.c
index 1f60e04..d443e92 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -303,7 +303,7 @@ static void cmd_acquire(struct task *task, struct cmd_args *ca)
token->host_generation = spi.host_generation;
token->pid = cl_pid;
token->io_timeout = spi.io_timeout;
- if (cl->restrict & SANLK_RESTRICT_SIGKILL)
+ if (cl->restricted & SANLK_RESTRICT_SIGKILL)
token->flags |= T_RESTRICT_SIGKILL;
/* save a record of what this token_id is for later debugging */
@@ -1399,7 +1399,7 @@ static int print_state_client(struct client *cl, int ci, char *str)
"fd=%d "
"pid=%d "
"flags=%x "
- "restrict=%x "
+ "restricted=%x "
"cmd_active=%d "
"cmd_last=%d "
"pid_dead=%d "
@@ -1411,7 +1411,7 @@ static int print_state_client(struct client *cl, int ci, char *str)
cl->fd,
cl->pid,
cl->flags,
- cl->restrict,
+ cl->restricted,
cl->cmd_active,
cl->cmd_last,
cl->pid_dead,
@@ -1749,7 +1749,7 @@ static void cmd_restrict(int ci, int fd, struct sm_header *h_recv)
log_debug("cmd_restrict ci %d fd %d pid %d flags %x",
ci, fd, client[ci].pid, h_recv->cmd_flags);
- client[ci].restrict = h_recv->cmd_flags;
+ client[ci].restricted = h_recv->cmd_flags;
send_result(fd, h_recv, 0);
}
diff --git a/src/main.c b/src/main.c
index 33f90a7..87c784d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -253,7 +253,7 @@ static void _client_free(int ci)
cl->need_free = 0;
cl->kill_count = 0;
cl->kill_last = 0;
- cl->restrict = 0;
+ cl->restricted = 0;
cl->flags = 0;
memset(cl->owner_name, 0, sizeof(cl->owner_name));
memset(cl->killpath, 0, SANLK_HELPER_PATH_LEN);
@@ -631,10 +631,10 @@ static void kill_pids(struct space *sp)
* sigkill will be used in place of sigterm if restricted
*/
- if ((sig == SIGKILL) && (cl->restrict & SANLK_RESTRICT_SIGKILL))
+ if ((sig == SIGKILL) && (cl->restricted & SANLK_RESTRICT_SIGKILL))
sig = SIGTERM;
- if ((sig == SIGTERM) && (cl->restrict & SANLK_RESTRICT_SIGTERM))
+ if ((sig == SIGTERM) && (cl->restricted & SANLK_RESTRICT_SIGTERM))
sig = SIGKILL;
do_kill = 1;
@@ -1138,7 +1138,7 @@ static void process_connection(int ci)
ci, rv, h.magic, SM_MAGIC);
goto dead;
}
- if (client[ci].restrict & SANLK_RESTRICT_ALL) {
+ if (client[ci].restricted & SANLK_RESTRICT_ALL) {
log_error("ci %d fd %d pid %d cmd %d restrict all",
ci, client[ci].fd, client[ci].pid, h.cmd);
goto dead;
diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h
index 53e5866..65496ff 100644
--- a/src/sanlock_internal.h
+++ b/src/sanlock_internal.h
@@ -67,7 +67,7 @@ struct sync_disk {
* 'struct resource' keeps track of resources globally, resources list
*/
-#define T_RESTRICT_SIGKILL 0x00000001 /* inherited from client->restrict */
+#define T_RESTRICT_SIGKILL 0x00000001 /* inherited from client->restricted */
#define T_LS_DEAD 0x00000002 /* don't bother trying to release if ls is dead */
struct token {
@@ -215,7 +215,7 @@ struct client {
int need_free;
int kill_count;
uint32_t flags;
- uint32_t restrict;
+ uint32_t restricted;
uint64_t kill_last;
char owner_name[SANLK_NAME_LEN+1];
char killpath[SANLK_HELPER_PATH_LEN];
commit 5e76f09f9bcecbc9349dc3ee7faf43bcc7c1376c
Author: David Teigland <teigland(a)redhat.com>
Date: Fri Oct 5 10:13:52 2012 -0500
sanlock: print command output to stdout
instead of stderr
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/log.h b/src/log.h
index db6d275..10b8c36 100644
--- a/src/log.h
+++ b/src/log.h
@@ -50,7 +50,7 @@ void copy_log_dump(char *buf, int *len);
#define log_tool(fmt, args...) \
do { \
- fprintf(stderr, fmt "\n", ##args); \
+ printf(fmt "\n", ##args); \
} while (0)
#endif
commit d05aac412b50baee23d2a0847e1676040d2efbff
Author: David Teigland <teigland(a)redhat.com>
Date: Thu Oct 4 16:47:58 2012 -0500
sanlock: client add_lockspace with timeout
When a -o io timeout value not equal to the
default (10) is used, the command will use
the add_lockspace_timeout api.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/main.c b/src/main.c
index a0b5145..33f90a7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2177,9 +2177,16 @@ static int do_client(void)
break;
case ACT_ADD_LOCKSPACE:
- log_tool("add_lockspace");
- rv = sanlock_add_lockspace(&com.lockspace, 0);
- log_tool("add_lockspace done %d", rv);
+ if (com.io_timeout_arg != DEFAULT_IO_TIMEOUT) {
+ log_tool("add_lockspace_timeout %d", com.io_timeout_arg);
+ rv = sanlock_add_lockspace_timeout(&com.lockspace, 0,
+ com.io_timeout_arg);
+ log_tool("add_lockspace_timeout done %d", rv);
+ } else {
+ log_tool("add_lockspace");
+ rv = sanlock_add_lockspace(&com.lockspace, 0);
+ log_tool("add_lockspace done %d", rv);
+ }
break;
case ACT_INQ_LOCKSPACE:
commit da94fe800c843b467f926420ccbe9961e8289f46
Author: David Teigland <teigland(a)redhat.com>
Date: Thu Oct 4 16:26:54 2012 -0500
sanlock: fix aborted command clearing
When clearing the remainder of an aborted
command, non-blocking recv is used to avoid
blocking the main thread, but this means it
needs to do a minimal amount of retrying when
EAGAIN is returned. It wasn't retrying at all,
so the remainder of the message was handled as
a new command, which caused errors when the
fragment was found to have a bad magic number.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/main.c b/src/main.c
index 522ae6a..a0b5145 100644
--- a/src/main.c
+++ b/src/main.c
@@ -396,13 +396,22 @@ void client_recv_all(int ci, struct sm_header *h_recv, int pos)
{
char trash[64];
int rem = h_recv->length - sizeof(struct sm_header) - pos;
- int rv, error = 0, total = 0;
+ int rv, error = 0, total = 0, retries = 0;
if (!rem)
return;
while (1) {
rv = recv(client[ci].fd, trash, sizeof(trash), MSG_DONTWAIT);
+
+ if (rv == -1 && errno == EAGAIN) {
+ usleep(1000);
+ if (retries < 20) {
+ retries++;
+ continue;
+ }
+ }
+
if (rv == -1)
error = errno;
if (rv <= 0)
@@ -413,8 +422,8 @@ void client_recv_all(int ci, struct sm_header *h_recv, int pos)
break;
}
- log_debug("recv_all %d,%d,%d pos %d rv %d error %d rem %d total %d",
- ci, client[ci].fd, client[ci].pid, pos, rv, error, rem, total);
+ log_debug("recv_all %d,%d,%d pos %d rv %d error %d retries %d rem %d total %d",
+ ci, client[ci].fd, client[ci].pid, pos, rv, error, retries, rem, total);
}
void send_result(int fd, struct sm_header *h_recv, int result);
@@ -998,6 +1007,8 @@ static void process_cmd_thread_registered(int ci_in, struct sm_header *h_recv)
break;
}
if (ci_target < 0) {
+ log_error("cmd %d target pid %d not found",
+ h_recv->cmd, h_recv->data2);
result = -ESRCH;
goto fail;
}
commit 85887f4d8e22fbf57e9012ec6dccd2d17a2ff21a
Author: David Teigland <teigland(a)redhat.com>
Date: Mon Oct 1 11:47:46 2012 -0500
sanlock: update man page
to reflect recent changes
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/main.c b/src/main.c
index 46aa5ef..522ae6a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1759,8 +1759,8 @@ static void print_usage(void)
printf(" -t <num> max worker threads (%d)\n", DEFAULT_MAX_WORKER_THREADS);
printf(" -g <sec> seconds for graceful recovery (%d)\n", DEFAULT_GRACE_SEC);
printf(" -w 0|1 use watchdog through wdmd (%d)\n", DEFAULT_USE_WATCHDOG);
- printf(" -h 0|1 use high priority features (%d)\n", DEFAULT_HIGH_PRIORITY);
- printf(" (realtime scheduling, mlockall)\n");
+ printf(" -h 0|1 use high priority (RR) scheduling (%d)\n", DEFAULT_HIGH_PRIORITY);
+ printf(" -l <num> use mlockall (0 none, 1 current, 2 current and future) (2)\n");
printf(" -a 0|1 use async io (%d)\n", DEFAULT_USE_AIO);
printf(" -o 0|1 io timeout in seconds (%d)\n", DEFAULT_IO_TIMEOUT);
printf("\n");
diff --git a/src/sanlock.8 b/src/sanlock.8
index e716264..a6bf6c4 100644
--- a/src/sanlock.8
+++ b/src/sanlock.8
@@ -234,7 +234,10 @@ seconds for graceful recovery
use watchdog through wdmd
.BR -h " 0|1"
-use high priority features (realtime scheduling, mlockall)
+use high priority (RR) scheduling
+
+.BR -l " num"
+use mlockall (0 none, 1 current, 2 current and future)
.BR \-a " 0|1"
use async i/o
@@ -252,10 +255,10 @@ Print processes, lockspaces, and resources being manged by the sanlock
daemon. Add -D to show extra internal daemon status for debugging.
Add -o p to show resources by pid, or -o s to show resources by lockspace.
-.BR "sanlock client host_status -s" " LOCKSPACE"
+.B sanlock client host_status
Print state of host_id delta leases read during the last renewal.
-Only lockspace_name is used from the LOCKSPACE argument.
+State of all lockspaces is shown (use -s to select one).
Add -D to show extra internal daemon status for debugging.
.B sanlock client log_dump
@@ -491,7 +494,10 @@ take:
\fB1\fP (KILL_PID): kill the process holding the resource lease. When the
process has exited, the resource lease will be released, and can then be
-acquired by anyone.
+acquired by anyone. The kill signal is SIGKILL (or SIGTERM if SIGKILL
+is restricted.)
+
+\fB2\fP (SIGUSR1): send SIGUSR1 to the process holding the resource lease.
.SS Graceful recovery
commit cc2fd83accfd6c9389dd8adc53ec58ab5b083f82
Author: David Teigland <teigland(a)redhat.com>
Date: Fri Sep 28 14:30:27 2012 -0500
sanlock: change log level for startup and io timeouts
make daemon startup and io timeout messages a warning instead
of an error, so they are written to sanlock.log,
not /var/log/messages (which should be for real errors).
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/diskio.c b/src/diskio.c
index f187ea4..7647094 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -348,7 +348,7 @@ static struct aicb *find_callback_slot(struct task *task, int ioto)
struct aicb *ev_aicb = container_of(ev_iocb, struct aicb, iocb);
int op = ev_iocb ? ev_iocb->aio_lio_opcode : -1;
- log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld old free",
+ log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld old free",
op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2);
ev_aicb->used = 0;
free(ev_aicb->buf);
@@ -429,20 +429,20 @@ static int do_linux_aio(int fd, uint64_t offset, char *buf, int len,
ev_aicb->used = 0;
if (ev_iocb != iocb) {
- log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld other free",
+ log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld other free",
op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2);
free(ev_aicb->buf);
ev_aicb->buf = NULL;
goto retry;
}
if ((int)event.res < 0) {
- log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld match res",
+ log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld match res",
op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2);
rv = event.res;
goto out;
}
if (event.res != len) {
- log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld match len %d",
+ log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld match len %d",
op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2, len);
rv = -EMSGSIZE;
goto out;
@@ -466,7 +466,7 @@ static int do_linux_aio(int fd, uint64_t offset, char *buf, int len,
task->to_count++;
- log_taske(task, "aio timeout %d %p:%p:%p ioto %d to_count %d",
+ log_taskw(task, "aio timeout %d %p:%p:%p ioto %d to_count %d",
cmd, aicb, iocb, buf, ioto, task->to_count);
rv = io_cancel(task->aio_ctx, iocb, &event);
@@ -802,26 +802,26 @@ int read_iobuf_reap(int fd, uint64_t offset, char *iobuf, int iobuf_len,
ev_aicb->used = 0;
if (ev_iocb != iocb) {
- log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld other free r",
+ log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld other free r",
op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2);
free(ev_aicb->buf);
ev_aicb->buf = NULL;
goto retry;
}
if ((int)event.res < 0) {
- log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld match res r",
+ log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld match res r",
op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2);
rv = event.res;
goto out;
}
if (event.res != iobuf_len) {
- log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld match len %d r",
+ log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld match len %d r",
op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2, iobuf_len);
rv = -EMSGSIZE;
goto out;
}
- log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld match reap",
+ log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld match reap",
op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2);
rv = 0;
diff --git a/src/log.h b/src/log.h
index 2421597..db6d275 100644
--- a/src/log.h
+++ b/src/log.h
@@ -9,6 +9,21 @@
#ifndef __LOG_H__
#define __LOG_H__
+/*
+ * Log levels are used mainly to indicate where the message
+ * should be recorded:
+ *
+ * log_error() write to /var/log/messages and /var/log/sanlock.log
+ * log_level(WARNING) write to /var/log/sanlock.log
+ * log_debug() write to incore buffer, not to file
+ *
+ * Anything in /var/log/messages should not happen and should be reported.
+ * So anything we want to visible and reported should be LOG_ERR.
+ *
+ * If we want to log something to assist in debugging, but not be reported,
+ * it should be LOG_WARNING (goes only to sanlock.log)
+ */
+
void log_level(uint32_t space_id, uint32_t token_id, char *name_in, int level, const char *fmt, ...)
__attribute__((format(printf, 5, 6)));
@@ -27,6 +42,7 @@ void copy_log_dump(char *buf, int *len);
#define log_errst(space, token, fmt, args...) log_level(space->space_id, token->token_id, NULL, LOG_ERR, fmt, ##args)
#define log_taske(task, fmt, args...) log_level(0, 0, task->name, LOG_ERR, fmt, ##args)
+#define log_taskw(task, fmt, args...) log_level(0, 0, task->name, LOG_WARNING, fmt, ##args)
#define log_taskd(task, fmt, args...) log_level(0, 0, task->name, LOG_DEBUG, fmt, ##args)
/* use log_tool for tool actions (non-daemon), and for daemon until
diff --git a/src/main.c b/src/main.c
index eea6bb3..46aa5ef 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1625,9 +1625,8 @@ static int do_daemon(void)
setup_groups();
- log_error("sanlock daemon started %s host %s time %llu",
- RELEASE_VERSION, our_host_name_global,
- (unsigned long long)time(NULL));
+ log_level(0, 0, NULL, LOG_WARNING, "sanlock daemon started %s host %s",
+ RELEASE_VERSION, our_host_name_global);
setup_priority();
commit 3cc457d215713035cf9aa2024841184913c350d7
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Thu Sep 27 12:06:03 2012 -0400
sanlock: use signal handler for all terminating signals
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
diff --git a/src/main.c b/src/main.c
index b85eca6..eea6bb3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1242,7 +1242,9 @@ static int setup_listener(void)
return -1;
}
-static void sigterm_handler(int sig GNUC_UNUSED)
+static void sigterm_handler(int sig GNUC_UNUSED,
+ siginfo_t *info GNUC_UNUSED,
+ void *ctx GNUC_UNUSED)
{
external_shutdown = 1;
}
@@ -1438,6 +1440,25 @@ static void setup_groups(void)
free(pgroup);
}
+static void setup_signals(void)
+{
+ struct sigaction act;
+ int rv, i, sig_list[] = { SIGHUP, SIGINT, SIGTERM, 0 };
+
+ memset(&act, 0, sizeof(act));
+
+ act.sa_flags = SA_SIGINFO;
+ act.sa_sigaction = sigterm_handler;
+
+ for (i = 0; sig_list[i] != 0; i++) {
+ rv = sigaction(sig_list[i], &act, NULL);
+ if (rv < 0) {
+ log_error("cannot set the signal handler for: %i", sig_list[i]);
+ exit(EXIT_FAILURE);
+ }
+ }
+}
+
/*
* first pipe for daemon to send requests to helper; they are not acknowledged
* and the daemon does not get any result back for the requests.
@@ -1563,7 +1584,6 @@ static void helper_dead(int ci GNUC_UNUSED)
static int do_daemon(void)
{
- struct sigaction act;
int fd, rv;
/* TODO: copy comprehensive daemonization method from libvirtd */
@@ -1594,12 +1614,7 @@ static int do_daemon(void)
goto out_logging;
strcpy(client[helper_ci].owner_name, "helper");
- memset(&act, 0, sizeof(act));
- act.sa_handler = sigterm_handler;
- rv = sigaction(SIGTERM, &act, NULL);
- if (rv < 0)
- return rv;
-
+ setup_signals();
setup_logging();
fd = lockfile(SANLK_RUN_DIR, SANLK_LOCKFILE_NAME, com.uid, com.gid);
commit b08e8726c7e854921ec6d8d590c77d4e4d18c4b0
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Thu Sep 27 12:06:02 2012 -0400
python: fix the tuple parsing for py_add_lockspace
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
diff --git a/python/sanlock.c b/python/sanlock.c
index cefe3d4..e32fab3 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -288,7 +288,7 @@ py_add_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds)
memset(&ls, 0, sizeof(struct sanlk_lockspace));
/* parse python tuple */
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "sks|ki", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "sks|kIi", kwlist,
&lockspace, &ls.host_id, &path, &ls.host_id_disk.offset, &iotimeout,
&async)) {
return NULL;
commit abaf80bbf21b9c771684def60f73f3f1a287bc20
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Thu Sep 27 15:46:59 2012 -0400
sanlock: configuring the core dump output
All the setrlimit calls have been moved to a new setup_limits function
that is called regardless the presence of the -U and -G options.
The new RLIMIT_CORE limit is set to allow the core dump to be written
in case of a crash (for more details: man core).
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
diff --git a/src/main.c b/src/main.c
index 9645e3e..b85eca6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,6 +24,7 @@
#include <pwd.h>
#include <grp.h>
#include <sys/types.h>
+#include <sys/prctl.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/socket.h>
@@ -1328,19 +1329,10 @@ static void setup_host_name(void)
uuid, name.nodename);
}
-static void setup_groups(void)
+static void setup_limits(void)
{
- int rv, i, j, h;
- int pngroups, sngroups, ngroups_max;
- gid_t *pgroup, *sgroup;
- struct rlimit rlim;
-
- if (!com.uname || !com.gname)
- return;
-
- /* before switching to a different user/group we must configure
- the limits for memlock and rtprio */
- rlim.rlim_cur = rlim.rlim_max= -1;
+ int rv;
+ struct rlimit rlim = { .rlim_cur = -1, .rlim_max= -1 };
rv = setrlimit(RLIMIT_MEMLOCK, &rlim);
if (rv < 0) {
@@ -1354,6 +1346,22 @@ static void setup_groups(void)
exit(EXIT_FAILURE);
}
+ rv = setrlimit(RLIMIT_CORE, &rlim);
+ if (rv < 0) {
+ log_error("cannot set the limits for core dumps %i", errno);
+ exit(EXIT_FAILURE);
+ }
+}
+
+static void setup_groups(void)
+{
+ int rv, i, j, h;
+ int pngroups, sngroups, ngroups_max;
+ gid_t *pgroup, *sgroup;
+
+ if (!com.uname || !com.gname)
+ return;
+
ngroups_max = sysconf(_SC_NGROUPS_MAX);
if (ngroups_max < 0) {
log_error("cannot get the max number of groups %i", errno);
@@ -1417,6 +1425,15 @@ static void setup_groups(void)
log_error("cannot set user id to %i errno %i", com.uid, errno);
}
+ /* When a program is owned by a user (group) other than the real user
+ * (group) ID of the process, the PR_SET_DUMPABLE option gets cleared.
+ * See RLIMIT_CORE in setup_limits and man 5 core.
+ */
+ rv = prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
+ if (rv < 0) {
+ log_error("cannot set dumpable process errno %i", errno);
+ }
+
out:
free(pgroup);
}
@@ -1558,6 +1575,7 @@ static int do_daemon(void)
}
}
+ setup_limits();
setup_helper();
/* main task never does disk io, so we don't really need to set
commit aff1f7713ca8f3836e1b76611b3222628f9c2b84
Author: David Teigland <teigland(a)redhat.com>
Date: Wed Sep 26 14:02:00 2012 -0500
sanlock: configurable mlockall level
-l 0 -> no mlockall
-l 1 -> mlockall(CURRENT)
-l 2 -> mlockall(CURRENT|FUTURE)
The default is now set to 1 (was 2).
CURRENT|FUTURE results in each pthread_create using
8MB of RSS for the thread stack. CURRENT alone does
not.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/main.c b/src/main.c
index dea78f7..9645e3e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1249,16 +1249,21 @@ static void sigterm_handler(int sig GNUC_UNUSED)
static void setup_priority(void)
{
struct sched_param sched_param;
- int rv;
+ int rv = 0;
- if (!com.high_priority)
- return;
+ if (com.mlock_level == 1)
+ rv = mlockall(MCL_CURRENT);
+ else if (com.mlock_level == 2)
+ rv = mlockall(MCL_CURRENT | MCL_FUTURE);
- rv = mlockall(MCL_CURRENT | MCL_FUTURE);
if (rv < 0) {
- log_error("mlockall failed: %s", strerror(errno));
+ log_error("mlockall %d failed: %s",
+ com.mlock_level, strerror(errno));
}
+ if (!com.high_priority)
+ return;
+
rv = sched_get_priority_max(SCHED_RR);
if (rv < 0) {
log_error("could not get max scheduler priority err %d", errno);
@@ -1956,6 +1961,9 @@ static int read_command_line(int argc, char *argv[])
case 'h':
com.high_priority = atoi(optionarg);
break;
+ case 'l':
+ com.mlock_level = atoi(optionarg);
+ break;
case 'o':
if (com.action == ACT_STATUS) {
com.sort_arg = *optionarg;
@@ -2386,6 +2394,7 @@ int main(int argc, char *argv[])
memset(&com, 0, sizeof(com));
com.use_watchdog = DEFAULT_USE_WATCHDOG;
com.high_priority = DEFAULT_HIGH_PRIORITY;
+ com.mlock_level = DEFAULT_MLOCK_LEVEL;
com.max_worker_threads = DEFAULT_MAX_WORKER_THREADS;
com.io_timeout_arg = DEFAULT_IO_TIMEOUT;
com.aio_arg = DEFAULT_USE_AIO;
diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h
index 2c67fc8..53e5866 100644
--- a/src/sanlock_internal.h
+++ b/src/sanlock_internal.h
@@ -239,6 +239,7 @@ EXTERN struct client *client;
#define DEFAULT_GRACE_SEC 40
#define DEFAULT_USE_WATCHDOG 1
#define DEFAULT_HIGH_PRIORITY 1
+#define DEFAULT_MLOCK_LEVEL 1 /* 1=CURRENT, 2=CURRENT|FUTURE */
#define DEFAULT_SOCKET_UID 0
#define DEFAULT_SOCKET_GID 0
#define DEFAULT_SOCKET_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
@@ -254,6 +255,7 @@ struct command_line {
int quiet_fail;
int use_watchdog;
int high_priority;
+ int mlock_level;
int max_worker_threads;
int aio_arg;
int io_timeout_arg;
11 years, 1 month
[PATCH] Replace "restrict" field name
by David Weber
Hi,
"restrict" is a keyword in C99 so it mustn't be used as a field name.
I couldn't come up with a better name, so I replaced it with
"restricted".
Reported in: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=689696
Cheers,
David
---------------------------------------------------------
commit a87f2f788b60c1efa7b813de307f1834e73a592d
Author: David Weber <wb(a)munzinger.de>
Date: Mon Oct 8 09:05:57 2012 +0200
Replace restrict field name with restricted
"restrict" is a keyword in C99 so it mustn't be used.
diff --git a/src/cmd.c b/src/cmd.c
index 1f60e04..d443e92 100644
--- a/src/cmd.c
+++ b/src/cmd.c
static void cmd_acquire(struct task *task, struct cmd_args *ca)
token->host_generation = spi.host_generation;
token->pid = cl_pid;
token->io_timeout = spi.io_timeout;
- if (cl->restrict & SANLK_RESTRICT_SIGKILL)
+ if (cl->restricted & SANLK_RESTRICT_SIGKILL)
token->flags |= T_RESTRICT_SIGKILL;
/* save a record of what this token_id is for later debugging */
static int print_state_client(struct client *cl, int ci, char *str)
"fd=%d "
"pid=%d "
"flags=%x "
- "restrict=%x "
+ "restricted=%x "
"cmd_active=%d "
"cmd_last=%d "
"pid_dead=%d "
static int print_state_client(struct client *cl, int ci, char *str)
cl->fd,
cl->pid,
cl->flags,
- cl->restrict,
+ cl->restricted,
cl->cmd_active,
cl->cmd_last,
cl->pid_dead,
static void cmd_restrict(int ci, int fd, struct sm_header *h_recv)
log_debug("cmd_restrict ci %d fd %d pid %d flags %x",
ci, fd, client[ci].pid, h_recv->cmd_flags);
- client[ci].restrict = h_recv->cmd_flags;
+ client[ci].restricted = h_recv->cmd_flags;
send_result(fd, h_recv, 0);
}
diff --git a/src/main.c b/src/main.c
index dea78f7..478e436 100644
--- a/src/main.c
+++ b/src/main.c
static void _client_free(int ci)
cl->need_free = 0;
cl->kill_count = 0;
cl->kill_last = 0;
- cl->restrict = 0;
+ cl->restricted = 0;
cl->flags = 0;
memset(cl->owner_name, 0, sizeof(cl->owner_name));
memset(cl->killpath, 0, SANLK_HELPER_PATH_LEN);
static void kill_pids(struct space *sp)
* sigkill will be used in place of sigterm if restricted
*/
- if ((sig == SIGKILL) && (cl->restrict & SANLK_RESTRICT_SIGKILL))
+ if ((sig == SIGKILL) && (cl->restricted & SANLK_RESTRICT_SIGKILL))
sig = SIGTERM;
- if ((sig == SIGTERM) && (cl->restrict & SANLK_RESTRICT_SIGTERM))
+ if ((sig == SIGTERM) && (cl->restricted & SANLK_RESTRICT_SIGTERM))
sig = SIGKILL;
do_kill = 1;
static void process_connection(int ci)
ci, rv, h.magic, SM_MAGIC);
goto dead;
}
- if (client[ci].restrict & SANLK_RESTRICT_ALL) {
+ if (client[ci].restricted & SANLK_RESTRICT_ALL) {
log_error("ci %d fd %d pid %d cmd %d restrict all",
ci, client[ci].fd, client[ci].pid, h.cmd);
goto dead;
diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h
index 2c67fc8..bce00f6 100644
--- a/src/sanlock_internal.h
+++ b/src/sanlock_internal.h
struct sync_disk {
* 'struct resource' keeps track of resources globally, resources list
*/
-#define T_RESTRICT_SIGKILL 0x00000001 /* inherited from client->restrict */
+#define T_RESTRICT_SIGKILL 0x00000001 /* inherited from client->restricted */
#define T_LS_DEAD 0x00000002 /* don't bother trying to release if ls is dead */
struct token {
struct client {
int need_free;
int kill_count;
uint32_t flags;
- uint32_t restrict;
+ uint32_t restricted;
uint64_t kill_last;
char owner_name[SANLK_NAME_LEN+1];
char killpath[SANLK_HELPER_PATH_LEN];
11 years, 1 month