diff options
author | Zack Kirsch <zack.kirsch@isilon.com> | 2009-02-09 21:51:29 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2009-02-13 10:08:40 -0800 |
commit | 813273c87e4f48d7d8415c8ee9a1a553ed369429 (patch) | |
tree | 2f6140e3f75d987f437ff93a291a4e8e14117d1b /source3/smbd/reply.c | |
parent | eb3d964f20f44deaf2b4f07adba64785875710e0 (diff) | |
download | samba-813273c87e4f48d7d8415c8ee9a1a553ed369429.tar.gz samba-813273c87e4f48d7d8415c8ee9a1a553ed369429.tar.bz2 samba-813273c87e4f48d7d8415c8ee9a1a553ed369429.zip |
Add VFS ops for Windows BRL: Lock, Unlock and Cancel:
This patch adds 3 new VFS OPs for Windows byte range locking: BRL_LOCK_WINDOWS,
BRL_UNLOCK_WINDOWS and BRL_CANCEL_WINDOWS. Specifically:
* I renamed brl_lock_windows, brl_unlock_windows and brl_lock_cancel to
*_default as the default implementations of the VFS ops.
* The blocking_lock_record (BLR) is now passed into the brl_lock_windows and
brl_cancel_windows paths. The Onefs implementation uses it - future
implementations may find it useful too.
* Created brl_lock_cancel to do what brl_lock/brl_unlock do: set up a
lock_struct and call either the Posix or Windows lock function. These happen
to be the same for the default implementation.
* Added helper functions: increment_current_lock_count() and
decrement_current_lock_count().
* Minor spelling correction in brl_timeout_fn: brl -> blr.
* Changed blocking_lock_cancel() to return the BLR that it has cancelled. This
allows us to assert its the lock that we wanted to cancel. If this assert ever
fires, this path will need to take in the BLR to cancel, rather than choosing
on its own.
* Adds a small helper function: find_blocking_lock_record_by_id(). Used by the
OneFS implementation, but could be useful for others.
Diffstat (limited to 'source3/smbd/reply.c')
-rw-r--r-- | source3/smbd/reply.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 256160c402..1ed5e7229e 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -3040,6 +3040,7 @@ void reply_lockread(struct smb_request *req) WINDOWS_LOCK, False, /* Non-blocking lock. */ &status, + NULL, NULL); TALLOC_FREE(br_lck); @@ -4514,6 +4515,7 @@ void reply_lock(struct smb_request *req) WINDOWS_LOCK, False, /* Non-blocking lock. */ &status, + NULL, NULL); TALLOC_FREE(br_lck); @@ -6904,6 +6906,9 @@ void reply_lockingX(struct smb_request *req) offset, WINDOWS_LOCK); + DEBUG(10, ("reply_lockingX: unlock returned %s\n", + nt_errstr(status))); + if (NT_STATUS_V(status)) { END_PROFILE(SMBlockingX); reply_nterror(req, status); @@ -6945,19 +6950,22 @@ void reply_lockingX(struct smb_request *req) fsp->fsp_name, (int)lock_timeout )); if (locktype & LOCKING_ANDX_CANCEL_LOCK) { + struct blocking_lock_record *blr; + if (lp_blocking_locks(SNUM(conn))) { /* Schedule a message to ourselves to remove the blocking lock record and return the right error. */ - if (!blocking_lock_cancel(fsp, + blr = blocking_lock_cancel(fsp, lock_pid, offset, count, WINDOWS_LOCK, locktype, - NT_STATUS_FILE_LOCK_CONFLICT)) { + NT_STATUS_FILE_LOCK_CONFLICT); + if (blr == NULL) { END_PROFILE(SMBlockingX); reply_nterror( req, @@ -6972,7 +6980,8 @@ void reply_lockingX(struct smb_request *req) lock_pid, count, offset, - WINDOWS_LOCK); + WINDOWS_LOCK, + blr); } else { bool blocking_lock = lock_timeout ? True : False; bool defer_lock = False; @@ -6988,7 +6997,8 @@ void reply_lockingX(struct smb_request *req) WINDOWS_LOCK, blocking_lock, &status, - &block_smbpid); + &block_smbpid, + NULL); if (br_lck && blocking_lock && ERROR_WAS_LOCK_DENIED(status)) { /* Windows internal resolution for blocking locks seems |