Can the hostId be self-organization by the servers themselves ?
by Qixiaozhen
Hi, all
As everyone known, the host id is the essential of sanlock. It identifies all the servers with different offset in the shared disk.
Could the host id be self-organization by the servers themselves ? In this condition, the manager node that generated the unique host id would be useless.
My thought lists here:
1. Get the system uuid with dmidecode.
2. System uuid maps into a uint32 integer.
3. Calculate the host id with the hash function with the uint32 integer. Hash function f(x) = value % MAX_HOST_ID
a) Once the conflict occurs, choose its neighbor id.
b) The detection of conflict can use the bitmap in the delta lease.
Is this idea feasibility?
Thank you.
Qi
10 years, 9 months
How can I build and install the sanlock(v2.7) with the source code?
by Qixiaozhen
Hi,all
1) Does anyone tell me that how can I build and install the sanlock(v2.7) with the source code?
2) How can I build it into the rpm package?
I have tried the solution of the two questions above. But less helpful information was found in the internet.
Thank you.
Qi
10 years, 9 months
Question about the usage of SANLock as the cluster lock
by Qixiaozhen
Hi, all
I have an idea of cluster lock with sanlock. However, I am not familiar with the principle detail of sanlock. This mail is sent to the expert of sanlock to discuss its feasibility.
My idea about the cluster lock:
1) Initialize the lockspace and resource at first.
2) Add the hostId of nodes into the lockspace after step 1.
3) Loop:
4) If the node wants to acquire the cluster lock, "sanlock.acquire()" can be called. "sanlock.release()" will be called once the operation finished.
What about the feasibility of this idea?
I hava debuged the demo code of sanlock named 'python/example.py' step by step in two nodes(Node1, Node2). Demo code likes the following segment:
Demo code:
L1 import sanlock
L2 sd_path = "/dev/pool/"
L3 ids_file = sd_path + "ids_file"
L4 lease_file = sd_path + "lease_file"
L5 LEASE_NAME = "LEASE"
L6 sanlock.init_lockspace(sd_path, ids_file)
L7 sanlock.init_resource(sd_path, LEASE_NAME, [lease_file])
L8 host_id = 2 <-----different node has its own host_id here.
L9 sanlock.add_lockspace(sd_path, host_id, ids_file)
L10 _sanlock_fd = sanlock.register()
L11 sanlock.acquire(sd_path, LEASE_NAME,[lease_file], slkfd=_sanlock_fd)
L1~L8 are executed in node1 and node2.
Execute in same time : L9 cannot be executed in the same time of these two nodes and one node would fail.
Execute one by one :When node1 was added its hostId into the lockspace successfully first, the add_lockspace of node2 would overwrite the lockspace in "ids_file" without any exception. There are only one node which writes its timestamp into its sector.
Appreciate for your reply.
Thank you very much.
Qi
10 years, 10 months
Changes to 'hosts2'
by David Teigland
New branch 'hosts2' available with the following commits:
commit 0ad0919ee5beb03f7213dfd57a07aeb16d0b5656
Author: David Teigland <teigland(a)redhat.com>
Date: Tue Jun 11 12:22:19 2013 -0500
sanlock: improve check of max_hosts and num_hosts
Signed-off-by: David Teigland <teigland(a)redhat.com>
commit 50a3a82ba64aa2905e174302d1623e076314d724
Author: David Teigland <teigland(a)redhat.com>
Date: Mon Jun 3 12:03:35 2013 -0500
sanlock: add flag SANLK_REQUEST_NEXT_LVER
To cause sanlock_request() to automatically request
the next lver so the caller does not need to specify
the next lver, which requires reading the current one.
This flag would produce unexpected/unwanted results
if used by multiple hosts targetting the same owner.
Signed-off-by: David Teigland <teigland(a)redhat.com>
commit db77ec21551c7857f4001412478a2fbde3147f20
Author: David Teigland <teigland(a)redhat.com>
Date: Tue Jun 4 12:27:55 2013 -0500
sanlock: add test_resource_owners
to test if a resource can be acquired.
It correlates the results of sanlock_get_hosts
and sanlock_read_resource_owners.
Signed-off-by: David Teigland <teigland(a)redhat.com>
commit 8f86449ef00e9b4b533b7f59f8bce12e11049079
Author: David Teigland <teigland(a)redhat.com>
Date: Thu May 30 17:31:31 2013 -0500
sanlock: add read_resource_owners
New api to read the resource owners from disk.
Signed-off-by: David Teigland <teigland(a)redhat.com>
commit d3d0c1519b21fe95e7e9a0eff6fe1419e8f8a2c2
Author: David Teigland <teigland(a)redhat.com>
Date: Wed May 22 14:55:07 2013 -0500
sanlock: remove direct read_id and live_id
These have not been used and better alternatives now exist.
Signed-off-by: David Teigland <teigland(a)redhat.com>
commit 90481ecfde3e7cec35b34d2431820d77a182d16b
Author: David Teigland <teigland(a)redhat.com>
Date: Wed May 8 16:28:41 2013 -0500
sanlock: add get_hosts api
Returns info about hosts in a lockspace.
Use this to display host status from the
command line: sanlock client gets -h 1
Signed-off-by: David Teigland <teigland(a)redhat.com>
10 years, 10 months
[PATCH 1/5] python: rename SANLK_LSF flags and constants macro
by Federico Simoncelli
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
python/sanlock.c | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index 7d39deb..13919ea 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -697,9 +697,9 @@ PyDoc_STRVAR(pydoc_get_lockspaces, "\
get_lockspaces() -> dict\n\
Return the list of lockspaces currently managed by sanlock. The reported\n\
flag indicates whether the lockspace is acquired (0) or in transition.\n\
-The possible transition values are SANLK_LSF_ADD if the lockspace is in\n\
-the process of being acquired, and SANLK_LSF_REM if it's in the process\n\
-of being released.\n");
+The possible transition values are LSFLAG_ADD if the lockspace is in the\n\
+process of being acquired, and LSFLAG_REM if it's in the process of being\n\
+released.\n");
static PyObject *
py_get_lockspaces(PyObject *self __unused, PyObject *args, PyObject *keywds)
@@ -1095,15 +1095,15 @@ initsanlock(void)
Py_INCREF(py_exception);
}
- if ((sk_constant = PyInt_FromLong(SANLK_LSF_ADD)) != NULL) {
- if (PyModule_AddObject(py_module, "SANLK_LSF_ADD", sk_constant)) {
- Py_DECREF(sk_constant);
- }
+#define PYSNLK_INIT_ADD_CONSTANT(x, y) \
+ if ((sk_constant = PyInt_FromLong(x)) != NULL) { \
+ if (PyModule_AddObject(py_module, y, sk_constant)) { \
+ Py_DECREF(sk_constant); \
+ } \
}
- if ((sk_constant = PyInt_FromLong(SANLK_LSF_REM)) != NULL) {
- if (PyModule_AddObject(py_module, "SANLK_LSF_REM", sk_constant)) {
- Py_DECREF(sk_constant);
- }
- }
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_LSF_ADD, "LSFLAG_ADD");
+ PYSNLK_INIT_ADD_CONSTANT(SANLK_LSF_REM, "LSFLAG_REM");
+
+#undef PYSNLK_INIT_ADD_CONSTANT
}
--
1.7.1
10 years, 10 months
Changes to 'hosts'
by David Teigland
New branch 'hosts' available with the following commits:
commit f7cef65c2599243fa4285fad9eb42ab9a26cdb91
Author: David Teigland <teigland(a)redhat.com>
Date: Tue Jun 11 12:22:19 2013 -0500
sanlock: improve check of max_hosts and num_hosts
Signed-off-by: David Teigland <teigland(a)redhat.com>
commit 916d952ca75dfaf6f50535cbc0908af795febd1b
Author: David Teigland <teigland(a)redhat.com>
Date: Tue Jun 4 12:27:55 2013 -0500
sanlock: add test_resource_owners
to test if a resource can be acquired.
It correlates the results of sanlock_get_hosts
and sanlock_read_resource_owners.
Signed-off-by: David Teigland <teigland(a)redhat.com>
commit 73effa514f9e3f700bdc378eaae1f0bab3fe1ded
Author: David Teigland <teigland(a)redhat.com>
Date: Mon Jun 3 12:03:35 2013 -0500
sanlock: add flag SANLK_REQUEST_NEXT_LVER
To cause sanlock_request() to automatically request
the next lver so the caller does not need to specify
the next lver, which requires reading the current one.
This flag would produce unexpected/unwanted results
if used by multiple hosts targetting the same owner.
Signed-off-by: David Teigland <teigland(a)redhat.com>
commit 142e4f324457d711aae3fcf79e953cb122b93010
Author: David Teigland <teigland(a)redhat.com>
Date: Thu May 30 17:31:31 2013 -0500
sanlock: add read_resource_owners
New api to read the resource owners from disk.
Signed-off-by: David Teigland <teigland(a)redhat.com>
commit bbdb0824b799b15d2149a5af23413a28957b4ba1
Author: David Teigland <teigland(a)redhat.com>
Date: Wed May 22 14:55:07 2013 -0500
sanlock: remove direct read_id and live_id
These have not been used and better alternatives now exist.
Signed-off-by: David Teigland <teigland(a)redhat.com>
commit 90e97db3e0195e3add44a1f478d4e5435a4f91fb
Author: David Teigland <teigland(a)redhat.com>
Date: Wed May 8 16:28:41 2013 -0500
sanlock: add get_hosts api
Returns info about hosts in a lockspace.
Use this to display host status from the
command line: sanlock client gets -h 1
Signed-off-by: David Teigland <teigland(a)redhat.com>
10 years, 10 months
ask the detail about 'read' and 'write' in sanlock
by tsiren tsi
Hi, all
I hava read the source code of sanlock some days. But I have a question, it
is that why scsi command was not used in the 'diskio.c'? The scsi command
can catch much more exception the io.
Could someone help me?
diskio.c
/* write aligned io buffer */
int write_iobuf(int fd, uint64_t offset, char *iobuf, int iobuf_len,
struct task *task, int ioto)
{
if (task && task->use_aio == 1)
return do_write_aio_linux(fd, offset, iobuf, iobuf_len, task, ioto);
else if (task && task->use_aio == 2)
return do_write_aio_posix(fd, offset, iobuf, iobuf_len, task, ioto);
else
return do_write(fd, offset, iobuf, iobuf_len, task);
}
10 years, 10 months