[SCM] Samba Shared Repository - branch v4-11-test updated

Stefan Metzmacher metze at samba.org
Mon Sep 9 17:20:02 UTC 2019


The branch, v4-11-test has been updated
       via  be42cfafee0 s3:selftest: add delay_inject:brl_lock_windows testing
       via  9bf1c5c3e48 vfs_delay_inject: add support for brl_[un]lock_windows()
       via  ec21e68912d s3:locking: add brl_req_guid() and brl_req_mem_ctx() helper functions
       via  74527a20584 s3:smb2_lock: handle NT_STATUS_RETRY from the VFS backend
       via  a1117587afb s3:blocking: handle NT_STATUS_RETRY from the VFS backend
       via  c8086b8873b s3:blocking: make use of smbd_smb1_do_locks_try() in smbd_smb1_do_locks_send()
       via  5e9d294a045 s3:blocking: call smbd_smb1_do_locks_setup_timeout() also in smbd_smb1_do_locks_try()
       via  11e489b0789 s3:blocking: fix the fsp->blocked_smb1_lock_reqs handling
       via  333026209a8 s3:blocking: do the timeout calculation before calling dbwrap_watched_watch_send()
       via  f479c7bc03a s3:blocking: split out smbd_smb1_do_locks_setup_timeout()
       via  9f46f3b0e72 s3:blocking: use timeval_expired(&state->endtime) to stop processing
       via  d857b21d4fe s4:torture/raw: add multilock6 test
       via  a037ebbc347 s4:torture/raw: add multilock5 test
       via  cc9afc3dac2 s4:torture/raw: add multilock4 test
       via  6bd411aad81 s4:torture/raw: add multilock3 test
       via  da765a062aa s4:torture/raw: improvements for multilock2
       via  c4d7c186aca s3:smb2_lock: add retry for POSIX locks
       via  061b60353d7 s4:torture/smb2: add smb2.samba3misc.localposixlock1
       via  00fc583960f s3:smb2_lock: make use of smbd_smb2_lock_try() in smbd_smb2_lock_send()
       via  1fb82e04d02 s3:smb2_lock: let smbd_smb2_lock_try() explicitly check for the retry condition
       via  c4ab0c85022 s3:smb2_lock: error out early in smbd_smb2_lock_send()
       via  5e156be97a3 s3:smb2_lock: split smbd_smb2_lock_retry() into _try() and _retry()
       via  e5385142987 s3:smb2_lock: move from 'blocking' to 'state->blocking'
       via  8b3a50609f4 s3:brlock: always return LOCK_NOT_GRANTED instead of FILE_LOCK_CONFLICT
       via  b56bb2ac59d s3:blocking: maintain state->deny_status
       via  85b9b5f04fd s4:torture/raw: assert to get LOCK_NOT_GRANTED in torture_samba3_posixtimedlock()
       via  1fd0a52e672 s3:blocking: use dynamic posix lock wait intervals
       via  e91bae2bdb1 s3:blocking: Remove bug reproducer from a few commits ago
       via  2c31c9d365d s3:blocking: fix posix lock retry
       via  6b23f24ee38 s3:blocking: move from 'timeout' to 'smbd_smb1_do_locks_state->timeout'
       via  b381f4b314c s3:blocking: split smbd_smb1_do_locks_retry() into _try() and _retry()
       via  841fceae680 s3:blocking: demonstrate the posix lock retry fails
       via  ffdb166e49f s3:torture: convert LOCK9 into LOCK9A and LOCK9B
       via  0742879bd8d s3:torture: fix the timeout alarm handling on LOCK9
       via  75e07d48594 s3:blocking: remove unused timeval_brl_min()
       via  f73b670b4db s3:locking: add share_mode_wakeup_waiters() helper function
       via  244ad1210cc s3:locking: add/split out byte_range_{valid,overlap}() helper functions
       via  80a04a4e19a s3:smb2_lock: call change_to_user_by_fsp() when dbwrap_watched_watch* finishes
       via  728e29d84ca s3:blocking: call change_to_user_by_fsp() when dbwrap_watched_watch* finishes
      from  d01dbe68cdf libcli/smb: send SMB2_NETNAME_NEGOTIATE_CONTEXT_ID

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-11-test


- Log -----------------------------------------------------------------
commit be42cfafee057993d038f7d476d094c53b00b57e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Aug 20 15:53:59 2019 +0200

    s3:selftest: add delay_inject:brl_lock_windows testing
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Mon Sep  9 15:42:45 UTC 2019 on sn-devel-184
    
    (cherry picked from commit 2b43ce6704ecf035e6734337a2dea3458153a4b2)
    
    Autobuild-User(v4-11-test): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(v4-11-test): Mon Sep  9 17:19:11 UTC 2019 on sn-devel-184

commit 9bf1c5c3e48ff905eec6f9ee469f1067b4105d42
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 19 18:22:38 2019 +0200

    vfs_delay_inject: add support for brl_[un]lock_windows()
    
    This demonstrates the two ways to handle the retry:
    - smb layer retry => plock->context.smblctx = UINT64_MAX
    - vfs backend retry => plock->context.smblctx = 0
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit c2503a5c68e967054ab84ca0d8ce693200c2e002)

