Jean-Marc Saffroy
2016-12-06 16:18:44 UTC
Hi,
I am trying to use the DLM userland API (libdlm3), and while I was able to
do plain lock acquisitions and conversions, I am stuck trying to update
and then read the lock value block.
Does anyone have working examples of this? I did look at the rhdlmbook
doc, but couldn't fine one.
Attached is a messy test I wrote, which fails because it looks like
up-converting a lock with the LKF_VALBLK set doesn't seem to overwrite the
buffer I provide for the lock value block (and with strace it looks like
the kernel device returns the LVB on a down-conversion! weird). Example
output below.
Cheers,
Jean-Marc
--
***@gmail.com
$ make D=1
gcc -D_REENTRANT -Wall -Werror -O0 -g locklvb.c -pthread -ldlm
-lpthread -o locklvb
$ ./locklvb
dlm_kernel_version 6.0.1
create_lockspace
create_lockspace: Operation not permitted
open_lockspace
dlm_pthread_init
acquiring NL on MyLock...
LOCK mode -> NL convert 0
read_lvb 0 write_lvb 0
completion ast
entering loop on lock #1
count 0
LOCK mode -> PW convert 1
read_lvb 0 write_lvb 0
completion ast
init lvb => 51
lvb cache => 52
LOCK mode -> CR convert 1
read_lvb 0 write_lvb 1
completion ast
count 1
LOCK mode -> PW convert 1
read_lvb 1 write_lvb 0
completion ast
read lvb -1
locklvb: locklvb.c:177: do_lock: Assertion `lvb_lock.val >= 0' failed.
Aborted (core dumped)
I am trying to use the DLM userland API (libdlm3), and while I was able to
do plain lock acquisitions and conversions, I am stuck trying to update
and then read the lock value block.
Does anyone have working examples of this? I did look at the rhdlmbook
doc, but couldn't fine one.
Attached is a messy test I wrote, which fails because it looks like
up-converting a lock with the LKF_VALBLK set doesn't seem to overwrite the
buffer I provide for the lock value block (and with strace it looks like
the kernel device returns the LVB on a down-conversion! weird). Example
output below.
Cheers,
Jean-Marc
--
***@gmail.com
$ make D=1
gcc -D_REENTRANT -Wall -Werror -O0 -g locklvb.c -pthread -ldlm
-lpthread -o locklvb
$ ./locklvb
dlm_kernel_version 6.0.1
create_lockspace
create_lockspace: Operation not permitted
open_lockspace
dlm_pthread_init
acquiring NL on MyLock...
LOCK mode -> NL convert 0
read_lvb 0 write_lvb 0
completion ast
entering loop on lock #1
count 0
LOCK mode -> PW convert 1
read_lvb 0 write_lvb 0
completion ast
init lvb => 51
lvb cache => 52
LOCK mode -> CR convert 1
read_lvb 0 write_lvb 1
completion ast
count 1
LOCK mode -> PW convert 1
read_lvb 1 write_lvb 0
completion ast
read lvb -1
locklvb: locklvb.c:177: do_lock: Assertion `lvb_lock.val >= 0' failed.
Aborted (core dumped)