summaryrefslogtreecommitdiffstats
path: root/source3/locking/brlock.c
Commit message (Collapse)AuthorAgeFilesLines
* s3:locking: fix uninitialiazed variable in brl_get_locks_readonly_parser()Stefan Metzmacher2014-12-181-0/+1
| | | | | | | | | | | | | In a cluster this can be called with an empty record, while brl_parse_data() relies on an initialized structure. This is a regression in commit 837e29035c911f3509135252c3f423d0f56b606d. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10911 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:locking: convert brl_have_read field to brl_num_read.Volker Lendecke2014-11-111-67/+56
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* brlock: don't leak lock_path onto talloc tosDavid Disseldorp2014-11-031-2/+11
| | | | | | | Also check for allocation failures. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:locking: remove dead code from brl_get_locks_readonly()Stefan Metzmacher2014-10-311-50/+28
| | | | | | | | | | | | | | | struct byte_range_lock *rw = NULL; will never change... commit 105724073300af03eb0835b3c93d9b2e2bfacb07 removed the possible assigment of 'rw'. So we can remove all code under if (rw != NULL) { ... Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Oct 31 06:07:43 CET 2014 on sn-devel-104
* brlock: Remove validate_lock_entriesVolker Lendecke2014-08-231-94/+1
| | | | | | | | | This is now only called during brl_forall. It does not really hurt if we list dead processes here. If the upper layers really care, they can filter it out themselves. The real lock conflicts are not removed on-demand. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* brlock: Do auto-cleanup at conflict timeVolker Lendecke2014-08-231-46/+46
| | | | | | | This avoids the need to do sweeping validate_lock_entries calls Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Simplify brl_locktestVolker Lendecke2014-07-221-19/+13
| | | | | | | | Pass "struct lock_struct" as a parameter. This had to be destructured before the call and re-constructed inside brl_locktest. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Restructure brl_conflict_otherVolker Lendecke2014-07-221-14/+39
| | | | | | | | It took me really long to grasp what's going on in this routine. I hope its logic is easier to understand now Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Fix indentation, {} and line length in brl_conflict_otherVolker Lendecke2014-07-221-6/+14
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Rename lck2->rw_probe in brl_conflict_otherVolker Lendecke2014-07-221-8/+8
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Rename lck1->lock in brl_conflict_otherVolker Lendecke2014-07-221-8/+8
| | | | | | | | lck1 and lck2 are treated differently. They should carry more descriptive names. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Use a struct initializer brl_lockVolker Lendecke2014-07-221-13/+10
| | | | | | | Avoids a #ifdef DEVELOPER and saves a few bytes .text Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Use %ju/uintmax_t in source3/lockingVolker Lendecke2014-07-221-12/+14
| | | | | | | Avoid going through (double) and %.0f Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: brl_lock_cancel does not need "blr" anymoreVolker Lendecke2014-07-041-2/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove unused blocking_lock_record* from VFS_BRL_CANCEL_WINDOWSVolker Lendecke2014-07-041-4/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: brl_lock does not need "blr" anymoreVolker Lendecke2014-07-041-2/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove unused blocking_lock_record* from VFS_BRL_LOCK_WINDOWSVolker Lendecke2014-07-041-4/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Use brl_delete_lock_struct in brl_lock_cancel_defaultVolker Lendecke2014-07-041-6/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: smbd: Locking, fix off-by one calculation in brl_pending_overlap().Jeremy Allison2014-07-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider: lock = start=110,size=10 pend_lock = 100, size=10 Do not overlap. However, (lock->start <= pend_lock->start + pend_lock->size) 110 100 10 is true, so it returns true (overlap). lock->start <= pend_lock->start + pend_lock->size should be: lock->start < pend_lock->start + pend_lock->size BUG: https://bugzilla.samba.org/show_bug.cgi?id=10685 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Wed Jul 2 10:18:17 CEST 2014 on sn-devel-104
* smbd: validate_lock_entries does not need mem_ctx anymoreVolker Lendecke2014-06-301-4/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Simplify validate_lock_entriesVolker Lendecke2014-06-301-36/+10
| | | | Signed-off-by: Volker Lendecke <vl@samba.org>
* smbd: Factor out brl_delete_lock_structVolker Lendecke2014-06-301-6/+12
| | | | | | | | memmove calculations are never nice, and this is going to be used in validate_lock_entries soon :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Simplify validate_lock_entriesVolker Lendecke2014-06-301-10/+11
| | | | | | | ... saves >100 bytes object code :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3 : smbd : Protect all possible code paths from fsp->op == NULL.Jeremy Allison2014-05-021-2/+14
| | | | | | | | | | | | | In changes to come this will be possible for an INTERNAL_OPEN_ONLY. The protection was already in place for some code paths, this makes the coverage compete. Bug 10564 - Lock order violation and file lost https://bugzilla.samba.org/show_bug.cgi?id=10564 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* smbd: Fix an uninitialized memory readVolker Lendecke2014-03-031-0/+2
| | | | | | | | | | This might be the reason for a few flaky builds. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Mon Mar 3 16:30:53 CET 2014 on sn-devel-104
* s3: smbd: Ensure brl_get_locks_readonly() always returns a valid struct ↵Jeremy Allison2014-02-271-1/+15
| | | | | | | | | | | | | | | | | | | | | | byte_range_lock even if there are no locks. brl_get_locks_readonly() currently returns NULL when it can't find any byte range locks on the file. This is an error - it should return a valid struct byte_range_lock containing num_locks == 0 so it can be cached. Returning NULL when there are no locks causes POSIX lock tests to fail returning NT_STATUS_NO_MEMORY (as it thinks it can't allocate the struct) instead of NT_STATUS_OK. Fixes bug: Bug 10431 - STATUS_NO_MEMORY response from Query File Posix Lock request https://bugzilla.samba.org/show_bug.cgi?id=10431 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <Volker.Lendecke@SerNet.DE>
* dbwrap: add a dbwrap_flags argument to db_open()Michael Adam2014-02-071-1/+1
| | | | | | | | | | This is in preparation to support handing flags to backends, in particular activating read only record support for ctdb databases. For a start, this does nothing but adding the parameter, and all databases use DBWRAP_FLAG_NONE. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* param: Complete the removal of the "open files database hash size" parameterGarming Sam2014-01-311-1/+1
| | | | | | | | This parameter was originally set for removal in 2007 in 28210588edc39eb2b6cd237f11b488fa4d6b6985 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3:brlock: fix a comment typoMichael Adam2014-01-301-1/+1
| | | | | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Thu Jan 30 13:25:22 CET 2014 on sn-devel-104
* smbd: Early exitVolker Lendecke2013-12-141-1/+7
| | | | | | | Yes, this also showed up in profiles Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Fix CID 1035434 Same on both sidesVolker Lendecke2013-11-111-1/+1
| | | | | | | Looks scary, but the only effect of this bug is too many UNLOCK messages Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ira Cooper <ira@samba.org>
* smbd: Add debugs to brlock.cVolker Lendecke2013-10-151-0/+15
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Put "have_read_oplocks" into brlock.tdbVolker Lendecke2013-10-151-10/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements an idea by metze: Right now Samba does not grant level2 oplocks where it should: After an initial no-oplock open that has been written to, we don't have the FAKE_LEVEL2_OPLOCK entry in locking.tdb around anymore, this downgraded to NO_OPLOCK. Windows in this case will grant level2 if being asked, we don't. Part of the reason for this is that we don't have a proper mechanism to communicate the fact that level2 needs to be broken to other smbds. Metze's insight was that we have to look into brlock.tdb for every write anyway, so this might be the right place to store this information. My first reaction was that this is really hackish, but on further thought this is not. oplocks depend on brlocks anyway, and we have the proper mechanisms in place for brlocks. The format for this change is to add one byte to the end of the brlock.tdb record with value 1 if we have level2 oplocks around. Thus this patch effectively reverts 8f41142 which I discovered while writing this change. We now legally have unaligned records. We can certainly talk about the format, but I'm not yet convinced we need an idl for this yet. This is a potentially very hot code path, and ndr marshalling has a cost. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove byte_range_lock->read_onlyVolker Lendecke2013-10-061-10/+0
| | | | | | | | | | | With the rewritten brl_get_lock_readonly we only set the destructor for r/w lock records anyway. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Sun Oct 6 22:20:05 CEST 2013 on sn-devel-104
* smbd: Remove the brl_get_locks wrapperVolker Lendecke2013-10-061-9/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: brl_get_locks_internal is always called r/w nowVolker Lendecke2013-10-061-37/+11
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Restructure brl_get_locks_readonlyVolker Lendecke2013-10-061-10/+103
| | | | | | | | | | | | This is step 1 to get rid of brl_get_locks_internal with its complex readonly business. It also optimizes 2 things: First, it uses dbwrap_parse_record to avoid a talloc and memcpy, and second it uses talloc_pooled_object. And -- hopefully it is easier to understand the caching logic with fsp->brlock_rec and the clustering escape. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Avoid an if-statement per read/write in the non-clustered caseVolker Lendecke2013-10-061-4/+4
| | | | | | | | | | | Without clustering, fsp->brlock_rec will never be set anyway. In the clustering case we can't use the seqnum trick, so this is slow enough that the additional if-statement does not matter in this case anyway. In the non-clustered case it might. Have not measured it, but every little bit helps I guess. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Remove unused "brl->key" struct elementVolker Lendecke2013-10-061-3/+1
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Sun Oct 6 15:49:43 CEST 2013 on sn-devel-104
* smbd: Properly protect against invalid lock dataVolker Lendecke2013-09-121-0/+6
| | | | | | | | | | | If someone messes with brlock.tdb and inserts an invalid record length, this will lead to memcpy overwriting a few bytes behind malloc'ed data. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Sep 12 03:26:45 CEST 2013 on sn-devel-104
* smbd: Convert br_lck->lock_data to tallocVolker Lendecke2013-09-111-26/+29
| | | | | Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Wed Sep 11 10:15:38 CEST 2013 on sn-devel-104
* smbd: Move "struct byte_range_lock" definition to brlock.cVolker Lendecke2013-09-111-0/+10
|
* smbd: Add brl_fsp access functionVolker Lendecke2013-09-111-0/+5
|
* smbd: Add brl_num_locks access functionVolker Lendecke2013-09-111-0/+5
|
* smbd: Use ZERO_STRUCT instead of memsetVolker Lendecke2013-09-111-1/+1
|
* smbd: Make brl_lock_failed staticVolker Lendecke2013-09-111-1/+3
|
* smbd: Make brl_same_context staticVolker Lendecke2013-09-111-1/+1
|
* smbd: Fix blank line endingsVolker Lendecke2013-09-111-19/+19
|
* s3:locking:brlock: add function brl_cleanup_disconnected()Gregor Beck2013-04-181-0/+73
| | | | | | | | For a given file, clean up brl entries belonging to a given persistent file id. Signed-off-by: Gregor Beck <gbeck@sernet.de> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:locking:brlock: explain the lockdb_clean semantic better in ↵Michael Adam2013-04-181-1/+5
| | | | | | | | brl_reconnect_disconnected() Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Gregor Beck <gbeck@sernet.de> Reviewed-by: Stefan Metzmacher <metze@samba.org>