1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

846 Commits

Author SHA1 Message Date
Volker Lendecke
b70d855e1a smbd: Make do_lock() return NTSTATUS
This routine did a NO-GO: It returned something on talloc_tos(), for
later consumption by push_blocking_lock_request. This is now gone, no
caller uses the "struct byte_range_lock" returned anymore.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02 17:01:27 +00:00
Volker Lendecke
b0d4939d6c smbd: Avoid casts in do_lock()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02 17:01:27 +00:00
Volker Lendecke
e36398d93b smbd: Ensure initialized vars in do_lock
brl_lock does not initialize these variables in all cases

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-02 17:01:27 +00:00
Volker Lendecke
c88240e0e7 smbd: Fix broken brlock for clustering
This should have been in f11c5887f4, sorry. We now always need
TDB_SEQNUM on brlock.tdb.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2019-06-28 15:02:21 +00:00
Volker Lendecke
4bbe291efc vfs: Remove SMB_VFS_BRL_CANCEL_WINDOWS
This is not called anymore, bump the VFS version number in a separate
commit

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 Jun 20 18:34:20 UTC 2019 on sn-devel-184
2019-06-20 18:34:20 +00:00
Volker Lendecke
871bb7562c smbd: Remove unused brlock code
No PENDING locks in brlock.tdb anymore.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-06-20 17:18:19 +00:00
Volker Lendecke
f37c14dd63 smbd: Add a clarifying comment on triggering waiters
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-06-20 17:18:19 +00:00
Volker Lendecke
d60a35bd75 smbd: Don't call cancel_pending_lock_requests_by_fid on close
We don't use that queue anymore

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-06-20 17:18:19 +00:00
Volker Lendecke
ab149a611f smbd: Remove SMB1 special case handling from brlock.c
This is now handled in smbd_smb1_do_locks_send/recv.

From here on for a few commits we won't survive make test.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-06-20 17:18:19 +00:00
Volker Lendecke
67f89bb330 smbd: Return "blocker_pid" from do_lock()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-06-20 17:18:18 +00:00
Volker Lendecke
ca73ba859e smbd: Add some paranoia against NULL dereference
Quite a few callers set "psmblctx" to NULL, and I could not really
follow 100% that brl_lock only assigns that in the blocking lock
case. Too many layers :-)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-06-20 17:18:18 +00:00
Volker Lendecke
4adbeb9714 smbd: Add "blocker_pid" to brl_lock()
Soon we will wait on a conflicting lock to become free via
dbwrap_watched_watch_send. That routine can take a server_id that
blocks us, watching it to go away. To use that, we need to know which
PID it is that blocks us.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-06-20 17:18:18 +00:00
Volker Lendecke
73080f255e smbd: Adapt brl_pending_overlap to README.Coding
Just reformatting, no behaviour change. This just looked too ugly to me.

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 May 28 22:22:28 UTC 2019 on sn-devel-184
2019-05-28 22:22:28 +00:00
Volker Lendecke
8b478aaf2c smbd: Avoid casts in do_unlock()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-05-28 20:27:16 +00:00
Volker Lendecke
4e56d2280a smbd: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-05-28 20:27:15 +00:00
Volker Lendecke
f11c5887f4 brlock: Remove clustering special case
With e7424897a1 we don't need this special case for clustering
anymore.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-05-28 20:27:15 +00:00
Gary Lockyer
412afb2aef Fix ubsan null pointer passed as argument 2
Fix ubsan warning null pointer passed as argument 2 when the source
pointer is NULL.  The calls to memcpy are now guarded by an
if (len > 0)

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Mon May 27 01:29:48 UTC 2019 on sn-devel-184
2019-05-27 01:29:48 +00:00
Volker Lendecke
564e0f2566 smbd: Merge "print_lock_struct" into one DBG
Also, avoid some casts

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-05-23 16:56:17 +00:00
Volker Lendecke
07bbcf3aec smbd: Send "share_file_id" with the rename msg
file_id plus share_file_id remotely specify the fsp. This avoids the
explicit loop in the receiver.

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): Sat May 18 20:18:55 UTC 2019 on sn-devel-184
2019-05-18 20:18:54 +00:00
Volker Lendecke
f1226bfbe9 smbd: Add file_rename_message in idl
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-05-18 19:06:23 +00:00
Volker Lendecke
a187b7ef8f smbd: Remove share_mode_lease and the leases array from share_mode_entry
This also removes the temporary functions introduced during the patchset.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>

