summaryrefslogtreecommitdiffstats
path: root/source3/locking
Commit message (Collapse)AuthorAgeFilesLines
* locking: use correct conversion specifier for printing variablesRalph Boehme2014-06-132-8/+9
| | | | | | | | | | | | Fix several occurences of using printf conversion to fload when printing offset and count variables in locking debug messages and smbstatus. Conversion to float may lead to wrong results with very large values. Signed-off-by: Ralph Boehme <rb@sernet.de> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@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: Remove unused "share_mode_data->id"Volker Lendecke2014-03-211-1/+0
| | | | | | | | 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): Fri Mar 21 21:22:24 CET 2014 on sn-devel-104
* smbd: Keep "the_lock"s file id separatelyVolker Lendecke2014-03-211-1/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Avoid checking the_lock->id for fresh locksVolker Lendecke2014-03-211-4/+5
| | | | | | | If we just fetched the lock, this check will always be true. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Explicitly pass "file_id" to rename_share_filenameVolker Lendecke2014-03-212-2/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@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-072-2/+2
| | | | | | | | | | 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-312-2/+2
| | | | | | | | 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: Simplify get_share_mode_lock a bitVolker Lendecke2013-12-141-14/+13
| | | | | | | | | This does two things: It gets rid of a talloc_stackframe in a hot code path and to me it makes the code easier to understand. It makes the talloc hierarchy more obvious to follow. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Factor out get_share_mode_write_time of get_file_infosVolker Lendecke2013-11-222-8/+12
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@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: Factor out remove_stale_share_mode_entriesVolker Lendecke2013-10-153-14/+18
| | | | | | | Will be used in the next commit Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@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: Remove FAKE_LEVEL_II_OPLOCKVolker Lendecke2013-10-151-13/+1
| | | | | | | | | FAKE_LEVEL_II_OPLOCK was an indicator to break level2 oplock holders on write. This information is now being held in brlock.tdb, which makes the FAKE_LEVEL_II_OPLOCK type unnecessary. 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-152-10/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Simplify set_share_modeVolker Lendecke2013-10-081-30/+15
| | | | | | | | With the find_share_mode simplification we don't need fill_share_mode anymore. So this coalesces add_share_mode as well. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Simplify find_share_mode_entry callersVolker Lendecke2013-10-081-46/+25
| | | | | | | | All callers used fill_share_mode_entry before calling find_share_mode_entry. Remove that requirement. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Convert set_share_mode to return bool for successVolker Lendecke2013-10-082-3/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Make add_share_mode return boolVolker Lendecke2013-10-081-4/+13
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Change parameter from unsigned to uint32_tVolker Lendecke2013-10-082-2/+2
| | | | | | | | share_mode_stale_pid internally only has to deal with uint32_t. Make the parameter match this. 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: Avoid calling serverid_exists twiceVolker Lendecke2013-10-061-0/+6
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* 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-112-0/+6
|
* smbd: Add brl_num_locks access functionVolker Lendecke2013-09-112-0/+7
|
* smbd: Use ZERO_STRUCT instead of memsetVolker Lendecke2013-09-111-1/+1
|
* smbd: Fix a typoVolker Lendecke2013-09-111-1/+1
|
* smbd: Make brl_lock_failed staticVolker Lendecke2013-09-112-2/+3
|
* smbd: Make brl_same_context staticVolker Lendecke2013-09-112-3/+1
|
* smbd: Fix blank line endingsVolker Lendecke2013-09-111-19/+19
|
* smbd: Apply some const to find_share_mode_entryVolker Lendecke2013-09-061-2/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* smbd: Apply some const to share_modes_identicalVolker Lendecke2013-09-061-2/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* smbd: Simplify find_share_mode_entryVolker Lendecke2013-09-061-2/+5
| | | | | | | | There's no point checking the validity of the "entry" argument more than once Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* smbd: Fix flawed share_mode_stale_pid APIVolker Lendecke2013-09-032-9/+50
| | | | | | | | | | | | | | | | The comment for this routine said: > Modifies d->num_share_modes, watch out in routines iterating over > that array. Well, it turns out that *every* caller of this API got it wrong. So I think it's better to change the routine. This leaves the array untouched while iterating but filters out the deleted ones while saving them back to disk. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* smbd: Rename parameter "i" to "idx"Volker Lendecke2013-09-032-7/+7
| | | | | | | We'll need "i" in a later checkin ... :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* smbd: We don't use DEFERRED_OPEN_ENTRY anymoreVolker Lendecke2013-04-262-67/+0
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Use dbwrap_record_watch_send for defer_openVolker Lendecke2013-04-261-0/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:locking add NDR debug in share_mode_forallChristian Ambach2013-04-191-0/+4
| | | | | | | | Reviewed-by: Volker Lendecke <vl@samba.org> Signed-off-by: Christian Ambach <ambi@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Fri Apr 19 15:06:33 CEST 2013 on sn-devel-104
* s3:locking: add function share_mode_cleanup_disconnected()Gregor Beck2013-04-182-0/+102
| | | | | | | | | | | For a given file, clean share mode entries for a given persistent file id. Pair-Programmed-With: Michael Adam <obnox@samba.org> Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Gregor Beck <gbeck@sernet.de> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>