summaryrefslogtreecommitdiff
path: root/source3/locking
Commit message (Collapse)AuthorAgeFilesLines
* s3/locking: make find_share_mode_entry publicRalph Boehme2017-05-282-1/+3
| | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12798 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: smbd: Fix open_files.idl to correctly ignore share_mode_lease *lease in ↵Jeremy Allison2017-05-181-2/+2
| | | | | | | | | | | | | | | | | | | | | share_mode_entry. This is currently marked 'skip', which means it isn't stored in the db, but printed out in ndr dump. However, this pointer can be invalid if the lease_idx is set to 0xFFFFFFFF (invalid). This is fixed up inside parse_share_modes(), but not until after ndr_pull_share_mode_data() is called. If lease_idx == 0xFFFFFFFF then ndr_print_share_mode_lease() prints an invalid value and crashes. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12793 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu May 18 03:01:40 CEST 2017 on sn-devel-144
* s3/locking: helper functions for lease typesRalph Boehme2017-05-062-0/+19
| | | | | | | | | | Add some helper functions that will be used to update a bunch of checks for exclusive oplocks to the lease area. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12766 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3/locking: add const to fsp_lease_typeRalph Boehme2017-05-062-2/+2
| | | | | | | Bug: https://bugzilla.samba.org/show_bug.cgi?id=12766 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3/locking: add fetch_share_mode_send/recvRalph Boehme2017-04-182-0/+132
| | | | | | | | | | | | | | | | | | | | | | | | The boolean out parameter "queued" tells the caller whether the async request is blocked in a full send queue: false := request is dispatched true := send queue is full, request waiting to be dispatched This is useful in a clustered Samba environment where the async dbwrap request is sent over a socket to the local ctdbd. If the send queue is full and the caller was issuing multiple async dbwrap requests in a loop, the caller knows it's probably time to stop sending requests for now and try again later. This will be used in subsequent commits in smbd_smb2_query_directory_send() when implementing async write time updates. Directories may contain umpteen files so we send many requests to ctdb without going through tevent and reading the responses which has the potential to deadlock. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3: locking: Update oplock optimization for the leases era !Jeremy Allison2017-03-151-9/+13
| | | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12628 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Wed Mar 15 20:04:32 CET 2017 on sn-devel-144
* s3: locking: Move two leases functions into a new file.Jeremy Allison2017-03-152-0/+59
| | | | | | | | | map_oplock_to_lease_type(), fsp_lease_type(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=12628 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3/locking: Avoid a talloc for nonexisting fetch_share_mode_unlockedVolker Lendecke2017-01-221-15/+17
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib: Add lib/util/server_id.hVolker Lendecke2017-01-224-0/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: ignore ctdb tombstone records in fetch_share_mode_unlocked_parser()Ralph Boehme2016-08-081-0/+6
| | | | | | | | | | dbwrap_parse_record() can return ctdb tombstone records from the lctdb, ignore them. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12005 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Convert locking.tdb to new dbwrap_watchVolker Lendecke2016-07-151-5/+13
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Fix memory leak in share mode locking.Hemanth Thummala2016-05-271-0/+5
| | | | | | | | | | | | | | | | | | Not freeing up(and reparenting to NULL context) ndr buffer used for TDB updates resulting in huge memory leak when there in high volume of opens and closes happening on same object. Free the buffer before reparenting its parent to NULL context. https://bugzilla.samba.org/show_bug.cgi?id=11934 Signed-off-by: Hemanth Thummala <hemanth.thummala@nutanix.com> Signed-off-by: Saji VR <saji.vr@nutanix.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Fri May 27 18:43:31 CEST 2016 on sn-devel-144
* s3: VFS: Map process-associated lock operation to open file description lock ↵Jeremy Allison2016-05-211-3/+13
| | | | | | | | | | | | | | | operation. Only in the default VFS. Gpfs, Ceph, Gluster and other modern backend VFS filesystems might want to do the same. Allow tuneable "smbd:force process locks = true" to turn off OFD locks if in use and the kernel doesn't support them. Display debug message showing admins what to do in this case. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Jeff Layton <jlayton@samba.org>
* s3: VFS: Add bool use_ofd_locks member to struct files_struct.Jeremy Allison2016-05-211-4/+5
| | | | | | | | Not yet used. We will set this if we translate a process-associated lock operation to a open file description lock operation. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Jeff Layton <jlayton@samba.org>
* s3: locking: Convert on the wire behavior of POSIX (UNIX extensions) locks ↵Jeremy Allison2016-05-211-0/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from process-associated locks to open file description locks. This means locks are associated with the SMB handle they were created on, not the inode. In all other ways they behave like UNIX extensions fcntl (process-associated) locks. Torture test to follow. When a handle is closed all locks attached to that handle are closed, not all locks on the underlying inode. In this respect they now behave like Windows locks. The key to this in the UNIX extensions locking codepath is modifying the reference count only when a new locking context is seen on any lock request, and decrementing the reference count when the last instance of a locking context is seen on any unlock request. For SMB2+ the persistent part of a file handle is used as the locking context so this behavior becomes natural. This is a behavior change but after consultation with Jeff Layton and Steve French the only client that implements UNIX extensions POSIX locks - the cifsfs client - already expects these locks to behave like open file description (ofd) locks. With our previous behavior Linux ofd-locks fail against smbd. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Jeff Layton <jlayton@samba.org>
* s3: locking: Add a const struct lock_context * paramter to ↵Jeremy Allison2016-05-213-0/+3
| | | | | | | | | set_posix_lock_posix_flavour() We will need this to implement open file description record locks. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Jeff Layton <jlayton@samba.org>
* s3: locking: Add some const.Jeremy Allison2016-05-212-12/+13
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Jeff Layton <jlayton@samba.org>
* s3: locking: Rename xxx_windows_lock_ref_count to xxx_lock_ref_count.Jeremy Allison2016-05-211-20/+16
| | | | | | | | | We will be using this to also ref count a posix lock applied to a file handle when changing to open file description lock semantics. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Jeff Layton <jlayton@samba.org>
* s3:smbd: convert file_struct.posix_open to a bitmap with flagsRalph Boehme2015-12-011-1/+2
| | | | | | | | | | | | | This is in preperation of a more fine grained control of POSIX behaviour in the SMB and VFS layers. Inititally we use an uint8_t for the flags bitmap and add a define posix_flags as posix_open in order to avoid breaking the VFS ABI. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11065 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* remove many valgrind errors for base.lock testNoel Power2015-11-061-0/+2
| | | | | | | | | | | | | mostly "Conditional jump or move depends on uninitialised value" & "Use of uninitialised value of size 8" errors, suspect this is related to compiler padding for the struct Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Nov 6 00:16:53 CET 2015 on sn-devel-104
* s3:locking: initialize lease pointer in share_mode_traverse_fn()Ralph Boehme2015-10-131-3/+7
| | | | | | | | | | | | | | | Initialize lease pointer to point to the share_mode_data leases array entry at index lease_idx. This fixes a bug in smbstatus where the lease info is not printed. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11549 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Oct 13 01:14:09 CEST 2015 on sn-devel-104
* s3:smbstatus: add stream name to share_entry_forall()Ralph Boehme2015-10-122-4/+10
| | | | | | | | | | Add stream name argument to share_entry_forall machinery so smbstatus can print the stream name of a file. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11550 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Convert uint64 to uint64_tRichard Sharpe2015-05-152-2/+2
| | | | | | | We seemed to have very few uses of that. Signed-off-by: Richard Sharpe <rsharpe@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Convert all uint32/16/8 to _t in source3/locking.Richard Sharpe2015-05-133-6/+6
| | | | | Signed-off-by: Richard Sharpe <rsharpe@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Remove server_id_str()Volker Lendecke2015-04-282-3/+7
| | | | | | | | | | Call server_id_str_buf instead 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): Tue Apr 28 20:48:01 CEST 2015 on sn-devel-104
* lib: Remove procid_str_staticVolker Lendecke2015-04-282-10/+27
| | | | | | | | Replace all callers with direct calls to server_id_str_buf without talloc_tos() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Cancel pending notifies if the directory goes awayVolker Lendecke2015-04-221-1/+30
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove bool arg from set_delete_on_close_lckVolker Lendecke2015-04-222-11/+1
| | | | | | | | We now have reset_delete_on_close_lck, this was called with "true" everywhere now. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Use reset_delete_on_close_lck directlyVolker Lendecke2015-04-221-3/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Introduce reset_delete_on_close_lckVolker Lendecke2015-04-222-26/+37
| | | | | | | Boolean flags passed down make things more complex than necessary... Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Save a few lines of C :-)Volker Lendecke2015-04-221-4/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: locking: Add a memcache based lock cache.Jeremy Allison2015-04-171-9/+199
| | | | | | | | | | | | | | | | | | | | | | | | | | Based on an idea by Volker to optimize cpu usage when parsing struct share_mode_data entries. Add a 64-bit sequence number to the share mode entry, and after the entry is stored back in the db, cache the in-memory version using talloc reparenting into the memcache. The memcache key used is the same struct file_id used as the key into the locking db. On read, check if the locking db version sequence number matches the in-memory cache, and if so reparent the memcache version back onto the required memory context. Saves all the ndr decoding when multiple accesses to the same lock entry happen in succession. Design also improved by Metze and Ira. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ira Cooper <ira@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Apr 17 22:38:34 CEST 2015 on sn-devel-104
* brlock: Use 0 instead of empty initializer listChristof Schmitt2015-03-121-1/+1
| | | | | | | | | | | | | C does not allow empty initializer lists. Although gcc accepts that, the SunOS compiler fails in this case with an error. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11153 Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Christof Schmitt <cs@samba.org> Autobuild-Date(master): Thu Mar 12 02:49:36 CET 2015 on sn-devel-104
* leases_db: don't leak lock_path onto talloc tosDavid Disseldorp2015-01-121-2/+9
| | | | | | | | | | Also check for allocation failures. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Mon Jan 12 19:22:31 CET 2015 on sn-devel-104
* smbd: Fix a small leak on talloc_tos()Volker Lendecke2015-01-111-1/+1
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Sun Jan 11 20:34:56 CET 2015 on sn-devel-104
* smbd: Fix an uninitialized variable readVolker Lendecke2015-01-111-2/+1
| | | | | | | | If dbwrap_fetch_locked failed, we did a TALLOC_FREE(value). Fix this with a talloc hierarchy. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* 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: Change the data model for leases_db to cope with dynamic path ↵Jeremy Allison2014-12-092-31/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | renames. interface leases_db { typedef [public] struct { GUID client_guid; smb2_lease_key lease_key; } leases_db_key; typedef [public] struct { file_id id; [string,charset(UTF8)] char *servicepath; [string,charset(UTF8)] char *base_name; [string,charset(UTF8)] char *stream_name; } leases_db_file; typedef [public] struct { uint32 num_files; [size_is(num_files)] leases_db_file files[]; } leases_db_value; } As designed by metze. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Dec 9 03:44:04 CET 2014 on sn-devel-104
* s3:locking: pass down servicepath to leases_db_add()Jeremy Allison2014-12-092-0/+3
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:locking: Add new utility function leases_db_copy_file_ids()Jeremy Allison2014-12-092-0/+25
| | | | | | | Will be used by lease db parsers. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:locking: pass servicename_new to leases_db_rename()Jeremy Allison2014-12-093-0/+3
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3: leases : Cope with renaming leased open files.Jeremy Allison2014-12-051-1/+24
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3: leases: Add leases_db_rename() to cope with renaming a leased file.Jeremy Allison2014-12-052-1/+27
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:locking: add downgrade_share_lease() helper functionVolker Lendecke2014-12-042-0/+86
| | | | | | | | | Pair-Programmed-With: Jeremy Allison <jra@samba.org> Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Jeremy Allison <jra@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:locking: cleanup leases_db from share_mode_cleanup_disconnected()Stefan Metzmacher2014-12-041-0/+12
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:locking: ensure all share mode removal functions go through a common ↵Jeremy Allison2014-12-041-3/+88
| | | | | | | | | lease refcount manager. Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Jeremy Allison <jra@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:open_files.idl: add data structures for SMB2.1 and SMB3.0 leases.Stefan Metzmacher2014-12-043-5/+29
| | | | | | | Pair-Programmed-With: Volker Lendecke <vl@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:locking: add leases_db infrastructureVolker Lendecke2014-12-042-0/+433
| | | | | | | | | | | | | | Will enable us to solve the dynamic share path problem with leases on [homes]. We're also able to give the correct error codes when a lease key is re-used with a different file name. Pair-Programmed-With: Jeremy Allison <jra@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:locking: convert brl_have_read field to brl_num_read.Volker Lendecke2014-11-112-70/+59
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* share_mode_lock: don't leak lock_path onto talloc tosDavid Disseldorp2014-11-031-2/+9
| | | | | | | Also check for allocation failures. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>