Autobuild-User(master): Christof Schmitt <cs@samba.org>
Autobuild-Date(master): Sun Apr 14 05:18:14 UTC 2019 on sn-devel-144
2019-04-14 05:18:14 +00:00
Volker Lendecke
ad413ce91b smbd: Use share_mode_forall_leases in share_mode_cleanup_disconnected()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14 04:01:33 +00:00
Volker Lendecke
c12641e80d smbd: Use share_mode_forall_leases in rename_share_filename()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14 04:01:33 +00:00
Volker Lendecke
302bdd7f91 smbd: Add share_mode_forall_leases()
Function to walk all leases for a file exactly once. This used to be simpler
with the leases[] array, thus this function that encapsulates the complexity.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14 04:01:32 +00:00
Volker Lendecke
552faa910f smbd: Don't pass lease_idx down to set_share_mode()
Temporary patch to keep the code running. The new code in set_share_mode() will
leave again once the patchset to remove share_mode_lease and thus the lease_idx
in share_mode_entry goes away.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14 04:01:32 +00:00
Volker Lendecke
9ca5b61157 smbd: Use share_mode_entry's lease data in remove_share_mode_lease()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14 04:01:31 +00:00
Volker Lendecke
1ae7736148 smbd: Use share_mode_entry's lease data in remove_share_mode_lease()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14 04:01:31 +00:00
Volker Lendecke
10a60df1cc smbd: Add lease key to share_mode_entry
Instead of indexing into the leases[] array, put the lease_db reference into
the share_mode_entry. For simplicity, put in the client guid as well. We
*might* be able to retrieve that from somewhere else, but as other smbd
processes have to look at the lease values, put in the full leases_db index
data.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14 04:01:30 +00:00
Volker Lendecke
5f850a80d2 leases_db: Add getter/setter for share_mode_lease metadata
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14 04:01:30 +00:00
Volker Lendecke
f46023ed70 leases_db: Add share_mode_lease info to leases.tdb
This is the data stored in share_mode_lease inside the leases[] array in
locking.tdb. This and all the following patches move all leases array to
looking at the leases.tdb.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14 04:01:30 +00:00
Volker Lendecke
bfbe24d827 leases_db: Make leases_db_del use leases_db_do_locked
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  9 19:31:09 UTC 2019 on sn-devel-144
2019-04-09 19:31:09 +00:00
Volker Lendecke
885d433b46 leases_db: Make leases_db_add use leases_db_do_locked
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-04-09 18:29:14 +00:00
Volker Lendecke
ee53763a3e leases_db: Make leases_db_rename atomic
Do the rename under one lock to protect against potential races while
we don't hold it.

Factor out the NDR marshalling into leases_db_do_locked(), leaving the
rename function pretty simple.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-04-09 18:29:14 +00:00
Andreas Schneider
77dbe6b9ef s3:locking: Add missing NULL check
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-02-12 23:02:07 +01:00
Volker Lendecke
43a0e635ea leases: Streamline leases_db_key a bit
We don't need to talloc the blob, it's always the same size

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): Wed Oct  3 04:11:59 CEST 2018 on sn-devel-144
2018-10-03 04:11:59 +02:00
Volker Lendecke
e22d5e5b7f smbd: Fix a warning
gcc complains that the "const" is ignored on function return
types. Right now I'm compiling this file a lot, so silence this
warning :-)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-10-03 01:07:15 +02:00
Volker Lendecke
0e7c546463 smbd: Move downgrade_share_lease() to smbd/oplock.c
This function is pretty closely entangled with its only caller. In
particular the NT_STATUS_OPLOCK_BREAK_IN_PROGRESS triggers acitivity
in the caller, and that's the only case where "*_l" is being set to
non-NULL. Prepare for cleanup

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2018-10-02 18:13:20 +02:00
Anoop C S
380066d2e5 s3/locking: Fix logging of lock reference count
lock reference count is always increased and reduced by a value of 1.
But lock_ref_count variable holds the old value prior to change and
was being logged wrongly under debug level 10. DEBUG statement must
log lock_ref_count+1 and lock_ref_count-1 respectively when value
gets increased and decreased.

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-10-02 10:40:05 +02:00
Anoop C S
c3211c8e59 s3/locking: Fix comments to reflect code flow
* posix_pending_close_db is an in-memory database and not a tdb.
  Therefore adjusting comments to convey the correct meaning of the
  database.
