Commit Graph

560 Commits

Author SHA1 Message Date
Ferenc Wágner
6a476017b9 build: Use the SED variable provided by configure
Signed-off-by: Ferenc Wágner <wferi@debian.org>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2019-02-06 16:04:55 +01:00
Jan Friesse
82f35f1720 log: Implement support for reopening log files
Feature depends on existence of libqb function qb_log_file_reopen.

New function call is added into CFG service API. This function is
used by corosync-cfgtool which now accepts -L parameter.

Finally, logrotate "postrotate" script is calling
corosync-cfgtool -L to notify corosync, instead of using
copytruncate option.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-10-16 14:46:52 +02:00
Jan Friesse
f286388275 cmap: Fix strncpy warning in cmap_iter_next
cmap_iter_next in contrast of it's icmap counterpart copies key name
into user preallocated space. In the worst case, key name may be
CMAP_KEYNAME_MAXLEN, so cmap_iter_next then need CMAP_KEYNAME_MAXLEN +
additional byte to store zero. strncpy was copying only
CMAP_KEYNAME_MAXLEN characters so there was possibility of unterminated
string.

Patch solves this by using memcpy and always add trailing zero.
Documentation was improved suggesting minimum size of keyname buffer to
be CMAP_KEYNAME_MAXLEN + 1.

Also sam and quorumtool were using too short buffer so they are fixed too.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-08-13 09:00:41 +02:00
Rytis Karpuška
aa62c2c028 cpg: Handle fragmented message sending interrupt
It turns out that there are some legitimate cases where fragmented
messages might be interrupted during sending (e.g. CS_ERR_TRY_AGAIN or
as in my case: CS_ERR_INTERRUPT). This creates a situation where
LIBCPG_PARTIAL_FIRST is sent multiple times before receiving
LIBCPG_PARTIAL_LAST.

Solution is to drop incomplete message and start assembly of new message
as libcpg should have reported error during sending of that
incomplete message.

Signed-off-by: Rytis Karpuška <rytisk@neurotechnology.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-04-11 18:40:07 +02:00
Rytis Karpuška
c9dd11772c libcpg: Fix issue with partial big packet assembly
Packet assembly is done seperately for each nodeid, pid pair, therefore
multiple packets are not mixed into single buffer.

Signed-off-by: Rytis Karpuška <rytisk@neurotechnology.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-01-04 13:08:12 +01:00
Christine Caulfield
1ca72a1154 totemsrp: Revert totemsrp_get_ifaces() changes
In my enthusiasm for removing code while integrating knet I
also deleted the correct code for returning IP address for a node,
so that only the IP addres of the local node was ever returned.

This commit restores the the previous code.

Also, because we always return INTERFACE_MAX interfaces now (they don't
have to be contiguous) set ss_family to zero if that interface is not
in use so that downstream apps know and don't display a lot of 0.0.0.0

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2017-11-30 16:59:05 +01:00
Jan Friesse
5abffa2fa1 sam: Fix snprintf compiler warnings
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2017-11-08 09:09:31 +01:00
Bin Liu
250750b829 cfg: nodeid should be unsigned int
nodeid in struct req_lib_cfg_get_node_addrs is "unsigned int",
so the function corosync_cfg_get_node_addrs should have its param
"nodeid" to be unsigned int.

Signed-off-by: Bin Liu <bliu@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2017-11-01 17:34:04 +01:00
Christine Caulfield
9da89f32c2 CFG: Remove ring-reenable code
RRP doesn't exist any more so all the ring re-enable code is redundant.

I've removed it from the library and all the code that does anything,
but I've left the hole in the IPC just in case old libraries are
hanging around.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2017-08-03 14:32:02 +02:00
Christine Caulfield
55c3dcb76d stats: Add map with on-demand statistics
Icmap is factored out so it's possible to add other
maps for cmap. API call to switch maps from application
end is added.

Corosync-cmapctl is enhanced with -m option.

Stats contains all statistics previously found in runtime.connections,
runtime.services and runtime.totem prefixes together with new knet
related. All stats are read only.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2017-07-27 15:53:04 +02:00
Jan Friesse
17a6387f55 libvotequorum: Bump version
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2016-11-07 17:40:00 +01:00
Jan Friesse
1f90c31ba7 list: Replace for_each by safe version where need
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2016-10-27 14:56:52 +02:00
Michael Jones
b4c06e52f3 list: Replace uses of list.h with qblist.h
Signed-off-by: Michael Jones <jonesmz@jonesmz.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2016-10-27 14:56:52 +02:00
Fabio M. Di Nitto
e204e871ec [build] Fix build on RHEL7.3 latest
header inclusion have changed

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2016-10-23 08:23:52 +02:00
Jan Friesse
1925074909 Fix few bugs found by coverity
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2016-06-28 13:58:43 +02:00
Christine Caulfield
3a5d51fca7 votequorum: Fix up quorum/nodelist callbacks
This patch tidies the two state change callbacks and explains them
in the man page:

