Description
To test and stress NFSv4 locks, a new tool has been written. The locktests program creates a master program and slave programs. The master program opens a file and sets a lock on the whole file (fcntl). Then it tells the slaves processes to perform the same operation on the test file.
The slave processes try to perform one operation :
- read the file
- write the file
- set a write lock
- set a read lock
The operation can work or fail. This information is returned to the master program. It compares the result with the expected and predeterminated results of the test.
Slaves can be created as new processes (fork, default) or as threads (pthread_create, -T). Expected results are different for some tests.
Expected results
The expected results of test, depend on:
- The lock type set by the master (shared or exclusive lock)
- The operation done by slaves
- The kind of locks : advisory (POSIX, default) or mandatory (passing -omand option to mount)
- The kind of slaves : process or threads
Here is a table of expected results. Allowed mean no error is returned by the operation. Denied mean an error (EAGAIN) is returned.
|
|
|
Master |
|
|
| Slave type |
Test operation |
advisory |
locking |
mandatory |
locking |
|
|
read lock |
write lock |
read lock |
write lock |
| thread |
set a read lock |
Allowed |
Allowed |
Allowed |
Allowed |
|
set a write lock |
Allowed |
Allowed |
Allowed |
Allowed |
|
read |
Allowed |
Allowed |
Allowed |
Allowed |
|
write |
Allowed |
Allowed |
Allowed |
Allowed |
| process |
set a read lock |
Allowed |
Denied |
Allowed |
Denied |
|
set a write lock |
Denied |
Denied |
Denied |
Denied |
|
read |
Allowed |
Allowed |
Denied |
Allowed |
|
write |
Allowed |
Allowed |
Denied |
Denied |
Effective results
Advisory locking (default)
Results over NFSv4 are correct. However, when using more than 50 concurents process or threads,
- fcntl returns an error fcntl: Input/output error
- The master get the error fcntl: Resource temporarily unavailable. This error is NOT expected at this point and is clearly a consequence of a NFSv4 problem
- Sometimes a run of the program with 250 or more process have been blocked. The master program was in D state and its wchan were on the iosem_lock function. A kill on all lockmeter child programs made them defunct (Z state).
Mandatory locking (-omand)
Mounting with the -omand option does not seem to have any effect. The NFSv4 locking behaviour is the same with and without the -omand option.
Software configuration
kernel is 2.6.14-rc1-CITI_NFS4_ALL-2