python/sanlock.c
by David Teigland
python/sanlock.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
New commits:
commit fa977a9478a0478d7e7bf7781ce1a8e9b5662cd5
Author: David Teigland <teigland(a)redhat.com>
Date: Fri Mar 23 08:51:33 2012 -0500
python: fix path strncpy
and an error exit
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/python/sanlock.c b/python/sanlock.c
index cef3bff..9ece9da 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -198,7 +198,7 @@ py_init_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds)
/* prepare sanlock names */
strncpy(ls.name, lockspace, SANLK_NAME_LEN);
- strncpy(ls.host_id_disk.path, path, SANLK_PATH_LEN);
+ strncpy(ls.host_id_disk.path, path, SANLK_PATH_LEN - 1);
/* init sanlock lockspace (gil disabled) */
Py_BEGIN_ALLOW_THREADS
@@ -288,7 +288,7 @@ py_add_lockspace(PyObject *self __unused, PyObject *args)
/* prepare sanlock names */
strncpy(ls.name, lockspace, SANLK_NAME_LEN);
- strncpy(ls.host_id_disk.path, path, SANLK_PATH_LEN);
+ strncpy(ls.host_id_disk.path, path, SANLK_PATH_LEN - 1);
/* add sanlock lockspace (gil disabled) */
Py_BEGIN_ALLOW_THREADS
@@ -328,7 +328,7 @@ py_inq_lockspace(PyObject *self __unused, PyObject *args)
/* prepare sanlock names */
strncpy(ls.name, lockspace, SANLK_NAME_LEN);
- strncpy(ls.host_id_disk.path, path, SANLK_PATH_LEN);
+ strncpy(ls.host_id_disk.path, path, SANLK_PATH_LEN - 1);
/* add sanlock lockspace (gil disabled) */
Py_BEGIN_ALLOW_THREADS
@@ -370,7 +370,7 @@ py_rem_lockspace(PyObject *self __unused, PyObject *args)
/* prepare sanlock names */
strncpy(ls.name, lockspace, SANLK_NAME_LEN);
- strncpy(ls.host_id_disk.path, path, SANLK_PATH_LEN);
+ strncpy(ls.host_id_disk.path, path, SANLK_PATH_LEN - 1);
/* remove sanlock lockspace (gil disabled) */
Py_BEGIN_ALLOW_THREADS
@@ -412,17 +412,17 @@ py_acquire(PyObject *self __unused, PyObject *args, PyObject *keywds)
return NULL;
}
- /* parse and check sanlock resource */
- if (__parse_resource(disks, &res) != 0) {
- return NULL;
- }
-
/* check if any of the slkfd or pid parameters was given */
if (sanlockfd == -1 && pid == -1) {
__set_exception(EINVAL, "Invalid slkfd and pid values");
return NULL;
}
+ /* parse and check sanlock resource */
+ if (__parse_resource(disks, &res) != 0) {
+ return NULL;
+ }
+
/* prepare sanlock names */
strncpy(res->lockspace_name, lockspace, SANLK_NAME_LEN);
strncpy(res->name, resource, SANLK_NAME_LEN);
11 years, 8 months
Fwd: [libvirt-users] libvirt with sanlock
by Frido Roose
Hello,
I'm a little bit confused about the io_timeout option for sanlock. I
increased the io_timeout to 30 seconds, but it seems like the overall
initialization becomes slower now.
libvirtd is the client through the sanlock plugin.
sanlock runs as "sanlock daemon -R 1 -o 30"
Restarting sanlock + libvirtd takes about 60 seconds before libvirtd
acquires the lease (or at least, before libvirtd starts responding).
After a reboot, for some reason, this delay increases up to 360 seconds...
I have no idea why this would take longer...
The libvirtd guys don't seem to know why this happens... so I hope to find
an answer on this list... I didn't find any other timeouts that are
configurable. From the source code, it looks like most of the timeouts are
based on the io_timeout.
Best regards,
Frido
---------- Forwarded message ----------
From: Daniel P. Berrange <berrange(a)redhat.com>
Date: Tue, Mar 13, 2012 at 3:54 PM
Subject: Re: [libvirt-users] libvirt with sanlock
To: Frido Roose <fr.roose(a)gmail.com>
Cc: libvirt-users(a)redhat.com
On Tue, Mar 13, 2012 at 03:42:36PM +0100, Frido Roose wrote:
> Hello,
>
> I configured libvirtd with the sanlock lock manager plugin:
>
> # rpm -qa | egrep "libvirt-0|sanlock-[01]"
> libvirt-lock-sanlock-0.9.4-23.el6_2.4.x86_64
> sanlock-1.8-2.el6.x86_64
> libvirt-0.9.4-23.el6_2.4.x86_64
>
> # egrep -v "^#|^$" /etc/libvirt/qemu-sanlock.conf
> auto_disk_leases = 1
> disk_lease_dir = "/var/lib/libvirt/sanlock"
> host_id = 4
>
> # mount | grep sanlock
> /dev/mapper/kvm--shared-sanlock on /var/lib/libvirt/sanlock type gfs2
> (rw,noatime,hostdata=jid=0)
>
> # cat /etc/sysconfig/sanlock
> SANLOCKOPTS="-R 1 -o 30"
>
> I increased the sanlock io_timeout to 30 seconds (default = 10), because
> the sanlock dir is on a GFS2 volume and can be blocked for some time while
> fencing and journal recovery takes place.
> With the default sanlock io timeout, I get lease timeouts because IO is
> blocked:
> Mar 5 15:37:14 raiti sanlock[5858]: 3318 s1 check_our_lease warning 79
> last_success 3239
> Mar 5 15:37:15 raiti sanlock[5858]: 3319 s1 check_our_lease failed 80
>
> So far, all fine, but when I restart sanlock and libvirtd, it takes about
2
> * 30 seconds = 1 minute before libvirtd is usable. "virsh list" hangs
> during this time. I can still live with that...
> But it gets worse after a reboot, when running a "virsh list" even takes a
> couple of minutes (like about 5 minutes) before it responds. After this
> initial time, virsh is responding normally, so it looks like an
> initialization issue to me.
>
> Is this a configuration issue, a bug, or expected behavior?
Each libvirtd instance has a lease that it owns. When restarting libvirtd
it tries to acquire this lease. I don't really understand why, but sanlock
sometimes has to wait a very long time between starting & completing its
lease acquisition. You'll probably have to ask the sanlock developers for
an explanation of why
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/:|
|: http://libvirt.org -o- http://virt-manager.org:|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/:|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc:|
11 years, 9 months
Changes to 'refs/tags/sanlock-2.1'
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 (328):
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
David Weber (2):
Fix order of linking
Install another symlink to shared library
Fabio M. Di Nitto (5):
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
Federico Simoncelli (41):
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
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, 9 months
src/main.c wdmd/main.c
by David Teigland
src/main.c | 2 +-
wdmd/main.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
New commits:
commit baa3aed6fe5e9711b10153975d0c99c25f63f3f8
Author: David Teigland <teigland(a)redhat.com>
Date: Mon Mar 12 09:57:21 2012 -0500
release 2.1
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/main.c b/src/main.c
index 7222e22..8ca5d14 100644
--- a/src/main.c
+++ b/src/main.c
@@ -50,7 +50,7 @@
#include "client_cmd.h"
#include "cmd.h"
-#define RELEASE_VERSION "2.0"
+#define RELEASE_VERSION "2.1"
struct thread_pool {
int num_workers;
diff --git a/wdmd/main.c b/wdmd/main.c
index 1bd517a..18a4109 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -41,7 +41,7 @@
#define GNUC_UNUSED __attribute__((__unused__))
#endif
-#define RELEASE_VERSION "2.0"
+#define RELEASE_VERSION "2.1"
#define DEFAULT_TEST_INTERVAL 10
#define DEFAULT_FIRE_TIMEOUT 60
11 years, 9 months
2 commits - python/example.py python/sanlock.c
by David Teigland
python/example.py | 8 +++++---
python/sanlock.c | 37 ++++++++++++++++++++++++-------------
2 files changed, 29 insertions(+), 16 deletions(-)
New commits:
commit d506f7f445cf2e8106b93989ed7f24fe3c9ec881
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Wed Mar 7 16:28:01 2012 +0000
python: release leases for other processes
The python binding was lacking the support for releasing leases on
behalf of other processes.
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
diff --git a/python/example.py b/python/example.py
index 1f2f3a7..ef1c957 100644
--- a/python/example.py
+++ b/python/example.py
@@ -13,6 +13,8 @@ def main():
offset = sanlock.get_alignment(disk)
+ SNLK_DISKS = [(disk, offset)]
+
print "Registering to sanlock"
fd = sanlock.register()
@@ -20,16 +22,16 @@ def main():
sanlock.init_lockspace(LOCKSPACE_NAME, disk)
print "Initializing '%s' on '%s'" % (RESOURCE_NAME, LOCKSPACE_NAME)
- sanlock.init_resource(LOCKSPACE_NAME, RESOURCE_NAME, [(disk, offset)])
+ sanlock.init_resource(LOCKSPACE_NAME, RESOURCE_NAME, SNLK_DISKS)
print "Acquiring the id '%i' on '%s'" % (HOST_ID, LOCKSPACE_NAME)
sanlock.add_lockspace(LOCKSPACE_NAME, HOST_ID, disk)
try:
print "Acquiring '%s' on '%s'" % (RESOURCE_NAME, LOCKSPACE_NAME)
- sanlock.acquire(fd, LOCKSPACE_NAME, RESOURCE_NAME, [(disk, offset)])
+ sanlock.acquire(LOCKSPACE_NAME, RESOURCE_NAME, SNLK_DISKS, slkfd=fd)
print "Releasing '%s' on '%s'" % (RESOURCE_NAME, LOCKSPACE_NAME)
- sanlock.release(fd, LOCKSPACE_NAME, RESOURCE_NAME, [(disk, offset)])
+ sanlock.release(LOCKSPACE_NAME, RESOURCE_NAME, SNLK_DISKS, slkfd=fd)
finally:
print "Releasing the id '%i' on '%s'" % (HOST_ID, LOCKSPACE_NAME)
sanlock.rem_lockspace(LOCKSPACE_NAME, HOST_ID, disk)
diff --git a/python/sanlock.c b/python/sanlock.c
index 25791fd..cef3bff 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -452,21 +452,24 @@ exit_fail:
/* release */
PyDoc_STRVAR(pydoc_release, "\
-release(fd, lockspace, resource, disks)\n\
+release(lockspace, resource, disks [, slkfd=fd, pid=owner])\n\
Release a resource lease for the current process.\n\
The disks must be in the format: [(path, offset), ... ]");
static PyObject *
-py_release(PyObject *self __unused, PyObject *args)
+py_release(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
- int rv, sanlockfd;
+ int rv, sanlockfd = -1, pid = -1;
const char *lockspace, *resource;
struct sanlk_resource *res;
PyObject *disks;
+ static char *kwlist[] = {"lockspace", "resource", "disks", "slkfd",
+ "pid", NULL};
+
/* parse python tuple */
- if (!PyArg_ParseTuple(args, "issO!",
- &sanlockfd, &lockspace, &resource, &PyList_Type, &disks)) {
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "ssO!|ii", kwlist,
+ &lockspace, &resource, &PyList_Type, &disks, &sanlockfd, &pid)) {
return NULL;
}
@@ -481,7 +484,7 @@ py_release(PyObject *self __unused, PyObject *args)
/* release sanlock resource (gil disabled) */
Py_BEGIN_ALLOW_THREADS
- rv = sanlock_release(sanlockfd, -1, 0, 1, &res);
+ rv = sanlock_release(sanlockfd, pid, 0, 1, &res);
Py_END_ALLOW_THREADS
if (rv != 0) {
@@ -527,7 +530,8 @@ sanlock_methods[] = {
{"rem_lockspace", py_rem_lockspace, METH_VARARGS, pydoc_rem_lockspace},
{"acquire", (PyCFunction) py_acquire,
METH_VARARGS|METH_KEYWORDS, pydoc_acquire},
- {"release", py_release, METH_VARARGS, pydoc_release},
+ {"release", (PyCFunction) py_release,
+ METH_VARARGS|METH_KEYWORDS, pydoc_release},
{NULL, NULL, 0, NULL}
};
commit ea97a5f1d4f04f63f9a30985f725216ca88addf1
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Wed Mar 7 16:28:00 2012 +0000
python: add shared resource parameter to acquire
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
diff --git a/python/sanlock.c b/python/sanlock.c
index 48d75be..25791fd 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -387,26 +387,28 @@ py_rem_lockspace(PyObject *self __unused, PyObject *args)
/* acquire */
PyDoc_STRVAR(pydoc_acquire, "\
-acquire(lockspace, resource, disks [, slkfd=fd, pid=owner])\n\
+acquire(lockspace, resource, disks [, slkfd=fd, pid=owner, shared=False])\n\
Acquire a resource lease for the current process (using the slkfd argument\n\
to specify the sanlock file descriptor) or for an other process (using the\n\
-pid argument).\n\
+pid argument). If shared is True the resource will be acquired in the shared\n\
+mode.\n\
The disks must be in the format: [(path, offset), ... ]\n");
static PyObject *
py_acquire(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
- int rv, sanlockfd = -1, pid = -1;
+ int rv, sanlockfd = -1, pid = -1, shared = 0;
const char *lockspace, *resource;
struct sanlk_resource *res;
PyObject *disks;
static char *kwlist[] = {"lockspace", "resource", "disks", "slkfd",
- "pid", NULL};
+ "pid", "shared", NULL};
/* parse python tuple */
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "ssO!|ii", kwlist,
- &lockspace, &resource, &PyList_Type, &disks, &sanlockfd, &pid)) {
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "ssO!|iii", kwlist,
+ &lockspace, &resource, &PyList_Type, &disks, &sanlockfd, &pid,
+ &shared)) {
return NULL;
}
@@ -425,6 +427,11 @@ py_acquire(PyObject *self __unused, PyObject *args, PyObject *keywds)
strncpy(res->lockspace_name, lockspace, SANLK_NAME_LEN);
strncpy(res->name, resource, SANLK_NAME_LEN);
+ /* prepare sanlock flags */
+ if (shared) {
+ res->flags |= SANLK_RES_SHARED;
+ }
+
/* acquire sanlock resource (gil disabled) */
Py_BEGIN_ALLOW_THREADS
rv = sanlock_acquire(sanlockfd, pid, 0, 1, &res, 0);
11 years, 9 months
src/logrotate.sanlock
by David Teigland
src/logrotate.sanlock | 10 ++++++++++
1 file changed, 10 insertions(+)
New commits:
commit 3f49493548065114e09e5bb3f40b0a51268121ae
Author: David Teigland <teigland(a)redhat.com>
Date: Thu Mar 8 11:30:00 2012 -0600
sanlock: add a logrotate file
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/logrotate.sanlock b/src/logrotate.sanlock
new file mode 100644
index 0000000..7cf4bcb
--- /dev/null
+++ b/src/logrotate.sanlock
@@ -0,0 +1,10 @@
+/var/log/sanlock.log {
+ rotate 3
+ missingok
+ copytruncate
+ size 10M
+ compress
+ compresscmd /usr/bin/xz
+ uncompresscmd /usr/bin/unxz
+ compressext .xz
+}
11 years, 9 months
4 commits - src/cmd.c src/diskio.c src/leader.h src/lockspace.c src/main.c src/paxos_lease.c src/paxos_lease.h src/resource.c src/sanlock.h src/sanlock_internal.h src/sanlock_rv.h tests/sanlk_load.c
by David Teigland
src/cmd.c | 26 +++++++++++++--------
src/diskio.c | 4 +--
src/leader.h | 4 ++-
src/lockspace.c | 3 ++
src/main.c | 2 +
src/paxos_lease.c | 21 +++++++++++++++++
src/paxos_lease.h | 1
src/resource.c | 59 +++++++++++++++++++++++++++++++++++++++----------
src/sanlock.h | 2 -
src/sanlock_internal.h | 2 +
src/sanlock_rv.h | 1
tests/sanlk_load.c | 10 +++++---
12 files changed, 106 insertions(+), 29 deletions(-)
New commits:
commit 3c40f2a3ff23320340da2cd858ef9b4ed720b1ed
Author: David Teigland <teigland(a)redhat.com>
Date: Wed Mar 7 15:37:52 2012 -0600
sanlock: status for all shared tokens
For the status command, output a resource
once for each token so the specific pid
and token_id can be included.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/cmd.c b/src/cmd.c
index 60d36b2..7a44ce2 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1293,17 +1293,20 @@ static int print_state_lockspace(struct space *sp, char *str, const char *list_n
return strlen(str) + 1;
}
-static int print_state_resource(struct resource *r, char *str, const char *list_name)
+static int print_state_resource(struct resource *r, char *str, const char *list_name,
+ uint32_t token_id)
{
memset(str, 0, SANLK_STATE_MAXSTR);
snprintf(str, SANLK_STATE_MAXSTR-1,
"list=%s "
"flags=%x "
- "lver=%llu",
+ "lver=%llu "
+ "token_id=%u",
list_name,
r->flags,
- (unsigned long long)r->leader.lver);
+ (unsigned long long)r->leader.lver,
+ token_id);
return strlen(str) + 1;
}
@@ -1399,9 +1402,11 @@ static void send_state_lockspace(int fd, struct space *sp, const char *list_name
send(fd, &lockspace, sizeof(lockspace), MSG_NOSIGNAL);
}
-void send_state_resource(int fd, struct resource *r, const char *list_name);
+void send_state_resource(int fd, struct resource *r, const char *list_name,
+ int pid, uint32_t token_id);
-void send_state_resource(int fd, struct resource *r, const char *list_name)
+void send_state_resource(int fd, struct resource *r, const char *list_name,
+ int pid, uint32_t token_id)
{
struct sanlk_state st;
char str[SANLK_STATE_MAXSTR];
@@ -1411,11 +1416,11 @@ void send_state_resource(int fd, struct resource *r, const char *list_name)
memset(&st, 0, sizeof(st));
st.type = SANLK_STATE_RESOURCE;
- st.data32 = r->pid;
+ st.data32 = pid;
st.data64 = r->leader.lver;
strncpy(st.name, r->r.name, NAME_ID_SIZE);
- str_len = print_state_resource(r, str, list_name);
+ str_len = print_state_resource(r, str, list_name, token_id);
st.str_len = str_len;
diff --git a/src/resource.c b/src/resource.c
index 664d69e..6e6de5d 100644
--- a/src/resource.c
+++ b/src/resource.c
@@ -33,7 +33,8 @@
#include "mode_block.h"
/* from cmd.c */
-void send_state_resource(int fd, struct resource *r, const char *list_name);
+void send_state_resource(int fd, struct resource *r, const char *list_name, int pid, uint32_t token_id);
+
/* from main.c */
int get_rand(int a, int b);
@@ -50,14 +51,20 @@ static pthread_cond_t resource_cond;
void send_state_resources(int fd)
{
struct resource *r;
+ struct token *token;
pthread_mutex_lock(&resource_mutex);
- list_for_each_entry(r, &resources_held, list)
- send_state_resource(fd, r, "resources_held");
- list_for_each_entry(r, &resources_add, list)
- send_state_resource(fd, r, "resources_add");
+ list_for_each_entry(r, &resources_held, list) {
+ list_for_each_entry(token, &r->tokens, list)
+ send_state_resource(fd, r, "held", token->pid, token->token_id);
+ }
+
+ list_for_each_entry(r, &resources_add, list) {
+ list_for_each_entry(token, &r->tokens, list)
+ send_state_resource(fd, r, "add", token->pid, token->token_id);
+ }
list_for_each_entry(r, &resources_rem, list)
- send_state_resource(fd, r, "resources_rem");
+ send_state_resource(fd, r, "rem", r->pid, r->release_token_id);
pthread_mutex_unlock(&resource_mutex);
}
commit 0d816d9d14990c9f4e5f773a412569d51bab8997
Author: David Teigland <teigland(a)redhat.com>
Date: Wed Mar 7 14:10:58 2012 -0600
sanlock: retry transient sh failures
Because acquiring a shared lease includes holding
the lease in ex for a short period, multiple hosts
trying to acquire the sh lease in parallel can see
transient failures. Detect this situation and
retry the sh acquire up to eight times.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/cmd.c b/src/cmd.c
index 00fff98..60d36b2 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -306,11 +306,12 @@ static void cmd_acquire(struct task *task, struct cmd_args *ca)
/* save a record of what this token_id is for later debugging */
log_level(space.space_id, token->token_id, NULL, LOG_WARNING,
- "resource %.48s:%.48s:%.256s:%llu for %d,%d,%d",
+ "resource %.48s:%.48s:%.256s:%llu%s for %d,%d,%d",
token->r.lockspace_name,
token->r.name,
token->r.disks[0].path,
(unsigned long long)token->r.disks[0].offset,
+ (token->acquire_flags & SANLK_RES_SHARED) ? ":SH" : "",
cl_ci, cl_fd, cl_pid);
}
diff --git a/src/leader.h b/src/leader.h
index cd0dc56..0575255 100644
--- a/src/leader.h
+++ b/src/leader.h
@@ -42,10 +42,12 @@
#define LEADER_CHECKSUM_LEN 168
#define LEASE_FREE 0
+#define LFL_SHORT_HOLD 0x00000001
+
struct leader_record {
uint32_t magic;
uint32_t version;
- uint32_t unused0;
+ uint32_t flags;
uint32_t sector_size;
uint64_t num_hosts;
uint64_t max_hosts;
diff --git a/src/main.c b/src/main.c
index af82320..7222e22 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1892,6 +1892,7 @@ static int do_direct(void)
log_tool("read_leader done %d", rv);
log_tool("magic 0x%0x", leader.magic);
log_tool("version 0x%x", leader.version);
+ log_tool("flags 0x%x", leader.flags);
log_tool("sector_size %u", leader.sector_size);
log_tool("num_hosts %llu",
(unsigned long long)leader.num_hosts);
@@ -2006,6 +2007,7 @@ int main(int argc, char *argv[])
com.uid = DEFAULT_SOCKET_UID;
com.gid = DEFAULT_SOCKET_GID;
com.pid = -1;
+ com.sh_retries = DEFAULT_SH_RETRIES;
memset(&main_task, 0, sizeof(main_task));
diff --git a/src/paxos_lease.c b/src/paxos_lease.c
index e6e1aa4..a52c085 100644
--- a/src/paxos_lease.c
+++ b/src/paxos_lease.c
@@ -1276,6 +1276,7 @@ int paxos_lease_acquire(struct task *task,
(unsigned long long)host_id_leader.owner_generation,
(unsigned long long)host_id_leader.timestamp);
}
+ memcpy(leader_ret, &cur_leader, sizeof(struct leader_record));
error = SANLK_ACQUIRE_IDLIVE;
goto out;
}
@@ -1391,6 +1392,7 @@ int paxos_lease_acquire(struct task *task,
(unsigned long long)tmp_leader.owner_generation,
(unsigned long long)tmp_leader.timestamp);
+ memcpy(leader_ret, &tmp_leader, sizeof(struct leader_record));
error = SANLK_ACQUIRE_OWNED;
}
goto out;
@@ -1456,6 +1458,23 @@ int paxos_lease_acquire(struct task *task,
if (new_num_hosts)
new_leader.num_hosts = new_num_hosts;
+
+ if (new_leader.owner_id == token->host_id) {
+ /*
+ * The LFL_SHORT_HOLD flag is just a "hint" to help
+ * other nodes be more intelligent about retrying
+ * due to transient failures when acquiring shared
+ * leases. Only modify SHORT_HOLD if we're commiting
+ * ourself as the new owner. If we're commiting another
+ * host as owner, we don't know if they are acquiring
+ * shared or not.
+ */
+ if (flags & PAXOS_ACQUIRE_SHARED)
+ new_leader.flags |= LFL_SHORT_HOLD;
+ else
+ new_leader.flags &= ~LFL_SHORT_HOLD;
+ }
+
new_leader.checksum = leader_checksum(&new_leader);
error = write_new_leader(task, token, &new_leader, "paxos_acquire");
@@ -1471,6 +1490,7 @@ int paxos_lease_acquire(struct task *task,
(unsigned long long)new_leader.owner_generation,
(unsigned long long)new_leader.timestamp);
+ memcpy(leader_ret, &new_leader, sizeof(struct leader_record));
error = SANLK_ACQUIRE_OTHER;
goto out;
}
@@ -1590,6 +1610,7 @@ int paxos_lease_release(struct task *task,
leader.write_id = token->host_id;
leader.write_generation = token->host_generation;
leader.write_timestamp = monotime();
+ leader.flags &= ~LFL_SHORT_HOLD;
leader.checksum = leader_checksum(&leader);
error = write_new_leader(task, token, &leader, "paxos_release");
diff --git a/src/paxos_lease.h b/src/paxos_lease.h
index 5f71ba4..6e7e833 100644
--- a/src/paxos_lease.h
+++ b/src/paxos_lease.h
@@ -11,6 +11,7 @@
#define PAXOS_ACQUIRE_FORCE 0x00000001
#define PAXOS_ACQUIRE_QUIET_FAIL 0x00000002
+#define PAXOS_ACQUIRE_SHARED 0x00000004
uint32_t leader_checksum(struct leader_record *lr);
diff --git a/src/resource.c b/src/resource.c
index bb4f787..664d69e 100644
--- a/src/resource.c
+++ b/src/resource.c
@@ -34,6 +34,8 @@
/* from cmd.c */
void send_state_resource(int fd, struct resource *r, const char *list_name);
+/* from main.c */
+int get_rand(int a, int b);
static pthread_t resource_pt;
static int resource_thread_stop;
@@ -292,6 +294,9 @@ static int acquire_disk(struct task *task, struct token *token,
if (com.quiet_fail)
flags |= PAXOS_ACQUIRE_QUIET_FAIL;
+ if (token->acquire_flags & SANLK_RES_SHARED)
+ flags |= PAXOS_ACQUIRE_SHARED;
+
memset(&leader_tmp, 0, sizeof(leader_tmp));
rv = paxos_lease_acquire(task, token, flags, &leader_tmp, acquire_lver,
@@ -301,11 +306,9 @@ static int acquire_disk(struct task *task, struct token *token,
(unsigned long long)leader_tmp.lver,
(unsigned long long)leader_tmp.timestamp);
- if (rv < 0)
- return rv;
-
memcpy(leader, &leader_tmp, sizeof(struct leader_record));
- return rv; /* SANLK_OK */
+
+ return rv; /* SANLK_RV */
}
/* return < 0 on error, 1 on success */
@@ -526,7 +529,9 @@ int acquire_token(struct task *task, struct token *token)
struct resource *r;
uint64_t acquire_lver = 0;
uint32_t new_num_hosts = 0;
- int rv, live_count = 0;
+ int sh_retries = 0;
+ int live_count = 0;
+ int rv;
if (token->acquire_flags & SANLK_RES_LVER)
acquire_lver = token->acquire_lver;
@@ -589,8 +594,29 @@ int acquire_token(struct task *task, struct token *token)
copy_disks(&r->r.disks, &token->r.disks, token->r.num_disks);
+ retry:
+ memset(&leader, 0, sizeof(struct leader_record));
+
rv = acquire_disk(task, token, acquire_lver, new_num_hosts, &leader);
if (rv < 0) {
+ if ((token->acquire_flags & SANLK_RES_SHARED) &&
+ (leader.flags & LFL_SHORT_HOLD)) {
+ /*
+ * Multiple parallel sh requests can fail because
+ * the lease is briefly held in ex mode. The ex
+ * holder sets SHORT_HOLD in the leader record to
+ * indicate that it's only held for a short time
+ * while acquiring a shared lease. A retry will
+ * probably succeed.
+ */
+ if (sh_retries++ < com.sh_retries) {
+ int us = get_rand(0, 1000000);
+ log_token(token, "acquire_token sh_retry %d %d", rv, us);
+ usleep(us);
+ goto retry;
+ }
+ rv = SANLK_ACQUIRE_SHRETRY;
+ }
release_token_opened(task, token);
return rv;
}
diff --git a/src/sanlock.h b/src/sanlock.h
index e65215d..9267c2b 100644
--- a/src/sanlock.h
+++ b/src/sanlock.h
@@ -62,7 +62,7 @@ struct sanlk_resource {
uint64_t data64; /* per-resource command-specific data */
uint32_t data32; /* per-resource command-specific data */
uint32_t unused;
- uint32_t flags;
+ uint32_t flags; /* SANLK_RES_ */
uint32_t num_disks;
/* followed by num_disks sanlk_disk structs */
struct sanlk_disk disks[0];
diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h
index 1ed5d98..4565855 100644
--- a/src/sanlock_internal.h
+++ b/src/sanlock_internal.h
@@ -518,6 +518,7 @@ EXTERN struct client *client;
#define DEFAULT_SOCKET_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
#define DEFAULT_MIN_WORKER_THREADS 2
#define DEFAULT_MAX_WORKER_THREADS 8
+#define DEFAULT_SH_RETRIES 8
struct command_line {
int type; /* COM_ */
@@ -539,6 +540,7 @@ struct command_line {
int num_hosts; /* -n */
int max_hosts; /* -m */
int res_count;
+ int sh_retries;
uint32_t force_mode;
char our_host_name[SANLK_NAME_LEN+1];
char *dump_path;
diff --git a/src/sanlock_rv.h b/src/sanlock_rv.h
index 60f90c8..95234c7 100644
--- a/src/sanlock_rv.h
+++ b/src/sanlock_rv.h
@@ -45,6 +45,7 @@
#define SANLK_ACQUIRE_IDLIVE -243
#define SANLK_ACQUIRE_OWNED -244
#define SANLK_ACQUIRE_OTHER -245
+#define SANLK_ACQUIRE_SHRETRY -246
#define SANLK_RELEASE_LVER -250
#define SANLK_RELEASE_OWNER -251
commit f5d100e46d5c97ac2ed5632c11e89df30039d5fc
Author: David Teigland <teigland(a)redhat.com>
Date: Mon Mar 5 14:24:17 2012 -0600
sanlock: fix inquire state string
If the first entry of the token array was null
(due to a release), the inquire state string
would have a leading space.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/cmd.c b/src/cmd.c
index b4f356d..00fff98 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -654,7 +654,7 @@ static void cmd_inquire(struct task *task, struct cmd_args *ca)
goto done;
}
- if (i)
+ if (cat_count)
strcat(state, " ");
strcat(state, str);
cat_count++;
diff --git a/tests/sanlk_load.c b/tests/sanlk_load.c
index 7f4da37..cc511f2 100644
--- a/tests/sanlk_load.c
+++ b/tests/sanlk_load.c
@@ -165,7 +165,10 @@ static void dump_inquire_state(int pid, char *state)
for (i = 0; i < len; i++) {
if (state[i] == ' ') {
state[i] = '\0';
- log_debug("%d %s", pid, p);
+ if (!i)
+ log_debug("%d leading space", pid);
+ else
+ log_debug("%d %s", pid, p);
p = state + i + 1;
}
}
@@ -227,8 +230,6 @@ static int check_lock_state(int pid, int result, int count, char *res_state)
if ((found_count != count) || bad_count)
goto fail;
- if (res_state)
- free(res_state);
return 0;
fail:
@@ -472,6 +473,9 @@ static void inquire_all(int pid, int fd)
if (count && debug_verbose)
dump_inquire_state(pid, state);
+
+ if (state)
+ free(state);
}
int do_rand_child(void)
commit 2dffb14a90e9e9fee4fc91a85d7ddc795e0228d3
Author: David Teigland <teigland(a)redhat.com>
Date: Mon Mar 5 13:54:41 2012 -0600
sanlock: clean up warnings
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/cmd.c b/src/cmd.c
index 8845260..b4f356d 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1061,7 +1061,7 @@ static void cmd_init_lockspace(struct task *task, struct cmd_args *ca)
static void cmd_init_resource(struct task *task, struct cmd_args *ca)
{
- struct token *token;
+ struct token *token = NULL;
struct sanlk_resource res;
int token_len, disks_len;
int j, fd, rv, result;
diff --git a/src/diskio.c b/src/diskio.c
index 32f1b86..ec702f9 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -112,7 +112,7 @@ int open_disks_fd(struct sync_disk *disks, int num_disks)
{
struct sync_disk *disk;
int num_opens = 0;
- int d, fd, rv;
+ int d, fd, rv = -1;
for (d = 0; d < num_disks; d++) {
disk = &disks[d];
@@ -217,7 +217,7 @@ int open_disks(struct sync_disk *disks, int num_disks)
{
struct sync_disk *disk;
int num_opens = 0;
- int d, err, rv;
+ int d, err, rv = -1;
uint32_t ss = 0;
for (d = 0; d < num_disks; d++) {
diff --git a/src/lockspace.c b/src/lockspace.c
index 812264b..3432555 100644
--- a/src/lockspace.c
+++ b/src/lockspace.c
@@ -396,6 +396,7 @@ static void *lockspace_thread(void *arg_in)
if (rv < 0) {
log_erros(sp, "open_disk %s error %d", sp->host_id_disk.path, rv);
acquire_result = -ENODEV;
+ delta_result = -1;
goto set_status;
}
opened = 1;
@@ -404,12 +405,14 @@ static void *lockspace_thread(void *arg_in)
if (sp->align_size < 0) {
log_erros(sp, "direct_align error");
acquire_result = sp->align_size;
+ delta_result = -1;
goto set_status;
}
sp->lease_status.renewal_read_buf = malloc(sp->align_size);
if (!sp->lease_status.renewal_read_buf) {
acquire_result = -ENOMEM;
+ delta_result = -1;
goto set_status;
}
diff --git a/src/resource.c b/src/resource.c
index ba2dcb6..bb4f787 100644
--- a/src/resource.c
+++ b/src/resource.c
@@ -370,8 +370,10 @@ static int _release_token(struct task *task, struct token *token, int opened, in
goto out;
}
- if (nodisk)
+ if (nodisk) {
+ rv = SANLK_OK;
goto out;
+ }
if (!opened) {
rv = open_disks_fd(token->disks, token->r.num_disks);
11 years, 9 months
Changes to 'refs/tags/sanlock-2.0'
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 (322):
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
David Weber (2):
Fix order of linking
Install another symlink to shared library
Fabio M. Di Nitto (5):
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
Federico Simoncelli (39):
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
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, 9 months
3 commits - src/main.c src/resource.c src/sanlock.8 wdmd/main.c
by David Teigland
src/main.c | 2 +-
src/resource.c | 8 ++++++--
src/sanlock.8 | 2 +-
wdmd/main.c | 2 +-
4 files changed, 9 insertions(+), 5 deletions(-)
New commits:
commit 2337dc701058058e588b4aa28ca18cc61c44f267
Author: David Teigland <teigland(a)redhat.com>
Date: Fri Mar 2 15:13:24 2012 -0600
release 2.0
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/main.c b/src/main.c
index 290f65d..af82320 100644
--- a/src/main.c
+++ b/src/main.c
@@ -50,7 +50,7 @@
#include "client_cmd.h"
#include "cmd.h"
-#define RELEASE_VERSION "1.9"
+#define RELEASE_VERSION "2.0"
struct thread_pool {
int num_workers;
diff --git a/wdmd/main.c b/wdmd/main.c
index 6a3815e..1bd517a 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -41,7 +41,7 @@
#define GNUC_UNUSED __attribute__((__unused__))
#endif
-#define RELEASE_VERSION "1.9"
+#define RELEASE_VERSION "2.0"
#define DEFAULT_TEST_INTERVAL 10
#define DEFAULT_FIRE_TIMEOUT 60
commit f8dc878ba2d813969c7565f489be8255414f5b30
Author: David Teigland <teigland(a)redhat.com>
Date: Fri Mar 2 15:10:20 2012 -0600
sanlock man page: mention SH
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/sanlock.8 b/src/sanlock.8
index fd8accb..5a2fb7c 100644
--- a/src/sanlock.8
+++ b/src/sanlock.8
@@ -431,7 +431,7 @@ RESOURCE option string with version
.BR \-r " " \fIlockspace_name\fP:\fIresource_name\fP:\fIpath\fP:\fIoffset\fP:\fIlver\fP
.P
-.IR lver " leader version"
+.IR lver " leader version or SH for shared lease"
.SS Defaults
commit 6214f2e1b4e3ab0d9c33ac9fe4d8c3160f309711
Author: David Teigland <teigland(a)redhat.com>
Date: Fri Mar 2 15:07:12 2012 -0600
sanlock: set sector_size in shared tokens
New tokens on existing shared resources need to
have sector_size set in the disk since they aren't
opened. release will expect the sector_size to be set.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/resource.c b/src/resource.c
index 7032e6d..ba2dcb6 100644
--- a/src/resource.c
+++ b/src/resource.c
@@ -147,6 +147,8 @@ static int set_mode_block(struct task *task, struct token *token,
disk = &token->disks[0];
iobuf_len = disk->sector_size;
+ if (!iobuf_len)
+ return -EINVAL;
p_iobuf = &iobuf;
@@ -199,6 +201,8 @@ static int read_mode_block(struct task *task, struct token *token,
disk = &token->disks[0];
iobuf_len = disk->sector_size;
+ if (!iobuf_len)
+ return -EINVAL;
p_iobuf = &iobuf;
@@ -323,8 +327,7 @@ static int release_disk(struct task *task, struct token *token,
return rv; /* SANLK_OK */
}
-static int _release_token(struct task *task, struct token *token, int opened,
- int nodisk)
+static int _release_token(struct task *task, struct token *token, int opened, int nodisk)
{
struct resource *r = token->resource;
uint64_t lver;
@@ -550,6 +553,7 @@ int acquire_token(struct task *task, struct token *token)
if (r && (token->acquire_flags & SANLK_RES_SHARED) && (r->flags & R_SHARED)) {
/* multiple shared holders allowed */
log_token(token, "acquire_token add shared");
+ copy_disks(&token->r.disks, &r->r.disks, token->r.num_disks);
token->resource = r;
list_add(&token->list, &r->tokens);
pthread_mutex_unlock(&resource_mutex);
11 years, 9 months
invalid lockspace found
by Frido Roose
Hello,
I'm not sure if this is the appropriate place to ask, but we're running
libvirtd with the sanlock plugin.
Ater a while, I noticed the following in the sanlock logfile after I
couldn't create a new VM:
838555 sanlock daemon started aio 1 10 renew 20 80 host
144ce1f8-ddf7-4139-8e97-291aeddd7b81.arqua time 1330086549
838556 s1 lockspace
__LIBVIRT__DISKS__:13:/var/lib/libvirt/sanlock/__LIBVIRT__DISKS__:0
838616 s1:r1 resource
__LIBVIRT__DISKS__:7cf11c7a5da5d530521646d738636e84:/var/lib/libvirt/sanlock/7cf11c7a5da5d530521646d738636e84:0
for 1,9,31377
838632 s1:r2 resource
__LIBVIRT__DISKS__:b2ad1e0874ba7c316cc848d3e0a98439:/var/lib/libvirt/sanlock/b2ad1e0874ba7c316cc848d3e0a98439:0
for 2,12,31499
839477 s1 check_our_lease warning 60 last_success 839417
839478 s1 check_our_lease warning 61 last_success 839417
839479 s1 check_our_lease warning 62 last_success 839417
839480 s1 check_our_lease warning 63 last_success 839417
839481 s1 check_our_lease warning 64 last_success 839417
839482 s1 check_our_lease warning 65 last_success 839417
839483 s1 check_our_lease warning 66 last_success 839417
839484 s1 check_our_lease warning 67 last_success 839417
839485 s1 check_our_lease warning 68 last_success 839417
839486 s1 check_our_lease warning 69 last_success 839417
839487 s1 check_our_lease warning 70 last_success 839417
839488 s1 check_our_lease warning 71 last_success 839417
839489 s1 check_our_lease warning 72 last_success 839417
839490 s1 check_our_lease warning 73 last_success 839417
839491 s1 check_our_lease warning 74 last_success 839417
839492 s1 check_our_lease warning 75 last_success 839417
839493 s1 check_our_lease warning 76 last_success 839417
839494 s1 check_our_lease warning 77 last_success 839417
839495 s1 check_our_lease warning 78 last_success 839417
839496 s1 check_our_lease warning 79 last_success 839417
839497 s1 check_our_lease failed 80
841667 s1 renewed 841667 delta_length 2229 too long
841671 r3 cmd_acquire 1,9,7234 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
841672 r4 cmd_acquire 2,10,7268 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
841674 r5 cmd_acquire 2,10,7765 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
841675 r6 cmd_acquire 1,9,7735 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
842012 r7 cmd_acquire 1,9,8495 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
842013 r8 cmd_acquire 1,9,8622 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
842015 r9 cmd_acquire 1,9,9130 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
842016 r10 cmd_acquire 1,9,9241 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
842019 r11 cmd_acquire 1,9,9669 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
842020 r12 cmd_acquire 2,10,9697 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
842021 r13 cmd_acquire 1,9,10146 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
842022 r14 cmd_acquire 1,9,10240 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
842115 r15 cmd_acquire 1,9,10755 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
842117 r16 cmd_acquire 1,9,11008 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
842410 r17 cmd_acquire 1,9,11511 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
842410 r18 cmd_acquire 1,9,11616 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
843609 r19 cmd_acquire 1,9,12835 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
843616 r20 cmd_acquire 1,9,13093 invalid lockspace found -1 failed 0 name
__LIBVIRT__DISKS__
So for some reason, the lockspace became invalid (and it looks like the
host lease was not renewed).
Running sanlock-1.8-2.el6.x86_64.
Anything else I can check?
Best regards,
Frido
11 years, 9 months