* we do not have posix_locking_close_file() any more which got renamed
  to locking_close_file(). Thus fixing comment to mention the new name.

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Sep 19 22:23:28 CEST 2018 on sn-devel-144
2018-09-19 22:23:28 +02:00
Volker Lendecke
50adbbe0c8 smbd: Simplify parse_share_modes
Since 823bc4c07a pidl initializes the [skip] entries

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2018-09-14 07:49:14 +02:00
Volker Lendecke
9e515f7c66 smbd: Simplify share_mode_lock.c
"the_lock_id" is not required here. The share mode data carry the file
id, so use that.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2018-09-14 07:49:14 +02:00
Volker Lendecke
89e500d8ad smbd: Fix a false comment
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2018-09-14 07:49:13 +02:00
Volker Lendecke
41f2d1d1bd smbd: Avoid casts in DEBUG statements
Some indentation changed, best viewed with "git show -w"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2018-09-14 07:49:13 +02:00
Volker Lendecke
e4498de163 smbd: Avoid casts in DEBUG statements
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2018-09-14 07:49:13 +02:00
Volker Lendecke
6be25d5683 smbd: Simplify logic in remove_stale_share_mode_entries
To me, an early "continue" is easier to follow than a "else".

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2018-09-07 17:26:18 +02:00
Volker Lendecke
6a76a31779 smbd: Simplify share_mode_stale_pid
This loop does not need to count valid share modes. A single valid one
is sufficient for keeping the delete token around

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2018-09-07 17:26:18 +02:00
Christof Schmitt
cc76aaeb62 s3: Rename server_messaging_context() to global_messaging_context()
This reflects that the messaging context is also used outside of the
server processes.

The command used for the rename:
find . -name '*.[hc]' -print0 | xargs -0 sed -i 's/server_messaging_context/global_messaging_context/'

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2018-09-07 17:26:17 +02:00
Volker Lendecke
0bd109b733 smbd: Fix a memleak in async search ask sharemode
fetch_share_mode_unlocked_parser() takes a "struct
fetch_share_mode_unlocked_state *" as
"private_data". fetch_share_mode_send() used a talloc_zero'ed "struct
share_mode_lock". This lead to the parser putting a "struct
share_mode_lock on the NULL talloc_context where nobody really picked it
up.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13602
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2018-09-03 18:44:23 +02:00
Volker Lendecke
14f9e6f833 dbwrap: Clarify db_open_watched API
Point out in the API that "backend" talloc_moves into the watched
database.

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 Aug 17 21:29:15 CEST 2018 on sn-devel-144
2018-08-17 21:29:15 +02:00
Volker Lendecke
22be863ba3 smbd: Fix a few DEBUG statements
%u is not necessarily correct for uint32_t, avoid casts

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-08-17 18:25:08 +02:00
Volker Lendecke
f986a73b24 lib: Pass mem_ctx to lock_path()
Fix a confusing API: Many places TALLOC_FREE the path where it's not
clear you have to do it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2018-08-17 11:30:10 +02:00
Anoop C S
bf9cb64d51 s3/locking: Corrections and improvements to inline comments
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Jim McDonough <jmcd@samba.org>
2018-08-09 01:16:22 +02:00
Anoop C S
80c9219d60 s3/locking: Fix assertion check on lock reference count
lock_ref_count will always hold the old value prior to change. Thus it
would mean that if lock_ref_count is 0 the new value is already -1 which
is not expected here. Therefore it is better to make sure that it is
always greater than 0 rather than >= 0.

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Jul 31 04:23:47 CEST 2018 on sn-devel-144
2018-07-31 04:23:47 +02:00
Volker Lendecke
2dffcde408 smbd: Remove "share_mode_entry->lease"
smbstatus was the only user, and this could be solved by adapting
share_entry_forall.

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 Jul 27 01:42:31 CEST 2018 on sn-devel-144
2018-07-27 01:42:31 +02:00
Volker Lendecke
3bff0494e1 smbd: Pass "share_mode_data" to share_entry_forall callback
Quite a bit of the contents have been passed explicitly anyway.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-07-26 22:44:25 +02:00
Ralph Boehme
dd8cf54c79 s3:locking: add file_has_open_streams()
This can be used to check if a file opened by fsp also has stream opens.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13451

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-05-30 19:10:26 +02:00
Andreas Schneider
9f6de82ef2 s3:locking: Fix integer overflow check in posix_lock_in_range()
This fixes compilation with -Wstrict-overflow=2

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-03-20 23:16:16 +01:00
Volker Lendecke
3bbc575644 smbd: remove "id" from share_mode_entry
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 Feb 13 05:01:38 CET 2018 on sn-devel-144
2018-02-13 05:01:38 +01:00
Volker Lendecke
5fdc62b236 smbd: Remove a redundant check
The file ids in all share modes match the share_mode_data's one

