The Samba-Bugzilla – Attachment 13636 Details for
Bug 12903
File change notification for renames not working
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for 4.7 backported from master
bug12903-v47.patch (text/plain), 52.13 KB, created by
Ralph Böhme
on 2017-09-27 10:19:19 UTC
(
hide
)
Description:
Patch for 4.7 backported from master
Filename:
MIME Type:
Creator:
Ralph Böhme
Created:
2017-09-27 10:19:19 UTC
Size:
52.13 KB
patch
obsolete
>From 5006f49f7064ac9eea272ea0712bac4ef64cec12 Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Fri, 16 Jun 2017 15:20:22 +0200 >Subject: [PATCH 01/13] notifyd: Only ask for messaging_ctdb_conn when > clustering > >Without clustering, messaging_ctdb_conn will fail anyway. > >Review with "git show -b". > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 939576d968d1e0159456baf6dd1e3c454b98995a) >--- > source3/smbd/notifyd/notifyd.c | 65 +++++++++++++++++++++++------------------- > source3/smbd/server.c | 8 ++++-- > 2 files changed, 42 insertions(+), 31 deletions(-) > >diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c >index f02ccfa11d3..377d9535aa8 100644 >--- a/source3/smbd/notifyd/notifyd.c >+++ b/source3/smbd/notifyd/notifyd.c >@@ -242,13 +242,15 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > tevent_req_set_callback(subreq, notifyd_handler_done, req); > > #ifdef CLUSTER_SUPPORT >- subreq = messaging_handler_send(state, ev, msg_ctx, >- MSG_SMB_NOTIFY_DB, >- notifyd_got_db, state); >- if (tevent_req_nomem(subreq, req)) { >- return tevent_req_post(req, ev); >+ if (ctdbd_conn != NULL) { >+ subreq = messaging_handler_send(state, ev, msg_ctx, >+ MSG_SMB_NOTIFY_DB, >+ notifyd_got_db, state); >+ if (tevent_req_nomem(subreq, req)) { >+ return tevent_req_post(req, ev); >+ } >+ tevent_req_set_callback(subreq, notifyd_handler_done, req); > } >- tevent_req_set_callback(subreq, notifyd_handler_done, req); > #endif > > names_db = messaging_names_db(msg_ctx); >@@ -270,32 +272,37 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > } > > #ifdef CLUSTER_SUPPORT >- state->log = talloc_zero(state, struct messaging_reclog); >- if (tevent_req_nomem(state->log, req)) { >- return tevent_req_post(req, ev); >- } >+ if (ctdbd_conn != NULL) { >+ state->log = talloc_zero(state, struct messaging_reclog); >+ if (tevent_req_nomem(state->log, req)) { >+ return tevent_req_post(req, ev); >+ } > >- subreq = notifyd_broadcast_reclog_send( >- state->log, ev, ctdbd_conn, messaging_server_id(msg_ctx), >- state->log); >- if (tevent_req_nomem(subreq, req)) { >- return tevent_req_post(req, ev); >- } >- tevent_req_set_callback(subreq, notifyd_broadcast_reclog_finished, >- req); >+ subreq = notifyd_broadcast_reclog_send( >+ state->log, ev, ctdbd_conn, >+ messaging_server_id(msg_ctx), >+ state->log); >+ if (tevent_req_nomem(subreq, req)) { >+ return tevent_req_post(req, ev); >+ } >+ tevent_req_set_callback(subreq, >+ notifyd_broadcast_reclog_finished, >+ req); > >- subreq = notifyd_clean_peers_send(state, ev, state); >- if (tevent_req_nomem(subreq, req)) { >- return tevent_req_post(req, ev); >- } >- tevent_req_set_callback(subreq, notifyd_clean_peers_finished, >- req); >+ subreq = notifyd_clean_peers_send(state, ev, state); >+ if (tevent_req_nomem(subreq, req)) { >+ return tevent_req_post(req, ev); >+ } >+ tevent_req_set_callback(subreq, notifyd_clean_peers_finished, >+ req); > >- ret = register_with_ctdbd(ctdbd_conn, CTDB_SRVID_SAMBA_NOTIFY_PROXY, >- notifyd_snoop_broadcast, state); >- if (ret != 0) { >- tevent_req_error(req, ret); >- return tevent_req_post(req, ev); >+ ret = register_with_ctdbd(ctdbd_conn, >+ CTDB_SRVID_SAMBA_NOTIFY_PROXY, >+ notifyd_snoop_broadcast, state); >+ if (ret != 0) { >+ tevent_req_error(req, ret); >+ return tevent_req_post(req, ev); >+ } > } > #endif > >diff --git a/source3/smbd/server.c b/source3/smbd/server.c >index 55fc25c77ef..181bcd1e123 100644 >--- a/source3/smbd/server.c >+++ b/source3/smbd/server.c >@@ -334,6 +334,7 @@ static struct tevent_req *notifyd_req(struct messaging_context *msg_ctx, > struct tevent_req *req; > sys_notify_watch_fn sys_notify_watch = NULL; > struct sys_notify_context *sys_notify_ctx = NULL; >+ struct ctdbd_connection *ctdbd_conn = NULL; > > if (lp_kernel_change_notify()) { > >@@ -358,8 +359,11 @@ static struct tevent_req *notifyd_req(struct messaging_context *msg_ctx, > } > } > >- req = notifyd_send(msg_ctx, ev, msg_ctx, >- messaging_ctdbd_connection(), >+ if (lp_clustering()) { >+ ctdbd_conn = messaging_ctdbd_connection(); >+ } >+ >+ req = notifyd_send(msg_ctx, ev, msg_ctx, ctdbd_conn, > sys_notify_watch, sys_notify_ctx); > if (req == NULL) { > TALLOC_FREE(sys_notify_ctx); >-- >2.13.5 > > >From ed0df825612125be6011dd52c4776d348f11039e Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Wed, 5 Jul 2017 09:34:51 +0200 >Subject: [PATCH 02/13] notifyd: Consolidate two #ifdef CLUSTER into one > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit d0a7bccae9856aba44a057c09499aa0de6b21862) >--- > source3/smbd/notifyd/notifyd.c | 21 +++++++++------------ > 1 file changed, 9 insertions(+), 12 deletions(-) > >diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c >index 377d9535aa8..fec9a5bd6cd 100644 >--- a/source3/smbd/notifyd/notifyd.c >+++ b/source3/smbd/notifyd/notifyd.c >@@ -241,18 +241,6 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > } > tevent_req_set_callback(subreq, notifyd_handler_done, req); > >-#ifdef CLUSTER_SUPPORT >- if (ctdbd_conn != NULL) { >- subreq = messaging_handler_send(state, ev, msg_ctx, >- MSG_SMB_NOTIFY_DB, >- notifyd_got_db, state); >- if (tevent_req_nomem(subreq, req)) { >- return tevent_req_post(req, ev); >- } >- tevent_req_set_callback(subreq, notifyd_handler_done, req); >- } >-#endif >- > names_db = messaging_names_db(msg_ctx); > > ret = server_id_db_set_exclusive(names_db, "notify-daemon"); >@@ -273,6 +261,15 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > > #ifdef CLUSTER_SUPPORT > if (ctdbd_conn != NULL) { >+ >+ subreq = messaging_handler_send(state, ev, msg_ctx, >+ MSG_SMB_NOTIFY_DB, >+ notifyd_got_db, state); >+ if (tevent_req_nomem(subreq, req)) { >+ return tevent_req_post(req, ev); >+ } >+ tevent_req_set_callback(subreq, notifyd_handler_done, req); >+ > state->log = talloc_zero(state, struct messaging_reclog); > if (tevent_req_nomem(state->log, req)) { > return tevent_req_post(req, ev); >-- >2.13.5 > > >From ef17d475cb8d49f0a0555136b8c4c49bfccfa778 Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Wed, 5 Jul 2017 09:37:14 +0200 >Subject: [PATCH 03/13] notifyd: Avoid an if-expression > >Best reviewed with "git show -b -U10" > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit b8dccd11ea3d43b9ee51811c1ce7d81b91a549ca) >--- > source3/smbd/notifyd/notifyd.c | 69 ++++++++++++++++++++---------------------- > 1 file changed, 33 insertions(+), 36 deletions(-) > >diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c >index fec9a5bd6cd..2b70371b4d9 100644 >--- a/source3/smbd/notifyd/notifyd.c >+++ b/source3/smbd/notifyd/notifyd.c >@@ -260,46 +260,43 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > } > > #ifdef CLUSTER_SUPPORT >- if (ctdbd_conn != NULL) { >- >- subreq = messaging_handler_send(state, ev, msg_ctx, >- MSG_SMB_NOTIFY_DB, >- notifyd_got_db, state); >- if (tevent_req_nomem(subreq, req)) { >- return tevent_req_post(req, ev); >- } >- tevent_req_set_callback(subreq, notifyd_handler_done, req); >+ subreq = messaging_handler_send(state, ev, msg_ctx, >+ MSG_SMB_NOTIFY_DB, >+ notifyd_got_db, state); >+ if (tevent_req_nomem(subreq, req)) { >+ return tevent_req_post(req, ev); >+ } >+ tevent_req_set_callback(subreq, notifyd_handler_done, req); > >- state->log = talloc_zero(state, struct messaging_reclog); >- if (tevent_req_nomem(state->log, req)) { >- return tevent_req_post(req, ev); >- } >+ state->log = talloc_zero(state, struct messaging_reclog); >+ if (tevent_req_nomem(state->log, req)) { >+ return tevent_req_post(req, ev); >+ } > >- subreq = notifyd_broadcast_reclog_send( >- state->log, ev, ctdbd_conn, >- messaging_server_id(msg_ctx), >- state->log); >- if (tevent_req_nomem(subreq, req)) { >- return tevent_req_post(req, ev); >- } >- tevent_req_set_callback(subreq, >- notifyd_broadcast_reclog_finished, >- req); >+ subreq = notifyd_broadcast_reclog_send( >+ state->log, ev, ctdbd_conn, >+ messaging_server_id(msg_ctx), >+ state->log); >+ if (tevent_req_nomem(subreq, req)) { >+ return tevent_req_post(req, ev); >+ } >+ tevent_req_set_callback(subreq, >+ notifyd_broadcast_reclog_finished, >+ req); > >- subreq = notifyd_clean_peers_send(state, ev, state); >- if (tevent_req_nomem(subreq, req)) { >- return tevent_req_post(req, ev); >- } >- tevent_req_set_callback(subreq, notifyd_clean_peers_finished, >- req); >+ subreq = notifyd_clean_peers_send(state, ev, state); >+ if (tevent_req_nomem(subreq, req)) { >+ return tevent_req_post(req, ev); >+ } >+ tevent_req_set_callback(subreq, notifyd_clean_peers_finished, >+ req); > >- ret = register_with_ctdbd(ctdbd_conn, >- CTDB_SRVID_SAMBA_NOTIFY_PROXY, >- notifyd_snoop_broadcast, state); >- if (ret != 0) { >- tevent_req_error(req, ret); >- return tevent_req_post(req, ev); >- } >+ ret = register_with_ctdbd(ctdbd_conn, >+ CTDB_SRVID_SAMBA_NOTIFY_PROXY, >+ notifyd_snoop_broadcast, state); >+ if (ret != 0) { >+ tevent_req_error(req, ret); >+ return tevent_req_post(req, ev); > } > #endif > >-- >2.13.5 > > >From 42614bebc0809d447ab91cda8ada04abdfe4b92c Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Sat, 24 Jun 2017 08:38:19 +0200 >Subject: [PATCH 04/13] messaging: make messaging_rec_create public > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 0c1e08b5901e54c70cf72c74837a8ed8cc77f0b8) >--- > source3/include/messages.h | 5 +++++ > source3/lib/messages.c | 2 +- > 2 files changed, 6 insertions(+), 1 deletion(-) > >diff --git a/source3/include/messages.h b/source3/include/messages.h >index 806f7b0aadb..46dc6c05854 100644 >--- a/source3/include/messages.h >+++ b/source3/include/messages.h >@@ -145,6 +145,11 @@ int messaging_cleanup(struct messaging_context *msg_ctx, pid_t pid); > > bool messaging_parent_dgm_cleanup_init(struct messaging_context *msg); > >+struct messaging_rec *messaging_rec_create( >+ TALLOC_CTX *mem_ctx, struct server_id src, struct server_id dst, >+ uint32_t msg_type, const struct iovec *iov, int iovlen, >+ const int *fds, size_t num_fds); >+ > #include "librpc/gen_ndr/ndr_messaging.h" > > #endif >diff --git a/source3/lib/messages.c b/source3/lib/messages.c >index b0edb30ab14..da13a1edf34 100644 >--- a/source3/lib/messages.c >+++ b/source3/lib/messages.c >@@ -110,7 +110,7 @@ static void ping_message(struct messaging_context *msg_ctx, > messaging_send(msg_ctx, src, MSG_PONG, data); > } > >-static struct messaging_rec *messaging_rec_create( >+struct messaging_rec *messaging_rec_create( > TALLOC_CTX *mem_ctx, struct server_id src, struct server_id dst, > uint32_t msg_type, const struct iovec *iov, int iovlen, > const int *fds, size_t num_fds) >-- >2.13.5 > > >From a361c239557d819b95b45f83717c5a2273b292dc Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Sat, 24 Jun 2017 08:38:53 +0200 >Subject: [PATCH 05/13] notifyd: Use messaging_register for > MSG_SMB_NOTIFY_REC_CHANGE > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit b6079af1c41481714ac981fdd19f89ee197b4200) >--- > source3/smbd/notifyd/notifyd.c | 73 ++++++++++++++++++++++++------------------ > 1 file changed, 41 insertions(+), 32 deletions(-) > >diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c >index 2b70371b4d9..e078b404036 100644 >--- a/source3/smbd/notifyd/notifyd.c >+++ b/source3/smbd/notifyd/notifyd.c >@@ -32,6 +32,7 @@ > #include "notifyd.h" > #include "lib/util/server_id_db.h" > #include "lib/util/tevent_unix.h" >+#include "lib/util/tevent_ntstatus.h" > #include "ctdbd_conn.h" > #include "ctdb_srvids.h" > #include "server_id_db_util.h" >@@ -122,9 +123,9 @@ struct notifyd_peer { > time_t last_broadcast; > }; > >-static bool notifyd_rec_change(struct messaging_context *msg_ctx, >- struct messaging_rec **prec, >- void *private_data); >+static void notifyd_rec_change(struct messaging_context *msg_ctx, >+ void *private_data, uint32_t msg_type, >+ struct server_id src, DATA_BLOB *data); > static bool notifyd_trigger(struct messaging_context *msg_ctx, > struct messaging_rec **prec, > void *private_data); >@@ -195,6 +196,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > struct tevent_req *req, *subreq; > struct notifyd_state *state; > struct server_id_db *names_db; >+ NTSTATUS status; > int ret; > > req = tevent_req_create(mem_ctx, &state, struct notifyd_state); >@@ -217,19 +219,17 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > return tevent_req_post(req, ev); > } > >- subreq = messaging_handler_send(state, ev, msg_ctx, >- MSG_SMB_NOTIFY_REC_CHANGE, >- notifyd_rec_change, state); >- if (tevent_req_nomem(subreq, req)) { >+ status = messaging_register(msg_ctx, state, MSG_SMB_NOTIFY_REC_CHANGE, >+ notifyd_rec_change); >+ if (tevent_req_nterror(req, status)) { > return tevent_req_post(req, ev); > } >- tevent_req_set_callback(subreq, notifyd_handler_done, req); > > subreq = messaging_handler_send(state, ev, msg_ctx, > MSG_SMB_NOTIFY_TRIGGER, > notifyd_trigger, state); > if (tevent_req_nomem(subreq, req)) { >- return tevent_req_post(req, ev); >+ goto deregister_rec_change; > } > tevent_req_set_callback(subreq, notifyd_handler_done, req); > >@@ -237,7 +237,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > MSG_SMB_NOTIFY_GET_DB, > notifyd_get_db, state); > if (tevent_req_nomem(subreq, req)) { >- return tevent_req_post(req, ev); >+ goto deregister_rec_change; > } > tevent_req_set_callback(subreq, notifyd_handler_done, req); > >@@ -248,7 +248,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > DEBUG(10, ("%s: server_id_db_add failed: %s\n", > __func__, strerror(ret))); > tevent_req_error(req, ret); >- return tevent_req_post(req, ev); >+ goto deregister_rec_change; > } > > if (ctdbd_conn == NULL) { >@@ -264,13 +264,13 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > MSG_SMB_NOTIFY_DB, > notifyd_got_db, state); > if (tevent_req_nomem(subreq, req)) { >- return tevent_req_post(req, ev); >+ goto deregister_rec_change; > } > tevent_req_set_callback(subreq, notifyd_handler_done, req); > > state->log = talloc_zero(state, struct messaging_reclog); > if (tevent_req_nomem(state->log, req)) { >- return tevent_req_post(req, ev); >+ goto deregister_rec_change; > } > > subreq = notifyd_broadcast_reclog_send( >@@ -278,7 +278,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > messaging_server_id(msg_ctx), > state->log); > if (tevent_req_nomem(subreq, req)) { >- return tevent_req_post(req, ev); >+ goto deregister_rec_change; > } > tevent_req_set_callback(subreq, > notifyd_broadcast_reclog_finished, >@@ -286,7 +286,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > > subreq = notifyd_clean_peers_send(state, ev, state); > if (tevent_req_nomem(subreq, req)) { >- return tevent_req_post(req, ev); >+ goto deregister_rec_change; > } > tevent_req_set_callback(subreq, notifyd_clean_peers_finished, > req); >@@ -296,11 +296,15 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > notifyd_snoop_broadcast, state); > if (ret != 0) { > tevent_req_error(req, ret); >- return tevent_req_post(req, ev); >+ goto deregister_rec_change; > } > #endif > > return req; >+ >+deregister_rec_change: >+ messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_REC_CHANGE, state); >+ return tevent_req_post(req, ev); > } > > static void notifyd_handler_done(struct tevent_req *subreq) >@@ -568,40 +572,38 @@ static bool notifyd_parse_rec_change(uint8_t *buf, size_t bufsize, > return true; > } > >-static bool notifyd_rec_change(struct messaging_context *msg_ctx, >- struct messaging_rec **prec, >- void *private_data) >+static void notifyd_rec_change(struct messaging_context *msg_ctx, >+ void *private_data, uint32_t msg_type, >+ struct server_id src, DATA_BLOB *data) > { > struct notifyd_state *state = talloc_get_type_abort( > private_data, struct notifyd_state); > struct server_id_buf idbuf; >- struct messaging_rec *rec = *prec; > struct notify_rec_change_msg *msg; > size_t pathlen; > bool ok; > >- DEBUG(10, ("%s: Got %d bytes from %s\n", __func__, >- (unsigned)rec->buf.length, >- server_id_str_buf(rec->src, &idbuf))); >+ DBG_DEBUG("Got %zu bytes from %s\n", data->length, >+ server_id_str_buf(src, &idbuf)); > >- ok = notifyd_parse_rec_change(rec->buf.data, rec->buf.length, >+ ok = notifyd_parse_rec_change(data->data, data->length, > &msg, &pathlen); > if (!ok) { >- return true; >+ return; > } > > ok = notifyd_apply_rec_change( >- &rec->src, msg->path, pathlen, &msg->instance, >+ &src, msg->path, pathlen, &msg->instance, > state->entries, state->sys_notify_watch, state->sys_notify_ctx, > state->msg_ctx); > if (!ok) { > DEBUG(1, ("%s: notifyd_apply_rec_change failed, ignoring\n", > __func__)); >- return true; >+ return; > } > > if ((state->log == NULL) || (state->ctdbd_conn == NULL)) { >- return true; >+ return; > } > > #ifdef CLUSTER_SUPPORT >@@ -609,6 +611,7 @@ static bool notifyd_rec_change(struct messaging_context *msg_ctx, > > struct messaging_rec **tmp; > struct messaging_reclog *log; >+ struct iovec iov = { .iov_base = data->data, .iov_len = data->length }; > > log = state->log; > >@@ -616,11 +619,19 @@ static bool notifyd_rec_change(struct messaging_context *msg_ctx, > log->num_recs+1); > if (tmp == NULL) { > DEBUG(1, ("%s: talloc_realloc failed, ignoring\n", __func__)); >- return true; >+ return; > } > log->recs = tmp; > >- log->recs[log->num_recs] = talloc_move(log->recs, prec); >+ log->recs[log->num_recs] = messaging_rec_create( >+ log->recs, src, messaging_server_id(msg_ctx), >+ msg_type, &iov, 1, NULL, 0); >+ >+ if (log->recs[log->num_recs] == NULL) { >+ DBG_WARNING("messaging_rec_create failed, ignoring\n"); >+ return; >+ } >+ > log->num_recs += 1; > > if (log->num_recs >= 100) { >@@ -633,8 +644,6 @@ static bool notifyd_rec_change(struct messaging_context *msg_ctx, > > } > #endif >- >- return true; > } > > struct notifyd_trigger_state { >-- >2.13.5 > > >From 539c4515312c9aa69a0bd0c6717fbb96395cea8b Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Sat, 24 Jun 2017 08:45:17 +0200 >Subject: [PATCH 06/13] notifyd: Use messaging_register for > MSG_SMB_NOTIFY_TRIGGER > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit db15feb162326cb03fb06df24bcdafa5d5cb3087) >--- > source3/smbd/notifyd/notifyd.c | 61 ++++++++++++++++++++---------------------- > 1 file changed, 29 insertions(+), 32 deletions(-) > >diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c >index e078b404036..99539f8948f 100644 >--- a/source3/smbd/notifyd/notifyd.c >+++ b/source3/smbd/notifyd/notifyd.c >@@ -126,9 +126,9 @@ struct notifyd_peer { > static void notifyd_rec_change(struct messaging_context *msg_ctx, > void *private_data, uint32_t msg_type, > struct server_id src, DATA_BLOB *data); >-static bool notifyd_trigger(struct messaging_context *msg_ctx, >- struct messaging_rec **prec, >- void *private_data); >+static void notifyd_trigger(struct messaging_context *msg_ctx, >+ void *private_data, uint32_t msg_type, >+ struct server_id src, DATA_BLOB *data); > static bool notifyd_get_db(struct messaging_context *msg_ctx, > struct messaging_rec **prec, > void *private_data); >@@ -225,19 +225,17 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > return tevent_req_post(req, ev); > } > >- subreq = messaging_handler_send(state, ev, msg_ctx, >- MSG_SMB_NOTIFY_TRIGGER, >- notifyd_trigger, state); >- if (tevent_req_nomem(subreq, req)) { >+ status = messaging_register(msg_ctx, state, MSG_SMB_NOTIFY_TRIGGER, >+ notifyd_trigger); >+ if (tevent_req_nterror(req, status)) { > goto deregister_rec_change; > } >- tevent_req_set_callback(subreq, notifyd_handler_done, req); > > subreq = messaging_handler_send(state, ev, msg_ctx, > MSG_SMB_NOTIFY_GET_DB, > notifyd_get_db, state); > if (tevent_req_nomem(subreq, req)) { >- goto deregister_rec_change; >+ goto deregister_trigger; > } > tevent_req_set_callback(subreq, notifyd_handler_done, req); > >@@ -248,7 +246,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > DEBUG(10, ("%s: server_id_db_add failed: %s\n", > __func__, strerror(ret))); > tevent_req_error(req, ret); >- goto deregister_rec_change; >+ goto deregister_trigger; > } > > if (ctdbd_conn == NULL) { >@@ -264,13 +262,13 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > MSG_SMB_NOTIFY_DB, > notifyd_got_db, state); > if (tevent_req_nomem(subreq, req)) { >- goto deregister_rec_change; >+ goto deregister_trigger; > } > tevent_req_set_callback(subreq, notifyd_handler_done, req); > > state->log = talloc_zero(state, struct messaging_reclog); > if (tevent_req_nomem(state->log, req)) { >- goto deregister_rec_change; >+ goto deregister_trigger; > } > > subreq = notifyd_broadcast_reclog_send( >@@ -278,7 +276,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > messaging_server_id(msg_ctx), > state->log); > if (tevent_req_nomem(subreq, req)) { >- goto deregister_rec_change; >+ goto deregister_trigger; > } > tevent_req_set_callback(subreq, > notifyd_broadcast_reclog_finished, >@@ -286,7 +284,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > > subreq = notifyd_clean_peers_send(state, ev, state); > if (tevent_req_nomem(subreq, req)) { >- goto deregister_rec_change; >+ goto deregister_trigger; > } > tevent_req_set_callback(subreq, notifyd_clean_peers_finished, > req); >@@ -296,12 +294,14 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > notifyd_snoop_broadcast, state); > if (ret != 0) { > tevent_req_error(req, ret); >- goto deregister_rec_change; >+ goto deregister_trigger; > } > #endif > > return req; > >+deregister_trigger: >+ messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_TRIGGER, state); > deregister_rec_change: > messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_REC_CHANGE, state); > return tevent_req_post(req, ev); >@@ -656,34 +656,33 @@ struct notifyd_trigger_state { > static void notifyd_trigger_parser(TDB_DATA key, TDB_DATA data, > void *private_data); > >-static bool notifyd_trigger(struct messaging_context *msg_ctx, >- struct messaging_rec **prec, >- void *private_data) >+static void notifyd_trigger(struct messaging_context *msg_ctx, >+ void *private_data, uint32_t msg_type, >+ struct server_id src, DATA_BLOB *data) > { > struct notifyd_state *state = talloc_get_type_abort( > private_data, struct notifyd_state); > struct server_id my_id = messaging_server_id(msg_ctx); >- struct messaging_rec *rec = *prec; > struct notifyd_trigger_state tstate; > const char *path; > const char *p, *next_p; > >- if (rec->buf.length < offsetof(struct notify_trigger_msg, path) + 1) { >- DEBUG(1, ("message too short, ignoring: %u\n", >- (unsigned)rec->buf.length)); >- return true; >+ if (data->length < offsetof(struct notify_trigger_msg, path) + 1) { >+ DBG_WARNING("message too short, ignoring: %zu\n", >+ data->length); >+ return; > } >- if (rec->buf.data[rec->buf.length-1] != 0) { >+ if (data->data[data->length-1] != 0) { > DEBUG(1, ("%s: path not 0-terminated, ignoring\n", __func__)); >- return true; >+ return; > } > > tstate.msg_ctx = msg_ctx; > >- tstate.covered_by_sys_notify = (rec->src.vnn == my_id.vnn); >- tstate.covered_by_sys_notify &= !server_id_equal(&rec->src, &my_id); >+ tstate.covered_by_sys_notify = (src.vnn == my_id.vnn); >+ tstate.covered_by_sys_notify &= !server_id_equal(&src, &my_id); > >- tstate.msg = (struct notify_trigger_msg *)rec->buf.data; >+ tstate.msg = (struct notify_trigger_msg *)data->data; > path = tstate.msg->path; > > DEBUG(10, ("%s: Got trigger_msg action=%u, filter=%u, path=%s\n", >@@ -693,7 +692,7 @@ static bool notifyd_trigger(struct messaging_context *msg_ctx, > if (path[0] != '/') { > DEBUG(1, ("%s: path %s does not start with /, ignoring\n", > __func__, path)); >- return true; >+ return; > } > > for (p = strchr(path+1, '/'); p != NULL; p = next_p) { >@@ -717,7 +716,7 @@ static bool notifyd_trigger(struct messaging_context *msg_ctx, > continue; > } > >- if (rec->src.vnn != my_id.vnn) { >+ if (src.vnn != my_id.vnn) { > continue; > } > >@@ -732,8 +731,6 @@ static bool notifyd_trigger(struct messaging_context *msg_ctx, > notifyd_trigger_parser, &tstate); > } > } >- >- return true; > } > > static void notifyd_send_delete(struct messaging_context *msg_ctx, >-- >2.13.5 > > >From 7b6f70293dcd839071c0fa6e48642d6c5d2e3773 Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Sat, 24 Jun 2017 08:48:45 +0200 >Subject: [PATCH 07/13] notifyd: Use messaging_register for > MSG_SMB_NOTIFY_GET_DB > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit dc39bb45624f8d6859dadc3c9a9a85793a5a7d0d) >--- > source3/smbd/notifyd/notifyd.c | 47 ++++++++++++++++++++---------------------- > 1 file changed, 22 insertions(+), 25 deletions(-) > >diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c >index 99539f8948f..cd98ff56040 100644 >--- a/source3/smbd/notifyd/notifyd.c >+++ b/source3/smbd/notifyd/notifyd.c >@@ -129,9 +129,9 @@ static void notifyd_rec_change(struct messaging_context *msg_ctx, > static void notifyd_trigger(struct messaging_context *msg_ctx, > void *private_data, uint32_t msg_type, > struct server_id src, DATA_BLOB *data); >-static bool notifyd_get_db(struct messaging_context *msg_ctx, >- struct messaging_rec **prec, >- void *private_data); >+static void notifyd_get_db(struct messaging_context *msg_ctx, >+ void *private_data, uint32_t msg_type, >+ struct server_id src, DATA_BLOB *data); > > #ifdef CLUSTER_SUPPORT > static bool notifyd_got_db(struct messaging_context *msg_ctx, >@@ -231,13 +231,11 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > goto deregister_rec_change; > } > >- subreq = messaging_handler_send(state, ev, msg_ctx, >- MSG_SMB_NOTIFY_GET_DB, >- notifyd_get_db, state); >- if (tevent_req_nomem(subreq, req)) { >+ status = messaging_register(msg_ctx, state, MSG_SMB_NOTIFY_GET_DB, >+ notifyd_get_db); >+ if (tevent_req_nterror(req, status)) { > goto deregister_trigger; > } >- tevent_req_set_callback(subreq, notifyd_handler_done, req); > > names_db = messaging_names_db(msg_ctx); > >@@ -246,7 +244,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > DEBUG(10, ("%s: server_id_db_add failed: %s\n", > __func__, strerror(ret))); > tevent_req_error(req, ret); >- goto deregister_trigger; >+ goto deregister_get_db; > } > > if (ctdbd_conn == NULL) { >@@ -262,13 +260,13 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > MSG_SMB_NOTIFY_DB, > notifyd_got_db, state); > if (tevent_req_nomem(subreq, req)) { >- goto deregister_trigger; >+ goto deregister_get_db; > } > tevent_req_set_callback(subreq, notifyd_handler_done, req); > > state->log = talloc_zero(state, struct messaging_reclog); > if (tevent_req_nomem(state->log, req)) { >- goto deregister_trigger; >+ goto deregister_get_db; > } > > subreq = notifyd_broadcast_reclog_send( >@@ -276,7 +274,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > messaging_server_id(msg_ctx), > state->log); > if (tevent_req_nomem(subreq, req)) { >- goto deregister_trigger; >+ goto deregister_get_db; > } > tevent_req_set_callback(subreq, > notifyd_broadcast_reclog_finished, >@@ -284,7 +282,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > > subreq = notifyd_clean_peers_send(state, ev, state); > if (tevent_req_nomem(subreq, req)) { >- goto deregister_trigger; >+ goto deregister_get_db; > } > tevent_req_set_callback(subreq, notifyd_clean_peers_finished, > req); >@@ -294,12 +292,14 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > notifyd_snoop_broadcast, state); > if (ret != 0) { > tevent_req_error(req, ret); >- goto deregister_trigger; >+ goto deregister_get_db; > } > #endif > > return req; > >+deregister_get_db: >+ messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_GET_DB, state); > deregister_trigger: > messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_TRIGGER, state); > deregister_rec_change: >@@ -852,13 +852,12 @@ static void notifyd_send_delete(struct messaging_context *msg_ctx, > } > } > >-static bool notifyd_get_db(struct messaging_context *msg_ctx, >- struct messaging_rec **prec, >- void *private_data) >+static void notifyd_get_db(struct messaging_context *msg_ctx, >+ void *private_data, uint32_t msg_type, >+ struct server_id src, DATA_BLOB *data) > { > struct notifyd_state *state = talloc_get_type_abort( > private_data, struct notifyd_state); >- struct messaging_rec *rec = *prec; > struct server_id_buf id1, id2; > NTSTATUS status; > uint64_t rec_index = UINT64_MAX; >@@ -869,11 +868,11 @@ static bool notifyd_get_db(struct messaging_context *msg_ctx, > > dbsize = dbwrap_marshall(state->entries, NULL, 0); > >- buf = talloc_array(rec, uint8_t, dbsize); >+ buf = talloc_array(talloc_tos(), uint8_t, dbsize); > if (buf == NULL) { > DEBUG(1, ("%s: talloc_array(%ju) failed\n", > __func__, (uintmax_t)dbsize)); >- return true; >+ return; > } > > dbsize = dbwrap_marshall(state->entries, buf, dbsize); >@@ -883,7 +882,7 @@ static bool notifyd_get_db(struct messaging_context *msg_ctx, > (uintmax_t)talloc_get_size(buf), > (uintmax_t)dbsize)); > TALLOC_FREE(buf); >- return true; >+ return; > } > > if (state->log != NULL) { >@@ -899,17 +898,15 @@ static bool notifyd_get_db(struct messaging_context *msg_ctx, > DEBUG(10, ("%s: Sending %ju bytes to %s->%s\n", __func__, > (uintmax_t)iov_buflen(iov, ARRAY_SIZE(iov)), > server_id_str_buf(messaging_server_id(msg_ctx), &id1), >- server_id_str_buf(rec->src, &id2))); >+ server_id_str_buf(src, &id2))); > >- status = messaging_send_iov(msg_ctx, rec->src, MSG_SMB_NOTIFY_DB, >+ status = messaging_send_iov(msg_ctx, src, MSG_SMB_NOTIFY_DB, > iov, ARRAY_SIZE(iov), NULL, 0); > TALLOC_FREE(buf); > if (!NT_STATUS_IS_OK(status)) { > DEBUG(1, ("%s: messaging_send_iov failed: %s\n", > __func__, nt_errstr(status))); > } >- >- return true; > } > > #ifdef CLUSTER_SUPPORT >-- >2.13.5 > > >From 69b862094467824c2555a47adaf7d0aff8d74766 Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Sat, 24 Jun 2017 08:56:35 +0200 >Subject: [PATCH 08/13] notifyd: Use messaging_register for MSG_SMB_NOTIFY_DB > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 9430fab61cb746e590db307af37219f8f29b7fd8) >--- > source3/smbd/notifyd/notifyd.c | 71 +++++++++++++++++++++--------------------- > 1 file changed, 36 insertions(+), 35 deletions(-) > >diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c >index cd98ff56040..bc694850e28 100644 >--- a/source3/smbd/notifyd/notifyd.c >+++ b/source3/smbd/notifyd/notifyd.c >@@ -134,9 +134,9 @@ static void notifyd_get_db(struct messaging_context *msg_ctx, > struct server_id src, DATA_BLOB *data); > > #ifdef CLUSTER_SUPPORT >-static bool notifyd_got_db(struct messaging_context *msg_ctx, >- struct messaging_rec **prec, >- void *private_data); >+static void notifyd_got_db(struct messaging_context *msg_ctx, >+ void *private_data, uint32_t msg_type, >+ struct server_id src, DATA_BLOB *data); > static void notifyd_broadcast_reclog(struct ctdbd_connection *ctdbd_conn, > struct server_id src, > struct messaging_reclog *log); >@@ -193,7 +193,10 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > sys_notify_watch_fn sys_notify_watch, > struct sys_notify_context *sys_notify_ctx) > { >- struct tevent_req *req, *subreq; >+ struct tevent_req *req; >+#ifdef CLUSTER_SUPPORT >+ struct tevent_req *subreq; >+#endif > struct notifyd_state *state; > struct server_id_db *names_db; > NTSTATUS status; >@@ -256,17 +259,15 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > } > > #ifdef CLUSTER_SUPPORT >- subreq = messaging_handler_send(state, ev, msg_ctx, >- MSG_SMB_NOTIFY_DB, >- notifyd_got_db, state); >- if (tevent_req_nomem(subreq, req)) { >+ status = messaging_register(msg_ctx, state, MSG_SMB_NOTIFY_DB, >+ notifyd_got_db); >+ if (tevent_req_nterror(req, status)) { > goto deregister_get_db; > } >- tevent_req_set_callback(subreq, notifyd_handler_done, req); > > state->log = talloc_zero(state, struct messaging_reclog); > if (tevent_req_nomem(state->log, req)) { >- goto deregister_get_db; >+ goto deregister_db; > } > > subreq = notifyd_broadcast_reclog_send( >@@ -274,7 +275,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > messaging_server_id(msg_ctx), > state->log); > if (tevent_req_nomem(subreq, req)) { >- goto deregister_get_db; >+ goto deregister_db; > } > tevent_req_set_callback(subreq, > notifyd_broadcast_reclog_finished, >@@ -282,7 +283,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > > subreq = notifyd_clean_peers_send(state, ev, state); > if (tevent_req_nomem(subreq, req)) { >- goto deregister_get_db; >+ goto deregister_db; > } > tevent_req_set_callback(subreq, notifyd_clean_peers_finished, > req); >@@ -292,12 +293,16 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, > notifyd_snoop_broadcast, state); > if (ret != 0) { > tevent_req_error(req, ret); >- goto deregister_get_db; >+ goto deregister_db; > } > #endif > > return req; > >+#ifdef CLUSTER_SUPPORT >+deregister_db: >+ messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_DB, state); >+#endif > deregister_get_db: > messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_GET_DB, state); > deregister_trigger: >@@ -914,13 +919,12 @@ static void notifyd_get_db(struct messaging_context *msg_ctx, > static int notifyd_add_proxy_syswatches(struct db_record *rec, > void *private_data); > >-static bool notifyd_got_db(struct messaging_context *msg_ctx, >- struct messaging_rec **prec, >- void *private_data) >+static void notifyd_got_db(struct messaging_context *msg_ctx, >+ void *private_data, uint32_t msg_type, >+ struct server_id src, DATA_BLOB *data) > { > struct notifyd_state *state = talloc_get_type_abort( > private_data, struct notifyd_state); >- struct messaging_rec *rec = *prec; > struct notifyd_peer *p = NULL; > struct server_id_buf idbuf; > NTSTATUS status; >@@ -928,52 +932,49 @@ static bool notifyd_got_db(struct messaging_context *msg_ctx, > size_t i; > > for (i=0; i<state->num_peers; i++) { >- if (server_id_equal(&rec->src, &state->peers[i]->pid)) { >+ if (server_id_equal(&src, &state->peers[i]->pid)) { > p = state->peers[i]; > break; > } > } > > if (p == NULL) { >- DEBUG(10, ("%s: Did not find peer for db from %s\n", >- __func__, server_id_str_buf(rec->src, &idbuf))); >- return true; >+ DBG_DEBUG("Did not find peer for db from %s\n", >+ server_id_str_buf(src, &idbuf)); >+ return; > } > >- if (rec->buf.length < 8) { >- DEBUG(10, ("%s: Got short db length %u from %s\n", __func__, >- (unsigned)rec->buf.length, >- server_id_str_buf(rec->src, &idbuf))); >+ if (data->length < 8) { >+ DBG_DEBUG("Got short db length %zu from %s\n", data->length, >+ server_id_str_buf(src, &idbuf)); > TALLOC_FREE(p); >- return true; >+ return; > } > >- p->rec_index = BVAL(rec->buf.data, 0); >+ p->rec_index = BVAL(data->data, 0); > > p->db = db_open_rbt(p); > if (p->db == NULL) { > DEBUG(10, ("%s: db_open_rbt failed\n", __func__)); > TALLOC_FREE(p); >- return true; >+ return; > } > >- status = dbwrap_unmarshall(p->db, rec->buf.data + 8, >- rec->buf.length - 8); >+ status = dbwrap_unmarshall(p->db, data->data + 8, >+ data->length - 8); > if (!NT_STATUS_IS_OK(status)) { > DEBUG(10, ("%s: dbwrap_unmarshall returned %s for db %s\n", > __func__, nt_errstr(status), >- server_id_str_buf(rec->src, &idbuf))); >+ server_id_str_buf(src, &idbuf))); > TALLOC_FREE(p); >- return true; >+ return; > } > > dbwrap_traverse_read(p->db, notifyd_add_proxy_syswatches, state, > &count); > > DEBUG(10, ("%s: Database from %s contained %d records\n", __func__, >- server_id_str_buf(rec->src, &idbuf), count)); >- >- return true; >+ server_id_str_buf(src, &idbuf), count)); > } > > static void notifyd_broadcast_reclog(struct ctdbd_connection *ctdbd_conn, >-- >2.13.5 > > >From 84678b28d231a54bff2f9bd172fb85aeb11e1851 Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Sat, 24 Jun 2017 08:57:18 +0200 >Subject: [PATCH 09/13] notifyd: Remove notifyd_handler_done > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 197186a1fcc2c190fac9a16893234c337e6ec01c) >--- > source3/smbd/notifyd/notifyd.c | 13 ------------- > 1 file changed, 13 deletions(-) > >diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c >index bc694850e28..caf894e956e 100644 >--- a/source3/smbd/notifyd/notifyd.c >+++ b/source3/smbd/notifyd/notifyd.c >@@ -176,8 +176,6 @@ static int sys_notify_watch_dummy( > return 0; > } > >-static void notifyd_handler_done(struct tevent_req *subreq); >- > #ifdef CLUSTER_SUPPORT > static void notifyd_broadcast_reclog_finished(struct tevent_req *subreq); > static void notifyd_clean_peers_finished(struct tevent_req *subreq); >@@ -312,17 +310,6 @@ deregister_rec_change: > return tevent_req_post(req, ev); > } > >-static void notifyd_handler_done(struct tevent_req *subreq) >-{ >- struct tevent_req *req = tevent_req_callback_data( >- subreq, struct tevent_req); >- int ret; >- >- ret = messaging_handler_recv(subreq); >- TALLOC_FREE(subreq); >- tevent_req_error(req, ret); >-} >- > #ifdef CLUSTER_SUPPORT > > static void notifyd_broadcast_reclog_finished(struct tevent_req *subreq) >-- >2.13.5 > > >From 1dbaae5e812fca820d6d390df8f9d292bc454c85 Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Sat, 24 Jun 2017 09:01:46 +0200 >Subject: [PATCH 10/13] messaging: Remove messaging_handler_send > >This did not really take off, notifyd was the only user > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903 > >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 7 05:11:48 CEST 2017 on sn-devel-144 > >(cherry picked from commit 5eccc2fd0072409f166c63e6876266f926411423) >--- > source3/include/messages.h | 8 ----- > source3/lib/messages.c | 81 ---------------------------------------------- > 2 files changed, 89 deletions(-) > >diff --git a/source3/include/messages.h b/source3/include/messages.h >index 46dc6c05854..970dc381acf 100644 >--- a/source3/include/messages.h >+++ b/source3/include/messages.h >@@ -133,14 +133,6 @@ struct tevent_req *messaging_read_send(TALLOC_CTX *mem_ctx, > int messaging_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, > struct messaging_rec **presult); > >-struct tevent_req *messaging_handler_send( >- TALLOC_CTX *mem_ctx, struct tevent_context *ev, >- struct messaging_context *msg_ctx, uint32_t msg_type, >- bool (*handler)(struct messaging_context *msg_ctx, >- struct messaging_rec **rec, void *private_data), >- void *private_data); >-int messaging_handler_recv(struct tevent_req *req); >- > int messaging_cleanup(struct messaging_context *msg_ctx, pid_t pid); > > bool messaging_parent_dgm_cleanup_init(struct messaging_context *msg); >diff --git a/source3/lib/messages.c b/source3/lib/messages.c >index da13a1edf34..b94a6965eb8 100644 >--- a/source3/lib/messages.c >+++ b/source3/lib/messages.c >@@ -906,87 +906,6 @@ int messaging_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, > return 0; > } > >-struct messaging_handler_state { >- struct tevent_context *ev; >- struct messaging_context *msg_ctx; >- uint32_t msg_type; >- bool (*handler)(struct messaging_context *msg_ctx, >- struct messaging_rec **rec, void *private_data); >- void *private_data; >-}; >- >-static void messaging_handler_got_msg(struct tevent_req *subreq); >- >-struct tevent_req *messaging_handler_send( >- TALLOC_CTX *mem_ctx, struct tevent_context *ev, >- struct messaging_context *msg_ctx, uint32_t msg_type, >- bool (*handler)(struct messaging_context *msg_ctx, >- struct messaging_rec **rec, void *private_data), >- void *private_data) >-{ >- struct tevent_req *req, *subreq; >- struct messaging_handler_state *state; >- >- req = tevent_req_create(mem_ctx, &state, >- struct messaging_handler_state); >- if (req == NULL) { >- return NULL; >- } >- state->ev = ev; >- state->msg_ctx = msg_ctx; >- state->msg_type = msg_type; >- state->handler = handler; >- state->private_data = private_data; >- >- subreq = messaging_read_send(state, state->ev, state->msg_ctx, >- state->msg_type); >- if (tevent_req_nomem(subreq, req)) { >- return tevent_req_post(req, ev); >- } >- tevent_req_set_callback(subreq, messaging_handler_got_msg, req); >- return req; >-} >- >-static void messaging_handler_got_msg(struct tevent_req *subreq) >-{ >- struct tevent_req *req = tevent_req_callback_data( >- subreq, struct tevent_req); >- struct messaging_handler_state *state = tevent_req_data( >- req, struct messaging_handler_state); >- struct messaging_rec *rec; >- int ret; >- bool ok; >- >- ret = messaging_read_recv(subreq, state, &rec); >- TALLOC_FREE(subreq); >- if (tevent_req_error(req, ret)) { >- return; >- } >- >- subreq = messaging_read_send(state, state->ev, state->msg_ctx, >- state->msg_type); >- if (tevent_req_nomem(subreq, req)) { >- return; >- } >- tevent_req_set_callback(subreq, messaging_handler_got_msg, req); >- >- ok = state->handler(state->msg_ctx, &rec, state->private_data); >- TALLOC_FREE(rec); >- if (ok) { >- /* >- * Next round >- */ >- return; >- } >- TALLOC_FREE(subreq); >- tevent_req_done(req); >-} >- >-int messaging_handler_recv(struct tevent_req *req) >-{ >- return tevent_req_simple_recv_unix(req); >-} >- > static bool messaging_append_new_waiters(struct messaging_context *msg_ctx) > { > if (msg_ctx->num_new_waiters == 0) { >-- >2.13.5 > > >From 50220d0268b585a8c0d75a70cc764df226e2c508 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 13 Jul 2017 16:01:53 +0200 >Subject: [PATCH 11/13] selftest: enable kernel change notifications in the > fileserver environment > >This environment is currently not used for any test in the smb2 >testsuite, so this change doesn't affect any existing test. > >A subsequent commit will add a test for change notifications with kernel >change notify enabled. It verifies a bug (this one) that only crops up >in such a setup and causes rename events to get lost. > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit fb8e0343ebebac322d545b54c33b3c1e7bcda393) >--- > selftest/target/Samba3.pm | 2 ++ > 1 file changed, 2 insertions(+) > >diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm >index 79b1a53ad2d..2a4069a585c 100755 >--- a/selftest/target/Samba3.pm >+++ b/selftest/target/Samba3.pm >@@ -795,6 +795,8 @@ sub setup_fileserver($$) > push(@dirs,$usershare_sharedir); > > my $fileserver_options = " >+ kernel change notify = yes >+ > usershare path = $usershare_dir > usershare max shares = 10 > usershare allow guests = yes >-- >2.13.5 > > >From f7121012b271e4a541cdcadc5e707bb5db0993aa Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 13 Jul 2017 16:04:50 +0200 >Subject: [PATCH 12/13] selftest: run smb2.notify-inotify testsuite against > fileserver > >Next commit adds the suite and a test. > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 71a68d22a15d12c4038026dd065c54721ddc6723) >--- > source3/selftest/tests.py | 4 ++++ > 1 file changed, 4 insertions(+) > >diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py >index d459edeca63..c9af94b73cd 100755 >--- a/source3/selftest/tests.py >+++ b/source3/selftest/tests.py >@@ -56,6 +56,7 @@ finally: > > have_libarchive = ("HAVE_LIBARCHIVE" in config_hash) > have_linux_kernel_oplocks = ("HAVE_KERNEL_OPLOCKS_LINUX" in config_hash) >+have_inotify = ("HAVE_INOTIFY" in config_hash) > > plantestsuite("samba3.blackbox.success", "nt4_dc:local", [os.path.join(samba3srcdir, "script/tests/test_success.sh")]) > plantestsuite("samba3.blackbox.failure", "nt4_dc:local", [os.path.join(samba3srcdir, "script/tests/test_failure.sh")]) >@@ -496,6 +497,9 @@ for t in tests: > elif t == "smb2.kernel-oplocks": > if have_linux_kernel_oplocks: > plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER/kernel_oplocks -U$USERNAME%$PASSWORD') >+ elif t == "smb2.notify-inotify": >+ if have_inotify: >+ plansmbtorture4testsuite(t, "fileserver", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD') > elif t == "vfs.acl_xattr": > plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD') > elif t == "smb2.compound_find": >-- >2.13.5 > > >From 569ae9bee5c697290bca0531cd464dd4cf0037b3 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 13 Jul 2017 16:05:49 +0200 >Subject: [PATCH 13/13] s4/torture: add a test for rename change notification > with inotify enabled > >This is already fixed in master by >5eccc2fd0072409f166c63e6876266f926411423~10..5eccc2fd0072409f166c63e6876266f926411423. > >Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903 > >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): Sat Aug 26 05:05:08 CEST 2017 on sn-devel-144 > >(cherry picked from commit 51f40a0e1d10069f55a5884ff1579e8f15f10a1e) >--- > source4/torture/smb2/notify.c | 158 ++++++++++++++++++++++++++++++++++++++++++ > source4/torture/smb2/smb2.c | 1 + > 2 files changed, 159 insertions(+) > >diff --git a/source4/torture/smb2/notify.c b/source4/torture/smb2/notify.c >index 9fc856cd1a4..6ef24fe889e 100644 >--- a/source4/torture/smb2/notify.c >+++ b/source4/torture/smb2/notify.c >@@ -2354,6 +2354,151 @@ static bool torture_smb2_notify_rmdir4(struct torture_context *torture, > return torture_smb2_notify_rmdir(torture, tree1, tree2, true); > } > >+static void notify_timeout(struct tevent_context *ev, >+ struct tevent_timer *te, >+ struct timeval current_time, >+ void *private_data) >+{ >+ struct smb2_request *req = talloc_get_type_abort( >+ private_data, struct smb2_request); >+ >+ smb2_cancel(req); >+} >+ >+static bool torture_smb2_inotify_rename(struct torture_context *torture, >+ struct smb2_tree *tree1, >+ struct smb2_tree *tree2) >+{ >+ NTSTATUS status; >+ struct smb2_notify notify; >+ struct notify_changes change1 = {0}; >+ struct notify_changes change2 = {0}; >+ struct smb2_create create; >+ union smb_setfileinfo sinfo; >+ struct smb2_handle h1 = {{0}}; >+ struct smb2_handle h2 = {{0}}; >+ struct smb2_request *req; >+ struct tevent_timer *te = NULL; >+ bool ok = false; >+ >+ smb2_deltree(tree1, BASEDIR); >+ >+ torture_comment(torture, "Testing change notify of a rename with inotify\n"); >+ >+ status = torture_smb2_testdir(tree1, BASEDIR, &h1); >+ torture_assert_ntstatus_ok_goto(torture, status, ok, done, "torture_smb2_testdir failed"); >+ >+ ZERO_STRUCT(create); >+ create.in.desired_access = SEC_RIGHTS_FILE_READ | >+ SEC_RIGHTS_FILE_WRITE| >+ SEC_RIGHTS_FILE_ALL; >+ create.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; >+ create.in.file_attributes = FILE_ATTRIBUTE_NORMAL; >+ create.in.share_access = NTCREATEX_SHARE_ACCESS_READ | >+ NTCREATEX_SHARE_ACCESS_WRITE | >+ NTCREATEX_SHARE_ACCESS_DELETE; >+ create.in.create_disposition = NTCREATEX_DISP_OPEN_IF; >+ create.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS; >+ create.in.fname = BASEDIR "\\subdir-name"; >+ >+ status = smb2_create(tree2, torture, &create); >+ torture_assert_ntstatus_ok_goto(torture, status, ok, done, "smb2_create failed\n"); >+ h2 = create.out.file.handle; >+ >+ ZERO_STRUCT(notify); >+ notify.level = RAW_NOTIFY_SMB2; >+ notify.in.buffer_size = 4096; >+ notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; >+ notify.in.file.handle = h1; >+ notify.in.recursive = true; >+ req = smb2_notify_send(tree1, ¬ify); >+ torture_assert_not_null_goto(torture, req, ok, done, "smb2_notify_send failed\n"); >+ >+ while (!NT_STATUS_EQUAL(req->status, STATUS_PENDING)) { >+ if (tevent_loop_once(torture->ev) != 0) { >+ return false; >+ } >+ } >+ >+ ZERO_STRUCT(sinfo); >+ sinfo.rename_information.level = RAW_SFILEINFO_RENAME_INFORMATION; >+ sinfo.rename_information.in.file.handle = h2; >+ sinfo.rename_information.in.new_name = BASEDIR "\\subdir-name-r"; >+ >+ status = smb2_setinfo_file(tree2, &sinfo); >+ torture_assert_ntstatus_ok_goto(torture, status, ok, done, "smb2_setinfo_file failed\n"); >+ >+ smb2_util_close(tree2, h2); >+ >+ te = tevent_add_timer(torture->ev, >+ tree1, >+ tevent_timeval_current_ofs(1, 0), >+ notify_timeout, >+ req); >+ torture_assert_not_null_goto(torture, te, ok, done, "tevent_add_timer failed\n"); >+ >+ status = smb2_notify_recv(req, torture, ¬ify); >+ torture_assert_ntstatus_ok_goto(torture, status, ok, done, "smb2_notify_recv failed\n"); >+ >+ torture_assert_goto(torture, notify.out.num_changes == 1 || notify.out.num_changes == 2, >+ ok, done, "bad notify\n"); >+ >+ change1 = notify.out.changes[0]; >+ if (notify.out.num_changes == 2) { >+ change2 = notify.out.changes[1]; >+ } else { >+ /* >+ * We may only get one event at a time, so check for the >+ * matching second event for the oldname/newname or >+ * removed/added pair. >+ */ >+ ZERO_STRUCT(notify); >+ notify.level = RAW_NOTIFY_SMB2; >+ notify.in.buffer_size = 4096; >+ notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; >+ notify.in.file.handle = h1; >+ notify.in.recursive = true; >+ req = smb2_notify_send(tree1, ¬ify); >+ torture_assert_not_null_goto(torture, req, ok, done, "smb2_notify_send failed\n"); >+ >+ status = smb2_notify_recv(req, torture, ¬ify); >+ torture_assert_ntstatus_ok_goto(torture, status, ok, done, "smb2_notify_recv failed\n"); >+ >+ torture_assert_goto(torture, notify.out.num_changes == 1, ok, done, >+ "bad notify\n"); >+ >+ change2 = notify.out.changes[0]; >+ } >+ >+ if ((change1.action != NOTIFY_ACTION_OLD_NAME) && >+ (change1.action != NOTIFY_ACTION_REMOVED)) >+ { >+ torture_fail_goto(torture, done, "bad change notification\n"); >+ } >+ torture_assert_str_equal_goto(torture, change1.name.s, "subdir-name", >+ ok, done, "bad change notification\n"); >+ >+ if ((change2.action != NOTIFY_ACTION_NEW_NAME) && >+ (change2.action != NOTIFY_ACTION_ADDED)) >+ { >+ torture_fail_goto(torture, done, "bad change notification\n"); >+ } >+ torture_assert_str_equal_goto(torture, change2.name.s, "subdir-name-r", >+ ok, done, "bad change notification\n"); >+ >+ ok = true; >+done: >+ if (!smb2_util_handle_empty(h1)) { >+ smb2_util_close(tree2, h1); >+ } >+ if (!smb2_util_handle_empty(h2)) { >+ smb2_util_close(tree2, h2); >+ } >+ >+ smb2_deltree(tree1, BASEDIR); >+ return ok; >+} >+ > /* > basic testing of SMB2 change notify > */ >@@ -2393,3 +2538,16 @@ struct torture_suite *torture_smb2_notify_init(TALLOC_CTX *ctx) > return suite; > } > >+/* >+ basic testing of SMB2 change notify >+*/ >+struct torture_suite *torture_smb2_notify_inotify_init(TALLOC_CTX *ctx) >+{ >+ struct torture_suite *suite = torture_suite_create(ctx, "notify-inotify"); >+ >+ suite->description = talloc_strdup(suite, "SMB2-NOTIFY tests that use inotify"); >+ >+ torture_suite_add_2smb2_test(suite, "inotify-rename", torture_smb2_inotify_rename); >+ >+ return suite; >+} >diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c >index e766005536c..ae942428dd4 100644 >--- a/source4/torture/smb2/smb2.c >+++ b/source4/torture/smb2/smb2.c >@@ -155,6 +155,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx) > torture_suite_add_suite(suite, torture_smb2_create_init(suite)); > torture_suite_add_suite(suite, torture_smb2_acls_init(suite)); > torture_suite_add_suite(suite, torture_smb2_notify_init(suite)); >+ torture_suite_add_suite(suite, torture_smb2_notify_inotify_init(suite)); > torture_suite_add_suite(suite, > torture_smb2_notify_disabled_init(suite)); > torture_suite_add_suite(suite, torture_smb2_durable_open_init(suite)); >-- >2.13.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
slow
:
review?
(
jra
)
vl
:
review+
Actions:
View
Attachments on
bug 12903
:
13635
| 13636