[sanlock] 02/02: python: Clean up alignment and sector constants
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit af126ed0c3d0088344727eb36107c8807aca2129
Author: Nir Soffer <nirsof(a)gmail.com>
AuthorDate: Fri Apr 12 05:02:50 2019 +0300
python: Clean up alignment and sector constants
The constants used SANLK_RES_ prefix, which is not needed, confusing,
and make client code uglier.
- SANLK_ prefix is not needed since all the constants are in the sanlock
module namespace (e.g sanlock.ALIGN1M).
- RES_ prefix is incorrect because the alignment and sector size are
used for lockspace, rindex and resources.
The help for the python functions mentioned the C API constants names
(e.g. SANLK_LSF_ALIGN1M). Now we mention the python constant name (e.g
ALIGN1M) which is the value the user of this module must use.
Since this version was not released yet, we still have time to fix this
API.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
python/example.py | 4 ++--
python/sanlock.c | 26 ++++++++++++--------------
2 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/python/example.py b/python/example.py
index c0adf54..4fe845d 100644
--- a/python/example.py
+++ b/python/example.py
@@ -29,10 +29,10 @@ def main():
fd = sanlock.register()
print "Initializing '%s'" % (LOCKSPACE_NAME,)
- sanlock.write_lockspace(LOCKSPACE_NAME, disk, max_hosts=0, iotimeout=0, align=sanlock.SANLK_RES_ALIGN1M, sector=sanlock.SANLK_RES_SECTOR512)
+ sanlock.write_lockspace(LOCKSPACE_NAME, disk, max_hosts=0, iotimeout=0, align=sanlock.ALIGN1M, sector=sanlock.SECTOR512)
print "Initializing '%s' on '%s'" % (RESOURCE_NAME, LOCKSPACE_NAME)
- sanlock.write_resource(LOCKSPACE_NAME, RESOURCE_NAME, SNLK_DISKS, align=sanlock.SANLK_RES_ALIGN1M, sector=sanlock.SANLK_RES_SECTOR512)
+ sanlock.write_resource(LOCKSPACE_NAME, RESOURCE_NAME, SNLK_DISKS, align=sanlock.ALIGN1M, sector=sanlock.SECTOR512)
print "Acquiring the id '%i' on '%s'" % (HOST_ID, LOCKSPACE_NAME)
sanlock.add_lockspace(LOCKSPACE_NAME, HOST_ID, disk)
diff --git a/python/sanlock.c b/python/sanlock.c
index 5ddb6d4..b387307 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -361,7 +361,7 @@ exit_fail:
/* write_lockspace */
PyDoc_STRVAR(pydoc_write_lockspace, "\
write_lockspace(lockspace, path, offset=0, max_hosts=0, iotimeout=0, \
-align=SANLK_LSF_ALIGN1M, sector=SANLK_LSF_SECTOR512)\n\
+align=ALIGN1M, sector=SECTOR512)\n\
Initialize or update a device to be used as sanlock lockspace.");
static PyObject *
@@ -409,8 +409,7 @@ py_write_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds)
/* read_lockspace */
PyDoc_STRVAR(pydoc_read_lockspace, "\
-read_lockspace(path, offset=0 \
-align=SANLK_LSF_ALIGN1M, sector=SANLK_LSF_SECTOR512)\n -> dict\n\
+read_lockspace(path, offset=0, align=ALIGN1M, sector=SECTOR512)\n -> dict\n\
Read the lockspace information from a device at a specific offset.");
static PyObject *
@@ -482,15 +481,14 @@ exit_fail:
/* read_resource */
PyDoc_STRVAR(pydoc_read_resource, "\
-read_resource(path, offset=0, \
-align=SANLK_LSF_ALIGN1M, sector=SANLK_LSF_SECTOR512) -> dict\n\
+read_resource(path, offset=0, align=ALIGN1M, sector=SECTOR512) -> dict\n\
Read the resource information from a device at a specific offset.");
static PyObject *
py_read_resource(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
int rv, rs_len;
- uint32_t align=SANLK_LSF_ALIGN1M, sector=SANLK_LSF_SECTOR512;
+ uint32_t align=SANLK_RES_ALIGN1M, sector=SANLK_RES_SECTOR512;
const char *path;
struct sanlk_resource *rs;
PyObject *rs_info = NULL, *rs_entry = NULL;
@@ -575,7 +573,7 @@ exit_fail:
/* write_resource */
PyDoc_STRVAR(pydoc_write_resource, "\
write_resource(lockspace, resource, disks, max_hosts=0, num_hosts=0, \
-clear=False, align=SANLK_LSF_ALIGN1M, sector=SANLK_LSF_SECTOR512)\n\
+clear=False, align=ALIGN1M, sector=SECTOR512)\n\
Initialize a device to be used as sanlock resource.\n\
The disks must be in the format: [(path, offset), ... ].\n\
If clear is True, the resource is cleared so subsequent read will\n\
@@ -585,7 +583,7 @@ static PyObject *
py_write_resource(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
int rv, max_hosts = 0, num_hosts = 0, clear = 0;
- uint32_t align=SANLK_LSF_ALIGN1M, sector=SANLK_LSF_SECTOR512;
+ uint32_t align=SANLK_RES_ALIGN1M, sector=SANLK_RES_SECTOR512;
const char *lockspace, *resource;
struct sanlk_resource *rs;
PyObject *disks;
@@ -1656,12 +1654,12 @@ initsanlock(void)
PYSNLK_INIT_ADD_CONSTANT(SANLK_SETEV_ALL_HOSTS, "SETEV_ALL_HOSTS");
/* Sector and align size flags */
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_SECTOR512, "SANLK_RES_SECTOR512");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_SECTOR4K, "SANLK_RES_SECTOR4K");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN1M, "SANLK_RES_ALIGN1M");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN2M, "SANLK_RES_ALIGN2M");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN4M, "SANLK_RES_ALIGN4M");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN8M, "SANLK_RES_ALIGN8M");
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_SECTOR512, "SECTOR512");
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_SECTOR4K, "SECTOR4K");
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN1M, "ALIGN1M");
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN2M, "ALIGN2M");
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN4M, "ALIGN4M");
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN8M, "ALIGN8M");
#undef PYSNLK_INIT_ADD_CONSTANT
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
5 years
[sanlock] 01/02: python: Unify python extension make command
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit e2ff29e3e2a8a036d0d99242af2af23bb1eee19a
Author: Nir Soffer <nirsof(a)gmail.com>
AuthorDate: Fri Apr 12 20:04:17 2019 +0300
python: Unify python extension make command
Replace the python Makefile inplace target with environment variable,
fixing the tests after the top Makefile was simplified to use:
$(SUBDIRS):
$(MAKE) -C $@
When running tox, we build sanlock extension inside the tox relevant tox
environment (e.g. .tox/py27/...). This will be helpful for supporting
python 3.
On Travis we still build in the python directory - sanlock import fails
if we build it elsewhere. This is not an issue for python 3 since on
Travis we have separate build for every python version.
Fixes: 6133e3471ca3
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
.travis.yml | 5 ++---
python/Makefile | 5 +----
tox.ini | 4 +---
3 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 8cc2859..37643f4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,6 @@
dist: xenial
language: python
+python: 2.7
addons:
apt:
@@ -16,8 +17,6 @@ env:
- CC="gcc-8"
script:
- - make -C wdmd
- - make -C src
- - make -C python inplace
+ - make BUILDARGS="--build-lib=."
- source tests/env.sh
- pytest
diff --git a/python/Makefile b/python/Makefile
index 06c2201..c97e45a 100644
--- a/python/Makefile
+++ b/python/Makefile
@@ -5,10 +5,7 @@
# of the GNU General Public License v.2.
all:
- python2 setup.py build
-
-inplace:
- python2 setup.py build_ext --inplace
+ python2 setup.py build $(BUILDARGS)
install:
python2 setup.py install --root=$(DESTDIR)
diff --git a/tox.ini b/tox.ini
index f65f487..1c2349e 100644
--- a/tox.ini
+++ b/tox.ini
@@ -14,13 +14,11 @@ setenv =
LD_LIBRARY_PATH={env:PWD}/wdmd:{env:PWD}/src
SANLOCK_PRIVILEGED=0
SANLOCK_RUN_DIR=/tmp/sanlock
- PYTHONPATH={env:PWD}/python
-sitepackages = True
whitelist_externals = make
deps =
pytest==4.0
commands =
- make
+ make BUILDARGS="--build-lib={envsitepackagesdir}"
pytest {posargs}
[pytest]
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
5 years
[PATCH v2] python: Unify python extension make command
by Nir Soffer
Replace the python Makefile inplace target with environment variable,
fixing the tests after the top Makefile was simplified to use:
$(SUBDIRS):
$(MAKE) -C $@
When running tox, we build sanlock extension inside the tox relevant tox
environment (e.g. .tox/py27/...). This will be helpful for supporting
python 3.
On Travis we still build in the python directory - sanlock import fails
if we build it elsewhere. This is not an issue for python 3 since on
Travis we have separate build for every python version.
Fixes: 6133e3471ca3
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
.travis.yml | 5 ++---
python/Makefile | 5 +----
tox.ini | 4 +---
3 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 8cc2859..37643f4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,8 @@
dist: xenial
language: python
+python: 2.7
addons:
apt:
sources:
- ubuntu-toolchain-r-test
@@ -14,10 +15,8 @@ before_install:
env:
- CC="gcc-8"
script:
- - make -C wdmd
- - make -C src
- - make -C python inplace
+ - make BUILDARGS="--build-lib=."
- source tests/env.sh
- pytest
diff --git a/python/Makefile b/python/Makefile
index 06c2201..c97e45a 100644
--- a/python/Makefile
+++ b/python/Makefile
@@ -3,14 +3,11 @@
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
all:
- python2 setup.py build
-
-inplace:
- python2 setup.py build_ext --inplace
+ python2 setup.py build $(BUILDARGS)
install:
python2 setup.py install --root=$(DESTDIR)
clean:
diff --git a/tox.ini b/tox.ini
index f65f487..1c2349e 100644
--- a/tox.ini
+++ b/tox.ini
@@ -12,17 +12,15 @@ skip_missing_interpreters = True
passenv = USER
setenv =
LD_LIBRARY_PATH={env:PWD}/wdmd:{env:PWD}/src
SANLOCK_PRIVILEGED=0
SANLOCK_RUN_DIR=/tmp/sanlock
- PYTHONPATH={env:PWD}/python
-sitepackages = True
whitelist_externals = make
deps =
pytest==4.0
commands =
- make
+ make BUILDARGS="--build-lib={envsitepackagesdir}"
pytest {posargs}
[pytest]
# Notes:
# --basetemp: we must use /var/tmp as sanlock uses direct I/O.
--
2.17.2
5 years
[PATCH] python: Clean up alignment and sector constants
by Nir Soffer
The constants used SANLK_RES_ prefix, which is not needed, confusing,
and make client code uglier.
- SANLK_ prefix is not needed since all the constants are in the sanlock
module namespace (e.g sanlock.ALIGN1M).
- RES_ prefix is incorrect because the alignment and sector size are
used for lockspace, rindex and resources.
The help for the python functions mentioned the C API constants names
(e.g. SANLK_LSF_ALIGN1M). Now we mention the python constant name (e.g
ALIGN1M) which is the value the user of this module must use.
Since this version was not released yet, we still have time to fix this
API.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
python/example.py | 4 ++--
python/sanlock.c | 26 ++++++++++++--------------
2 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/python/example.py b/python/example.py
index c0adf54..4fe845d 100644
--- a/python/example.py
+++ b/python/example.py
@@ -27,14 +27,14 @@ def main():
print "Registering to sanlock"
fd = sanlock.register()
print "Initializing '%s'" % (LOCKSPACE_NAME,)
- sanlock.write_lockspace(LOCKSPACE_NAME, disk, max_hosts=0, iotimeout=0, align=sanlock.SANLK_RES_ALIGN1M, sector=sanlock.SANLK_RES_SECTOR512)
+ sanlock.write_lockspace(LOCKSPACE_NAME, disk, max_hosts=0, iotimeout=0, align=sanlock.ALIGN1M, sector=sanlock.SECTOR512)
print "Initializing '%s' on '%s'" % (RESOURCE_NAME, LOCKSPACE_NAME)
- sanlock.write_resource(LOCKSPACE_NAME, RESOURCE_NAME, SNLK_DISKS, align=sanlock.SANLK_RES_ALIGN1M, sector=sanlock.SANLK_RES_SECTOR512)
+ sanlock.write_resource(LOCKSPACE_NAME, RESOURCE_NAME, SNLK_DISKS, align=sanlock.ALIGN1M, sector=sanlock.SECTOR512)
print "Acquiring the id '%i' on '%s'" % (HOST_ID, LOCKSPACE_NAME)
sanlock.add_lockspace(LOCKSPACE_NAME, HOST_ID, disk)
try:
diff --git a/python/sanlock.c b/python/sanlock.c
index 5ddb6d4..b387307 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -359,11 +359,11 @@ exit_fail:
}
/* write_lockspace */
PyDoc_STRVAR(pydoc_write_lockspace, "\
write_lockspace(lockspace, path, offset=0, max_hosts=0, iotimeout=0, \
-align=SANLK_LSF_ALIGN1M, sector=SANLK_LSF_SECTOR512)\n\
+align=ALIGN1M, sector=SECTOR512)\n\
Initialize or update a device to be used as sanlock lockspace.");
static PyObject *
py_write_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
@@ -407,12 +407,11 @@ py_write_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds)
Py_RETURN_NONE;
}
/* read_lockspace */
PyDoc_STRVAR(pydoc_read_lockspace, "\
-read_lockspace(path, offset=0 \
-align=SANLK_LSF_ALIGN1M, sector=SANLK_LSF_SECTOR512)\n -> dict\n\
+read_lockspace(path, offset=0, align=ALIGN1M, sector=SECTOR512)\n -> dict\n\
Read the lockspace information from a device at a specific offset.");
static PyObject *
py_read_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
@@ -480,19 +479,18 @@ exit_fail:
return NULL;
}
/* read_resource */
PyDoc_STRVAR(pydoc_read_resource, "\
-read_resource(path, offset=0, \
-align=SANLK_LSF_ALIGN1M, sector=SANLK_LSF_SECTOR512) -> dict\n\
+read_resource(path, offset=0, align=ALIGN1M, sector=SECTOR512) -> dict\n\
Read the resource information from a device at a specific offset.");
static PyObject *
py_read_resource(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
int rv, rs_len;
- uint32_t align=SANLK_LSF_ALIGN1M, sector=SANLK_LSF_SECTOR512;
+ uint32_t align=SANLK_RES_ALIGN1M, sector=SANLK_RES_SECTOR512;
const char *path;
struct sanlk_resource *rs;
PyObject *rs_info = NULL, *rs_entry = NULL;
static char *kwlist[] = {"path", "offset", "align", "sector", NULL};
@@ -573,21 +571,21 @@ exit_fail:
}
/* write_resource */
PyDoc_STRVAR(pydoc_write_resource, "\
write_resource(lockspace, resource, disks, max_hosts=0, num_hosts=0, \
-clear=False, align=SANLK_LSF_ALIGN1M, sector=SANLK_LSF_SECTOR512)\n\
+clear=False, align=ALIGN1M, sector=SECTOR512)\n\
Initialize a device to be used as sanlock resource.\n\
The disks must be in the format: [(path, offset), ... ].\n\
If clear is True, the resource is cleared so subsequent read will\n\
return an error.");
static PyObject *
py_write_resource(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
int rv, max_hosts = 0, num_hosts = 0, clear = 0;
- uint32_t align=SANLK_LSF_ALIGN1M, sector=SANLK_LSF_SECTOR512;
+ uint32_t align=SANLK_RES_ALIGN1M, sector=SANLK_RES_SECTOR512;
const char *lockspace, *resource;
struct sanlk_resource *rs;
PyObject *disks;
uint32_t flags = 0;
@@ -1654,14 +1652,14 @@ initsanlock(void)
PYSNLK_INIT_ADD_CONSTANT(SANLK_SETEV_CLEAR_EVENT, "SETEV_CLEAR_EVENT");
PYSNLK_INIT_ADD_CONSTANT(SANLK_SETEV_REPLACE_EVENT, "SETEV_REPLACE_EVENT");
PYSNLK_INIT_ADD_CONSTANT(SANLK_SETEV_ALL_HOSTS, "SETEV_ALL_HOSTS");
/* Sector and align size flags */
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_SECTOR512, "SANLK_RES_SECTOR512");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_SECTOR4K, "SANLK_RES_SECTOR4K");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN1M, "SANLK_RES_ALIGN1M");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN2M, "SANLK_RES_ALIGN2M");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN4M, "SANLK_RES_ALIGN4M");
- PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN8M, "SANLK_RES_ALIGN8M");
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_SECTOR512, "SECTOR512");
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_SECTOR4K, "SECTOR4K");
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN1M, "ALIGN1M");
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN2M, "ALIGN2M");
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN4M, "ALIGN4M");
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN8M, "ALIGN8M");
#undef PYSNLK_INIT_ADD_CONSTANT
}
--
2.17.2
5 years
[PATCH] makefiles: factor out common.mk
by Nir Soffer
From: Michael Shigorin <mike(a)altlinux.org>
This commit started with adding the test for checking for
-fstack-clash-protection before use (not available before
gcc8, added with 0533006b4d36e8699ea51036d8914c22e46fae3f
unconditionally); should help cases like the one mentioned
in commit a904a3de2997bc7ce55b6cb3647d5ec347f0a2fa as well
as myself with lcc/e2k.
The CFLAGS specification and handling duplication didn't
look all that well so I chose to reimplement the whole set
of Makefiles into a proper recursive form with a shared one
to include; should be easier to maintain overall.
Signed-off-by: Michael Shigorin <mike(a)altlinux.org>
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
Tested-by: Nir Soffer <nsoffer(a)redhat.com>
---
I rebased and tested on top of:
https://github.com/nirs/sanlock/commit/bb0211a8a0cff302b09a5b419f30594d49...
Makefile | 26 +++++++++++++++++---------
common.mk | 31 +++++++++++++++++++++++++++++++
reset/Makefile | 29 ++---------------------------
src/Makefile | 29 ++---------------------------
wdmd/Makefile | 29 ++---------------------------
5 files changed, 54 insertions(+), 90 deletions(-)
create mode 100644 common.mk
diff --git a/Makefile b/Makefile
index 8b41526..36587e0 100644
--- a/Makefile
+++ b/Makefile
@@ -8,19 +8,27 @@ release := 0
endif
distname := sanlock-$(version)
tarball := $(distname).tar.gz
-all:
- $(MAKE) -C wdmd
- $(MAKE) -C src
- $(MAKE) -C python
-
-clean:
- $(MAKE) -C wdmd clean
- $(MAKE) -C src clean
- $(MAKE) -C python clean
+SUBDIRS = wdmd src python reset
+
+.PHONY: all $(SUBDIRS) clean install
+
+all: $(SUBDIRS)
+
+$(SUBDIRS):
+ $(MAKE) -C $@
+
+src: wdmd
+
+python reset: src
+
+clean install:
+ for dir in $(SUBDIRS); do \
+ $(MAKE) -C $$dir $@; \
+ done
dist: spec
rm -f $(tarball)
git archive --prefix=$(distname)/ HEAD > $(distname).tar
tar rf $(distname).tar --transform="s|^|$(distname)/&|" sanlock.spec
diff --git a/common.mk b/common.mk
new file mode 100644
index 0000000..3221393
--- /dev/null
+++ b/common.mk
@@ -0,0 +1,31 @@
+export CC ?= cc
+
+check = $(shell echo "int main() { return 0; }" \
+ | $(CC) $(1) -xc - >&/dev/null && echo $(1) ||:)
+
+export CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
+ -Wall \
+ -Wformat \
+ -Wformat-security \
+ -Wmissing-prototypes \
+ -Wnested-externs \
+ -Wpointer-arith \
+ -Wextra \
+ -Wshadow \
+ -Wcast-align \
+ -Wwrite-strings \
+ -Waggregate-return \
+ -Wstrict-prototypes \
+ -Winline \
+ -Wredundant-decls \
+ -Wno-sign-compare \
+ -Wno-unused-parameter \
+ -Wp,-D_FORTIFY_SOURCE=2 \
+ -Wno-strict-overflow \
+ -fexceptions \
+ -fasynchronous-unwind-tables \
+ -fdiagnostics-show-option \
+ -Wp,-D_GLIBCXX_ASSERTIONS \
+ -fstack-protector-strong \
+ $(check -fstack-clash-protection) \
+ -Wl,-z,now
diff --git a/reset/Makefile b/reset/Makefile
index 5f5c425..004dbb6 100644
--- a/reset/Makefile
+++ b/reset/Makefile
@@ -1,38 +1,13 @@
+include ../common.mk
+
TARGET1 = sanlk-resetd
TARGET2 = sanlk-reset
SOURCE1 = sanlk_resetd.c
SOURCE2 = sanlk_reset.c
-CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
- -Wall \
- -Wformat \
- -Wformat-security \
- -Wmissing-prototypes \
- -Wnested-externs \
- -Wpointer-arith \
- -Wextra \
- -Wshadow \
- -Wcast-align \
- -Wwrite-strings \
- -Waggregate-return \
- -Wstrict-prototypes \
- -Winline \
- -Wredundant-decls \
- -Wno-sign-compare \
- -Wno-unused-parameter \
- -Wp,-D_FORTIFY_SOURCE=2 \
- -Wno-strict-overflow \
- -fexceptions \
- -fasynchronous-unwind-tables \
- -fdiagnostics-show-option \
- -Wp,-D_GLIBCXX_ASSERTIONS \
- -fstack-protector-strong \
- -fstack-clash-protection \
- -Wl,-z,now
-
VER=$(shell cat ../VERSION)
CFLAGS += -DVERSION=\"$(VER)\" -I../src -I../wdmd
CFLAGS += -fPIE -DPIE
diff --git a/src/Makefile b/src/Makefile
index 623ea3a..533dd79 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2,10 +2,12 @@
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v2 or (at your option) any later version.
+include ../common.mk
+
CMD_TARGET = sanlock
HEADER_TARGET = sanlock.h sanlock_rv.h sanlock_resource.h sanlock_admin.h sanlock_direct.h
MAN_TARGET = sanlock.8
SOMAJOR=1
@@ -65,37 +67,10 @@ LIB_CLIENT_SOURCE = \
env.c
LIBPC_ENTIRE_SOURCE = libsanlock.pc.in
LIBPC_CLIENT_SOURCE = libsanlock_client.pc.in
-CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
- -Wall \
- -Wformat \
- -Wformat-security \
- -Wmissing-prototypes \
- -Wnested-externs \
- -Wpointer-arith \
- -Wextra \
- -Wshadow \
- -Wcast-align \
- -Wwrite-strings \
- -Waggregate-return \
- -Wstrict-prototypes \
- -Winline \
- -Wredundant-decls \
- -Wno-sign-compare \
- -Wno-unused-parameter \
- -Wp,-D_FORTIFY_SOURCE=2 \
- -Wno-strict-overflow \
- -fexceptions \
- -fasynchronous-unwind-tables \
- -fdiagnostics-show-option \
- -Wp,-D_GLIBCXX_ASSERTIONS \
- -fstack-protector-strong \
- -fstack-clash-protection \
- -Wl,-z,now
-
VER=$(shell cat ../VERSION)
CFLAGS += -DVERSION=\"$(VER)\"
CMD_CFLAGS = $(CFLAGS) -fPIE -DPIE
LIB_ENTIRE_CFLAGS = $(CFLAGS) -fPIC
diff --git a/wdmd/Makefile b/wdmd/Makefile
index 74b04e2..5849efc 100644
--- a/wdmd/Makefile
+++ b/wdmd/Makefile
@@ -2,10 +2,12 @@
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v2 or (at your option) any later version.
+include ../common.mk
+
CMD_TARGET = wdmd
LIB_TARGET = libwdmd
HEADER_TARGET = wdmd.h
MAN_TARGET = wdmd.8
TEST_TARGET = wdmd_client
@@ -18,37 +20,10 @@ CMD_SOURCE = main.c wdmd_sock.c
LIB_SOURCE = client.c wdmd_sock.c
TEST_SOURCE = wdmd_client.c
-CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
- -Wall \
- -Wformat \
- -Wformat-security \
- -Wmissing-prototypes \
- -Wnested-externs \
- -Wpointer-arith \
- -Wextra \
- -Wshadow \
- -Wcast-align \
- -Wwrite-strings \
- -Waggregate-return \
- -Wstrict-prototypes \
- -Winline \
- -Wredundant-decls \
- -Wno-sign-compare \
- -Wno-unused-parameter \
- -Wp,-D_FORTIFY_SOURCE=2 \
- -Wno-strict-overflow \
- -fexceptions \
- -fasynchronous-unwind-tables \
- -fdiagnostics-show-option \
- -Wp,-D_GLIBCXX_ASSERTIONS \
- -fstack-protector-strong \
- -fstack-clash-protection \
- -Wl,-z,now
-
VER=$(shell cat ../VERSION)
CFLAGS += -DVERSION=\"$(VER)\"
CMD_CFLAGS = $(CFLAGS) -fPIE -DPIE
LIB_CFLAGS = $(CFLAGS) -fPIC
--
2.17.2
5 years
[PATCH] python: Unify python extension make command
by Nir Soffer
Replace the python Makefile inplace target with environment variable, so
the top Makefile can be simplified to:
$(SUBDIRS):
$(MAKE) -C $@
When running tox, we build sanlock extension inside the tox relevant tox
environment (e.g. .tox/py27/...). This will be helpful for supporting
python 3.
On Travis we still build in the python directory - sanlock import fails
if we build it elsewhere. This is not an issue for python 3 since on
Travis we have separate build for every python version.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
.travis.yml | 5 ++---
Makefile | 2 +-
python/Makefile | 5 +----
tox.ini | 4 +---
4 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 8cc2859..37643f4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,8 @@
dist: xenial
language: python
+python: 2.7
addons:
apt:
sources:
- ubuntu-toolchain-r-test
@@ -14,10 +15,8 @@ before_install:
env:
- CC="gcc-8"
script:
- - make -C wdmd
- - make -C src
- - make -C python inplace
+ - make BUILDARGS="--build-lib=."
- source tests/env.sh
- pytest
diff --git a/Makefile b/Makefile
index bc1b3ce..8b41526 100644
--- a/Makefile
+++ b/Makefile
@@ -11,11 +11,11 @@ distname := sanlock-$(version)
tarball := $(distname).tar.gz
all:
$(MAKE) -C wdmd
$(MAKE) -C src
- $(MAKE) -C python inplace
+ $(MAKE) -C python
clean:
$(MAKE) -C wdmd clean
$(MAKE) -C src clean
$(MAKE) -C python clean
diff --git a/python/Makefile b/python/Makefile
index 06c2201..c97e45a 100644
--- a/python/Makefile
+++ b/python/Makefile
@@ -3,14 +3,11 @@
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
all:
- python2 setup.py build
-
-inplace:
- python2 setup.py build_ext --inplace
+ python2 setup.py build $(BUILDARGS)
install:
python2 setup.py install --root=$(DESTDIR)
clean:
diff --git a/tox.ini b/tox.ini
index f65f487..1c2349e 100644
--- a/tox.ini
+++ b/tox.ini
@@ -12,17 +12,15 @@ skip_missing_interpreters = True
passenv = USER
setenv =
LD_LIBRARY_PATH={env:PWD}/wdmd:{env:PWD}/src
SANLOCK_PRIVILEGED=0
SANLOCK_RUN_DIR=/tmp/sanlock
- PYTHONPATH={env:PWD}/python
-sitepackages = True
whitelist_externals = make
deps =
pytest==4.0
commands =
- make
+ make BUILDARGS="--build-lib={envsitepackagesdir}"
pytest {posargs}
[pytest]
# Notes:
# --basetemp: we must use /var/tmp as sanlock uses direct I/O.
--
2.17.2
5 years
[sanlock] branch master updated: release 3.7.1
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
The following commit(s) were added to refs/heads/master by this push:
new 8b9ae27 release 3.7.1
8b9ae27 is described below
commit 8b9ae27668d71f13519bf14b029c88e7824dad27
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Apr 5 11:08:40 2019 -0500
release 3.7.1
---
VERSION | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/VERSION b/VERSION
index 7c69a55..a76ccff 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.7.0
+3.7.1
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
5 years
[sanlock] branch master updated: README.rst
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
The following commit(s) were added to refs/heads/master by this push:
new c2df4c0 README.rst
c2df4c0 is described below
commit c2df4c0266d1e491d9693bfca102f2f07bfe8008
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Apr 5 10:23:30 2019 -0500
README.rst
---
README.rst | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/README.rst b/README.rst
index 87a6b59..59df2f1 100644
--- a/README.rst
+++ b/README.rst
@@ -6,15 +6,15 @@ From sanlock(8) at sanlock.git/src/sanlock.8
::
-SANLOCK(8) System Manager's Manual SANLOCK(8)
+ SANLOCK(8) System Manager's Manual SANLOCK(8)
-NAME
+ NAME
sanlock - shared storage lock manager
-SYNOPSIS
+ SYNOPSIS
sanlock [COMMAND] [ACTION] ...
-DESCRIPTION
+ DESCRIPTION
sanlock is a lock manager built on shared storage. Hosts with access
to the storage can perform locking. An application running on the
hosts is given a small amount of space on the shared block device or
@@ -473,7 +473,7 @@ DESCRIPTION
# sanlock shutdown
-OPTIONS
+ OPTIONS
COMMAND can be one of three primary top level choices
sanlock daemon start daemon
@@ -773,7 +773,7 @@ OPTIONS
sanlock version shows the build version.
-OTHER
+ OTHER
Request/Examine
The first part of making a request for a resource is writing the
request record of the resource (the sector following the leader
@@ -876,7 +876,7 @@ OTHER
about 1 hour of history when using a 20 second renewal interval for a
10 second io timeout.
-INTERNALS
+ INTERNALS
Disk Format
· This example uses 512 byte sectors.
@@ -1026,7 +1026,7 @@ INTERNALS
value in the paxos_lease becomes expired, and other hosts will use the
paxos algorithm to acquire the paxos_lease, and set a new owner.
-FILES
+ FILES
/etc/sanlock/sanlock.conf
· quiet_fail = 1
@@ -1096,21 +1096,21 @@ FILES
lockspace disk to the align size of the lockspace. Set to a number
to set a specific number of KB for all lockspace disks.
-SEE ALSO
+ SEE ALSO
wdmd(8)
2015-01-23 SANLOCK(8)
-WDMD(8) System Manager's Manual WDMD(8)
+ WDMD(8) System Manager's Manual WDMD(8)
-NAME
+ NAME
wdmd - watchdog multiplexing daemon
-SYNOPSIS
+ SYNOPSIS
wdmd [OPTIONS]
-DESCRIPTION
+ DESCRIPTION
This daemon opens /dev/watchdog and allows multiple independent sources
to detmermine whether each KEEPALIVE is done. Every test interval (10
seconds), the daemon tests each source. If any test fails, the
@@ -1158,7 +1158,7 @@ DESCRIPTION
failure. If a script does not exit by the end of the test interval, it
is considered a failure.
-OPTIONS
+ OPTIONS
--version, -V
Print version.
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
5 years
[sanlock] branch master updated: tests: sanlk_load
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
The following commit(s) were added to refs/heads/master by this push:
new 393fbb1 tests: sanlk_load
393fbb1 is described below
commit 393fbb12f4b4fbbf9861e17002d0b9940dc480a3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Apr 3 15:46:34 2019 -0500
tests: sanlk_load
---
tests/sanlk_load.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/tests/sanlk_load.c b/tests/sanlk_load.c
index bc5bbd1..926ccd2 100644
--- a/tests/sanlk_load.c
+++ b/tests/sanlk_load.c
@@ -545,6 +545,8 @@ int do_rand_child(void)
int iter = 1;
int pid = getpid();
+ error_count = 0;
+
srandom(pid);
memset(lock_state, 0, sizeof(lock_state));
@@ -637,10 +639,13 @@ int do_rand_child(void)
}
display_rv(pid);
- if (error_count)
+ if (error_count) {
+ printf("pid %d done error_count %d\n", pid, error_count);
exit(EXIT_FAILURE);
+ }
- return 0;
+ printf("pid %d done\n", pid);
+ exit(EXIT_SUCCESS);
}
int do_all_child(void)
@@ -898,19 +903,27 @@ int do_rand(int argc, char *argv[])
sleep(1);
}
- printf("stopping pids");
+ printf("stopping pids ");
for (i = 0; i < pid_count; i++)
kill(children[i], SIGTERM);
while (run_count) {
+ status = 0;
+
pid = wait(&status);
if (pid > 0) {
run_count--;
- printf(".");
- if (WEXITSTATUS(status))
+ if (!WIFEXITED(status)) {
+ error_count++;
+ printf("-");
+ } else if (WEXITSTATUS(status)) {
error_count++;
+ printf("x");
+ } else {
+ printf(".");
+ }
}
}
printf("\n");
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
5 years
[sanlock] branch master updated: tests: sanlk_load use error exit
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
The following commit(s) were added to refs/heads/master by this push:
new a3c0647 tests: sanlk_load use error exit
a3c0647 is described below
commit a3c0647d27617ffc2070f18bd087c1b9f7fc18c8
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Apr 3 13:08:23 2019 -0500
tests: sanlk_load use error exit
---
tests/sanlk_load.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 76 insertions(+), 9 deletions(-)
diff --git a/tests/sanlk_load.c b/tests/sanlk_load.c
index 4a93374..bc5bbd1 100644
--- a/tests/sanlk_load.c
+++ b/tests/sanlk_load.c
@@ -49,6 +49,10 @@ int res_count = DEFAULT_RES_COUNT;
int pid_count = DEFAULT_PID_COUNT;
int one_mode = 0;
int our_hostid;
+int run_sec;
+int count_sec;
+int error_count;
+int error_range = 1;
int acquire_rv[MAX_RV];
int release_rv[MAX_RV];
@@ -64,6 +68,7 @@ do { \
snprintf(error_buf, 4095, "%ld " fmt "\n", time(NULL), ##args); \
printf("ERROR: %s\n", error_buf); \
syslog(LOG_ERR, "%s", error_buf); \
+ error_count++; \
} while (0)
@@ -112,14 +117,47 @@ static void save_rv(int pid, int rv, int acquire)
else
release_rv[-rv]++;
}
+
+ if (error_range == 1) {
+ switch (rv) {
+ case 0:
+ case -EBUSY:
+ /* -16 */
+ case -EEXIST:
+ /* -17 */
+ case -EAGAIN:
+ /* -11 */
+ break;
+ default:
+ log_error("%d ERROR range %d save_rv %d %d", pid, error_range, rv, acquire);
+ break;
+ };
+
+ } else if (error_range == 2) {
+ switch (rv) {
+ case 0:
+ case -EBUSY:
+ /* -16 */
+ case -EEXIST:
+ /* -17 */
+ case -EAGAIN:
+ /* -11 */
+ break;
+ case -243:
+ case -244:
+ case -245:
+ break;
+ default:
+ log_error("%d ERROR range %d save_rv %d %d", pid, error_range, rv, acquire);
+ break;
+ };
+ }
+
return;
fail:
log_error("%d save_rv %d %d", pid, rv, acquire);
- while (1) {
- sleep(10);
- printf("%lu %d ERROR save_rv %d %d", time(NULL), pid, rv, acquire);
- }
+ printf("%lu %d ERROR save_rv %d %d", time(NULL), pid, rv, acquire);
}
static void display_rv(int pid)
@@ -241,11 +279,10 @@ static int check_lock_state(int pid, int result, int count, char *res_state)
dump_lock_state(pid);
- while (1) {
- sleep(10);
- printf("%lu %d ERROR check_lock_state result %d count %d found %d bad %d res_state %s",
- time(NULL), pid, result, count, found_count, bad_count, res_state);
- }
+ printf("%lu %d ERROR check_lock_state result %d count %d found %d bad %d res_state %s",
+ time(NULL), pid, result, count, found_count, bad_count, res_state);
+
+ return -1;
}
#if 0
@@ -599,6 +636,10 @@ int do_rand_child(void)
iter++;
}
display_rv(pid);
+
+ if (error_count)
+ exit(EXIT_FAILURE);
+
return 0;
}
@@ -685,6 +726,9 @@ void get_options(int argc, char *argv[])
case 'i':
our_hostid = atoi(optionarg);
break;
+ case 'S':
+ run_sec = atoi(optionarg);
+ break;
case 's':
ls_count = atoi(optionarg);
if (ls_count > MAX_LS_COUNT) {
@@ -709,6 +753,9 @@ void get_options(int argc, char *argv[])
case 'm':
one_mode = atoi(optionarg);
break;
+ case 'e':
+ error_range = atoi(optionarg);
+ break;
default:
log_error("unknown option: %c", optchar);
exit(EXIT_FAILURE);
@@ -844,6 +891,11 @@ int do_rand(int argc, char *argv[])
add_lockspace(lsi);
#endif
+
+ if (run_sec && (count_sec >= run_sec))
+ break;
+ count_sec++;
+ sleep(1);
}
printf("stopping pids");
@@ -856,10 +908,18 @@ int do_rand(int argc, char *argv[])
if (pid > 0) {
run_count--;
printf(".");
+
+ if (WEXITSTATUS(status))
+ error_count++;
}
}
printf("\n");
+ if (error_count) {
+ printf("child errors %d\n", error_count);
+ exit(EXIT_FAILURE);
+ }
+
return 0;
}
@@ -922,6 +982,11 @@ int do_all(int argc, char *argv[])
}
printf("\n");
+ if (error_count) {
+ printf("error_count %d\n", error_count);
+ exit(EXIT_FAILURE);
+ }
+
return 0;
}
@@ -1023,6 +1088,8 @@ int main(int argc, char *argv[])
printf(" -r <num> number of resources per lockspace\n");
printf(" -p <num> number of processes\n");
printf(" -m <num> use one mode for all locks, 3 = SH, 5 = EX\n");
+ printf(" -S <num> seconds to run (0 unlimited)\n");
+ printf(" -e <num> error range expected (1 single node, 2 multi node)\n");
printf(" -D debug output\n");
printf(" -V verbose debug output\n");
printf("\n");
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
5 years