We don't have a paranoia check for this, but the share mode is per inode.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-02-13 00:26:43 +01:00
Volker Lendecke
bab8bf7acb smbd: Use "share_mode_data->id", not "share_mode_entry->id"
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-02-13 00:26:43 +01:00
Volker Lendecke
9487510e9e smbd: Pass in "file_id" into share_mode_str()
This used to directly access share_entry->id, which will go

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-02-13 00:26:43 +01:00
Volker Lendecke
f519162657 smbd: Pass "file_id" through share_entry_forall
It's also in the share_entry, but that is redundant and will go

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-02-13 00:26:43 +01:00
Volker Lendecke
e6187be118 smbd: Fix a signed/unsigned hickup
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-02-13 00:26:43 +01:00
Ralph Boehme
67466271c2 s3/vfs: rename SMB_VFS_STRICT_LOCK to SMB_VFS_STRICT_LOCK_CHECK
As per MS-SMB2 and MS-FSA and our SMB_VFS_STRICT_LOCK implementation,
we're merely testing for locks, not setting any.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12887

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 Jul 11 03:37:44 CEST 2017 on sn-devel-144
2017-07-11 03:37:44 +02:00
Ralph Boehme
c9172c5a45 s3/vfs: remove SMB_VFS_STRICT_UNLOCK
It's just a noop, so let's remove it. SMB_VFS_STRICT_LOCK doesn't set
logs, it just checks for the presence of incompatible locks.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12887

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-07-10 23:22:10 +02:00
Ralph Boehme
9d7739e819 s3/locking: make find_share_mode_entry public
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>
2017-05-28 14:50:18 +02:00
Jeremy Allison
b691f6d32f s3: smbd: Fix open_files.idl to correctly ignore share_mode_lease *lease in 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
2017-05-18 03:01:40 +02:00
Ralph Boehme
f631e95e2d s3/locking: helper functions for lease types
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>
2017-05-06 19:01:14 +02:00
Ralph Boehme
952701dce0 s3/locking: add const to fsp_lease_type
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>
2017-05-06 19:01:14 +02:00
Ralph Boehme
06891c11d2 s3/locking: add fetch_share_mode_send/recv
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>
2017-04-18 22:54:16 +02:00
Jeremy Allison
1c4b15aa5f s3: locking: Update oplock optimization for the leases era !
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
2017-03-15 20:04:32 +01:00
Jeremy Allison
125c78ad0b s3: locking: Move two leases functions into a new file.
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>
2017-03-15 16:14:08 +01:00
Volker Lendecke
66cba9939b s3/locking: Avoid a talloc for nonexisting fetch_share_mode_unlocked
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2017-01-22 18:30:11 +01:00
Volker Lendecke
9af73f62ce lib: Add lib/util/server_id.h
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2017-01-22 18:30:11 +01:00
Ralph Boehme
7147859c7a smbd: ignore ctdb tombstone records in fetch_share_mode_unlocked_parser()
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>
2016-08-08 14:26:24 +02:00
Volker Lendecke
83e4e1a786 smbd: Convert locking.tdb to new dbwrap_watch
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-07-15 16:56:13 +02:00
Hemanth Thummala
7a725eea25 Fix memory leak in share mode locking.
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
2016-05-27 18:43:31 +02:00
Jeremy Allison
e39436e770 s3: VFS: Map process-associated lock operation to open file description lock 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>
2016-05-21 01:28:28 +02:00
Jeremy Allison
da9b7056fc s3: VFS: Add bool use_ofd_locks member to struct files_struct.
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>
2016-05-21 01:28:28 +02:00
Jeremy Allison
66b8ee1e64 s3: locking: Convert on the wire behavior of POSIX (UNIX extensions) locks 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>
2016-05-21 01:28:28 +02:00
Jeremy Allison
a3cb0a4c27 s3: locking: Add a const struct lock_context * paramter to 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>
2016-05-21 01:28:27 +02:00
Jeremy Allison
a3df904a7a s3: locking: Add some const.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Jeff Layton <jlayton@samba.org>
2016-05-21 01:28:27 +02:00
Jeremy Allison
4146fb94fe s3: locking: Rename xxx_windows_lock_ref_count to xxx_lock_ref_count.
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>
2016-05-21 01:28:27 +02:00
Ralph Boehme
d698cec1c7 s3:smbd: convert file_struct.posix_open to a bitmap with flags
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>
2015-12-01 20:45:20 +01:00
Noel Power
ce8068e70b remove many valgrind errors for base.lock test
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
2015-11-06 00:16:53 +01:00
Ralph Boehme
0ef9c67b56 s3:locking: initialize lease pointer in share_mode_traverse_fn()
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
2015-10-13 01:14:09 +02:00
Ralph Boehme
cd0c2a5eca s3:smbstatus: add stream name to share_entry_forall()
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>
2015-10-12 22:13:19 +02:00
Richard Sharpe
4602c86d58 Convert uint64 to uint64_t
We seemed to have very few uses of that.