commit ec21e68912d2c9b1f4c3aa57d9b34db038a6b66c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 8 19:26:28 2019 +0200

    s3:locking: add brl_req_guid() and brl_req_mem_ctx() helper functions
    
    This allows the vfs backend to detect a retry and keep state between
    the retries.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 66d92f37c3a643d97489a59bb6d1e75e91528c20)

commit 74527a20584bd9d22c8487a6ebdeaca21525afe3
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 19 16:25:59 2019 +0200

    s3:smb2_lock: handle NT_STATUS_RETRY from the VFS backend
    
    This allows the VFS backends to implement async byte
    range locking.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 7471b0f63276e707784c98b832992ff08b1898ef)

commit a1117587afb6bf2f813982dfca4a47e982f44b96
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 19 15:29:32 2019 +0200

    s3:blocking: handle NT_STATUS_RETRY from the VFS backend
    
    This allows the VFS backends to implement async byte
    range locking.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 7d1cd6f22e7e3d95aba04c45776057945c2a5e30)

commit c8086b8873b37fde75dfbcd0054b5db7565b8708
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 15 20:09:55 2019 +0200

    s3:blocking: make use of smbd_smb1_do_locks_try() in smbd_smb1_do_locks_send()
    
    We only need the logic to call smbd_smb1_do_locks_check() and a possible
    retry once in smbd_smb1_do_locks_try().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 8975673e3c3f9f7dbdb7ba7562bb81a62cd24e2e)

commit 5e9d294a045d7b7e1d77dd5f306d74b165585344
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 15 18:18:50 2019 +0200

    s3:blocking: call smbd_smb1_do_locks_setup_timeout() also in smbd_smb1_do_locks_try()
    
    This is a noop if smbd_smb1_do_locks_setup_timeout() was called before.
    
    But it allows us to use smbd_smb1_do_locks_try() in
    smbd_smb1_do_locks_send() in a following commit.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 6e30a89b3f00ad55391454fbaa1272074e1962f0)

commit 11e489b0789d7c9cc7f082c054c97c6c4c6f131a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 16 14:55:13 2019 +0200

    s3:blocking: fix the fsp->blocked_smb1_lock_reqs handling
    
    A new request is first checks against all pending
    requests before checking the already granted locks.
    
    Before we retried the lock array of another request
    (the first in the list), but then finished current request,
    which is wrong.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 312327106271abafeb53e62dfb71a38bf93e2d41)

commit 333026209a8abe5d9d00297ce7f0d6cdf66d6ce0
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 19 15:21:50 2019 +0200

    s3:blocking: do the timeout calculation before calling dbwrap_watched_watch_send()
    
    This makes the next commits easier to understand.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 997548a5f1a14d82f1e80cce6d9ee55e85b5107c)

commit f479c7bc03a06a409b0037d7957806ba3208b55b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 15 18:02:57 2019 +0200

    s3:blocking: split out smbd_smb1_do_locks_setup_timeout()
    
    This function can be called multiple times, but only
    the first time will setup the endtime. And the
    endtime is relative to the request time and not
    the current time.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 8da7c10a58292022ee57406db9a365de9ffaf5cf)

commit 9f46f3b0e722d993a650fc3659e842aad08837a6
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 15 18:17:47 2019 +0200

    s3:blocking: use timeval_expired(&state->endtime) to stop processing
    
    This is less racy than timeval_elapsed() > 0
    as the current time is already expired and timeout = 0
    will always work correct.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 5a841a43f9c4f862e2d7235429363b3066cf5850)

commit d857b21d4fec18aa71f9bec4343924053dd9f083
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 16 16:24:34 2019 +0200

    s4:torture/raw: add multilock6 test
    
    This is similar to multilock3, but uses a read-only
    (LOCKING_ANDX_SHARED_LOCK) locks for the 2nd lock
    request.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit d3bc0199697fd7d6e04479321ca644a227bc4ede)

commit a037ebbc34795de46196ff50ad439356056fe082
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 16 15:12:01 2019 +0200

    s4:torture/raw: add multilock5 test
    
    This is similar to multilock3, but uses a read-only
    (LOCKING_ANDX_SHARED_LOCK) locks for the first lock
    request.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 6d4296aca0c9a9287c0c78c8f8847a560bd2ea24)

commit cc9afc3dac2fd680fd5731160889fc39eb0e360c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 16 14:49:29 2019 +0200

    s4:torture/raw: add multilock4 test
    
    This is similar to multilock3, but uses read-only
    (LOCKING_ANDX_SHARED_LOCK) locks for the blocked
    requests.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit d3e65ceb1ec25c7b62a7e908506126269011f30d)

commit 6bd411aad81477637255fcb5c826ddaf43f593b1
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 16 12:13:15 2019 +0200

    s4:torture/raw: add multilock3 test
    
    This demonstrates that unrelated lock ranges
    are not blocked by other blocked requests on the same
    fsp.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 297763c6b618c07148d788b46218a0798225bf79)