The difference between votequorum_nodelist_notification_t and
votequorum_quorum_notification_t is subtle but important.
The 'nodelist' callback is sent at the start of a cluster state
transition and contains the new ring_id and only the list of
nodes that are included in the sync state - ie only active nodes. No
quorum information is included this callback because it is not
available at that time.

The 'quorum' callback is sent after the cluster state transition has
completed and does contain quorum information.
In addition, the nodelist contains a list of all nodes known to
votequorum (whether up or down) and their state as well
as information about the quorum device attached (if any). quorum
callbacks will not be sent for qdevice up and down
events unless they affect quorum.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2016-06-28 13:58:39 +02:00
Christine Caulfield
cf0028c86e votequorum: split callbacks into nodelist and quorum
This split is needed for qdevice, so that it gets the ring_id and
nodelist as part of the sync process and not afterwards - when quorum
has been calculated.

As this is and unsupported API I'm not too worried about breaking
existing code - all the clients I know of are using the quorum API
anyway as they should be.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2016-06-28 13:58:38 +02:00
Jan Friesse
3f51b169f5 cpg: Handle ipc error in cpg_zcb_alloc/free
- Error returned by coroipcc_msg_send_reply_receive is now correctly
  handled.
- If munmap fails, error is set to proper value and handle is put back
  into handle_db

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2016-02-24 16:06:57 +01:00
Athira Rajeev
1130e18595 cpg: Memory not unmapped in cpg_zcb_free
Function in cpg_zcb_alloc (from code lib/cpg.c) creates
/dev/shm/corosync_zerocopy-XXXXX and does mmap

The memory is allocated by corosync service (function zcb_alloc
in exec/cpg.c) also and both shares this memory via mmap
(uses MAP_SHARED in mmap call)

Corosync calls unlink which deletes the file from /dev/shm while
closing the file descriptor, but unmap is not happening correctly
while calling cpg_zcb_free.

So:
- still the deleted file holds the memory
- As munmap is not happening correctly, the number of mappings per
  process gets exceeded and corosync dies with ENOMEM

From gdb, the size passed to munmap appears to be zero and address
looks wrong. Also in the code return code of munmap is not checked.

The patch adds check for:
-  munmap return code and getting correct address for munmap

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2016-02-24 16:06:57 +01:00
Christine Caulfield
8cc8e51363 cpg: Add support for messages larger than 1Mb
If a cpg client sends a message larger than 1Mb (actually slightly
less to allow for internal buffers) cpg will now fragment that into
several corosync messages before sending it around the ring.

cpg_mcast_joined() can now return CS_ERR_INTERRUPT which means that the
cpg membership was disrupted during the send operation and the message
needs to be resent.

The new API call cpg_max_atomic_msgsize_get() returns the maximum size
of a message that will not be fragmented internally.

New test program cpghum was written to stress test this functionality,
it checks message integrity and order of receipt.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2015-03-05 16:45:15 +00:00
Jan Friesse
b8902464d1 votequorum: Add ring id to poll call
If votequorum service receives incorrect (not current) ringid, call is
ignored and CS_ERR_MESSAGE_ERROR is returned.

This and previous commits makes incompatible changes in votequorum
API/ABI, so library version is increased.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2014-08-05 17:22:41 +02:00
Jan Friesse
5f6f68805c votequorum: Return current ring id in callback
Returning ring id will be used in poll function.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2014-08-05 17:22:37 +02:00
Christine Caulfield
82fbffc34b Reload: Add reload code to cfg
Add the code to do the actual corosync.conf reload to cfg, along with
a corosync-cfgtool -R command to trigger it

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2013-09-12 16:09:41 +01:00
Jan Friesse
665a197f90 cpg: Set umask in memory_map function
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2013-06-18 14:36:12 +02:00
Jan Friesse
c53cbc08e5 cpg: Check cpg zc buffer path name length
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2013-06-18 14:34:46 +02:00
Jan Friesse
c264eb3be9 Handle errors when getting SC_PAGESIZE
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2013-06-13 10:53:56 +02:00
Jan Friesse
e684e4ca6f Remove unnecessary mmap in cpg
Code for zero-copy in cpg does following mmaps:
- Mmap anonymous, private memory to some address (-> malloc)
- Mmap shared memory of fd to address returned by first mmap
  (effectively shadows first mapping)

This is not necessary and only one mapping is needed.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2013-05-21 14:46:15 +02:00
Andrei Belov
276bfccb77 Added checks for "--as-needed" and "--version-script" linker flags.
This makes possible to build Corosync from sources on SunOS 5.11,
Mac OS X 10.8.3 and probably other systems with non-GNU linker.

Signed-off-by: Andrei Belov <defanator@gmail.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2013-04-03 12:30:51 +02:00
Jan Friesse
11f4c1141d cmap: Handle NULL params in few more functions
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2012-12-06 09:40:23 +01:00
Jan Friesse
28af35234a Fix handling of NULL parameters in cmap
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2012-11-22 11:46:25 +01:00
Fabio M. Di Nitto
bb5946babb build: clean AM_CFLAGS and AM_CPPFLAGS usage around
also set commont include dirs.