Signed-off-by: Richard Sharpe <rsharpe@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-05-15 19:31:24 +02:00
Richard Sharpe
c833baa24c Convert all uint32/16/8 to _t in source3/locking.
Signed-off-by: Richard Sharpe <rsharpe@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-05-13 19:11:23 +02:00
Volker Lendecke
06f4ba3217 lib: Remove server_id_str()
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
2015-04-28 20:48:01 +02:00
Volker Lendecke
db5b766903 lib: Remove procid_str_static
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>
2015-04-28 18:11:13 +02:00
Volker Lendecke
50a1247927 smbd: Cancel pending notifies if the directory goes away
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-04-22 23:00:20 +02:00
Volker Lendecke
b0d4a7daa1 smbd: Remove bool arg from set_delete_on_close_lck
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>
2015-04-22 23:00:20 +02:00
Volker Lendecke
1f3735a28c smbd: Use reset_delete_on_close_lck directly
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-04-22 23:00:20 +02:00
Volker Lendecke
d75a0a589f smbd: Introduce reset_delete_on_close_lck
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>
2015-04-22 23:00:20 +02:00
Volker Lendecke
c8b4b119af smbd: Save a few lines of C :-)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-04-22 03:44:17 +02:00
Jeremy Allison
13b6199a2f s3: locking: Add a memcache based lock cache.
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
2015-04-17 22:38:34 +02:00
Christof Schmitt
ddcf3614ce brlock: Use 0 instead of empty initializer list
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
2015-03-12 02:49:36 +01:00
David Disseldorp
8365318b6d leases_db: don't leak lock_path onto talloc tos
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
2015-01-12 19:22:30 +01:00
Volker Lendecke
26809d17f4 smbd: Fix a small leak on talloc_tos()
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
2015-01-11 20:34:56 +01:00
Volker Lendecke
7dceb3a2df smbd: Fix an uninitialized variable read
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>
2015-01-11 18:12:10 +01:00
Stefan Metzmacher
6bc41c459f s3:locking: fix uninitialiazed variable in brl_get_locks_readonly_parser()
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 837e29035c.

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>
2014-12-18 04:22:05 +01:00
Jeremy Allison
5ebb190385 s3:locking: Change the data model for leases_db to cope with dynamic path 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
2014-12-09 03:44:04 +01:00
Jeremy Allison
708f87b79d s3:locking: pass down servicepath to leases_db_add()
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-12-09 01:18:08 +01:00
Jeremy Allison
b3b878eea4 s3:locking: Add new utility function leases_db_copy_file_ids()
Will be used by lease db parsers.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-12-09 01:18:08 +01:00
Jeremy Allison
2cd9a5c320 s3:locking: pass servicename_new to leases_db_rename()
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-12-09 01:18:08 +01:00
Jeremy Allison
4061b8db1b s3: leases : Cope with renaming leased open files.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-12-05 18:37:10 +01:00
Jeremy Allison
59cd638a1d s3: leases: Add leases_db_rename() to cope with renaming a leased file.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-12-05 18:37:10 +01:00
Volker Lendecke
3e91b823e4 s3:locking: add downgrade_share_lease() helper function
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>
2014-12-04 05:45:09 +01:00
Stefan Metzmacher
62e7e142aa s3:locking: cleanup leases_db from share_mode_cleanup_disconnected()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-12-04 05:45:09 +01:00
Jeremy Allison
a504b84ec1 s3:locking: ensure all share mode removal functions go through a common 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>
2014-12-04 05:45:09 +01:00
Stefan Metzmacher
6b2f19a5e6 s3:open_files.idl: add data structures for SMB2.1 and SMB3.0 leases.
Pair-Programmed-With: Volker Lendecke <vl@samba.org>

Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-12-04 05:45:09 +01:00
Volker Lendecke
14fac5dbc0 s3:locking: add leases_db infrastructure
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>
2014-12-04 05:45:09 +01:00
Volker Lendecke
837e29035c s3:locking: convert brl_have_read field to brl_num_read.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-11-11 21:41:05 +01:00
David Disseldorp
8f9137cb52 share_mode_lock: don't leak lock_path onto talloc tos
Also check for allocation failures.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-11-03 23:46:05 +01:00
David Disseldorp
39f8ff2355 brlock: don't leak lock_path onto talloc tos
Also check for allocation failures.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-11-03 23:46:05 +01:00
Stefan Metzmacher
a3b333a1a2 s3:locking: remove dead code from brl_get_locks_readonly()
struct byte_range_lock *rw = NULL; will never change...

