s3/smbd: change locking behavior when "lock spin time = 0".
authorSteven Danneman <steven.danneman@isilon.com>
Fri, 12 Feb 2010 23:42:50 +0000 (15:42 -0800)
committerKarolin Seeger <kseeger@samba.org>
Tue, 16 Feb 2010 09:02:29 +0000 (10:02 +0100)
The "lock spin time" parameter mimics the following Windows
setting which by default is 250ms in Windows and 200ms in Samba.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\LockViolationDelay

When a client sends repeated, non-blocking, contending BRL requests
to a Windows server, after the first Windows starts treating these
requests as timed blocking locks with the above timeout.

As an efficiency, I've changed the behavior when this setting is 0,
to skip this logic and treat all requests as non-blocking locks.

This gives the smbd server behavior similar to the 3.0 release with
the do_spin_lock() implementation.

I've also changed the blocking lock parameter in the call from
push_blocking_lock_request() to true as all requests made in this
path are blocking by definition.
(cherry picked from commit cb0ea273696fc9024e6da18eb3e319024f8643f5)

Fix bug #7138 (Backport 'lock spin time" enhancement to 3.5.1).

source3/smbd/blocking.c
source3/smbd/reply.c

index deb7f8f221d26acd20cc2c5cba4eb696bce1c5a6..e33c0b6ae51281b52bd2e3879dd755186580d8dc 100644 (file)
@@ -185,7 +185,7 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck,
                        count,
                        lock_type == READ_LOCK ? PENDING_READ_LOCK : PENDING_WRITE_LOCK,
                        blr->lock_flav,
-                       lock_timeout ? True : False, /* blocking_lock. */
+                       True,
                        NULL,
                        blr);
 
index b6316aac467cf545b364f08ef6c8a8edf236193d..b1a4e31951f3a0bf2f159fe6430e6828cb74ed47 100644 (file)
@@ -7120,13 +7120,22 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
                                defer_lock = true;
                        }
 
-                       /* This heuristic seems to match W2K3 very well. If a
-                          lock sent with timeout of zero would fail with NT_STATUS_FILE_LOCK_CONFLICT
-                          it pretends we asked for a timeout of between 150 - 300 milliseconds as
-                          far as I can tell. Replacement for do_lock_spin(). JRA. */
+                       /* If a lock sent with timeout of zero would fail, and
+                        * this lock has been requested multiple times,
+                        * according to brl_lock_failed() we convert this
+                        * request to a blocking lock with a timeout of between
+                        * 150 - 300 milliseconds.
+                        *
+                        * If lp_lock_spin_time() has been set to 0, we skip
+                        * this blocking retry and fail immediately.
+                        *
+                        * Replacement for do_lock_spin(). JRA. */
 
-                       if (br_lck && lp_blocking_locks(SNUM(conn)) && !blocking_lock &&
-                                       NT_STATUS_EQUAL((status), NT_STATUS_FILE_LOCK_CONFLICT)) {
+                       if (br_lck && lp_blocking_locks(SNUM(conn)) &&
+                           lp_lock_spin_time() && !blocking_lock &&
+                           NT_STATUS_EQUAL((status),
+                               NT_STATUS_FILE_LOCK_CONFLICT))
+                       {
                                defer_lock = true;
                                timeout = lp_lock_spin_time();
                        }