This test shows problems when we mount share with forcemandatory flag. It doesn't work: after that no one process can read from the file. Structure of the test: | Start first main process | Create Unix socket |\ | \ | | Start a first child process | | Open a file | | Lock it from 0 to 1 | | Open this file again | | Lock it from 1 to 3 | | Close secondary open file descriptor | | Send the firstly open descriptor to the main process | | Check the area from 0 to 1 - it must be no locks there | | Try to read this area from 0 to 1 | | Sleep |\ | \ | | Start a second child process process | | Lock it from 10 to 12 | | Try to read it | | Sleep | ... | | Receive th file descriptor from the second child process | Check locking by first child process area | (if we see lock, that prevent us - the pid is invalid - Samba Protocol doesn't allow ut to see the valid pid) | Try to read the area from 0 to 1 | Try to read the area from 1 to 3 | Try to read the area from 10 to 11 .... [piastry@tartarus m]$ ./a.out start 25123 server start 25124 server open for 5 server second open for 6 server close 6 server send 5 server file not locked second server start 25125 fd received=5 (len=1) second server open for 5 second server lock for 5 file 5 not locked first read failed on 5 (Permission denied) second lseek done on 5 with 1 second read failed on 5 (Permission denied) third lseek done on 5 with 10 third read failed on 5 (Permission denied) done [piastry@tartarus m]$ second server lseek done on 5 with 10 second server read failed on 5 (Permission denied) wait second server for end server end [piastry@tartarus m]$ second server end Then I changed start position of last read from 10 to 14, but result didn't change: [piastry@tartarus m]$ ./a.out start 25157 server start 25158 server open for 5 server second open for 6 second server start 25159 server close 6 server send 5 fd received=5 (len=1) server file not locked second server open for 5 second server lock for 5 file 5 not locked first read failed on 5 (Permission denied) second lseek done on 5 with 1 second read failed on 5 (Permission denied) third lseek done on 5 with 14 third read failed on 5 (Permission denied) done second server lseek done on 5 with 10 second server read failed on 5 (Permission denied) wait second server for end [piastry@tartarus m]$ server end [piastry@tartarus m]$ second server end After that I did 'vim "file"' and it failed with 'reading error' at first time, but at second time it worked right! So, after that, the behavior of the test changed!!!!!! [piastry@tartarus m]$ gcc raw7.c raw7.c: In function ‘main’: raw7.c:217: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’ [piastry@tartarus m]$ ./a.out start 25811 server start 25812 server open for 5 server second open for 6 server close 6 server send 5 server file not locked fd received=5 (len=1) second server start 25813 second server open for 5 second server lock for 5 file 5 not locked first read done on 5 with 1 second lseek done on 5 with 1 second read done on 5 with 2 third lseek done on 5 with 10 third read done on 5 with 2 data:ab done [piastry@tartarus m]$ second server lseek done on 5 with 10 second server read done on 5 with 2 wait second server for end server end [piastry@tartarus m]$ second server end And with 14 instead of 10 too! [piastry@tartarus m]$ ./a.out start 25732 server start 25733 server open for 5 server second open for 6 second server start 25734 server close 6 server send 5 server file not locked fd received=5 (len=1) second server open for 5 second server lock for 5 second server lseek done on 5 with 10 second server read done on 5 with 2 wait second server for end file 5 not locked first read done on 5 with 1 second lseek done on 5 with 1 second read done on 5 with 2 third lseek done on 5 with 14 third read done on 5 with 2 data:ef done [piastry@tartarus m]$ server end second server end [piastry@tartarus m]$ cat PDOXUSRS.NET 1234567890abcdefghghoerhjgoergoiearogeroghoerhgoerhgore bverhbiue ougbkelbkesrb I use 2.6.30 kernel and CIFS Version 1.58. All mount options: noperm,forcemand.
Created attachment 4863 [details] The test, that shows the problem
Fixed with strictcache mount option in cifs-2.6 git tree.