commit da765a062aa4b57814ea426c94c6b3ba23dca47c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 16 12:28:39 2019 +0200

    s4:torture/raw: improvements for multilock2
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 8a7039be530adcdda9e7e7621bdcf902f5ca1721)

commit c4d7c186aca3b9fb42354ac47f10514468b4c8b7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 2 14:50:27 2019 +0200

    s3:smb2_lock: add retry for POSIX locks
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 8decf41bbb8be2b4ac463eb6ace16a8628276ab5)

commit 061b60353d76ac368f7e48df9fe7fb899f7a2642
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 19 17:38:30 2019 +0200

    s4:torture/smb2: add smb2.samba3misc.localposixlock1
    
    This demonstrates that the SMB2 code path doesn't do
    any retry for local posix locks.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 7155d3a2c5d7237f00cccb1802c1341cf295864e)

commit 00fc583960f0983c84f960408c8cc92c25c0a928
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Aug 13 16:39:41 2019 +0200

    s3:smb2_lock: make use of smbd_smb2_lock_try() in smbd_smb2_lock_send()
    
    We only need the logic to call smbd_do_locks_try() and a possible
    retry once in smbd_smb2_lock_try().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 359e9992be713bbecfdb19998d69e1d3f020c5e9)

commit 1fb82e04d0231392a9243b6b924e6c1765110a8d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Aug 13 16:39:41 2019 +0200

    s3:smb2_lock: let smbd_smb2_lock_try() explicitly check for the retry condition
    
    This makes it possible to reuse _try() in the _send() function in the
    next commit.
    
    We should not retry forever on a hard error.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 7f77e0b4e9878f1f3515206d052adc012e26aafb)

commit c4ab0c8502284ee0a4e4336f42c352b5a19dda43
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Aug 13 16:39:41 2019 +0200

    s3:smb2_lock: error out early in smbd_smb2_lock_send()
    
    We no longer expect NT_STATUS_FILE_LOCK_CONFLICT from
    the VFS layer and assert that in a future version.
    
    This makes it easier to port the same logic to smbd_smb2_lock_try().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 39d514cdc358f175d0968f4a78f8f2f05a6c1707)

commit 5e156be97a37b9bd42b18a78cf6ab541271971e7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Aug 13 16:39:41 2019 +0200

    s3:smb2_lock: split smbd_smb2_lock_retry() into _try() and _retry()
    
    This makes it possible to reuse _try() in the _send() function in the
    next commits.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit d096742da1a045357f52ccd5b28d499c30e96152)

commit e5385142987202a67fc3667506ee233f2c726107
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Aug 13 16:14:23 2019 +0200

    s3:smb2_lock: move from 'blocking' to 'state->blocking'
    
    This will simplify the next commits.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit f13d13ae9da3072862a781bc926e7a06e8384337)

commit 8b3a50609f430ec08add2bbac77b106a585d97c6
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 19 12:33:28 2019 +0200

    s3:brlock: always return LOCK_NOT_GRANTED instead of FILE_LOCK_CONFLICT
    
    Returning NT_STATUS_FILE_LOCK_CONFLICT is a SMB1 only detail
    for delayed brlock requests, which is handled in
    smbd_smb1_do_locks*().
    
    The brlock layer should be consistent even for posix locks.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Signed-off-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit ad98eec6090430ba5296a5111dde2e53b9cd217a)

commit b56bb2ac59dd190cdf3c726a7becf2ae9d296657
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 19 12:04:43 2019 +0200

    s3:blocking: maintain state->deny_status
    
    For Windows locks we start with LOCK_NOT_GRANTED and use
    FILE_LOCK_CONFLICT if we retried after a timeout.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit aba0ee46258f3dd910421facb742fce3318a6946)

commit 85b9b5f04fdf7fa432f7260b27f77342f27dddbb
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 19 16:30:16 2019 +0200

    s4:torture/raw: assert to get LOCK_NOT_GRANTED in torture_samba3_posixtimedlock()
    
    There should not be a different if the blocker is a posix process
    instead of another smbd.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 2a77025a1e16d897281e5840192c93fa03328681)

commit 1fd0a52e6727b191aa008f7a260ad748d34d5870
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 15 17:26:43 2019 +0200

    s3:blocking: use dynamic posix lock wait intervals
    
    We want to start with a short timeout (200ms) and
    slow down to larger timeouts up to 2s for the default
    value of "lock spin time".
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 15765644d2590d6549f8fcc01c39c56387eed654)

commit e91bae2bdb11c8466a42ae51660bb564de1aedc2
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 15 16:44:11 2019 +0200

    s3:blocking: Remove bug reproducer from a few commits ago
    
    The problem is fixed, now we can revert the change that made it
    easier to trigger.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 62ec58b06c38ee82bb3147c4d325413fd3a76499)

