There is an optimization made to is_locked that checks if a file is oplocked and if that is the case, it does not need to do more extensive checks. It has been committed as : https://github.com/samba-team/samba/commit/822fcec39d6597524a94b0e8b9c244d5eb62b972 Unfortunately this optimization does not carry over to leases. So when smb2 leases = yes (and in more or less recent versions of samba it is a default setting) there is much more time spent on locking. e.g. smb2 leases = yes Skipping user change - already user mid 7189, CreditCharge: 1, NeededCharge: 1 smbd_smb2_read: testfile.dat - fnum 3860045402 smb2: read size (4096) too small for minimum aio_read of 0 seqnum=1, fsp->brlock_seqnum=1 is_posix_locked: File testfile.dat, offset = 1933574144, count = 4096, type = READ posix_lock_in_range: offset_out = 1933574144, count_out = 4096 posix_fcntl_getlock 12 1933574144 4096 0 fcntl_getlock fd=12 op=5 offset=1933574144 count=4096 type=0 fcntl_getlock: fd 12 is returned info 2 pid 0 posix_fcntl_getlock: Lock query call successful brl_locktest: posix start=1933574144 len=4096 unlocked for fnum 3860045402 file testfile.dat strict_lock_default: flavour = WINDOWS_LOCK brl start=1933574144 len=4096 unlocked for fnum 3860045402 file testfile.dat read_file (testfile.dat): pos = 1933574144, size = 4096, returned 4096 smbd_smb2_read: file testfile.dat, fnum 3860045402, offset=1933574144 len=4096 returned 4096 smbd_smb2_read: fnum 3860045402, file testfile.dat, length=4096 offset=1933574144 read=4096 smbd_smb2_request_done_ex: idx[1] status[NT_STATUS_OK] body[16] dyn[yes:4096] at ../source3/smbd/smb2_read.c:164 smb2_set_operation_credit: requested 1, charge 1, granted 1, current possible/max 354/512, total granted/max/low/range 159/8192/7190/159 smbd_smb2_request idx[1] of 5 vectors smb2_validate_sequence_number: clearing id 7190 (position 7190) from bitmap smbd_smb2_request_dispatch: opcode[SMB2_OP_READ] mid = 7190 smb2 leases = no Skipping user change - already user mid 11722, CreditCharge: 1, NeededCharge: 1 smbd_smb2_read: testfile.dat - fnum 1413864810 smb2: read size (4096) too small for minimum aio_read of 0 is_locked: optimisation - exclusive oplock on file testfile.dat read_file (testfile.dat): pos = 138412032, size = 4096, returned 4096 smbd_smb2_read: file testfile.dat, fnum 1413864810, offset=138412032 len=4096 returned 4096 smbd_smb2_read: fnum 1413864810, file testfile.dat, length=4096 offset=138412032 read=4096 smbd_smb2_request_done_ex: idx[1] status[NT_STATUS_OK] body[16] dyn[yes:4096] at ../source3/smbd/smb2_read.c:155 smb2_set_operation_credit: requested 1, charge 1, granted 1, current possible/max 354/512, total granted/max/low/range 159/8192/11723/159 smbd_smb2_request idx[1] of 5 vectors smb2_validate_sequence_number: clearing id 11723 (position 3531) from bitmap smbd_smb2_request_dispatch: opcode[SMB2_OP_READ] mid = 11723
Created attachment 13059 [details] Proposed fix for master. Can you check this fix please ?
Created attachment 13073 [details] git-am fix for 4.6.next. Cherry-picked from master.
Created attachment 13074 [details] git-am fix for 4.5.next. Back-ported from master.
Created attachment 13075 [details] git-am fix for 4.4.next. Back-ported from master.
Reassigning to Karolin for inclusion in 4.4, 4.5 and 4.6.
Pushed to autobuild-v4-{6,5}. v4-4-test is in the security fixes only mode.
(In reply to Karolin Seeger from comment #6) Pushed to both branches. Closing out bug report. Thanks!
(In reply to Karolin Seeger from comment #6) This landed in v4-4-test somehow, I'll revert it from there.
(In reply to Stefan Metzmacher from comment #8) Explicitly requested by Ralph!
(In reply to Karolin Seeger from comment #9) Hm, sorry, I just acked the backports done by Jeremy without looking at version numbers.