Changes to 'refs/tags/sanlock-3.0.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 (427):
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
fix systemd service files
wdmd: use mode 775 for run dir
sanlock: clean up daemon exit error path
sanlock: read and write apis for lockspace and resource
sanlock: new get_lockspaces api
sanlock: get_lockspaces count only
sanlock: make get_lockspaces allocate space for data
wdmd: dynamically select working watchdog device
fence_sanlock: fix man page name of path arg
sanlock: shutdown or rem_lockspace should SIGKILL
sanlock: fix usage output typos
release 2.7
sanlock: add request killpath
sanlock/fence_sanlock: request modes FORCE and GRACEFUL
sanlock: update request types in man page
sanlock: add get_hosts api
sanlock: remove direct read_id and live_id
sanlock: add read_resource_owners
sanlock: add test_resource_owners
sanlock: add flag SANLK_REQUEST_NEXT_LVER
sanlock: improve check of max_hosts and num_hosts
sanlock: add a comment
test: add another test program
sanlock: check for null arg in sanlock_request
release 2.8
sanlock: add lvb feature
sanlock: add SANLK_REL_RENAME
release 3.0.0
sanlock: free hss on error
sanlock: reinit hss in loop
sanlock: fix read_lockspace name comparison
sanlock: initialize owner_id
sanlock: initialize send_len and send_buf
release 3.0.1
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 (76):
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
systemd: add wdmd dependency for sanlock
wdmd: trap also SIGINT for a clean exit
wdmd: make the watchdog device configurable
python: fix typo for the offset parameter
python: add write lockspace and resource
python: add read lockspace and resource
wdmd: fix miscellaneous build warnings
misc: add wdmd to gitignore
python: fix multiple issues reported by cpychecker
python: add get_lockspaces
python: use the write commands in example.py
python: add the versioning support to acquire
python: return lease version in read_resource
python: rename SANLK_LSF flags and constants macro
python: improve example with signals and exceptions
python: add the support for the resource request
python: add the get_hosts support
python: add support to read resource owners
Saggi Mizrahi (25):
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
Fix various build warnings
Tidy up some copy pasted code
Set constness in some places
Add a gitignore file
10 years, 8 months
VERSION
by David Teigland
VERSION | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit fcc8a372d421f9edaeda7fc31a6b31b8d3d13cbb
Author: David Teigland <teigland(a)redhat.com>
Date: Wed Jul 31 11:11:40 2013 -0500
release 3.0.1
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/VERSION b/VERSION
index 4a36342..cb2b00e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.0.0
+3.0.1
10 years, 8 months
5 commits - src/cmd.c src/delta_lease.c src/main.c
by David Teigland
src/cmd.c | 6 +++---
src/delta_lease.c | 2 ++
src/main.c | 6 +++++-
3 files changed, 10 insertions(+), 4 deletions(-)
New commits:
commit 686a5949e83094c7c3b51de37ada5aa700d74fe0
Author: David Teigland <teigland(a)redhat.com>
Date: Thu Jul 25 14:56:18 2013 -0500
sanlock: initialize send_len and send_buf
in read_resource_owners for error exit path
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/cmd.c b/src/cmd.c
index 39e72d5..050f595 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1400,7 +1400,7 @@ static void cmd_read_resource_owners(struct task *task, struct cmd_args *ca)
struct sanlk_resource res;
struct token *token = NULL;
char *send_buf;
- int token_len, disks_len, send_len;
+ int token_len, disks_len, send_len = 0;
int j, fd, rv, result, count = 0;
fd = client[ca->ci_in].fd;
@@ -1486,7 +1486,7 @@ static void cmd_read_resource_owners(struct task *task, struct cmd_args *ca)
h.length = sizeof(h) + sizeof(res) + send_len;
send(fd, &h, sizeof(h), MSG_NOSIGNAL);
send(fd, &res, sizeof(res), MSG_NOSIGNAL);
- if (send_len) {
+ if (send_len && send_buf) {
send(fd, send_buf, send_len, MSG_NOSIGNAL);
free(send_buf);
}
commit 6976984dbe90ff1563f1b1bd15c2107bdeb23b8b
Author: David Teigland <teigland(a)redhat.com>
Date: Thu Jul 25 14:54:13 2013 -0500
sanlock: initialize owner_id
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/cmd.c b/src/cmd.c
index da56d9d..39e72d5 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -787,7 +787,7 @@ static void cmd_request(struct task *task, struct cmd_args *ca)
struct token *token;
struct sanlk_resource res;
struct space_info spi;
- uint64_t owner_id;
+ uint64_t owner_id = 0;
uint32_t force_mode;
int token_len, disks_len;
int j, fd, rv, error, result;
commit c130ca3c8d2b1abba8719a38708b3895f6c08a8f
Author: David Teigland <teigland(a)redhat.com>
Date: Thu Jul 25 14:51:08 2013 -0500
sanlock: fix read_lockspace name comparison
when the lockspace name is specified (rather than
blank), the comparison was random.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/delta_lease.c b/src/delta_lease.c
index 19c342b..91d0a83 100644
--- a/src/delta_lease.c
+++ b/src/delta_lease.c
@@ -173,6 +173,8 @@ int delta_read_lockspace(struct task *task,
if (!ls->name[0])
space_name = leader.space_name;
+ else
+ space_name = ls->name;
error = verify_leader(disk, space_name, host_id, &leader, "read_lockspace");
commit 86fc2b926ef92cb113b7766641e487c3aa54b57b
Author: David Teigland <teigland(a)redhat.com>
Date: Thu Jul 25 14:27:25 2013 -0500
sanlock: reinit hss in loop
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/main.c b/src/main.c
index 2667263..23c27cb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2205,6 +2205,9 @@ static int do_client_gets(void)
if (!com.get_hosts)
goto next;
+ hss = NULL;
+ hss_count = 0;
+
rv = sanlock_get_hosts(ls->name, 0, &hss, &hss_count, 0);
if (rv == -EAGAIN) {
log_tool("hosts not ready");
commit 6c6e1022d75f349537bcfda43d272290307ca405
Author: David Teigland <teigland(a)redhat.com>
Date: Thu Jul 25 14:24:18 2013 -0500
sanlock: free hss on error
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/main.c b/src/main.c
index cac66ff..2667263 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2297,8 +2297,9 @@ static int do_client_read(void)
(unsigned long long)hs->generation);
hs++;
}
- free(hss);
out:
+ if (hss)
+ free(hss);
return rv;
}
10 years, 8 months
Changes to 'refs/tags/sanlock-3.0.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 (421):
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
fix systemd service files
wdmd: use mode 775 for run dir
sanlock: clean up daemon exit error path
sanlock: read and write apis for lockspace and resource
sanlock: new get_lockspaces api
sanlock: get_lockspaces count only
sanlock: make get_lockspaces allocate space for data
wdmd: dynamically select working watchdog device
fence_sanlock: fix man page name of path arg
sanlock: shutdown or rem_lockspace should SIGKILL
sanlock: fix usage output typos
release 2.7
sanlock: add request killpath
sanlock/fence_sanlock: request modes FORCE and GRACEFUL
sanlock: update request types in man page
sanlock: add get_hosts api
sanlock: remove direct read_id and live_id
sanlock: add read_resource_owners
sanlock: add test_resource_owners
sanlock: add flag SANLK_REQUEST_NEXT_LVER
sanlock: improve check of max_hosts and num_hosts
sanlock: add a comment
test: add another test program
sanlock: check for null arg in sanlock_request
release 2.8
sanlock: add lvb feature
sanlock: add SANLK_REL_RENAME
release 3.0.0
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 (76):
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
systemd: add wdmd dependency for sanlock
wdmd: trap also SIGINT for a clean exit
wdmd: make the watchdog device configurable
python: fix typo for the offset parameter
python: add write lockspace and resource
python: add read lockspace and resource
wdmd: fix miscellaneous build warnings
misc: add wdmd to gitignore
python: fix multiple issues reported by cpychecker
python: add get_lockspaces
python: use the write commands in example.py
python: add the versioning support to acquire
python: return lease version in read_resource
python: rename SANLK_LSF flags and constants macro
python: improve example with signals and exceptions
python: add the support for the resource request
python: add the get_hosts support
python: add support to read resource owners
Saggi Mizrahi (25):
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
Fix various build warnings
Tidy up some copy pasted code
Set constness in some places
Add a gitignore file
10 years, 8 months
VERSION
by David Teigland
VERSION | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 75aceb576a1f94891cb06a8c508605b5f368ebc5
Author: David Teigland <teigland(a)redhat.com>
Date: Wed Jul 24 13:56:29 2013 -0500
release 3.0.0
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/VERSION b/VERSION
index a4412fa..4a36342 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.8
+3.0.0
10 years, 8 months
2 commits - src/client.c src/cmd.c src/direct.c src/main.c src/paxos_lease.c src/paxos_lease.h src/resource.c src/resource.h src/sanlock_internal.h src/sanlock_resource.h src/sanlock_sock.h tests/sanlk_lvb.c tests/sanlk_rename.c
by David Teigland
src/client.c | 104 +++++++++++++++++++++++++++++
src/cmd.c | 138 +++++++++++++++++++++++++++++++++++++--
src/direct.c | 2
src/main.c | 21 ++++-
src/paxos_lease.c | 4 +
src/paxos_lease.h | 1
src/resource.c | 173 +++++++++++++++++++++++++++++++++++++++++++++----
src/resource.h | 8 +-
src/sanlock_internal.h | 2
src/sanlock_resource.h | 28 +++++++
src/sanlock_sock.h | 2
tests/sanlk_lvb.c | 125 +++++++++++++++++++++++++++++++++++
tests/sanlk_rename.c | 77 +++++++++++++++++++++
13 files changed, 659 insertions(+), 26 deletions(-)
New commits:
commit 513ed1a335be9c2803786e83d27ce24accc1c4cc
Author: David Teigland <teigland(a)redhat.com>
Date: Wed Jul 10 16:32:47 2013 -0500
sanlock: add SANLK_REL_RENAME
Used to rename a resource when releasing the lease.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/cmd.c b/src/cmd.c
index 4ca87f2..da56d9d 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -65,7 +65,7 @@ static void release_cl_tokens(struct task *task, struct client *cl)
token = cl->tokens[j];
if (!token)
continue;
- release_token(task, token);
+ release_token(task, token, NULL);
free(token);
}
}
@@ -76,7 +76,7 @@ static void release_new_tokens(struct task *task, struct token *new_tokens[],
int i;
for (i = 0; i < acquire_count; i++)
- release_token(task, new_tokens[i]);
+ release_token(task, new_tokens[i], NULL);
for (i = 0; i < alloc_count; i++)
free(new_tokens[i]);
@@ -477,6 +477,8 @@ static void cmd_release(struct task *task, struct cmd_args *ca)
struct token *token;
struct token *rem_tokens[SANLK_MAX_RESOURCES];
struct sanlk_resource res;
+ struct sanlk_resource new;
+ struct sanlk_resource *resrename = NULL;
int fd, rv, i, j, found, pid_dead;
int rem_tokens_count = 0;
int result = 0;
@@ -506,6 +508,54 @@ static void cmd_release(struct task *task, struct cmd_args *ca)
goto do_remove;
}
+ if (ca->header.cmd_flags & SANLK_REL_RENAME) {
+ rv = recv(fd, &res, sizeof(struct sanlk_resource), MSG_WAITALL);
+ if (rv != sizeof(struct sanlk_resource)) {
+ log_error("cmd_release %d,%d,%d recv res %d %d",
+ cl_ci, cl_fd, cl_pid, rv, errno);
+ result = -ENOTCONN;
+ goto do_remove;
+ }
+
+ /* second res struct has new name for first res */
+ rv = recv(fd, &new, sizeof(struct sanlk_resource), MSG_WAITALL);
+ if (rv != sizeof(struct sanlk_resource)) {
+ log_error("cmd_release %d,%d,%d recv new %d %d",
+ cl_ci, cl_fd, cl_pid, rv, errno);
+ result = -ENOTCONN;
+ goto do_remove;
+ }
+
+ found = 0;
+
+ pthread_mutex_lock(&cl->mutex);
+ for (j = 0; j < SANLK_MAX_RESOURCES; j++) {
+ token = cl->tokens[j];
+ if (!token)
+ continue;
+
+ if (memcmp(token->r.lockspace_name, res.lockspace_name, NAME_ID_SIZE))
+ continue;
+ if (memcmp(token->r.name, res.name, NAME_ID_SIZE))
+ continue;
+
+ rem_tokens[rem_tokens_count++] = token;
+ cl->tokens[j] = NULL;
+ found = 1;
+ break;
+ }
+ pthread_mutex_unlock(&cl->mutex);
+
+ if (!found) {
+ log_error("cmd_release %d,%d,%d no resource %.48s",
+ cl_ci, cl_fd, cl_pid, res.name);
+ result = -1;
+ }
+
+ resrename = &new;
+ goto do_remove;
+ }
+
/* caller is specifying specific resources to release */
for (i = 0; i < ca->header.data; i++) {
@@ -548,7 +598,7 @@ static void cmd_release(struct task *task, struct cmd_args *ca)
for (i = 0; i < rem_tokens_count; i++) {
token = rem_tokens[i];
- rv = release_token(task, token);
+ rv = release_token(task, token, resrename);
if (rv < 0)
result = rv;
free(token);
diff --git a/src/direct.c b/src/direct.c
index 63684b8..ed6cca4 100644
--- a/src/direct.c
+++ b/src/direct.c
@@ -132,7 +132,7 @@ static int do_paxos_action(int action, struct task *task, int io_timeout,
rv = paxos_lease_leader_read(task, token, &leader, "direct_release");
if (rv < 0)
break;
- rv = paxos_lease_release(task, token, &leader, leader_ret);
+ rv = paxos_lease_release(task, token, NULL, &leader, leader_ret);
break;
case ACT_READ_LEADER:
diff --git a/src/paxos_lease.c b/src/paxos_lease.c
index 69a4ed1..3b21017 100644
--- a/src/paxos_lease.c
+++ b/src/paxos_lease.c
@@ -1669,6 +1669,7 @@ int paxos_lease_renew(struct task *task,
int paxos_lease_release(struct task *task,
struct token *token,
+ struct sanlk_resource *resrename,
struct leader_record *leader_last,
struct leader_record *leader_ret)
{
@@ -1725,6 +1726,9 @@ int paxos_lease_release(struct task *task,
*/
}
+ if (resrename)
+ memcpy(leader.resource_name, resrename->name, NAME_ID_SIZE);
+
leader.timestamp = LEASE_FREE;
leader.write_id = token->host_id;
leader.write_generation = token->host_generation;
diff --git a/src/paxos_lease.h b/src/paxos_lease.h
index d924923..588cb39 100644
--- a/src/paxos_lease.h
+++ b/src/paxos_lease.h
@@ -29,6 +29,7 @@ int paxos_lease_acquire(struct task *task,
int paxos_lease_release(struct task *task,
struct token *token,
+ struct sanlk_resource *resrename,
struct leader_record *leader_last,
struct leader_record *leader_ret);
diff --git a/src/resource.c b/src/resource.c
index 2fa0752..b2a7ba1 100644
--- a/src/resource.c
+++ b/src/resource.c
@@ -556,12 +556,13 @@ static int acquire_disk(struct task *task, struct token *token,
/* return < 0 on error, 1 on success */
static int release_disk(struct task *task, struct token *token,
- struct leader_record *leader)
+ struct sanlk_resource *resrename,
+ struct leader_record *leader)
{
struct leader_record leader_tmp;
int rv;
- rv = paxos_lease_release(task, token, leader, &leader_tmp);
+ rv = paxos_lease_release(task, token, resrename, leader, &leader_tmp);
log_token(token, "release_disk rv %d", rv);
@@ -572,7 +573,9 @@ 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,
+ struct sanlk_resource *resrename,
+ int opened, int nodisk)
{
struct resource *r = token->resource;
uint64_t lver;
@@ -642,7 +645,7 @@ static int _release_token(struct task *task, struct token *token, int opened, in
if (r->flags & R_LVB_WRITE_RELEASE)
write_lvb_block(task, r, token);
- rv = release_disk(task, token, &r->leader);
+ rv = release_disk(task, token, resrename, &r->leader);
}
close_disks(token->disks, token->r.num_disks);
@@ -664,17 +667,18 @@ static int _release_token(struct task *task, struct token *token, int opened, in
static int release_token_nodisk(struct task *task, struct token *token)
{
- return _release_token(task, token, 0, 1);
+ return _release_token(task, token, NULL, 0, 1);
}
static int release_token_opened(struct task *task, struct token *token)
{
- return _release_token(task, token, 1, 0);
+ return _release_token(task, token, NULL, 1, 0);
}
-int release_token(struct task *task, struct token *token)
+int release_token(struct task *task, struct token *token,
+ struct sanlk_resource *resrename)
{
- return _release_token(task, token, 0, 0);
+ return _release_token(task, token, resrename, 0, 0);
}
/* We're releasing a token from the main thread, in which we don't want to block,
@@ -931,7 +935,7 @@ int acquire_token(struct task *task, struct token *token, uint32_t cmd_flags,
release_token_opened(task, token);
return rv;
} else {
- release_disk(task, token, &leader);
+ release_disk(task, token, NULL, &leader);
/* the token is kept, the paxos lease is released but with shared set */
goto out;
}
@@ -1195,7 +1199,7 @@ static void resource_thread_release(struct task *task, struct resource *r, struc
if (r->flags & R_LVB_WRITE_RELEASE)
write_lvb_block(task, r, tt);
- release_disk(task, tt, &r->leader);
+ release_disk(task, tt, NULL, &r->leader);
}
close_disks(tt->disks, tt->r.num_disks);
diff --git a/src/resource.h b/src/resource.h
index 25e9c58..11ea4c0 100644
--- a/src/resource.h
+++ b/src/resource.h
@@ -17,7 +17,8 @@ void check_mode_block(struct token *token, int q, char *dblock);
int acquire_token(struct task *task, struct token *token, uint32_t cmd_flags,
char *killpath, char *killargs);
-int release_token(struct task *task, struct token *token);
+int release_token(struct task *task, struct token *token,
+ struct sanlk_resource *resrename);
void release_token_async(struct token *token);
int request_token(struct task *task, struct token *token, uint32_t force_mode,
diff --git a/src/sanlock_resource.h b/src/sanlock_resource.h
index 9c6112f..f691032 100644
--- a/src/sanlock_resource.h
+++ b/src/sanlock_resource.h
@@ -31,8 +31,25 @@
/* acquire flags */
#define SANLK_ACQUIRE_LVB 0x00000001
-/* release flags */
+/*
+ * release flags
+ *
+ * SANLK_REL_ALL
+ * Release all resources held by the client.
+ * The res args are ignored.
+ *
+ * SANLK_REL_RENAME
+ * Rename the resource lease on disk when it
+ * is released. The resource is freed and
+ * renamed in a single disk operation (write
+ * to the leader record.) The first res
+ * arg is the resource to release, and the
+ * second resource arg contains the new name
+ * for the first resource.
+ */
+
#define SANLK_REL_ALL 0x00000001
+#define SANLK_REL_RENAME 0x00000002
/*
* request flags
diff --git a/tests/sanlk_rename.c b/tests/sanlk_rename.c
new file mode 100644
index 0000000..4043c3e
--- /dev/null
+++ b/tests/sanlk_rename.c
@@ -0,0 +1,77 @@
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/un.h>
+#include <sys/mount.h>
+#include <sys/signalfd.h>
+#include <inttypes.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <limits.h>
+#include <time.h>
+#include <signal.h>
+
+#include "sanlock.h"
+#include "sanlock_resource.h"
+
+/* gcc with -lsanlock */
+
+int main(int argc, char *argv[])
+{
+ char rd[sizeof(struct sanlk_resource) + sizeof(struct sanlk_disk)];
+ char rd2[sizeof(struct sanlk_resource) + sizeof(struct sanlk_disk)];
+ struct sanlk_resource *res;
+ struct sanlk_resource *res2;
+ struct sanlk_resource **res_args;
+ int fd, rv;
+
+ if (argc < 6) {
+ printf("acquire with old name, release with new name\n");
+ printf("sanlk_rename <lockspace_name> <resource_name_old> <resource_name_new> <path> <resource_offset>\n");
+ return -1;
+ }
+
+ res_args = malloc(2 * sizeof(struct sanlk_resource *));
+
+ memset(rd, 0, sizeof(rd));
+ memset(rd2, 0, sizeof(rd2));
+
+ res = (struct sanlk_resource *)&rd;
+ res2 = (struct sanlk_resource *)&rd2;
+
+ res_args[0] = res;
+ res_args[1] = res2;
+
+ strcpy(res->lockspace_name, argv[1]);
+ strcpy(res->name, argv[2]);
+ strcpy(res2->name, argv[3]);
+ res->num_disks = 1;
+ strcpy(res->disks[0].path, argv[4]);
+ res->disks[0].offset = atoi(argv[5]);
+
+ fd = sanlock_register();
+ if (fd < 0) {
+ fprintf(stderr, "register error %d\n", fd);
+ return -1;
+ }
+
+ rv = sanlock_acquire(fd, -1, 0, 1, &res, NULL);
+ if (rv < 0) {
+ fprintf(stderr, "acquire error %d\n", rv);
+ return -1;
+ }
+
+ rv = sanlock_release(fd, -1, SANLK_REL_RENAME, 2, res_args);
+ if (rv < 0) {
+ fprintf(stderr, "release error %d\n", rv);
+ return -1;
+ }
+
+ return 0;
+}
+
commit a309b0af1f5598fdea56d738c86944aa4a751df1
Author: David Teigland <teigland(a)redhat.com>
Date: Wed Jul 10 11:19:32 2013 -0500
sanlock: add lvb feature
set_lvb and get_lvb allow up to a sector size of
application specific data to be stored with a
resource lease. They are similar to the lvb
feature found in the dlm.
host 1:
sanlock_acquire(ACQUIRE_LVB, r)
application data written to lvb
sanlock_set_lvb(r, lvb)
sanlock_release(r)
The lvb data is copied to the sanlock daemon in set_lvb,
and written to the resource lease on disk in release.
host 2:
sanlock_acquire(ACQUIRE_LVB, r)
sanlock_get_lvb(r, lvb)
application data read from lvb
sanlock_release(r)
The lvb data is read by the sanlock daemon from disk
in acquire, and copied to the application in get_lvb.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/client.c b/src/client.c
index 6ecf431..3c2f5b7 100644
--- a/src/client.c
+++ b/src/client.c
@@ -1115,6 +1115,110 @@ int sanlock_examine(uint32_t flags, struct sanlk_lockspace *ls,
return rv;
}
+int sanlock_set_lvb(uint32_t flags, struct sanlk_resource *res, char *lvb, int lvblen)
+{
+ int datalen = 0;
+ int rv, fd;
+
+ if (!res || !lvb || !lvblen)
+ return -EINVAL;
+
+ datalen = sizeof(struct sanlk_resource) + lvblen;
+
+ rv = connect_socket(&fd);
+ if (rv < 0)
+ return rv;
+
+ rv = send_header(fd, SM_CMD_SET_LVB, flags, datalen, 0, 0);
+ if (rv < 0)
+ return rv;
+
+ rv = send(fd, res, sizeof(struct sanlk_resource), 0);
+ if (rv < 0) {
+ rv = -1;
+ goto out;
+ }
+
+ rv = send(fd, lvb, lvblen, 0);
+ if (rv < 0) {
+ rv = -1;
+ goto out;
+ }
+
+ rv = recv_result(fd);
+ out:
+ close(fd);
+ return rv;
+}
+
+int sanlock_get_lvb(uint32_t flags, struct sanlk_resource *res, char *lvb, int lvblen)
+{
+ struct sm_header h;
+ char *reply_data = NULL;
+ int datalen = 0;
+ int rv, fd, len;
+
+ if (!res || !lvb || !lvblen)
+ return -EINVAL;
+
+ datalen = sizeof(struct sanlk_resource);
+
+ rv = connect_socket(&fd);
+ if (rv < 0)
+ return rv;
+
+ rv = send_header(fd, SM_CMD_GET_LVB, flags, datalen, 0, 0);
+ if (rv < 0)
+ return rv;
+
+ rv = send(fd, res, sizeof(struct sanlk_resource), 0);
+ if (rv < 0) {
+ rv = -1;
+ goto out;
+ }
+
+ /* get result */
+
+ memset(&h, 0, sizeof(h));
+
+ rv = recv(fd, &h, sizeof(h), MSG_WAITALL);
+ if (rv != sizeof(h)) {
+ rv = -1;
+ goto out;
+ }
+
+ len = h.length - sizeof(h);
+ if (!len) {
+ rv = (int)h.data;
+ goto out;
+ }
+
+ reply_data = malloc(len);
+ if (!reply_data) {
+ rv = -ENOMEM;
+ goto out;
+ }
+
+ rv = recv(fd, reply_data, len, MSG_WAITALL);
+ if (rv != len) {
+ free(reply_data);
+ rv = -1;
+ goto out;
+ }
+
+ if (lvblen < len)
+ len = lvblen;
+
+ memcpy(lvb, reply_data, len);
+
+ free(reply_data);
+
+ rv = (int)h.data;
+ out:
+ close(fd);
+ return rv;
+}
+
/*
* convert from struct sanlk_resource to string with format:
* <lockspace_name>:<resource_name>:<path>:<offset>[:<path>:<offset>...]:<lver>
diff --git a/src/cmd.c b/src/cmd.c
index 3c11055..4ca87f2 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -327,7 +327,7 @@ static void cmd_acquire(struct task *task, struct cmd_args *ca)
for (i = 0; i < new_tokens_count; i++) {
token = new_tokens[i];
- rv = acquire_token(task, token, killpath, killargs);
+ rv = acquire_token(task, token, ca->header.cmd_flags, killpath, killargs);
if (rv < 0) {
switch (rv) {
case -EEXIST:
@@ -888,6 +888,80 @@ static void cmd_examine(struct task *task GNUC_UNUSED, struct cmd_args *ca)
client_resume(ca->ci_in);
}
+static void cmd_set_lvb(struct task *task GNUC_UNUSED, struct cmd_args *ca)
+{
+ struct sanlk_resource res;
+ char *lvb = NULL;
+ int lvblen, rv, fd, result;
+
+ fd = client[ca->ci_in].fd;
+
+ rv = recv(fd, &res, sizeof(struct sanlk_resource), MSG_WAITALL);
+ if (rv != sizeof(struct sanlk_resource)) {
+ log_error("cmd_set_lvb %d,%d recv %d %d", ca->ci_in, fd, rv, errno);
+ result = -ENOTCONN;
+ goto reply;
+ }
+
+ lvblen = ca->header.length - sizeof(struct sm_header) - sizeof(struct sanlk_resource);
+
+ lvb = malloc(lvblen);
+ if (!lvb) {
+ result = -ENOMEM;
+ goto reply;
+ }
+
+ rv = recv(fd, lvb, lvblen, MSG_WAITALL);
+ if (rv != lvblen) {
+ result = -ENOTCONN;
+ goto reply;
+ }
+
+ result = res_set_lvb(&res, lvb, lvblen);
+ reply:
+ if (lvb)
+ free(lvb);
+
+ send_result(fd, &ca->header, result);
+ client_resume(ca->ci_in);
+}
+
+static void cmd_get_lvb(struct task *task GNUC_UNUSED, struct cmd_args *ca)
+{
+ struct sm_header h;
+ struct sanlk_resource res;
+ char *lvb = NULL;
+ int lvblen = 0, rv, fd, result;
+
+ fd = client[ca->ci_in].fd;
+
+ rv = recv(fd, &res, sizeof(struct sanlk_resource), MSG_WAITALL);
+ if (rv != sizeof(struct sanlk_resource)) {
+ log_error("cmd_get_lvb %d,%d recv %d %d", ca->ci_in, fd, rv, errno);
+ result = -ENOTCONN;
+ goto reply;
+ }
+
+ /* if 0 then we use the sector size as lvb len */
+ lvblen = ca->header.data2;
+
+ result = res_get_lvb(&res, &lvb, &lvblen);
+ reply:
+ memcpy(&h, &ca->header, sizeof(struct sm_header));
+ h.data = result;
+ h.data2 = 0;
+ h.length = sizeof(h) + lvblen;
+
+ send(fd, &h, sizeof(h), MSG_NOSIGNAL);
+
+ if (lvb) {
+ send(fd, lvb, lvblen, MSG_NOSIGNAL);
+ free(lvb);
+ }
+
+ client_resume(ca->ci_in);
+}
+
static void cmd_add_lockspace(struct cmd_args *ca)
{
struct sanlk_lockspace lockspace;
@@ -1625,6 +1699,12 @@ void call_cmd_thread(struct task *task, struct cmd_args *ca)
case SM_CMD_KILLPATH:
cmd_killpath(task, ca);
break;
+ case SM_CMD_SET_LVB:
+ cmd_set_lvb(task, ca);
+ break;
+ case SM_CMD_GET_LVB:
+ cmd_get_lvb(task, ca);
+ break;
};
}
diff --git a/src/main.c b/src/main.c
index 5c5fb2d..cac66ff 100644
--- a/src/main.c
+++ b/src/main.c
@@ -945,8 +945,12 @@ static int thread_pool_create(int min_workers, int max_workers)
return rv;
}
-/* cmd comes from a transient client/fd set up just to pass the cmd,
- and is not being done on behalf of another registered client/fd */
+/*
+ * cmd comes from a transient client/fd set up just to pass the cmd,
+ * and is not being done on behalf of another registered client/fd.
+ * The command is processed independently of the lifetime of a specific
+ * client or the tokens held by a specific client.
+ */
static void process_cmd_thread_unregistered(int ci_in, struct sm_header *h_recv)
{
@@ -975,8 +979,15 @@ static void process_cmd_thread_unregistered(int ci_in, struct sm_header *h_recv)
close(client[ci_in].fd);
}
-/* cmd either comes from a registered client/fd,
- or is targeting a registered client/fd */
+/*
+ * cmd either comes from a registered client/fd, or is targeting a registered
+ * client/fd. The processing of the cmd is closely coordinated with the
+ * lifetime of a specific client and to tokens held by that client. Handling
+ * of the client's death or changing of the client's tokens will be serialized
+ * with the processing of this command. This means that the end of processing
+ * this command needs to check if the client failed during the command
+ * processing and handle the cleanup of the client if so.
+ */
static void process_cmd_thread_registered(int ci_in, struct sm_header *h_recv)
{
@@ -1168,6 +1179,8 @@ static void process_connection(int ci)
case SM_CMD_READ_LOCKSPACE:
case SM_CMD_READ_RESOURCE:
case SM_CMD_READ_RESOURCE_OWNERS:
+ case SM_CMD_SET_LVB:
+ case SM_CMD_GET_LVB:
rv = client_suspend(ci);
if (rv < 0)
return;
diff --git a/src/resource.c b/src/resource.c
index bb6c643..2fa0752 100644
--- a/src/resource.c
+++ b/src/resource.c
@@ -50,6 +50,13 @@ static pthread_mutex_t resource_mutex;
static pthread_cond_t resource_cond;
+static void free_resource(struct resource *r)
+{
+ if (r->lvb)
+ free(r->lvb);
+ free(r);
+}
+
void send_state_resources(int fd)
{
struct resource *r;
@@ -405,6 +412,117 @@ static int clear_dead_shared(struct task *task, struct token *token,
return rv;
}
+/* the lvb is the sector after the dblock for host_id 2000, i.e. 2002 */
+
+#define LVB_SECTOR 2002
+
+static int read_lvb_block(struct task *task, struct token *token)
+{
+ struct sync_disk *disk;
+ struct resource *r;
+ char *iobuf;
+ uint64_t offset;
+ int iobuf_len, rv;
+
+ r = token->resource;
+ disk = &token->disks[0];
+ iobuf_len = disk->sector_size;
+ iobuf = r->lvb;
+ offset = disk->offset + (LVB_SECTOR * disk->sector_size);
+
+ rv = read_iobuf(disk->fd, offset, iobuf, iobuf_len, task, token->io_timeout);
+
+ return rv;
+}
+
+static int write_lvb_block(struct task *task, struct resource *r, struct token *token)
+{
+ struct sync_disk *disk;
+ char *iobuf;
+ uint64_t offset;
+ int iobuf_len, rv;
+
+ disk = &token->disks[0];
+ iobuf_len = disk->sector_size;
+ iobuf = r->lvb;
+ offset = disk->offset + (LVB_SECTOR * disk->sector_size);
+
+ rv = write_iobuf(disk->fd, offset, iobuf, iobuf_len, task, token->io_timeout);
+
+ return rv;
+}
+
+int res_set_lvb(struct sanlk_resource *res, char *lvb, int lvblen)
+{
+ struct resource *r;
+ int rv = -ENOENT;
+
+ pthread_mutex_lock(&resource_mutex);
+ list_for_each_entry(r, &resources_held, list) {
+ if (strncmp(r->r.lockspace_name, res->lockspace_name, NAME_ID_SIZE))
+ continue;
+ if (strncmp(r->r.name, res->name, NAME_ID_SIZE))
+ continue;
+
+ if (!r->lvb) {
+ rv = -EINVAL;
+ break;
+ }
+
+ if (lvblen > r->leader.sector_size) {
+ rv = -E2BIG;
+ break;
+ }
+
+ memcpy(r->lvb, lvb, lvblen);
+ r->flags |= R_LVB_WRITE_RELEASE;
+ rv = 0;
+ break;
+ }
+ pthread_mutex_unlock(&resource_mutex);
+
+ return rv;
+}
+
+int res_get_lvb(struct sanlk_resource *res, char **lvb_out, int *lvblen)
+{
+ struct resource *r;
+ char *lvb;
+ int rv = -ENOENT;
+ int len = *lvblen;
+
+ pthread_mutex_lock(&resource_mutex);
+ list_for_each_entry(r, &resources_held, list) {
+ if (strncmp(r->r.lockspace_name, res->lockspace_name, NAME_ID_SIZE))
+ continue;
+ if (strncmp(r->r.name, res->name, NAME_ID_SIZE))
+ continue;
+
+ if (!r->lvb) {
+ rv = -EINVAL;
+ break;
+ }
+
+ if (!len)
+ len = r->leader.sector_size;
+
+ lvb = malloc(len);
+ if (!lvb) {
+ rv = -ENOMEM;
+ break;
+ }
+
+ memcpy(lvb, r->lvb, len);
+ *lvb_out = lvb;
+ *lvblen = len;
+ rv = 0;
+ break;
+ }
+ pthread_mutex_unlock(&resource_mutex);
+
+ return rv;
+}
+
/* return < 0 on error, 1 on success */
static int acquire_disk(struct task *task, struct token *token,
@@ -521,6 +639,9 @@ static int _release_token(struct task *task, struct token *token, int opened, in
if (r->flags & R_SHARED) {
rv = set_mode_block(task, token, token->host_id, 0, 0);
} else {
+ if (r->flags & R_LVB_WRITE_RELEASE)
+ write_lvb_block(task, r, token);
+
rv = release_disk(task, token, &r->leader);
}
@@ -536,7 +657,7 @@ static int _release_token(struct task *task, struct token *token, int opened, in
pthread_mutex_lock(&resource_mutex);
list_del(&r->list);
pthread_mutex_unlock(&resource_mutex);
- free(r);
+ free_resource(r);
return rv;
}
@@ -572,7 +693,7 @@ void release_token_async(struct token *token)
is dead (release will probably fail), or the
lease wasn't never acquired */
list_del(&r->list);
- free(r);
+ free_resource(r);
} else {
r->flags |= R_THREAD_RELEASE;
r->release_token_id = token->token_id;
@@ -682,13 +803,14 @@ static struct resource *new_resource(struct token *token)
return r;
}
-int acquire_token(struct task *task, struct token *token,
+int acquire_token(struct task *task, struct token *token, uint32_t cmd_flags,
char *killpath, char *killargs)
{
struct leader_record leader;
struct resource *r;
uint64_t acquire_lver = 0;
uint32_t new_num_hosts = 0;
+ int sector_size;
int sh_retries = 0;
int live_count = 0;
int rv;
@@ -756,6 +878,19 @@ int acquire_token(struct task *task, struct token *token,
copy_disks(&r->r.disks, &token->r.disks, token->r.num_disks);
+ sector_size = token->disks[0].sector_size;
+
+ if (cmd_flags & SANLK_ACQUIRE_LVB) {
+ char *iobuf, **p_iobuf;
+ p_iobuf = &iobuf;
+
+ rv = posix_memalign((void *)p_iobuf, getpagesize(), sector_size);
+ if (rv)
+ log_error("acquire_token cannot allocate lvb");
+ else
+ r->lvb = iobuf;
+ }
+
retry:
memset(&leader, 0, sizeof(struct leader_record));
@@ -818,6 +953,9 @@ int acquire_token(struct task *task, struct token *token,
}
out:
+ if (cmd_flags & SANLK_ACQUIRE_LVB)
+ read_lvb_block(task, token);
+
close_disks(token->disks, token->r.num_disks);
pthread_mutex_lock(&resource_mutex);
@@ -1054,6 +1192,9 @@ static void resource_thread_release(struct task *task, struct resource *r, struc
if (r->flags & R_SHARED) {
set_mode_block(task, tt, tt->host_id, 0, 0);
} else {
+ if (r->flags & R_LVB_WRITE_RELEASE)
+ write_lvb_block(task, r, tt);
+
release_disk(task, tt, &r->leader);
}
@@ -1062,7 +1203,7 @@ static void resource_thread_release(struct task *task, struct resource *r, struc
pthread_mutex_lock(&resource_mutex);
list_del(&r->list);
pthread_mutex_unlock(&resource_mutex);
- free(r);
+ free_resource(r);
}
static void resource_thread_examine(struct task *task, struct token *tt, int pid, uint64_t lver)
diff --git a/src/resource.h b/src/resource.h
index aa7b615..25e9c58 100644
--- a/src/resource.h
+++ b/src/resource.h
@@ -15,7 +15,7 @@ int lockspace_is_used(struct sanlk_lockspace *ls);
void check_mode_block(struct token *token, int q, char *dblock);
-int acquire_token(struct task *task, struct token *token,
+int acquire_token(struct task *task, struct token *token, uint32_t cmd_flags,
char *killpath, char *killargs);
int release_token(struct task *task, struct token *token);
void release_token_async(struct token *token);
@@ -25,6 +25,9 @@ int request_token(struct task *task, struct token *token, uint32_t force_mode,
int set_resource_examine(char *space_name, char *res_name);
+int res_set_lvb(struct sanlk_resource *res, char *lvb, int lvblen);
+int res_get_lvb(struct sanlk_resource *res, char **lvb_out, int *lvblen);
+
int read_resource_owners(struct task *task, struct token *token,
struct sanlk_resource *res,
char **send_buf, int *send_len, int *count);
diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h
index b3e34ee..f3e5877 100644
--- a/src/sanlock_internal.h
+++ b/src/sanlock_internal.h
@@ -101,6 +101,7 @@ struct token {
#define R_THREAD_RELEASE 0x00000004
#define R_RESTRICT_SIGKILL 0x00000008 /* inherited from token */
#define R_RESTRICT_SIGTERM 0x00000010 /* inherited from token */
+#define R_LVB_WRITE_RELEASE 0x00000020
struct resource {
struct list_head list;
@@ -111,6 +112,7 @@ struct resource {
int pid; /* copied from token when ex */
uint32_t flags;
uint32_t release_token_id; /* copy to temp token (tt) for log messages */
+ char *lvb;
char killpath[SANLK_HELPER_PATH_LEN]; /* copied from client */
char killargs[SANLK_HELPER_ARGS_LEN]; /* copied from client */
struct leader_record leader; /* copy of last leader_record we wrote */
diff --git a/src/sanlock_resource.h b/src/sanlock_resource.h
index 2b95d3e..9c6112f 100644
--- a/src/sanlock_resource.h
+++ b/src/sanlock_resource.h
@@ -28,6 +28,9 @@
/* killpath flags */
#define SANLK_KILLPATH_PID 0x00000001
+/* acquire flags */
+#define SANLK_ACQUIRE_LVB 0x00000001
+
/* release flags */
#define SANLK_REL_ALL 0x00000001
@@ -86,6 +89,12 @@ int sanlock_request(uint32_t flags, uint32_t force_mode,
int sanlock_examine(uint32_t flags, struct sanlk_lockspace *ls,
struct sanlk_resource *res);
+int sanlock_set_lvb(uint32_t flags, struct sanlk_resource *res,
+ char *lvb, int lvblen);
+
+int sanlock_get_lvb(uint32_t flags, struct sanlk_resource *res,
+ char *lvb, int lvblen);
+
/*
* Functions to convert between string and struct resource formats.
* All allocate space for returned data that the caller must free.
diff --git a/src/sanlock_sock.h b/src/sanlock_sock.h
index bf26b40..952eab4 100644
--- a/src/sanlock_sock.h
+++ b/src/sanlock_sock.h
@@ -42,6 +42,8 @@ enum {
SM_CMD_GET_LOCKSPACES = 22,
SM_CMD_GET_HOSTS = 23,
SM_CMD_READ_RESOURCE_OWNERS = 24,
+ SM_CMD_SET_LVB = 25,
+ SM_CMD_GET_LVB = 26,
};
struct sm_header {
diff --git a/tests/sanlk_lvb.c b/tests/sanlk_lvb.c
new file mode 100644
index 0000000..1b4eacf
--- /dev/null
+++ b/tests/sanlk_lvb.c
@@ -0,0 +1,125 @@
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/un.h>
+#include <sys/mount.h>
+#include <sys/signalfd.h>
+#include <inttypes.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <limits.h>
+#include <time.h>
+#include <signal.h>
+
+#include "sanlock.h"
+#include "sanlock_resource.h"
+
+/* gcc with -lsanlock */
+
+int main(int argc, char *argv[])
+{
+ char rd[sizeof(struct sanlk_resource) + sizeof(struct sanlk_disk)];
+ struct sanlk_resource *res;
+ char lvb[512];
+ char *filename;
+ char *act;
+ FILE *fp;
+ int fd, rv;
+ int set = 0, get = 0;
+
+ memset(lvb, 0, sizeof(lvb));
+
+ if (argc < 7) {
+ printf("read file, write it to lvb:\n");
+ printf("sanlk_lvb set <lockspace_name> <resource_name> <path> <resource_offset> <file>\n");
+ printf("\n");
+ printf("read lvb, write it to file:\n");
+ printf("sanlk_lvb get <lockspace_name> <resource_name> <path> <resource_offset> <file>\n");
+ return -1;
+ }
+
+ memset(rd, 0, sizeof(rd));
+
+ res = (struct sanlk_resource *)&rd;
+
+ act = argv[1];
+ strcpy(res->lockspace_name, argv[2]);
+ strcpy(res->name, argv[3]);
+ res->num_disks = 1;
+ strcpy(res->disks[0].path, argv[4]);
+ res->disks[0].offset = atoi(argv[5]);
+ filename = argv[6];
+
+ if (!strcmp(act, "set")) {
+ set = 1;
+ fp = fopen(filename, "r");
+ } else if (!strcmp(act, "get")) {
+ get = 1;
+ fp = fopen(filename, "w");
+ } else {
+ printf("bad action %s\n", act);
+ return -1;
+ }
+
+ if (!fp) {
+ printf("fopen failed %s\n", strerror(errno));
+ return -1;
+ }
+
+ fd = sanlock_register();
+ if (fd < 0) {
+ printf("register error %d\n", fd);
+ return -1;
+ }
+
+ rv = sanlock_acquire(fd, -1, SANLK_ACQUIRE_LVB, 1, &res, NULL);
+ if (rv < 0) {
+ printf("acquire error %d\n", rv);
+ return -1;
+ }
+
+ if (get) {
+ rv = sanlock_get_lvb(0, res, lvb, sizeof(lvb));
+ if (rv < 0) {
+ printf("get_lvb error %d\n", rv);
+ return -1;
+ }
+
+ fwrite(lvb, sizeof(lvb), 1, fp);
+ if (ferror(fp)) {
+ printf("fwrite error\n");
+ return -1;
+ }
+
+ }
+
+ if (set) {
+ fread(lvb, sizeof(lvb), 1, fp);
+ if (ferror(fp)) {
+ printf("fread error\n");
+ return -1;
+ }
+
+ rv = sanlock_set_lvb(0, res, lvb, sizeof(lvb));
+ if (rv < 0) {
+ printf("set_lvb error %d\n", rv);
+ return -1;
+ }
+ }
+
+ fclose(fp);
+
+ rv = sanlock_release(fd, -1, 0, 1, &res);
+ if (rv < 0) {
+ fprintf(stderr, "release error %d\n", rv);
+ return -1;
+ }
+
+ return 0;
+}
+
10 years, 8 months
If I set the default value DEFAULT_USE_WATCHDOG to be 0, what would be happened in sanlock?
by Qixiaozhen
Hi, all
Sanlock daemon was monitored by watchdog as default in the code.
With the watchdog monitor on , if the connection(iscsi session, fc and etc.) between one node with SAN was off, the node that had been added into the lockspace would be reset.
In my experiment, my server had been connected to several SANs, and a cluster that contained several virtual machines was running in these SANs. If one of these SANs was disconnected, the server would reboot. In this situation, my virtual machines would be crashed, and so was the cluster.
I don't want the reset of server when it was disconnected with SAN.
I run the command "sanlock daemon -w 0" to solve this problem. And I also modify the code in src/sanlock_internal.h, set the default value of DEFAULT_USE_WATCHDOG to be 0.
I am not familiar with source code of sanlock. So what the effect of that if I have run command "sanlock daemon -w 0"?
Thank you.
Qi
10 years, 8 months