commit 2c31c9d365d3aaa323e10abff15fc4404a4a52dd
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 15 14:21:38 2019 +0200

    s3:blocking: fix posix lock retry
    
    We should evaluate the timeout condition after the very last
    retry and not before.
    
    Otherwise we'd fail to retry when waiting for posix locks.
    The problem happens if the client provided timeout is smaller
    than the 1 sec (for testing temporary 15 secs) retry.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit e8d719d31f885d7b6d5b317165f90ec40df169c9)

commit 6b23f24ee383763c45af8c627df09060d76d9dd8
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Aug 13 18:34:36 2019 +0200

    s3:blocking: move from 'timeout' to 'smbd_smb1_do_locks_state->timeout'
    
    This will make it possible to just use smbd_smb1_do_locks_try()
    in a later commit.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 8fe708acb43ea36d0cbf398713b125daba180a2d)

commit b381f4b314c71c446a847de7cdb5baa658455c90
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Aug 13 18:34:36 2019 +0200

    s3:blocking: split smbd_smb1_do_locks_retry() into _try() and _retry()
    
    This will make it possible to have just one caller to
    smbd_do_locks_try() later and use smbd_smb1_do_locks_try()
    from within smbd_smb1_do_locks_send().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit e79fcfaaf2ecfca6c3747f6fe4be51f332ebf10d)

commit 841fceae68098160627066dd6bd180948c048d96
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 15 11:09:47 2019 +0200

    s3:blocking: demonstrate the posix lock retry fails
    
    This is just a temporary commit that shows the bug and its
    fix. It will be reverted once the problem is fixed.
    
    The posix lock retry fails if the client specified timeout
    is smaller than the hardcoded 1 second retry.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 2ec9e93a7aac2706b4a5931495d56a7b64f8d894)

commit ffdb166e49fa1a786ac1ea4e1ab09c286e75af69
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 15 14:31:54 2019 +0200

    s3:torture: convert LOCK9 into LOCK9A and LOCK9B
    
    LOCK9A is the original test (with a timeout of -1)
    and LOCK9B is the same but with timeout of 10 seconds.
    
    LOCK9B is needed to demonstrate a server bug in the next
    commits.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit ac28eec3e4af710feab3be3d4b25bfbe38294431)

commit 0742879bd8d03333b8b7c2a790afebdb5f7dd92b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Aug 15 16:10:58 2019 +0200

    s3:torture: fix the timeout alarm handling on LOCK9
    
    smbXcli_conn_disconnect(alarm_cli->conn, NT_STATUS_OK)
    means existing requests are not finished with an error,
    but instead just keep dangling arround.
    
    Pass NT_STATUS_LOCAL_DISCONNECT in order to fail the
    cli_lock32() call after getting SIGALARM.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit e18c8ced8e7a872deb118191595425ef6b826bfa)

commit 75e07d485944fdc76a6510bf5d450959475e7e5b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Aug 13 19:19:07 2019 +0200

    s3:blocking: remove unused timeval_brl_min()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 3b788d97f9995e24e4005567f90a925957fb1e00)

commit f73b670b4db103069aa151d3af4ed7a92ce581c3
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 9 00:47:39 2019 +0200

    s3:locking: add share_mode_wakeup_waiters() helper function
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit bd8884e5722cbbb7783fb4ae53e4f35b31031b01)

commit 244ad1210cc29ede25fb8692bae46aab7d6725ac
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Sep 5 08:43:32 2019 +0200

    s3:locking: add/split out byte_range_{valid,overlap}() helper functions
    
    They implement the logic from [MS-FSA].
    
    The following commits will use these functions in other locations.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 0e5613e39d6c6bb892fed939c63b4f14b878803b)

commit 80a04a4e19adfe87c5217d75b11e41763f644749
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Sep 4 12:47:07 2019 +0200

    s3:smb2_lock: call change_to_user_by_fsp() when dbwrap_watched_watch* finishes
    
    This is not strictly required as fd-based calls are used,
    but it's more consistent to call SMB_VFS_BRL_LOCK_WINDOWS()
    in the same environment on retry.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 8b565de1acb0fda121cb0bd4cff42d66ee027529)

commit 728e29d84ca594a5607f072e50de60deaa9da45e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Sep 4 12:50:06 2019 +0200

    s3:blocking: call change_to_user_by_fsp() when dbwrap_watched_watch* finishes
    
    This is not strictly required as fd-based calls are used,
    but it's more consistent to call SMB_VFS_BRL_LOCK_WINDOWS()
    in the same environment on retry.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 28ac2cbaf92a8619f0380f024c5a220d9fdc4622)

-----------------------------------------------------------------------