fPIC and DPIC are automatically detected and added
as required by libtool. We don't need to carry it around.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-09-07 09:04:07 +02:00
Jan Friesse
932829bfca Add header files when needed
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2012-09-03 09:34:31 +02:00
Fabio M. Di Nitto
18929089d1 build: drop MAP_ANONYMOUS check from configure
define it only in case it's not there

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-30 15:00:27 +02:00
Fabio M. Di Nitto
a1c154e6fa build: use MADV_NOSYNC only when it's defined
so far only FreeBSD defines it.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-30 15:00:27 +02:00
Fabio M. Di Nitto
02d56da26a build: fix library version export in ELF header
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-30 09:44:32 +02:00
Fabio M. Di Nitto
0bdcb5d8da build: order library install to make sure libsam can relink against libcmap
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-28 15:14:49 +02:00
Fabio M. Di Nitto
76d18f964d build: use libtool for linking
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-28 15:14:48 +02:00
Fabio M. Di Nitto
de76d62d17 build: fix libsam dependencies when using make -j
tested on linux (can't verify solaris)

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-14 11:03:02 +02:00
Jan Friesse
2d10e2bbea cpg: Check input param name_t length
IPC is using buffer of CS_MAX_NAME_LENGTH for name. If user calls
function with longer string, such string can be passed to service
incomplete.

Solution is to not allow string larger then CS_MAX_NAME_LENGTH
and return error.

Same applies to cpg service.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2012-08-09 15:10:35 +02:00
Jan Friesse
fefdc2db87 cmap: Check input param name_t length
IPC is using buffer of CS_MAX_NAME_LENGTH for name. If user calls
function with longer string, such string can be passed to service
incomplete.

Solution is to not allow string larger then CS_MAX_NAME_LENGTH (what is
same as ICMAP_KEYNAME_MAXLEN) and return error.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2012-08-09 15:10:01 +02:00
Fabio M. Di Nitto
6b270c6cd1 votequorum: make the last QDEVICE define name consistent with everything else
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-07 11:07:17 +02:00
Fabio M. Di Nitto
49a8538f46 votequorum: bump soname
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-07 11:07:17 +02:00
Fabio M. Di Nitto
22c54358a9 votequorum: fix library checks on qdevice name and readd qdevice_update
for some odd reasons qdevice_update was just gone.. totally...

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-07 11:07:17 +02:00
Fabio M. Di Nitto
2f369e7039 votequorum: delegate qdevice_master_wins setting to qdevice
votequorum has no business to device if master_wins setting is correct or not.
only the qdevice can decide and should set the value for votequorum.

Logic is:

- user requests master_wins from config
- corosync starts
- qdevice starts
- qdevice reads cmap values / register with votequorum
- qdevice decides if the node can support master_wins or not and tells votequorum
- at this point votequorum can check if an unquorate node is part of the master_wins
  partition

it is the qdevice responsibility to keep that value up to date in votequorum and the
value can be changed at runtime.

this commit also exchange per node master_wins information to lay down the infrastructure
to verify discrepancies in node config for master_wins (coming next on this channel).

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-07 11:07:17 +02:00
Fabio M. Di Nitto
cc7bfeb462 votequorum: drop votequorum_qdevice_getinfo and collapse data into getinfo
it's really pointless to have basically a duplicated API call
to transfer one value and one name.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-07 11:07:17 +02:00
Fabio M. Di Nitto
2dae49e54a votequorum: remove last instance of state and rename it to cast_vote
also align naming of vote to cast_vote for info calls

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-07 11:07:17 +02:00
Fabio M. Di Nitto
43d1439600 votequorum: add qdevice CAST_VOTE status/flag
this is a preparation commit for the next changes. right now it is
no more than an alias to ALIVE.

CAST_VOTE is required to support master/slave feature from qdevice.

Effectively a quorum device can be:

Not registered / registered (connected to API but nothing else is happening)

if registered:

Not alive / alive (quorum device is petting the API via poll and timer is running)

if alive:

Not voting (slave) / voting (master)

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-07 11:07:16 +02:00
Fabio M. Di Nitto
987e26f8d1 votequorum: rename NODE_FLAGS_QDEVICE_STATE to NODE_FLAGS_QDEVICE_ALIVE
STATE is confusing and overloaded term in votequorum as it's used for nodes
and other bits.

make the name unique and ALIVE means that the qdevice is heartbeating
to votequorum.

improve display of the status in tools and tests.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-07 11:07:16 +02:00
Fabio M. Di Nitto
06e75d0b22 votequorum: re-enable qdevice api
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-07 11:07:16 +02:00
Angus Salkeld
acad48bf38 Only call qb_ipcc_disconnect when the instance is fully dereferenced.
Sometimes calling xyz_finilize() within a dispatch would
cause a crash because the qb_ipcc_disconnect actually
disconnects immediatly and frees it't memory. whereas
the corosync structure is reference counted. So this
makes use of the reference counting to only call
qb_ipcc_disconnect when it is fully dereferenced.

Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
2012-04-03 16:03:07 +10:00