The branch, v4-21-test has been updated
via 0f4e46398bd vfs_btrfs: Also call vfs_offload_token_ctx_init() in
btrfs_offload_write_send()
via 9a7047e8cca ctdb-common: Map ENOENT for a missing event script to
ENOEXEC
from a01a0c34dad VERSION: Bump version up to Samba 4.21.3...
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-21-test
- Log -----------------------------------------------------------------
commit 0f4e46398bdf16c6f73982fbb4ed0ddca8d25f94
Author: Andreas Schneider <[email protected]>
Date: Thu Nov 28 13:09:00 2024 +0100
vfs_btrfs: Also call vfs_offload_token_ctx_init() in
btrfs_offload_write_send()
If a client for whatever reason calls FSCTL_SRV_COPYCHUNK[_WRITE] without
FSCTL_SRV_REQUEST_RESUME_KEY, we call btrfs_offload_write_send
before btrfs_offload_read_send.
This is similar to 462b74da79c51f9ba6dbd24e603aa904485d5123
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15758
Signed-off-by: Andreas Schneider <[email protected]>
Autobuild-User(v4-21-test): Jule Anger <[email protected]>
Autobuild-Date(v4-21-test): Tue Dec 3 18:04:26 UTC 2024 on atb-devel-224
commit 9a7047e8cca28605c87536f5085b699d79842432
Author: Martin Schwenke <[email protected]>
Date: Wed Nov 20 14:37:09 2024 +1100
ctdb-common: Map ENOENT for a missing event script to ENOEXEC
This handles the case where an event script is disabled by unlinking,
while an event is being run, after the script list has been created.
Without this change the script will fail. With this change the script
will be marked as DISABLED. See the comment added by this commit for
more details.
Add a testcase to simulate the race, using an event script to disable
subsequent ones.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15755
RN: Avoid event failure race when disabling an event script
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
Autobuild-User(master): Amitay Isaacs <[email protected]>
Autobuild-Date(master): Thu Nov 21 01:42:09 UTC 2024 on atb-devel-224
(cherry picked from commit fee31b6cb2b8f7dd111bdd9d2ff5479c31cbca37)
-----------------------------------------------------------------------
Summary of changes:
ctdb/common/run_event.c | 23 ++++++++++++--
.../etc-ctdb/share/events/data/01.dummy.script | 4 +++
ctdb/tests/UNIT/eventd/eventd_009.sh | 37 ++++++++++++++++++++++
source3/modules/vfs_btrfs.c | 6 ++++
4 files changed, 68 insertions(+), 2 deletions(-)
Changeset truncated at 500 lines:
diff --git a/ctdb/common/run_event.c b/ctdb/common/run_event.c
index d283664e2cf..30369eeff22 100644
--- a/ctdb/common/run_event.c
+++ b/ctdb/common/run_event.c
@@ -268,8 +268,27 @@ static int run_event_script_status(struct run_event_script
*script)
if (script->result.sig > 0) {
ret = -EINTR;
} else if (script->result.err > 0) {
- if (script->result.err == EACCES) {
- /* Map EACCESS to ENOEXEC */
+ if (script->result.err == EACCES ||
+ script->result.err == ENOENT) {
+ /*
+ * Map EACCESS/ENOENT to ENOEXEC
+ *
+ * ENOENT: Disabling a standard event script
+ * by removing its symlink can result in
+ * ENOENT. This happens when the script list
+ * is built while the link exists, but the
+ * link is removed before the attempt to run
+ * it. Map it to ENOEXEC (which causes a
+ * script to be shown as DISABLED). This
+ * makes it impossible to distinguish a
+ * removed symlink from a dangling
+ * symlink... but the latter can just be
+ * defined as disabled. It should be rare
+ * because it shouldn't happen if event
+ * scripts are properly managed. If someone
+ * is doing weird things then they can easily
+ * debug such issues by looking at the link.
+ */
ret = -ENOEXEC;
} else {
ret = -script->result.err;
diff --git a/ctdb/tests/UNIT/eventd/etc-ctdb/share/events/data/01.dummy.script
b/ctdb/tests/UNIT/eventd/etc-ctdb/share/events/data/01.dummy.script
index 9c56f5b968b..b7b5945714c 100755
--- a/ctdb/tests/UNIT/eventd/etc-ctdb/share/events/data/01.dummy.script
+++ b/ctdb/tests/UNIT/eventd/etc-ctdb/share/events/data/01.dummy.script
@@ -2,5 +2,9 @@
case "$1" in
"failure") exit 1 ;;
+"disablehack")
+ ctdb-event script disable data 02.disabled
+ ctdb-event script disable data 03.notalink
+ ;;
*) exit 0 ;;
esac
diff --git a/ctdb/tests/UNIT/eventd/eventd_009.sh
b/ctdb/tests/UNIT/eventd/eventd_009.sh
index 39e5cd658cc..86c7224ad23 100755
--- a/ctdb/tests/UNIT/eventd/eventd_009.sh
+++ b/ctdb/tests/UNIT/eventd/eventd_009.sh
@@ -153,3 +153,40 @@ ok <<EOF
* 03.notalink
EOF
simple_test script list data
+
+#
+# Test disabling of scripts after the script list has been
+# built. Normally this would be an admin racing with eventd instead of
+# one script disabling subsequent ones.
+#
+
+# First enable all scripts - this might repeat some previous stuff
+ok_null
+simple_test script enable data 01.dummy
+ok_null
+simple_test script enable data 02.disabled
+ok_null
+simple_test script enable data 03.notalink
+
+# Confirm expected state
+ok <<EOF
+* 01.dummy
+* 02.disabled
+
+* 03.notalink
+EOF
+simple_test script list data
+
+# Now run the event that disables the subsequent scripts:
+# - 02.disabled has its link removed
+# - 03.notalink effectively has "chmod -x" applied
+ok_null
+simple_test run 10 data disablehack
+
+# Confirm that both subsequent scripts were disabled
+ok <<EOF
+01.dummy OK DURATION DATETIME
+02.disabled DISABLED
+03.notalink DISABLED
+EOF
+simple_test status data disablehack
diff --git a/source3/modules/vfs_btrfs.c b/source3/modules/vfs_btrfs.c
index 90312524287..908f4e43464 100644
--- a/source3/modules/vfs_btrfs.c
+++ b/source3/modules/vfs_btrfs.c
@@ -261,6 +261,12 @@ static struct tevent_req *btrfs_offload_write_send(struct
vfs_handle_struct *han
state->handle = handle;
+ status = vfs_offload_token_ctx_init(handle->conn->sconn->client,
+ &btrfs_offload_ctx);
+ if (tevent_req_nterror(req, status)) {
+ return tevent_req_post(req, ev);
+ }
+
tevent_req_set_cleanup_fn(req, btrfs_offload_write_cleanup);
status = vfs_offload_token_db_fetch_fsp(btrfs_offload_ctx,
--
Samba Shared Repository