Summary of changes:
 selftest/knownfail                 |    1 +
 selftest/skip                      |    3 +-
 selftest/target/Samba3.pm          |   12 +
 source3/include/locking.h          |    2 +
 source3/locking/brlock.c           |  162 +++++-
 source3/locking/locking.c          |   11 +-
 source3/locking/proto.h            |   15 +
 source3/locking/share_mode_lock.c  |   12 +
 source3/modules/vfs_delay_inject.c |  117 ++++
 source3/modules/vfs_fruit.c        |   13 +
 source3/selftest/tests.py          |    9 +-
 source3/smbd/blocking.c            |  545 ++++++++++++------
 source3/smbd/globals.c             |   18 +
 source3/smbd/globals.h             |    2 +
 source3/smbd/proto.h               |    4 +-
 source3/smbd/reply.c               |    7 +
 source3/smbd/smb2_lock.c           |  243 ++++++--
 source3/smbd/trans2.c              |    2 +
 source3/torture/torture.c          |   40 +-
 source4/torture/raw/lock.c         | 1069 +++++++++++++++++++++++++++++++++++-
 source4/torture/raw/samba3misc.c   |    6 +-
 source4/torture/smb2/samba3misc.c  |  188 +++++++
 source4/torture/smb2/smb2.c        |    1 +
 source4/torture/smb2/wscript_build |    1 +
 24 files changed, 2232 insertions(+), 251 deletions(-)
 create mode 100644 source4/torture/smb2/samba3misc.c


Changeset truncated at 500 lines:

diff --git a/selftest/knownfail b/selftest/knownfail
index ded80b12259..7b54b77a708 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -109,6 +109,7 @@
 .*net.api.delshare.*				# DelShare isn't implemented yet
 ^samba4.smb2.oplock.doc
 ^samba4.smb2.lock.valid-request
+^samba4.raw.lock.multilock6.ad_dc_ntvfs
 ^samba4.ldap.python \(ad_dc_default\).Test add_ldif\(\) with BASE64 security descriptor input using WRONG domain SID\(.*\)$
 ^samba4.raw.lock.*.async # bug 6960
 ^samba4.raw.open.ntcreatex_supersede
diff --git a/selftest/skip b/selftest/skip
index 1e7448acb9f..11bf29599fa 100644
--- a/selftest/skip
+++ b/selftest/skip
@@ -34,7 +34,7 @@
 ^samba3.smbtorture_s3.*.pipe_number
 ^samba3.smbtorture_s3.LOCAL-DBTRANS #hangs for some reason
 ^samba3.smbtorture_s3.*.DIR1 #loops on 64 bit linux with ext4
-^samba3.smbtorture_s3.plain.LOCK9\(ad_dc_ntvfs\) # Fails against the s4 ntvfs server
+^samba3.smbtorture_s3.plain.LOCK9.*\(ad_dc_ntvfs\) # Fails against the s4 ntvfs server
 ^samba3.smbtorture_s3.plain.OPLOCK2\(ad_dc_ntvfs\) # Fails against the s4 ntvfs server
 ^samba3.smbtorture_s3.plain.STREAMERROR\(ad_dc_ntvfs\) # Fails against the s4 ntvfs server
 ^samba3.smbtorture_s3.plain.DIR1\(ad_dc_ntvfs\) # Fails against the s4 ntvfs server
@@ -93,6 +93,7 @@
 ^samba4.rpc.samr.passwords.*ncacn_np\(ad_dc_slowtests\) # currently fails, possibly config issue
 ^samba4.rpc.samr.passwords.*s4member       # currently fails, possibly config issue
 ^samba4.raw.scan.eamax
+^samba4.smb2.samba3misc
 ^samba4.smb2.notify
 ^samba4.smb2.scan
 ^samba4.smb2.lease
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 9638bb44f08..131d576a767 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -2263,6 +2263,18 @@ sub provision($$$$$$$$$)
 	delay_inject:pread_send = 2000
 	delay_inject:pwrite_send = 2000
 
+[brl_delay_inject1]
+	copy = tmp
+	vfs objects = delay_inject
+	delay_inject:brl_lock_windows = 90
+	delay_inject:brl_lock_windows_use_timer = yes
+
+[brl_delay_inject2]
+	copy = tmp
+	vfs objects = delay_inject
+	delay_inject:brl_lock_windows = 90
+	delay_inject:brl_lock_windows_use_timer = no
+
 [delete_readonly]
 	path = $prefix_abs/share
 	delete readonly = yes
diff --git a/source3/include/locking.h b/source3/include/locking.h
index 3e7560bef9e..0175db2dd47 100644
--- a/source3/include/locking.h
+++ b/source3/include/locking.h
@@ -30,6 +30,7 @@ enum brl_type {READ_LOCK, WRITE_LOCK, UNLOCK_LOCK};
 enum brl_flavour {WINDOWS_LOCK = 0, POSIX_LOCK = 1};
 
 #include "librpc/gen_ndr/server_id.h"