commit 1057240733 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
2014-10-31 06:07:43 +01:00
Volker Lendecke
151b9caeef s3:locking: Change from ndr_pull_struct_blob() to ndr_pull_struct_blob_all() so we fail if not all bytes are consumed.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-31 03:47:40 +01:00
Volker Lendecke
9010bbeb00 s3:locking: allow early return for share_entry_forall()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-31 03:47:40 +01:00
Volker Lendecke
48926b7619 s3:locking: Introduce share_mode_forall
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-31 03:47:40 +01:00
Volker Lendecke
0d4f7bfdb9 s3:locking: Rename share_mode_forall->share_entry_forall
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-31 03:47:40 +01:00
Volker Lendecke
85935097b9 brlock: Remove validate_lock_entries
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>
2014-08-23 00:24:18 +02:00
Volker Lendecke
1057240733 brlock: Do auto-cleanup at conflict time
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>
2014-08-23 00:24:18 +02:00
Volker Lendecke
40386ee78d locking: posix_lock_list does not use "fsp"
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): Wed Aug  6 03:27:36 CEST 2014 on sn-devel-104
2014-08-06 03:27:36 +02:00
Volker Lendecke
380c282d44 locking: Avoid a pointless cast
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-06 01:05:14 +02:00
Volker Lendecke
188017ea32 smbd: Simplify brl_locktest
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>
2014-07-22 15:32:39 +02:00
Volker Lendecke
50b74ccb6a smbd: Restructure brl_conflict_other
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>
2014-07-22 15:32:39 +02:00
Volker Lendecke
a48c0a42ce smbd: Fix indentation, {} and line length in brl_conflict_other
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-07-22 15:32:39 +02:00
Volker Lendecke
2d8576ea7c smbd: Rename lck2->rw_probe in brl_conflict_other
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-07-22 15:32:39 +02:00
Volker Lendecke
e75e4b2ed8 smbd: Rename lck1->lock in brl_conflict_other
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>
2014-07-22 15:32:39 +02:00
Volker Lendecke
432130c572 smbd: Use a struct initializer brl_lock
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>
2014-07-22 15:32:39 +02:00
Volker Lendecke
164e0cb23c smbd: Simplify strict_lock_default with early returns
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-07-22 15:32:39 +02:00
Volker Lendecke
ff9a0a8993 smbd: Use %ju/uintmax_t in source3/locking
Avoid going through (double) and %.0f

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-07-22 15:32:39 +02:00
Volker Lendecke
085c7a71fd smbd: do_lock_cancel does not need "blr" anymore
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 Jul  4 08:52:31 CEST 2014 on sn-devel-104
2014-07-04 08:52:31 +02:00
Volker Lendecke
5a1fb2eb0d smbd: brl_lock_cancel does not need "blr" anymore
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-07-04 06:31:16 +02:00
Volker Lendecke
6f8fd3d5ab smbd: Remove unused blocking_lock_record* from VFS_BRL_CANCEL_WINDOWS
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-07-04 06:31:16 +02:00
Volker Lendecke
f038cf739d smbd: do_lock does not need "blr" anymore
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-07-04 06:31:16 +02:00
Volker Lendecke
c886e66232 smbd: brl_lock does not need "blr" anymore
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-07-04 06:31:16 +02:00
Volker Lendecke
b08fe2d98d smbd: Remove unused blocking_lock_record* from VFS_BRL_LOCK_WINDOWS
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-07-04 06:31:16 +02:00
Volker Lendecke
28df2b0d0d smbd: Use brl_delete_lock_struct in brl_lock_cancel_default
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-07-04 06:31:16 +02:00
Jeremy Allison
47748606dc s3: smbd: Locking, fix off-by one calculation in brl_pending_overlap().
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
2014-07-02 10:18:17 +02:00
Volker Lendecke
8ae692cc91 smbd: validate_lock_entries does not need mem_ctx anymore
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-06-30 22:28:15 +02:00
Volker Lendecke
c5fb0f9cc0 smbd: Simplify validate_lock_entries
Signed-off-by: Volker Lendecke <vl@samba.org>
2014-06-30 22:28:15 +02:00
Volker Lendecke
2282128ed0 smbd: Factor out brl_delete_lock_struct
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>
2014-06-30 22:28:15 +02:00
Volker Lendecke
3c2f4e328b smbd: Simplify validate_lock_entries
... saves >100 bytes object code :-)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-06-30 22:28:15 +02:00
Volker Lendecke
9f2e90754b smbstatus: Fix an uninitialized variable
We only print valid share mode entries, stale ones don't count. In
traverse, let the callback decide about staleness.

https://bugzilla.samba.org/show_bug.cgi?id=10680

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-06-30 22:28:15 +02:00
Ralph Boehme
3defbe2734 locking: use correct conversion specifier for printing variables
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>
2014-06-13 13:22:18 +02:00
Jeremy Allison
bed323cebc s3 : smbd : Protect all possible code paths from fsp->op == NULL.
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>
2014-05-02 21:27:07 +02:00
Volker Lendecke
9e754840de smbd: Remove unused "share_mode_data->id"
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
2014-03-21 21:22:24 +01:00
Volker Lendecke
698f7f21c2 smbd: Keep "the_lock"s file id separately
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-21 19:20:17 +01:00