Use the xfstests ltp/fsx.c to run test for cifs without clone|copy|dedupe range calls. It reports "READ BAD DATA". [root@kvm-01-guest23 xfstests-dev]# mount //localhost/cifs ~/cifs -o user=root,password=redhat [root@kvm-01-guest23 xfstests-dev]# dd if=/dev/zero of=~/cifs/file bs=1M count=1 1+0 records in 1+0 records out 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00361958 s, 290 MB/s [root@kvm-01-guest23 xfstests-dev]# ./ltp/fsx -E -B -J -A -d -N 1000 -S 0 ~/cifs/file Seed set to 27968 main: filesystem does not support fallocate mode 0, disabling! main: filesystem does not support fallocate mode FALLOC_FL_KEEP_SIZE, disabling! main: filesystem does not support fallocate mode FALLOC_FL_ZERO_RANGE, disabling! main: filesystem does not support fallocate mode FALLOC_FL_COLLAPSE_RANGE, disabling! main: filesystem does not support fallocate mode FALLOC_FL_INSERT_RANGE, disabling! truncating to largest ever: 0x20e51 1 trunc from 0x0 to 0x20e51 3 write 0x1abfa thru 0x1f430 (0x4837 bytes) 6 read 0xec66 thru 0x1a7ba (0xbb55 bytes) 7 read 0xf535 thru 0x1d04b (0xdb17 bytes) 9 read 0x4598 thru 0x10def (0xc858 bytes) 10 trunc from 0x20e51 to 0xc321 17 mapwrite 0x20666 thru 0x2c1be (0xbb59 bytes) 18 read 0x1eaf0 thru 0x2b52b (0xca3c bytes) 20 trunc from 0x2c1bf to 0x142ce 21 mapwrite 0x3bff9 thru 0x3ffff (0x4007 bytes) 22 mapread 0x35df9 thru 0x3ffff (0xa207 bytes) truncating to largest ever: 0x367cf 24 trunc from 0x40000 to 0x367cf 25 mapwrite 0x17378 thru 0x1b4e5 (0x416e bytes) 31 write 0x34adc thru 0x35286 (0x7ab bytes) 32 punch from 0x1662c to 0x1fad4, (0x94a8 bytes) 34 write 0x81b6 thru 0x115e4 (0x942f bytes) 41 punch from 0x24633 to 0x34564, (0xff31 bytes) 42 trunc from 0x367cf to 0xf902 45 mapwrite 0x2e69f thru 0x367ee (0x8150 bytes) 46 mapwrite 0xb9b2 thru 0x126fa (0x6d49 bytes) 48 punch from 0x3116d to 0x367ef, (0x5682 bytes) 49 read 0x26a1d thru 0x2ffa7 (0x958b bytes) 51 punch from 0x47f6 to 0x113f5, (0xcbff bytes) 54 mapwrite 0xad73 thru 0x1657e (0xb80c bytes) 55 trunc from 0x367ef to 0x2f0ec 59 mapread 0x2c6f4 thru 0x2e218 (0x1b25 bytes) 64 mapwrite 0x1768 thru 0x116fb (0xff94 bytes) 66 write 0x21be0 thru 0x27c43 (0x6064 bytes) 68 write 0x2c589 thru 0x34322 (0x7d9a bytes) 71 mapread 0x202f9 thru 0x2dd07 (0xda0f bytes) 74 punch from 0x1ea86 to 0x29b3d, (0xb0b7 bytes) 75 read 0x434f thru 0x4dcb (0xa7d bytes) 77 read 0x13fa1 thru 0x21353 (0xd3b3 bytes) truncating to largest ever: 0x3fd88 79 trunc from 0x34323 to 0x3fd88 81 mapwrite 0x33a8c thru 0x39be5 (0x615a bytes) 84 mapread 0x2cfbe thru 0x3a218 (0xd25b bytes) 87 mapread 0x2981b thru 0x2e8ef (0x50d5 bytes) 89 punch from 0x33911 to 0x3fd88, (0xc477 bytes) 91 mapwrite 0x15a5b thru 0x1bdb9 (0x635f bytes) 92 trunc from 0x3fd88 to 0xa358 94 mapwrite 0xb672 thru 0x1164c (0x5fdb bytes) 96 punch from 0x10af1 to 0x1128b, (0x79a bytes) 98 trunc from 0x1164d to 0x180df 100 punch from 0x1332b to 0x180df, (0x4db4 bytes) 104 write 0xd7c thru 0xa4ad (0x9732 bytes) 110 read 0x11146 thru 0x13a52 (0x290d bytes) READ BAD DATA: offset = 0x11146, size = 0x290d, fname = /root/cifs/file OFFSET GOOD BAD RANGE 0x11146 0x0000 0x5ebd 0x00000 operation# (mod 256) for the bad data may be 94 0x11147 0x0000 0xbd5e 0x00001 operation# (mod 256) for the bad data may be 94 0x11148 0x0000 0x5e95 0x00002 operation# (mod 256) for the bad data may be 94 0x11149 0x0000 0x955e 0x00003 operation# (mod 256) for the bad data may be 94 0x1114a 0x0000 0x5ecd 0x00004 operation# (mod 256) for the bad data may be 94 0x1114b 0x0000 0xcd5e 0x00005 operation# (mod 256) for the bad data may be 94 0x1114c 0x0000 0x5e16 0x00006 operation# (mod 256) for the bad data may be 94 0x1114d 0x0000 0x165e 0x00007 operation# (mod 256) for the bad data may be 94 0x1114e 0x0000 0x5eb8 0x00008 operation# (mod 256) for the bad data may be 94 0x1114f 0x0000 0xb85e 0x00009 operation# (mod 256) for the bad data may be 94 0x11150 0x0000 0x5eb7 0x0000a operation# (mod 256) for the bad data may be 94 0x11151 0x0000 0xb75e 0x0000b operation# (mod 256) for the bad data may be 94 0x11152 0x0000 0x5e00 0x0000c operation# (mod 256) for the bad data may be 94 0x11154 0x0000 0x5e4d 0x0000d operation# (mod 256) for the bad data may be 94 0x11155 0x0000 0x4d5e 0x0000e operation# (mod 256) for the bad data may be 94 0x11156 0x0000 0x5ee7 0x0000f operation# (mod 256) for the bad data may be 94 LOG DUMP (110 total operations): 1( 1 mod 256): TRUNCATE UP from 0x0 to 0x20e51 ******WWWW 2( 2 mod 256): SKIPPED (no operation) 3( 3 mod 256): WRITE 0x1abfa thru 0x1f430 (0x4837 bytes) 4( 4 mod 256): SKIPPED (no operation) 5( 5 mod 256): SKIPPED (no operation) 6( 6 mod 256): READ 0xec66 thru 0x1a7ba (0xbb55 bytes) ***RRRR*** 7( 7 mod 256): READ 0xf535 thru 0x1d04b (0xdb17 bytes) ***RRRR*** 8( 8 mod 256): SKIPPED (no operation) 9( 9 mod 256): READ 0x4598 thru 0x10def (0xc858 bytes) 10( 10 mod 256): TRUNCATE DOWN from 0x20e51 to 0xc321 ******WWWW 11( 11 mod 256): SKIPPED (no operation) 12( 12 mod 256): SKIPPED (no operation) 13( 13 mod 256): SKIPPED (no operation) 14( 14 mod 256): SKIPPED (no operation) 15( 15 mod 256): SKIPPED (no operation) 16( 16 mod 256): SKIPPED (no operation) 17( 17 mod 256): MAPWRITE 0x20666 thru 0x2c1be (0xbb59 bytes) 18( 18 mod 256): READ 0x1eaf0 thru 0x2b52b (0xca3c bytes) 19( 19 mod 256): SKIPPED (no operation) 20( 20 mod 256): TRUNCATE DOWN from 0x2c1bf to 0x142ce 21( 21 mod 256): MAPWRITE 0x3bff9 thru 0x3ffff (0x4007 bytes) 22( 22 mod 256): MAPREAD 0x35df9 thru 0x3ffff (0xa207 bytes) 23( 23 mod 256): SKIPPED (no operation) 24( 24 mod 256): TRUNCATE DOWN from 0x40000 to 0x367cf 25( 25 mod 256): MAPWRITE 0x17378 thru 0x1b4e5 (0x416e bytes) 26( 26 mod 256): SKIPPED (no operation) 27( 27 mod 256): SKIPPED (no operation) 28( 28 mod 256): SKIPPED (no operation) 29( 29 mod 256): SKIPPED (no operation) 30( 30 mod 256): SKIPPED (no operation) 31( 31 mod 256): WRITE 0x34adc thru 0x35286 (0x7ab bytes) 32( 32 mod 256): PUNCH 0x1662c thru 0x1fad3 (0x94a8 bytes) 33( 33 mod 256): SKIPPED (no operation) 34( 34 mod 256): WRITE 0x81b6 thru 0x115e4 (0x942f bytes) ***WWWW 35( 35 mod 256): SKIPPED (no operation) 36( 36 mod 256): SKIPPED (no operation) 37( 37 mod 256): SKIPPED (no operation) 38( 38 mod 256): SKIPPED (no operation) 39( 39 mod 256): SKIPPED (no operation) 40( 40 mod 256): SKIPPED (no operation) 41( 41 mod 256): PUNCH 0x24633 thru 0x34563 (0xff31 bytes) 42( 42 mod 256): TRUNCATE DOWN from 0x367cf to 0xf902 ******WWWW 43( 43 mod 256): SKIPPED (no operation) 44( 44 mod 256): SKIPPED (no operation) 45( 45 mod 256): MAPWRITE 0x2e69f thru 0x367ee (0x8150 bytes) 46( 46 mod 256): MAPWRITE 0xb9b2 thru 0x126fa (0x6d49 bytes) ******WWWW 47( 47 mod 256): SKIPPED (no operation) 48( 48 mod 256): PUNCH 0x3116d thru 0x367ee (0x5682 bytes) 49( 49 mod 256): READ 0x26a1d thru 0x2ffa7 (0x958b bytes) 50( 50 mod 256): SKIPPED (no operation) 51( 51 mod 256): PUNCH 0x47f6 thru 0x113f4 (0xcbff bytes) ******PPPP 52( 52 mod 256): SKIPPED (no operation) 53( 53 mod 256): SKIPPED (no operation) 54( 54 mod 256): MAPWRITE 0xad73 thru 0x1657e (0xb80c bytes) ******WWWW 55( 55 mod 256): TRUNCATE DOWN from 0x367ef to 0x2f0ec 56( 56 mod 256): SKIPPED (no operation) 57( 57 mod 256): SKIPPED (no operation) 58( 58 mod 256): SKIPPED (no operation) 59( 59 mod 256): MAPREAD 0x2c6f4 thru 0x2e218 (0x1b25 bytes) 60( 60 mod 256): SKIPPED (no operation) 61( 61 mod 256): SKIPPED (no operation) 62( 62 mod 256): SKIPPED (no operation) 63( 63 mod 256): SKIPPED (no operation) 64( 64 mod 256): MAPWRITE 0x1768 thru 0x116fb (0xff94 bytes) ******WWWW 65( 65 mod 256): SKIPPED (no operation) 66( 66 mod 256): WRITE 0x21be0 thru 0x27c43 (0x6064 bytes) 67( 67 mod 256): SKIPPED (no operation) 68( 68 mod 256): WRITE 0x2c589 thru 0x34322 (0x7d9a bytes) EXTEND 69( 69 mod 256): SKIPPED (no operation) 70( 70 mod 256): SKIPPED (no operation) 71( 71 mod 256): MAPREAD 0x202f9 thru 0x2dd07 (0xda0f bytes) 72( 72 mod 256): SKIPPED (no operation) 73( 73 mod 256): SKIPPED (no operation) 74( 74 mod 256): PUNCH 0x1ea86 thru 0x29b3c (0xb0b7 bytes) 75( 75 mod 256): READ 0x434f thru 0x4dcb (0xa7d bytes) 76( 76 mod 256): SKIPPED (no operation) 77( 77 mod 256): READ 0x13fa1 thru 0x21353 (0xd3b3 bytes) 78( 78 mod 256): SKIPPED (no operation) 79( 79 mod 256): TRUNCATE UP from 0x34323 to 0x3fd88 80( 80 mod 256): SKIPPED (no operation) 81( 81 mod 256): MAPWRITE 0x33a8c thru 0x39be5 (0x615a bytes) 82( 82 mod 256): SKIPPED (no operation) 83( 83 mod 256): SKIPPED (no operation) 84( 84 mod 256): MAPREAD 0x2cfbe thru 0x3a218 (0xd25b bytes) 85( 85 mod 256): SKIPPED (no operation) 86( 86 mod 256): SKIPPED (no operation) 87( 87 mod 256): MAPREAD 0x2981b thru 0x2e8ef (0x50d5 bytes) 88( 88 mod 256): SKIPPED (no operation) 89( 89 mod 256): PUNCH 0x33911 thru 0x3fd87 (0xc477 bytes) 90( 90 mod 256): SKIPPED (no operation) 91( 91 mod 256): MAPWRITE 0x15a5b thru 0x1bdb9 (0x635f bytes) 92( 92 mod 256): TRUNCATE DOWN from 0x3fd88 to 0xa358 ******WWWW 93( 93 mod 256): SKIPPED (no operation) 94( 94 mod 256): MAPWRITE 0xb672 thru 0x1164c (0x5fdb bytes) ******WWWW 95( 95 mod 256): SKIPPED (no operation) 96( 96 mod 256): PUNCH 0x10af1 thru 0x1128a (0x79a bytes) ******PPPP 97( 97 mod 256): SKIPPED (no operation) 98( 98 mod 256): TRUNCATE UP from 0x1164d to 0x180df 99( 99 mod 256): SKIPPED (no operation) 100(100 mod 256): PUNCH 0x1332b thru 0x180de (0x4db4 bytes) 101(101 mod 256): SKIPPED (no operation) 102(102 mod 256): SKIPPED (no operation) 103(103 mod 256): SKIPPED (no operation) 104(104 mod 256): WRITE 0xd7c thru 0xa4ad (0x9732 bytes) 105(105 mod 256): SKIPPED (no operation) 106(106 mod 256): SKIPPED (no operation) 107(107 mod 256): SKIPPED (no operation) 108(108 mod 256): SKIPPED (no operation) 109(109 mod 256): SKIPPED (no operation) 110(110 mod 256): READ 0x11146 thru 0x13a52 (0x290d bytes) ***RRRR*** Log of operations saved to "/root/cifs/file.fsxops"; replay with --replay-ops Correct content saved for comparison (maybe hexdump "/root/cifs/file" vs "/root/cifs/file.fsxgood")
Fixed patch: commit 6dfbd84684700cb58b34e8602c01c12f3d2595c8 Author: Pavel Shilovsky <piastryyy@gmail.com> Date: Mon Mar 4 17:48:01 2019 -0800 CIFS: Fix read after write for files with read caching When we have a READ lease for a file and have just issued a write operation to the server we need to purge the cache and set oplock/lease level to NONE to avoid reading stale data. Currently we do that only if a write operation succedeed thus not covering cases when a request was sent to the server but a negative error code was returned later for some other reasons (e.g. -EIOCBQUEUED or -EINTR). Fix this by turning off caching regardless of the error code being returned. The patches fixes generic tests 075 and 112 from the xfs-tests. Cc: <stable@vger.kernel.org> Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com> Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>