1f08c3bdfSopenharmony_ciCOMPILE : make 2f08c3bdfSopenharmony_ciRUN LOCAL: ./locktests -n <number of concurent process> -f <test file> [-T] 3f08c3bdfSopenharmony_ci 4f08c3bdfSopenharmony_ci 5f08c3bdfSopenharmony_ciGOAL : This test is aimed at stressing the fcntl locking functions. 6f08c3bdfSopenharmony_ciA master process sets a lock on a file region (byte range locking). 7f08c3bdfSopenharmony_ciSeveral slave processes try to perform operations on this region, such 8f08c3bdfSopenharmony_cias: read, write, set a new lock ... 9f08c3bdfSopenharmony_ciThe expected results of these operations are known. 10f08c3bdfSopenharmony_ciIf the operation's result is the same as the expected one, the test 11f08c3bdfSopenharmony_cisucceeds, otherwise it fails. 12f08c3bdfSopenharmony_ci 13f08c3bdfSopenharmony_ci 14f08c3bdfSopenharmony_ciHISTORY : This program was been written to stress NFSv4 locks. 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_ciSlaves are concurrent processes or threads. 17f08c3bdfSopenharmony_ci-n <num> : Number of threads to use (mandatory). 18f08c3bdfSopenharmony_ci-f <file> : Run the test on a test file defined by the -f option (mandatory). 19f08c3bdfSopenharmony_ci-T : Use threads instead of processes (optional). 20f08c3bdfSopenharmony_ci 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_ci 23f08c3bdfSopenharmony_ci* RUN NETWORK * 24f08c3bdfSopenharmony_ci 25f08c3bdfSopenharmony_ciTest server: 26f08c3bdfSopenharmony_ci./locktests -n <number of concurent processes> -f <test file> -c <number of clients> 27f08c3bdfSopenharmony_ci 28f08c3bdfSopenharmony_ciTest clients: 29f08c3bdfSopenharmony_ci./locktests --server <server host name> 30f08c3bdfSopenharmony_ci 31f08c3bdfSopenharmony_ci 32f08c3bdfSopenharmony_ciMultiple clients options 33f08c3bdfSopenharmony_ci_______________________ 34f08c3bdfSopenharmony_ci 35f08c3bdfSopenharmony_ciThese options have been developed to test NFSv4 locking when multiple 36f08c3bdfSopenharmony_ciclients try to use the same file. It uses a test server and several test 37f08c3bdfSopenharmony_ciclients. 38f08c3bdfSopenharmony_ci 39f08c3bdfSopenharmony_ci -------------- 40f08c3bdfSopenharmony_ci | | 41f08c3bdfSopenharmony_ci | NFS SERVER | 42f08c3bdfSopenharmony_ci | | 43f08c3bdfSopenharmony_ci -------------- 44f08c3bdfSopenharmony_ci | 45f08c3bdfSopenharmony_ci | 46f08c3bdfSopenharmony_ci ----------------------------------------------- 47f08c3bdfSopenharmony_ci | | | 48f08c3bdfSopenharmony_ci | | | 49f08c3bdfSopenharmony_ci ------------------ ------------------- ------------------ 50f08c3bdfSopenharmony_ci | NFS Client 1 | | NFS Client 1 | | NFS Client 1 | 51f08c3bdfSopenharmony_ci | running | | running | | running | 52f08c3bdfSopenharmony_ci | a CLIENT TEST | | the SERVER TEST | | a CLIENT TEST | 53f08c3bdfSopenharmony_ci ------------------ ------------------- ------------------ 54f08c3bdfSopenharmony_ci 55f08c3bdfSopenharmony_ciSee the DEPLOY file to know how to configure client test on each client. 56f08c3bdfSopenharmony_ci 57f08c3bdfSopenharmony_ciServer options are: 58f08c3bdfSopenharmony_ci 59f08c3bdfSopenharmony_ci-n <num> : Number of threads to use (mandatory). 60f08c3bdfSopenharmony_ci-f <file> : Run the test on given test file defined by the -f option (mandatory). 61f08c3bdfSopenharmony_ci-c <num> : Number of clients to connect before starting the tests. 62f08c3bdfSopenharmony_ci 63f08c3bdfSopenharmony_ci 64f08c3bdfSopenharmony_ciClient options 65f08c3bdfSopenharmony_ci______________ 66f08c3bdfSopenharmony_ci--server <server hostname> 67f08c3bdfSopenharmony_ci 68f08c3bdfSopenharmony_ci 69f08c3bdfSopenharmony_ci* EXAMPLES * 70f08c3bdfSopenharmony_ci============ 71f08c3bdfSopenharmony_ci 72f08c3bdfSopenharmony_ciLocal testing: 73f08c3bdfSopenharmony_ci./locktests -n 50 -f /file/system/to/test 74f08c3bdfSopenharmony_ci 75f08c3bdfSopenharmony_ciMultiple clients: 76f08c3bdfSopenharmony_ci-on the test server (called host1): 77f08c3bdfSopenharmony_ci ./locktest -n 50 -f /network/file/system/to/test -c 3 78f08c3bdfSopenharmony_ci (Server waiting for 3 clients to be connected) 79f08c3bdfSopenharmony_ci 80f08c3bdfSopenharmony_ci-test clients: 81f08c3bdfSopenharmony_ci ./locktest --server host1 82f08c3bdfSopenharmony_ci 83f08c3bdfSopenharmony_ci 84f08c3bdfSopenharmony_ciHOW TO UNDERSTAND TEST RESULTS 85f08c3bdfSopenharmony_ci============================== 86f08c3bdfSopenharmony_ciTen tests are performed: 87f08c3bdfSopenharmony_ci 1. WRITE ON A READ LOCK 88f08c3bdfSopenharmony_ci 2. WRITE ON A WRITE LOCK 89f08c3bdfSopenharmony_ci 3. READ ON A READ LOCK 90f08c3bdfSopenharmony_ci 4. READ ON A WRITE LOCK 91f08c3bdfSopenharmony_ci 5. SET A READ LOCK ON A READ LOCK 92f08c3bdfSopenharmony_ci 6. SET A WRITE LOCK ON A WRITE LOCK 93f08c3bdfSopenharmony_ci 7. SET A WRITE LOCK ON A READ LOCK 94f08c3bdfSopenharmony_ci 8. SET A READ LOCK ON A WRITE LOCK 95f08c3bdfSopenharmony_ci 9. READ LOCK THE WHOLE FILE BYTE BY BYTE 96f08c3bdfSopenharmony_ci 10. WRITE LOCK THE WHOLE FILE BYTE BY BYTE 97f08c3bdfSopenharmony_ci 98f08c3bdfSopenharmony_ci 99f08c3bdfSopenharmony_ciFor each test, the MASTER process takes a lock (READ/WRITE LOCK) and 100f08c3bdfSopenharmony_cithe SLAVE processes try to perform the following operations on the 101f08c3bdfSopenharmony_cilocked section: 102f08c3bdfSopenharmony_ci 103f08c3bdfSopenharmony_ci - WRITE 104f08c3bdfSopenharmony_ci - READ 105f08c3bdfSopenharmony_ci - SET A WRITE LOCK 106f08c3bdfSopenharmony_ci - SET A WRITE LOCK 107f08c3bdfSopenharmony_ci 108f08c3bdfSopenharmony_ciIf a slave process performs its test operation without error it prints 109f08c3bdfSopenharmony_ci"=", otherwise it prints "x". 110f08c3bdfSopenharmony_ci 111f08c3bdfSopenharmony_ciAn operation performed "without error" means: 112f08c3bdfSopenharmony_ci 113f08c3bdfSopenharmony_ci - The operation (write, read, fcntl ...) returns no error code, and 114f08c3bdfSopenharmony_ci - errno is not changed. 115f08c3bdfSopenharmony_ci 116f08c3bdfSopenharmony_ciHowever, "the slave performs its test operation without error" does NOT 117f08c3bdfSopenharmony_cimean the "result is correct". For example, a slave process is NOT 118f08c3bdfSopenharmony_ciallowed to set a READ LOCK on an already-set WRITE LOCK. When such 119f08c3bdfSopenharmony_cioperations are performed, the correct and expected result is that the 120f08c3bdfSopenharmony_citested function returns the EAGAIN error code. 121f08c3bdfSopenharmony_ci 122f08c3bdfSopenharmony_ciWhen all tests have been processed, the result of each process for each 123f08c3bdfSopenharmony_citest is compared with the table of expected results, and a new table is 124f08c3bdfSopenharmony_cidisplayed: 125f08c3bdfSopenharmony_ci 126f08c3bdfSopenharmony_ciFor example: 127f08c3bdfSopenharmony_ci 200 processes of 200 successfully ran test : READ ON A READ LOCK 128f08c3bdfSopenharmony_ci 200 processes of 200 successfully ran test : SET A READ LOCK ON A WRITE LOCK 129f08c3bdfSopenharmony_ci 130f08c3bdfSopenharmony_ciThis result lists the process/thread both on local and remote machines. 131f08c3bdfSopenharmony_ci 132f08c3bdfSopenharmony_ciNote that the testing locks with thread on multiple clients is disabled 133f08c3bdfSopenharmony_cibecause it does not make sense: 2 different clients obviously run at 134f08c3bdfSopenharmony_cileast 2 different processes (thread information cannot be shared 135f08c3bdfSopenharmony_cibetween this thread over the network). 136f08c3bdfSopenharmony_ci 137f08c3bdfSopenharmony_ciEXPECTED RESULTS 138f08c3bdfSopenharmony_ci================ 139f08c3bdfSopenharmony_ciHere is the table of expected results, depending on : 140f08c3bdfSopenharmony_ci - Slave test operations (READ, WRITE, SET A WRITE LOCK ... ) 141f08c3bdfSopenharmony_ci - Master Operation (SET A READ/A WRITE LOCK ) 142f08c3bdfSopenharmony_ci - Slave types (Processes, threads) 143f08c3bdfSopenharmony_ci - Locking profile (POSIX locking, Mandatory locking) 144f08c3bdfSopenharmony_ci 145f08c3bdfSopenharmony_ci 146f08c3bdfSopenharmony_ci================================================================================================ 147f08c3bdfSopenharmony_ci | Master process/thread | 148f08c3bdfSopenharmony_ci===================================|===========================================================| 149f08c3bdfSopenharmony_ciSlave type | Test operation | advisory locking | mandatory locking | 150f08c3bdfSopenharmony_ci___________________________________|______________________________|____________________________| 151f08c3bdfSopenharmony_ci | | read lock write lock | read lock write lock | 152f08c3bdfSopenharmony_ci___________________________________|______________________________|____________________________| 153f08c3bdfSopenharmony_cithread | set a read lock | Allowed Allowed | Allowed Allowed | 154f08c3bdfSopenharmony_ci | set a write lock | Allowed Allowed | Allowed Allowed | 155f08c3bdfSopenharmony_ci | read | Allowed Allowed | Allowed Allowed | 156f08c3bdfSopenharmony_ci | write | Allowed Allowed | Allowed Allowed | 157f08c3bdfSopenharmony_ci===================================+==============================+============================| 158f08c3bdfSopenharmony_ciprocess | set a read lock | Allowed Denied | Allowed Denied | 159f08c3bdfSopenharmony_ci | set a write lock | Denied Denied | Denied Denied | 160f08c3bdfSopenharmony_ci | read | Allowed Allowed | Denied Allowed | 161f08c3bdfSopenharmony_ci | write | Allowed Allowed | Denied Denied | 162f08c3bdfSopenharmony_ci================================================================================================ 163f08c3bdfSopenharmony_ci 164f08c3bdfSopenharmony_ci 165f08c3bdfSopenharmony_ci************** 166f08c3bdfSopenharmony_ciBull SA - 2006 - http://nfsv4.bullopensource.org 167f08c3bdfSopenharmony_ciTony Reix: tony.reix@bull.net 168f08c3bdfSopenharmony_ciAurélien Charbon: aurelien.charbon@ext bull.net 169f08c3bdfSopenharmony_ci************** 170