summaryrefslogtreecommitdiffstats
path: root/source3/locking
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* s3:locking: improve debug output of parse_share_modes()Gregor Beck2013-04-181-1/+2
| | | | | | Signed-off-by: Gregor Beck <gbeck@sernet.de> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:locking: no need to make a file_id passed by value a constantGregor Beck2013-04-182-13/+10
| | | | | | 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: add function brl_cleanup_disconnected()Gregor Beck2013-04-182-0/+74
| | | | | | | | 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>
* s3:locking:brlock: let validate_lock_entries keep entries for disconnected ↵Gregor Beck2013-04-181-8/+23
| | | | | | | | | | | | | servers in traverses We should not remove locks of disconnected opens just like that. When getting the byte range lock record for a newly connected file handle, we still do the clean up, because in that situation, disconnected entries are not valid any more. 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: improve the comment for the brl self cleaning codeMichael Adam2013-04-181-3/+6
| | | | | | Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Gregor Beck <gbeck@sernet.de> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:locking:brlock: use serverids_exist to validate_lock_entriesGregor Beck2013-04-181-3/+34
| | | | | | | | | ...instead of checking each server-id separately which can be expensive in a cluster. Signed-off-by: Gregor Beck <gbeck@sernet.de> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* brlock.c: Fix typo in comment.Karolin Seeger2013-02-181-1/+1
| | | | | | redundent -> redundant Signed-off-by: Karolin Seeger <kseeger@samba.org>
* s3: Use dbwrap_parse_record in fetch_share_mode_unlockedVolker Lendecke2012-11-281-13/+14
| | | | Reviewed-by: Andreas Schneider <asn@samba.org>
* s3:locking: add brl_mark_disconnected() and brl_reconnect_disconnected()Stefan Metzmacher2012-09-082-0/+127
| | | | Pair-Programmed-With: Michael Adam <obnox@samba.org>
* s3:locking: add mark_share_mode_disconnected()Stefan Metzmacher2012-09-082-0/+40
| | | | Pair-Programmed-With: Michael Adam <obnox@samba.org>