+#include "librpc/gen_ndr/misc.h"
 
 /* This contains elements that differentiate locks. The smbpid is a
    client supplied pid, and is essentially the locking context for
@@ -62,6 +63,7 @@ struct lock_struct {
 };
 
 struct smbd_lock_element {
+	struct GUID req_guid;
 	uint64_t smblctx;
 	enum brl_type brltype;
 	uint64_t offset;
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index cdfd09ceff1..f22580164f9 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -46,6 +46,8 @@ static struct db_context *brlock_db;
 
 struct byte_range_lock {
 	struct files_struct *fsp;
+	TALLOC_CTX *req_mem_ctx;
+	const struct GUID *req_guid;
 	unsigned int num_locks;
 	bool modified;
 	struct lock_struct *lock_data;
@@ -84,6 +86,25 @@ struct files_struct *brl_fsp(struct byte_range_lock *brl)
 	return brl->fsp;
 }
 
+TALLOC_CTX *brl_req_mem_ctx(const struct byte_range_lock *brl)
+{
+	if (brl->req_mem_ctx == NULL) {
+		return talloc_get_type_abort(brl, struct byte_range_lock);
+	}
+
+	return brl->req_mem_ctx;
+}
+
+const struct GUID *brl_req_guid(const struct byte_range_lock *brl)
+{
+	if (brl->req_guid == NULL) {
+		static const struct GUID brl_zero_req_guid;
+		return &brl_zero_req_guid;
+	}
+
+	return brl->req_guid;
+}
+
 /****************************************************************************
  See if two locking contexts are equal.
 ****************************************************************************/
@@ -96,6 +117,92 @@ static bool brl_same_context(const struct lock_context *ctx1,
 		(ctx1->tid == ctx2->tid));
 }
 
+bool byte_range_valid(uint64_t ofs, uint64_t len)
+{
+	uint64_t max_len = UINT64_MAX - ofs;
+	uint64_t effective_len;
+
+	/*
+	 * [MS-FSA] specifies this:
+	 *
+	 * If (((FileOffset + Length - 1) < FileOffset) && Length != 0) {
+	 *   return STATUS_INVALID_LOCK_RANGE
+	 * }
+	 *
+	 * We avoid integer wrapping and calculate
+	 * max and effective len instead.
+	 */
+
+	if (len == 0) {
+		return true;
+	}
+
+	effective_len = len - 1;
+	if (effective_len <= max_len) {
+		return true;
+	}
+
+	return false;
+}
+
+bool byte_range_overlap(uint64_t ofs1,
+			uint64_t len1,
+			uint64_t ofs2,
+			uint64_t len2)
+{
+	uint64_t last1;
+	uint64_t last2;
+	bool valid;
+
+	/*
+	 * This is based on [MS-FSA] 2.1.4.10
+	 * Algorithm for Determining If a Range Access
+	 * Conflicts with Byte-Range Locks
+	 */
+
+	/*
+	 * The {0, 0} range doesn't conflict with any byte-range lock
+	 */
+	if (ofs1 == 0 && len1 == 0) {
+		return false;
+	}
+	if (ofs2 == 0 && len2 == 0) {
+		return false;
+	}
+
+	/*
+	 * The caller should have checked that the ranges are
+	 * valid. But currently we gracefully handle
+	 * the overflow of a read/write check.
+	 */
+	valid = byte_range_valid(ofs1, len1);
+	if (valid) {
+		last1 = ofs1 + len1 - 1;
+	} else {
+		last1 = UINT64_MAX;
+	}
+	valid = byte_range_valid(ofs2, len2);
+	if (valid) {
+		last2 = ofs2 + len2 - 1;
+	} else {
+		last2 = UINT64_MAX;
+	}
+
+	/*
+	 * If one range starts after the last
+	 * byte of the other range there's
+	 * no conflict.
+	 */
+	if (ofs1 > last2) {
+		return false;
+	}
+	if (ofs2 > last1) {
+		return false;
+	}
+
+	return true;
+}
+
 /****************************************************************************
  See if lck1 and lck2 overlap.
 ****************************************************************************/
@@ -103,20 +210,10 @@ static bool brl_same_context(const struct lock_context *ctx1,
 static bool brl_overlap(const struct lock_struct *lck1,
                         const struct lock_struct *lck2)
 {
-	/* XXX Remove for Win7 compatibility. */
-	/* this extra check is not redundant - it copes with locks
-	   that go beyond the end of 64 bit file space */
-	if (lck1->size != 0 &&
-	    lck1->start == lck2->start &&
-	    lck1->size == lck2->size) {
-		return True;
-	}
-
-	if (lck1->start >= (lck2->start+lck2->size) ||
-	    lck2->start >= (lck1->start+lck1->size)) {
-		return False;
-	}
-	return True;
+	return byte_range_overlap(lck1->start,
+				  lck1->size,
+				  lck2->start,
+				  lck2->size);
 }
 
 /****************************************************************************
@@ -336,11 +433,12 @@ NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck,
 	files_struct *fsp = br_lck->fsp;
 	struct lock_struct *locks = br_lck->lock_data;
 	NTSTATUS status;
+	bool valid;
 
 	SMB_ASSERT(plock->lock_type != UNLOCK_LOCK);
 
-	if ((plock->start + plock->size - 1 < plock->start) &&
-			plock->size != 0) {
+	valid = byte_range_valid(plock->start, plock->size);
+	if (!valid) {
 		return NT_STATUS_INVALID_LOCK_RANGE;
 	}
 
@@ -385,7 +483,7 @@ NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck,
 			plock->context.smblctx = 0xFFFFFFFFFFFFFFFFLL;
 
 			if (errno_ret == EACCES || errno_ret == EAGAIN) {
-				status = NT_STATUS_FILE_LOCK_CONFLICT;
+				status = NT_STATUS_LOCK_NOT_GRANTED;
 				goto fail;
 			} else {
 				status = map_nt_error_from_unix(errno);
@@ -752,7 +850,7 @@ static NTSTATUS brl_lock_posix(struct byte_range_lock *br_lck,
 				TALLOC_FREE(tp);
 				/* Remember who blocked us. */
 				plock->context.smblctx = curr_lock->context.smblctx;
-				return NT_STATUS_FILE_LOCK_CONFLICT;
+				return NT_STATUS_LOCK_NOT_GRANTED;
 			}
 			/* Just copy the Windows lock into the new array. */
 			memcpy(&tp[count], curr_lock, sizeof(struct lock_struct));
