]>
git.ipfire.org Git - thirdparty/samba.git/log
Stefan Metzmacher [Wed, 10 Aug 2022 08:30:18 +0000 (08:30 +0000)]
s3:smbd: move grant_fsp_lease()/set_file_oplock() out of handle_share_mode_lease()
The aim is to call set_file_oplock() after set_share_mode(), so that we
only ask for kernel oplocks after set_share_mode().
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Wed, 10 Aug 2022 07:58:02 +0000 (07:58 +0000)]
s3:smbd: move grant_fsp_lease()/set_file_oplock() out of delay_for_oplocks()
It means delay_for_oplocks() is no longer asking for kernel oplocks.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 21 Aug 2022 09:46:16 +0000 (11:46 +0200)]
s3:smbd: add more detailed debugging to delay_for_oplock()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Mon, 29 Aug 2022 11:44:00 +0000 (13:44 +0200)]
s3:locking: add share_mode_entry_prepare_{lock,unlock}() infrastructure
When adding or deleting share mode entries elements, we typically
have a pattern like this:
1. get the g_lock via get_[existing_]share_mode_lock()
2. do some checking of the existing record
3. add/delete a share_mode_entry to the record
4. do some vfs operations still protected by the g_lock
5. (optional) cleanup of the record on failure
6. release the g_lock
We can optimize this to:
- Run 1-3. under a tdb chainlock
- Only protect vfs operations with the g_lock
if a new file was created/will be deleted
- Regrab the g_lock for a cleanup.
The new share_mode_entry_prepare_lock()
allows the caller to run a function within a tdb chainlock
similar to share_mode_do_locked_vfs_denied() where vfs calls are denied
and the execution is done within a tdb chainlock.
But the callback function is allowed to decide if it wants to
keep the lock at the g_lock layer on return.
The decision is kept in struct share_mode_entry_prepare_state,
which is then passed to share_mode_entry_prepare_unlock()
with an optional callback to do some cleanup under the
still existing g_lock or a regrabed g_lock.
In the ideal case the callback function passed to
share_mode_entry_prepare_lock() is able to decide that
it can drop the g_lock and the share_mode_entry_prepare_unlock().
gets a NULL callback as there's nothing to cleanup.
In this case share_mode_entry_prepare_unlock() is a noop.
This will allow us to avoid fallbacks to the dbwrap_watch based
waiting for the g_lock in the SMB2 Create and Close code paths.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Mon, 29 Aug 2022 10:50:20 +0000 (12:50 +0200)]
s3:locking: optimize share_mode_do_locked_vfs_denied() with g_lock_lock callback
It means that in callers function will run under a single tdb chainlock,
which means callers from the outside will never see the record being
locked at g_lock level, as the g_lock is only held in memory.
within the single tdb chainlock. As a result we'll very unlikely hit
the case where we need to wait for a g_lock using the dbwrap_watch
logic.
Review with: git show -w
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Mon, 29 Aug 2022 10:50:20 +0000 (12:50 +0200)]
s3:locking: add current_share_mode_glck helper functions
We'll soon make use of callback functions passed to g_lock_lock(),
during these callback function we'll only be allowed to
call 'g_lock_lock_cb_state' based functions.
Given that nesting of share_mode call, we need to
make it transparent to the callers and the detail
that we optimize using g_lock_lock() callbacks.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 28 Aug 2022 11:08:48 +0000 (13:08 +0200)]
s3:g_lock: add callback function to g_lock_lock()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 28 Aug 2022 10:38:24 +0000 (12:38 +0200)]
s3:g_lock: add callback function to g_lock_lock_send()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 28 Aug 2022 09:41:46 +0000 (11:41 +0200)]
s3:g_lock: add callback function to g_lock_lock_simple_fn()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 28 Aug 2022 10:38:24 +0000 (12:38 +0200)]
s3:g_lock: add callback function to g_lock_trylock()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 28 Aug 2022 10:31:23 +0000 (12:31 +0200)]
s3:g_lock: reorder the logic in g_lock_trylock()
We now have only one code path that stores the fully
granted lock.
This is not change in behavior, but it will simplify further
changes.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 28 Aug 2022 09:58:14 +0000 (11:58 +0200)]
s3:g_lock: remove redundant code in g_lock_trylock()
g_lock_cleanup_shared() handles lck.num_shared == 0 just fine...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 28 Aug 2022 09:41:46 +0000 (11:41 +0200)]
s3:g_lock: add g_lock_ctx->busy and assert it to false
This prepares some helper functions in order to
allow callers of g_lock_lock() to pass in a callback function
that will run under the tdb chainlock when G_LOCK_WRITE was granted.
The idea is that the callers callback function would run with
g_lock_ctx->busy == true and all key based function are not be allowed
during the execution of the callback function. Only the
g_lock_lock_cb_state based helper function are allowed to be used.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 28 Aug 2022 09:41:46 +0000 (11:41 +0200)]
s3:g_lock: add g_lock_lock_cb_state infrastructure
This prepares some helper functions in order to
allow callers of g_lock_lock() to pass in a callback function
that will run under the tdb chainlock when G_LOCK_WRITE was granted.
The idea is that the callers callback function would only be allowed
to run these new helper functions, while all key based function are
not to be allowed.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 28 Aug 2022 08:30:38 +0000 (10:30 +0200)]
s3:g_lock: reorder the logic in g_lock_lock_simple_fn()
First we fully check if we'll get the lock
and then store the lock.
This is not change in behavior, but it will simplify further changes.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 15:33:31 +0000 (17:33 +0200)]
lib/dbwrap: allow dbwrap_merge_dbufs() to update an existing buffer
This will be useful in future...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 16:13:24 +0000 (18:13 +0200)]
s3:dbwrap_watch: add dbwrap_watched_watch_force_alerting()
This is useful when we want to wakeup the next watcher
without modifying the record.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 28 Aug 2022 11:34:25 +0000 (13:34 +0200)]
s3:dbwrap_watch: add dbwrap_watched_watch_reset_alerting() helper
This can be used if the decision of using dbwrap_watched_watch_skip_alerting()
needs to be reverted...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 28 Aug 2022 11:32:59 +0000 (13:32 +0200)]
s3:dbwrap_watch: let dbwrap_watched_watch_skip_alerting() also clear the selected watcher
If a watcher was already selected for a wakeup notification reset it...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 11:06:40 +0000 (13:06 +0200)]
s3:locking: let _share_mode_do_locked_vfs_* use get/put_share_mode_lock_internal
This avoids calling talloc(mem_ctx, struct share_mode_lock)
and uses stack variables instead.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 28 Aug 2022 07:58:51 +0000 (09:58 +0200)]
s3:locking: split out put_share_mode_lock_internal()
This pairs with get_share_mode_lock_internal() and will allow us
to use a struct share_mode_lock stack variable in future,
which will be much cheaper.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 11:03:33 +0000 (13:03 +0200)]
s3:locking: split out get_share_mode_lock_internal()
This detaches the logic from the talloc(mem_ctx, struct share_mode_lock).
In future we will have cases where we use a stack variable instead,
which will be much cheaper.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 07:50:00 +0000 (09:50 +0200)]
s3:locking: remove static_share_mode_data_refcount
The effective value of share_mode_lock_key_refcount
is 'share_mode_lock_key_refcount + static_share_mode_data_refcount',
which is quite confusing.
This complexity is not needed and we can just use
share_mode_lock_key_refcount.
This will also simplify further changes.
Review with: git show -U15 -w
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 07:42:45 +0000 (09:42 +0200)]
s3:locking: move from uint8_t share_mode_lock_key_data[] to struct file_id
This will allow us to have better debug messages and will also make
further changes easier.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Thu, 1 Sep 2022 11:25:06 +0000 (13:25 +0200)]
s3:smb2_trans2: make use of share_mode_do_locked_vfs_allowed() in smb_posix_unlink()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Tue, 30 Aug 2022 06:11:12 +0000 (08:11 +0200)]
s3:smbd: let update_write_time_on_close() use share_mode_do_locked_vfs_denied()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Tue, 30 Aug 2022 05:57:48 +0000 (05:57 +0000)]
s3:smbd: let update_write_time_on_close() use share_mode_{old,changed}_write_time()
We're already holding a share_mode_lock, so we can use it directly.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Thu, 1 Sep 2022 10:54:35 +0000 (12:54 +0200)]
s3:locking: make use of share_mode_do_locked_vfs_denied() in set_sticky_write_time()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Thu, 1 Sep 2022 10:49:51 +0000 (12:49 +0200)]
s3:locking: make use of share_mode_do_locked_vfs_denied() in set_write_time()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Thu, 1 Sep 2022 10:34:16 +0000 (12:34 +0200)]
s3:locking: make use of share_mode_do_locked_vfs_denied() in file_has_open_streams()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Wed, 31 Aug 2022 15:14:09 +0000 (17:14 +0200)]
s3:smbd: let lease_match() use share_mode_do_locked_vfs_denied()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Wed, 31 Aug 2022 14:34:40 +0000 (16:34 +0200)]
s3:locking: let set_delete_on_close() use share_mode_do_locked_vfs_denied()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Tue, 30 Aug 2022 05:55:57 +0000 (05:55 +0000)]
s3:locking: make use of new share_mode_set_{changed,old}_write_time() helpers
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Tue, 30 Aug 2022 05:55:03 +0000 (05:55 +0000)]
s3:locking: add share_mode_set_{changed,old}_write_time() helpers
These will be used in future to call them unter an existing share mode
lock...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Mon, 29 Aug 2022 14:01:20 +0000 (16:01 +0200)]
s3:smbd: let setup_poll_open() use share_mode_do_locked_vfs_denied()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Mon, 29 Aug 2022 13:53:11 +0000 (15:53 +0200)]
s3:smbd: move get_existing_share_mode_lock() into setup_poll_open()
This will simplify the next steps...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 08:44:59 +0000 (10:44 +0200)]
s3:locking: make 'struct share_mode_lock' private to share_mode_lock.c
There are no callers left dereferencing it.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 10:11:44 +0000 (12:11 +0200)]
s3:locking: make use of share_mode_lock_access_private_data() in reset_share_mode_entry()
We should avoid dereference 'struct share_mode_lock' as much as possible.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 10:10:55 +0000 (12:10 +0200)]
s3:locking: pass struct share_mode_data to share_mode_entry_do()
We should avoid dereference 'struct share_mode_lock' as much as possible.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 10:09:06 +0000 (12:09 +0200)]
s3:locking: make use of share_mode_lock_access_private_data() in share_mode_forall_entries()
We should avoid dereference 'struct share_mode_lock' as much as possible.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 10:08:03 +0000 (12:08 +0200)]
s3:locking: make use of share_mode_lock_file_id() in share_mode_watch_send()
We should avoid dereference 'struct share_mode_lock' as much as possible.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 10:05:04 +0000 (12:05 +0200)]
s3:locking: add and use share_mode_lock_assert_private_data()
We should avoid dereference 'struct share_mode_lock' as much as possible.
In some places we just rely on share_mode_lock_access_private_data()
to work, if needed the caller should already check it's result...
Note that share_mode_lock_assert_private_data() can't fail up to
now, but we want to change that in future and only load it on
demand.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 09:17:51 +0000 (11:17 +0200)]
s3:locking: let get_share_mode_write_time() use share_mode_lock_access_private_data()
We should avoid dereference 'struct share_mode_lock' as much as possible.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 09:17:51 +0000 (11:17 +0200)]
s3:locking: let set_write_time() use share_mode_lock_access_private_data()
We should avoid dereference 'struct share_mode_lock' as much as possible.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 09:17:51 +0000 (11:17 +0200)]
s3:locking: let set_sticky_write_time() use share_mode_lock_access_private_data()
We should avoid dereference 'struct share_mode_lock' as much as possible.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 09:17:51 +0000 (11:17 +0200)]
s3:locking: let is_delete_on_close_set() use share_mode_lock_access_private_data()
We should avoid dereference 'struct share_mode_lock' as much as possible.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 09:17:51 +0000 (11:17 +0200)]
s3:locking: let get_delete_on_close_token() use share_mode_lock_access_private_data()
We should avoid dereference 'struct share_mode_lock' as much as possible.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 09:17:51 +0000 (11:17 +0200)]
s3:locking: let set_delete_on_close_lck() use share_mode_lock_access_private_data()
We should avoid dereference 'struct share_mode_lock' as much as possible.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 09:17:51 +0000 (11:17 +0200)]
s3:locking: let reset_delete_on_close_lck() use share_mode_lock_access_private_data()
We should avoid dereference 'struct share_mode_lock' as much as possible.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 08:43:12 +0000 (10:43 +0200)]
s3:locking: let remove_lease_if_stale() use share_mode_lock_file_id()
We should avoid dereference 'struct share_mode_lock' as much as possible.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 08:40:44 +0000 (10:40 +0200)]
s3:locking: add share_mode_lock_file_id()
This will simplify some (mostly debug) code soon.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 08:24:52 +0000 (10:24 +0200)]
s3:locking: make use of share_mode_lock_access_private_data() in rename_share_filename()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 08:21:25 +0000 (10:21 +0200)]
s3:locking: let rename_share_filename_state maintain a struct share_mode_data pointer
We only need to access lck->data once...
This will simplify further changes.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 08:24:52 +0000 (10:24 +0200)]
s3:locking: add share_mode_lock_access_private_data()
In future we should avoid dereference 'struct share_mode_lock'
as much as possible.
This will also allow us to load struct share_mode_data
only if required in future.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Fri, 26 Aug 2022 07:27:44 +0000 (09:27 +0200)]
s3:locking: let share_mode_wakeup_waiters() use share_mode_do_locked_vfs_denied()
This allows us get rid of the otherwise unused share_mode_do_locked().
It means we only have one code path that handles the g_lock handling.
This looks like a performance degradation, but all callers of
share_mode_wakeup_waiters() already took the share_mode_lock,
so we only increment the refcount. Note the additional
talloc(mem_ctx, struct share_mode_lock) will be optimized away
in the next commits.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Thu, 18 Aug 2022 12:38:55 +0000 (14:38 +0200)]
s3:locking: make share_mode_do_locked() static
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Thu, 18 Aug 2022 11:57:56 +0000 (13:57 +0200)]
s3:locking: protect do_lock() with share_mode_do_locked_vfs_allowed()
share_mode_do_locked() will be make static soon.
Here we just want to avoid concurrent access to brlock.tdb
in order to maintain the lock order, we're not interested in the
locking.tdb content at all, expect that there's at least one
entry.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Thu, 18 Aug 2022 11:57:56 +0000 (13:57 +0200)]
s3:smbd: protect smbd_do_unlocking() with share_mode_do_locked_vfs_allowed()
share_mode_do_locked() will be make static soon.
Here we just want to avoid concurrent access to brlock.tdb
in order to maintain the lock order, we're not interested in the
locking.tdb content at all, expect that there's at least one
entry and we want to wake potential watchers.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Thu, 18 Aug 2022 11:26:47 +0000 (13:26 +0200)]
s3:locking: add share_mode_do_locked_vfs_{denied,allowed}()
These function will add an abstraction to protect
a function that is not allowed to call vfs functions
or allow vfs functions to be called.
Currently these are implemented similar,
but we'll optimize them in the next commits.
The idea is that share_mode_do_locked_vfs_denied()
will be able to run fast enough in order to run
under a tdb chainlock (just a pthread mutex).
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 3 Sep 2022 00:46:34 +0000 (02:46 +0200)]
s3:smbd: add smb_vfs_assert_allowed() to kernel oplock code
Kernel oplocks can block in the same way vfs operations can do.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 21 Aug 2022 13:37:18 +0000 (15:37 +0200)]
s3:smbd: add helpers to deny vfs calls in some sections
Code denying vfs calls can do:
{
struct smb_vfs_deny_state vfs_deny = {};
smb_vfs_deny_push(&vfs_deny);
VFS calls are not allowed here...
smb_vfs_deny_pop(&vfs_deny);
}
This will allow us to safely run some code under a
tdb chainlock later...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 21 Aug 2022 13:19:59 +0000 (15:19 +0200)]
s3:smbd: move VFS_FIND() to smbd/vfs.c
It's only used there...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 21 Aug 2022 13:15:09 +0000 (15:15 +0200)]
s3:smbd: move locking related vfs functions to smbd/vfs.c
This allows us to make VFS_FIND local to smbd/vfs.c in the
next step.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Mon, 22 Aug 2022 14:19:40 +0000 (16:19 +0200)]
s3:locking: just use g_lock_dump() for fsp_update_share_mode_flags()
We don't need to protect this with g_lock_lock/g_lock_unlock
as we just want the current flags, we're still protected by the
dbwrap layer lock.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Mon, 22 Aug 2022 21:26:06 +0000 (23:26 +0200)]
s3:locking: move fsp_update_share_mode_flags* related functions further down
It will soon need to use 'struct locking_tdb_data'
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Mon, 22 Aug 2022 14:53:38 +0000 (16:53 +0200)]
s3:locking: replace locking_tdb_data_store() with share_mode_data_ltdb_store()
This means we flush share_mode_data at the same time...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 3 Sep 2022 23:35:06 +0000 (23:35 +0000)]
s3:locking: let share_mode_forall_entries() call TALLOC_FREE(ltdb)
We should free ltdb as soon as possible...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Mon, 22 Aug 2022 14:53:38 +0000 (16:53 +0200)]
s3:locking: split out share_mode_data_ltdb_store()
This will allow us to use it in other places too
and we'll avoid to storing multiple times.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Mon, 22 Aug 2022 14:53:38 +0000 (16:53 +0200)]
s3:locking: introduce share_mode_data->not_stored
share_mode_data->fresh was very similar, but only set
and never used.
Now we remember 'not_stored' instead, the 'not_' is easier
as ndr_pull sets [skip] elements to 0.
We use this as indication to move the value to
memcache.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 18:39:19 +0000 (20:39 +0200)]
s3:locking: change some debug messages to level unless we got NT_STATUS_NOT_FOUND
NT_STATUS_NOT_FOUND is not a real error in most cases so we should keep
it on level 10, but all other errors should never be without notice...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 18:39:19 +0000 (20:39 +0200)]
s3:locking: log all share_mode_forall_entries() errors at level 0
These should never fail without notice...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 18:39:19 +0000 (20:39 +0200)]
s3:locking: let share_mode_forall_leases() log all errors at level 0
These should never fail without notice...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Mon, 12 Sep 2022 07:18:00 +0000 (07:18 +0000)]
s3:locking: let set_delete_on_close_lck() log errors and panic
Most of the calls in set_delete_on_close_lck() are checked with
asserts, so do panic in all situation where things go wrong in an
unexpected way.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 18:39:19 +0000 (20:39 +0200)]
s3:locking: log g_lock_dump() error in locking_tdb_data_fetch() at level 0
This should never fail without notice...
Note we already checked for NT_STATUS_NOT_FOUND before.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 18:39:19 +0000 (20:39 +0200)]
s3:locking: log add locking_tdb_data_store() errors at level 0
These should never fail without notice...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 18:39:19 +0000 (20:39 +0200)]
s3:locking: log g_lock_locks() error at level 0
These should never fail without notice...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 18:39:19 +0000 (20:39 +0200)]
s3:locking: let fsp_update_share_mode_flags() log all errors at level 0
These should never fail without notice, share_mode_do_locked() should
never fail with NT_STATUS_NOT_FOUND for an existing fsp.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 18:39:19 +0000 (20:39 +0200)]
s3:locking: log all g_lock_writev_data() errors at level 0
These should never fail without notice.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 18:39:19 +0000 (20:39 +0200)]
s3:locking: log all locking_tdb_data_{get,fetch}() errors at level 0
These should never fail without notice.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 21 Aug 2022 09:17:19 +0000 (11:17 +0200)]
s3:open_files.idl: add share_mode_entry_op_type
This makes it easier to read log files...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Thu, 30 Jun 2022 10:25:47 +0000 (10:25 +0000)]
s3:smbd: let smbXsrv_{session,tcon,open}_global.tdb use TDB_VOLATILE
This avoids using fcntl() locks for dbwrap_delete()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 17:03:44 +0000 (19:03 +0200)]
s3:g_lock: fix error handling in g_lock_watch_data_send()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15167
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Wed, 31 Aug 2022 15:11:15 +0000 (17:11 +0200)]
s3:smbd: let lease_match() call TALLOC_FREE(lck); on error
We ignore the error from share_mode_forall_leases(), but
we still need to cleanup the share_mode_lock we are holding...
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 18:39:37 +0000 (20:39 +0200)]
s3:locking: let reset_share_mode_entry() report errors to the caller
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15166
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sat, 10 Sep 2022 18:41:17 +0000 (20:41 +0200)]
s3:locking: remove unused NO_LOCKING_COUNT
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Stefan Metzmacher [Sun, 21 Aug 2022 18:47:13 +0000 (20:47 +0200)]
s3:torture: fix strict aliasing warnings in cmd_vfs.c
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Volker Lendecke [Sat, 17 Sep 2022 21:02:31 +0000 (14:02 -0700)]
libsmb: Use find_snapshot_token() for clistr_is_previous_version_path()
Dedup that string parsing logic
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): Mon Sep 19 18:21:56 UTC 2022 on sn-devel-184
Volker Lendecke [Sat, 17 Sep 2022 20:48:31 +0000 (13:48 -0700)]
lib: Add separator argument to find_snapshot_token()
We'll use the logic for \ based strings next
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Volker Lendecke [Sat, 17 Sep 2022 17:13:27 +0000 (10:13 -0700)]
lib: Move extract_snapshot_token() to util_path.c
Make it available to replace clistr_is_previous_version_path() in
libsmb/
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Volker Lendecke [Sat, 17 Sep 2022 03:29:30 +0000 (20:29 -0700)]
vfs: Simplify xattr_tdb_mkdirat()
We have the dirfsp and the relative name. And with fstatat we don't
need the full pathname anymore.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Volker Lendecke [Fri, 16 Sep 2022 16:54:05 +0000 (09:54 -0700)]
streams_xattr: Avoid a talloc_strdup
We can print a short string with %.*s, no talloc_strdup()
and *stype='\0' required.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Volker Lendecke [Wed, 7 Sep 2022 09:32:26 +0000 (11:32 +0200)]
smbd: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Volker Lendecke [Wed, 7 Sep 2022 08:39:26 +0000 (10:39 +0200)]
smbd: Use PATH_MAX as symlink target buffer
We use that instead of the arbitrary 4k in open.c as well
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Volker Lendecke [Thu, 15 Sep 2022 00:16:46 +0000 (17:16 -0700)]
shadow_copy2: Don't implicitly return memory off talloc_tos()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Volker Lendecke [Fri, 9 Sep 2022 03:55:46 +0000 (05:55 +0200)]
shadow_copy2: Avoid a few ZERO_STRUCT()s
Give the compiler more hints what's going on
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Volker Lendecke [Mon, 12 Sep 2022 17:20:38 +0000 (10:20 -0700)]
source3: A few whitespace fixes
review with git sh -w
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Volker Lendecke [Mon, 12 Sep 2022 17:17:09 +0000 (10:17 -0700)]
registry3: Move registry_value_cmp() to its only user
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Volker Lendecke [Mon, 12 Sep 2022 17:13:46 +0000 (10:13 -0700)]
registry3: Remove some unused functions
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Volker Lendecke [Fri, 9 Sep 2022 11:59:28 +0000 (13:59 +0200)]
vfs: Simplify vfswrap_parent_pathname()
We don't really need a talloc_stackframe() here
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Volker Lendecke [Fri, 9 Sep 2022 11:43:54 +0000 (13:43 +0200)]
vfs: Avoid a talloc in vfswrap_parent_pathname()
We copy smb_fname_in->base_name just to overwrite it again
immediately. Expand synthetic_smb_fname() here.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>