diff options
author | Dave Richards <dave.richards@isilon.com> | 2009-03-13 14:15:28 -0700 |
---|---|---|
committer | Tim Prouty <tprouty@samba.org> | 2009-03-13 14:16:55 -0700 |
commit | 1fcc11ff25f1c3e7586b13b24e5d0eec4ccfaedc (patch) | |
tree | 48e52776085f9db96fce7e62f695aef5c6d774da /source3/locking | |
parent | 1355dc2fd3a10c54fc3534409b78972d59d59b30 (diff) | |
download | samba-1fcc11ff25f1c3e7586b13b24e5d0eec4ccfaedc.tar.gz samba-1fcc11ff25f1c3e7586b13b24e5d0eec4ccfaedc.tar.bz2 samba-1fcc11ff25f1c3e7586b13b24e5d0eec4ccfaedc.zip |
s3: Add strict lock/unlock calls to the vfs layer to replace is_locked
Diffstat (limited to 'source3/locking')
-rw-r--r-- | source3/locking/locking.c | 90 |
1 files changed, 55 insertions, 35 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c index e9a5f757e5..bafb89522a 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -75,69 +75,89 @@ const char *lock_flav_name(enum brl_flavour lock_flav) Called in the read/write codepath. ****************************************************************************/ -bool is_locked(files_struct *fsp, - uint32 smbpid, - uint64_t count, - uint64_t offset, - enum brl_type lock_type) +void init_strict_lock_struct(files_struct *fsp, + uint32 smbpid, + br_off start, + br_off size, + enum brl_type lock_type, + struct lock_struct *plock) +{ + SMB_ASSERT(lock_type == READ_LOCK || lock_type == WRITE_LOCK); + + plock->context.smbpid = smbpid; + plock->context.tid = fsp->conn->cnum; + plock->context.pid = procid_self(); + plock->start = start; + plock->size = size; + plock->fnum = fsp->fnum; + plock->lock_type = lock_type; + plock->lock_flav = lp_posix_cifsu_locktype(fsp); +} + +bool strict_lock_default(files_struct *fsp, struct lock_struct *plock) { int strict_locking = lp_strict_locking(fsp->conn->params); - enum brl_flavour lock_flav = lp_posix_cifsu_locktype(fsp); - bool ret = True; - - if (count == 0) { - return False; + bool ret = False; + + if (plock->size == 0) { + return True; } if (!lp_locking(fsp->conn->params) || !strict_locking) { - return False; + return True; } if (strict_locking == Auto) { - if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && (lock_type == READ_LOCK || lock_type == WRITE_LOCK)) { + if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && (plock->lock_type == READ_LOCK || plock->lock_type == WRITE_LOCK)) { DEBUG(10,("is_locked: optimisation - exclusive oplock on file %s\n", fsp->fsp_name )); - ret = False; + ret = True; } else if ((fsp->oplock_type == LEVEL_II_OPLOCK) && - (lock_type == READ_LOCK)) { + (plock->lock_type == READ_LOCK)) { DEBUG(10,("is_locked: optimisation - level II oplock on file %s\n", fsp->fsp_name )); - ret = False; + ret = True; } else { struct byte_range_lock *br_lck = brl_get_locks_readonly(talloc_tos(), fsp); if (!br_lck) { - return False; + return True; } - ret = !brl_locktest(br_lck, - smbpid, - procid_self(), - offset, - count, - lock_type, - lock_flav); + ret = brl_locktest(br_lck, + plock->context.smbpid, + plock->context.pid, + plock->start, + plock->size, + plock->lock_type, + plock->lock_flav); TALLOC_FREE(br_lck); } } else { struct byte_range_lock *br_lck = brl_get_locks_readonly(talloc_tos(), fsp); if (!br_lck) { - return False; + return True; } - ret = !brl_locktest(br_lck, - smbpid, - procid_self(), - offset, - count, - lock_type, - lock_flav); + ret = brl_locktest(br_lck, + plock->context.smbpid, + plock->context.pid, + plock->start, + plock->size, + plock->lock_type, + plock->lock_flav); TALLOC_FREE(br_lck); } - DEBUG(10,("is_locked: flavour = %s brl start=%.0f len=%.0f %s for fnum %d file %s\n", - lock_flav_name(lock_flav), - (double)offset, (double)count, ret ? "locked" : "unlocked", - fsp->fnum, fsp->fsp_name )); + DEBUG(10,("strict_lock_default: flavour = %s brl start=%.0f " + "len=%.0f %s for fnum %d file %s\n", + lock_flav_name(plock->lock_flav), + (double)plock->start, (double)plock->size, + ret ? "unlocked" : "locked", + plock->fnum, fsp->fsp_name )); return ret; } +void strict_unlock_default(files_struct *fsp, struct lock_struct *plock) +{ +} + /**************************************************************************** Find out if a lock could be granted - return who is blocking us if we can't. ****************************************************************************/ |