@@ -772,7 +870,7 @@ static NTSTATUS brl_lock_posix(struct byte_range_lock *br_lck,
 				TALLOC_FREE(tp);
 				/* Remember who blocked us. */
 				plock->context.smblctx = curr_lock->context.smblctx;
-				return NT_STATUS_FILE_LOCK_CONFLICT;
+				return NT_STATUS_LOCK_NOT_GRANTED;
 			}
 
 			/* Work out overlaps. */
@@ -835,7 +933,7 @@ static NTSTATUS brl_lock_posix(struct byte_range_lock *br_lck,
 
 			if (errno_ret == EACCES || errno_ret == EAGAIN) {
 				TALLOC_FREE(tp);
-				status = NT_STATUS_FILE_LOCK_CONFLICT;
+				status = NT_STATUS_LOCK_NOT_GRANTED;
 				goto fail;
 			} else {
 				TALLOC_FREE(tp);
@@ -1746,6 +1844,25 @@ struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx, files_struct *fsp)
 	return br_lck;
 }
 
+struct byte_range_lock *brl_get_locks_for_locking(TALLOC_CTX *mem_ctx,
+						  files_struct *fsp,
+						  TALLOC_CTX *req_mem_ctx,
+						  const struct GUID *req_guid)
+{
+	struct byte_range_lock *br_lck = NULL;
+
+	br_lck = brl_get_locks(mem_ctx, fsp);
+	if (br_lck == NULL) {
+		return NULL;
+	}
+	SMB_ASSERT(req_mem_ctx != NULL);
+	br_lck->req_mem_ctx = req_mem_ctx;
+	SMB_ASSERT(req_guid != NULL);
+	br_lck->req_guid = req_guid;
+
+	return br_lck;
+}
+
 struct brl_get_locks_readonly_state {
 	TALLOC_CTX *mem_ctx;
 	struct byte_range_lock **br_lock;
@@ -1807,14 +1924,11 @@ struct byte_range_lock *brl_get_locks_readonly(files_struct *fsp)
 		/*
 		 * No locks on this file. Return an empty br_lock.
 		 */
-		br_lock = talloc(fsp, struct byte_range_lock);
+		br_lock = talloc_zero(fsp, struct byte_range_lock);
 		if (br_lock == NULL) {
 			return NULL;
 		}
 
-		br_lock->num_locks = 0;
-		br_lock->lock_data = NULL;
-
 	} else if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(3, ("Could not parse byte range lock record: "
 			  "%s\n", nt_errstr(status)));
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index d87a882d14f..8fa1237d6ad 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -232,6 +232,8 @@ static void decrement_current_lock_count(files_struct *fsp,
 
 struct do_lock_state {
 	struct files_struct *fsp;
+	TALLOC_CTX *req_mem_ctx;
+	const struct GUID *req_guid;
 	uint64_t smblctx;
 	uint64_t count;
 	uint64_t offset;
@@ -251,7 +253,10 @@ static void do_lock_fn(
 	struct do_lock_state *state = private_data;
 	struct byte_range_lock *br_lck = NULL;
 
-	br_lck = brl_get_locks(talloc_tos(), state->fsp);
+	br_lck = brl_get_locks_for_locking(talloc_tos(),
+					   state->fsp,
+					   state->req_mem_ctx,
+					   state->req_guid);
 	if (br_lck == NULL) {
 		state->status = NT_STATUS_NO_MEMORY;
 		return;
@@ -272,6 +277,8 @@ static void do_lock_fn(
 }
 
 NTSTATUS do_lock(files_struct *fsp,
+		 TALLOC_CTX *req_mem_ctx,
+		 const struct GUID *req_guid,
 		 uint64_t smblctx,
 		 uint64_t count,
 		 uint64_t offset,
@@ -282,6 +289,8 @@ NTSTATUS do_lock(files_struct *fsp,
 {
 	struct do_lock_state state = {
 		.fsp = fsp,
+		.req_mem_ctx = req_mem_ctx,
+		.req_guid = req_guid,
 		.smblctx = smblctx,
 		.count = count,
 		.offset = offset,
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index 3a086fa0516..7cf681561bc 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -30,6 +30,14 @@ void brl_shutdown(void);
 
 unsigned int brl_num_locks(const struct byte_range_lock *brl);
 struct files_struct *brl_fsp(struct byte_range_lock *brl);
+TALLOC_CTX *brl_req_mem_ctx(const struct byte_range_lock *brl);
+const struct GUID *brl_req_guid(const struct byte_range_lock *brl);
+
+bool byte_range_valid(uint64_t ofs, uint64_t len);
+bool byte_range_overlap(uint64_t ofs1,
+			uint64_t len1,
+			uint64_t ofs2,
+			uint64_t len2);
 
 NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck,
 				  struct lock_struct *plock);
@@ -70,6 +78,10 @@ int brl_forall(void (*fn)(struct file_id id, struct server_id pid,
 			  br_off start, br_off size,
 			  void *private_data),
 	       void *private_data);
+struct byte_range_lock *brl_get_locks_for_locking(TALLOC_CTX *mem_ctx,
+						  files_struct *fsp,
+						  TALLOC_CTX *req_mem_ctx,
+						  const struct GUID *req_guid);
 struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx,
 					files_struct *fsp);
 struct byte_range_lock *brl_get_locks_readonly(files_struct *fsp);
@@ -94,6 +106,8 @@ NTSTATUS query_lock(files_struct *fsp,
 			enum brl_type *plock_type,
 			enum brl_flavour lock_flav);
 NTSTATUS do_lock(files_struct *fsp,
+		 TALLOC_CTX *req_mem_ctx,
+		 const struct GUID *req_guid,
 		 uint64_t smblctx,
 		 uint64_t count,
 		 uint64_t offset,
@@ -132,6 +146,7 @@ NTSTATUS share_mode_do_locked(
 		   bool *modified_dependent,
 		   void *private_data),
 	void *private_data);
+NTSTATUS share_mode_wakeup_waiters(struct file_id id);
 
 struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
 						  struct file_id id);
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index 430d14fab4a..372e188c1c0 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -771,6 +771,18 @@ NTSTATUS share_mode_do_locked(
 	return NT_STATUS_OK;
 }
 
+static void share_mode_wakeup_waiters_fn(struct db_record *rec,
+					 bool *modified_dependent,
+					 void *private_data)
+{
+	*modified_dependent = true;
+}
+
+NTSTATUS share_mode_wakeup_waiters(struct file_id id)
+{
+	return share_mode_do_locked(id, share_mode_wakeup_waiters_fn, NULL);
+}
+
 struct fetch_share_mode_unlocked_state {
 	TALLOC_CTX *mem_ctx;
 	struct share_mode_lock *lck;
diff --git a/source3/modules/vfs_delay_inject.c b/source3/modules/vfs_delay_inject.c
index d561fadb03b..569bd40054a 100644
--- a/source3/modules/vfs_delay_inject.c
+++ b/source3/modules/vfs_delay_inject.c
@@ -304,12 +304,129 @@ static ssize_t vfs_delay_inject_pwrite_recv(struct tevent_req *req,
 	return state->ret;
 }
 
+struct vfs_delay_inject_brl_lock_state {
+	struct vfs_delay_inject_brl_lock_state *prev, *next;
+	struct files_struct *fsp;
+	struct GUID req_guid;
+	struct timeval delay_tv;
+	struct tevent_timer *delay_te;
+};
+
+static struct vfs_delay_inject_brl_lock_state *brl_lock_states;
+
+static int vfs_delay_inject_brl_lock_state_destructor(struct vfs_delay_inject_brl_lock_state *state)
+{
+	DLIST_REMOVE(brl_lock_states, state);
+	return 0;
+}
+
+static void vfs_delay_inject_brl_lock_timer(struct tevent_context *ev,
+					    struct tevent_timer *te,
+					    struct timeval current_time,
+					    void *private_data)
+{
+	struct vfs_delay_inject_brl_lock_state *state =
+		talloc_get_type_abort(private_data,
+		struct vfs_delay_inject_brl_lock_state);
+	NTSTATUS status;
+
+	TALLOC_FREE(state->delay_te);
+
+	status = share_mode_wakeup_waiters(state->fsp->file_id);
+	if (!NT_STATUS_IS_OK(status)) {
+		DBG_ERR("share_mode_wakeup_waiters(%s) %s\n",
+			file_id_string_tos(&state->fsp->file_id),
+			nt_errstr(status));
+	}
+}
+
+static NTSTATUS vfs_delay_inject_brl_lock_windows(struct vfs_handle_struct *handle,
+						  struct byte_range_lock *br_lck,
+						  struct lock_struct *plock)
+{
+	struct files_struct *fsp = brl_fsp(br_lck);
+	TALLOC_CTX *req_mem_ctx = brl_req_mem_ctx(br_lck);
+	const struct GUID *req_guid = brl_req_guid(br_lck);
+	struct vfs_delay_inject_brl_lock_state *state = NULL;
+	bool expired;
+
+	for (state = brl_lock_states; state != NULL; state = state->next) {
+		bool match;
+
+		match = GUID_equal(&state->req_guid, req_guid);
+		if (match) {
+			break;
+		}


-- 
Samba Shared Repository



More information about the samba-cvs mailing list