The Samba-Bugzilla – Attachment 14421 Details for
Bug 13195
g_lock conflict detection broken when processing stale entries.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for 4.7
13195-4.7.txt (text/plain), 8.22 KB, created by
Volker Lendecke
on 2018-08-14 12:53:10 UTC
(
hide
)
Description:
Patch for 4.7
Filename:
MIME Type:
Creator:
Volker Lendecke
Created:
2018-08-14 12:53:10 UTC
Size:
8.22 KB
patch
obsolete
>From 03410aa871570e45ff49f36cd1eaedcf0d470c38 Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Wed, 20 Dec 2017 09:44:40 +0100 >Subject: [PATCH 1/3] torture3: add LOCAL-G-LOCK6 test > >This is a regression test for bug #13195. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13195 > >Signed-off-by: Stefan Metzmacher <metze@samba.org> >Reviewed-by: Volker Lendecke <vl@samba.org> >--- > source3/selftest/tests.py | 1 + > source3/torture/proto.h | 1 + > source3/torture/test_g_lock.c | 152 ++++++++++++++++++++++++++++++++++++++++++ > source3/torture/torture.c | 1 + > 4 files changed, 155 insertions(+) > >diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py >index 696c44b8ba4..9362627f47d 100755 >--- a/source3/selftest/tests.py >+++ b/source3/selftest/tests.py >@@ -161,6 +161,7 @@ local_tests = [ > "LOCAL-G-LOCK3", > "LOCAL-G-LOCK4", > "LOCAL-G-LOCK5", >+ "LOCAL-G-LOCK6", > "LOCAL-hex_encode_buf", > "LOCAL-remove_duplicate_addrs2"] > >diff --git a/source3/torture/proto.h b/source3/torture/proto.h >index a8400382e10..327fa3d6984 100644 >--- a/source3/torture/proto.h >+++ b/source3/torture/proto.h >@@ -132,5 +132,6 @@ bool run_g_lock2(int dummy); > bool run_g_lock3(int dummy); > bool run_g_lock4(int dummy); > bool run_g_lock5(int dummy); >+bool run_g_lock6(int dummy); > > #endif /* __TORTURE_H__ */ >diff --git a/source3/torture/test_g_lock.c b/source3/torture/test_g_lock.c >index ca373123e11..1134e0d0716 100644 >--- a/source3/torture/test_g_lock.c >+++ b/source3/torture/test_g_lock.c >@@ -642,3 +642,155 @@ bool run_g_lock5(int dummy) > > return true; > } >+ >+struct lock6_parser_state { >+ size_t num_locks; >+}; >+ >+static void lock6_parser(const struct g_lock_rec *locks, >+ size_t num_locks, >+ const uint8_t *data, >+ size_t datalen, >+ void *private_data) >+{ >+ struct lock6_parser_state *state = private_data; >+ state->num_locks = num_locks; >+} >+ >+/* >+ * Test cleanup with contention and stale locks >+ */ >+ >+bool run_g_lock6(int dummy) >+{ >+ struct tevent_context *ev = NULL; >+ struct messaging_context *msg = NULL; >+ struct g_lock_ctx *ctx = NULL; >+ const char *lockname = "lock6"; >+ pid_t child; >+ int exit_pipe[2], ready_pipe[2]; >+ NTSTATUS status; >+ size_t i, nprocs; >+ int ret; >+ bool ok; >+ ssize_t nread; >+ char c; >+ >+ if ((pipe(exit_pipe) != 0) || (pipe(ready_pipe) != 0)) { >+ perror("pipe failed"); >+ return false; >+ } >+ >+ ok = get_g_lock_ctx(talloc_tos(), &ev, &msg, &ctx); >+ if (!ok) { >+ fprintf(stderr, "get_g_lock_ctx failed"); >+ return false; >+ } >+ >+ nprocs = 2; >+ for (i=0; i<nprocs; i++) { >+ >+ child = fork(); >+ >+ if (child == -1) { >+ perror("fork failed"); >+ return false; >+ } >+ >+ if (child == 0) { >+ TALLOC_FREE(ctx); >+ >+ status = reinit_after_fork(msg, ev, false, ""); >+ if (!NT_STATUS_IS_OK(status)) { >+ fprintf(stderr, "reinit_after_fork failed: %s\n", >+ nt_errstr(status)); >+ exit(1); >+ } >+ >+ close(ready_pipe[0]); >+ close(exit_pipe[1]); >+ >+ ok = get_g_lock_ctx(talloc_tos(), &ev, &msg, &ctx); >+ if (!ok) { >+ fprintf(stderr, "get_g_lock_ctx failed"); >+ exit(1); >+ } >+ status = g_lock_lock(ctx, lockname, G_LOCK_READ, >+ (struct timeval) { .tv_sec = 1 }); >+ if (!NT_STATUS_IS_OK(status)) { >+ fprintf(stderr, >+ "child g_lock_lock failed %s\n", >+ nt_errstr(status)); >+ exit(1); >+ } >+ if (i == 0) { >+ exit(0); >+ } >+ close(ready_pipe[1]); >+ nread = sys_read(exit_pipe[0], &c, sizeof(c)); >+ if (nread != 0) { >+ fprintf(stderr, "sys_read returned %zu (%s)\n", >+ nread, strerror(errno)); >+ exit(1); >+ } >+ exit(0); >+ } >+ } >+ >+ close(ready_pipe[1]); >+ >+ nread = sys_read(ready_pipe[0], &c, sizeof(c)); >+ if (nread != 0) { >+ fprintf(stderr, "sys_read returned %zd (%s)\n", >+ nread, strerror(errno)); >+ return false; >+ } >+ >+ { >+ int child_status; >+ ret = waitpid(-1, &child_status, 0); >+ if (ret == -1) { >+ perror("waitpid failed"); >+ return false; >+ } >+ } >+ >+ { >+ struct lock6_parser_state state; >+ >+ status = g_lock_dump(ctx, lockname, lock6_parser, &state); >+ if (!NT_STATUS_IS_OK(status)) { >+ fprintf(stderr, "g_lock_dump returned %s\n", >+ nt_errstr(status)); >+ return false; >+ } >+ >+ if (state.num_locks != nprocs) { >+ fprintf(stderr, "nlocks=%zu, expected %zu\n", >+ state.num_locks, nprocs); >+ return false; >+ } >+ >+ status = g_lock_lock(ctx, lockname, G_LOCK_WRITE, >+ (struct timeval) { .tv_sec = 1 }); >+ if (!NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { >+ fprintf(stderr, "g_lock_lock should have failed with %s - %s\n", >+ nt_errstr(NT_STATUS_IO_TIMEOUT), >+ nt_errstr(status)); >+ return false; >+ } >+ } >+ >+ close(exit_pipe[1]); >+ >+ { >+ int child_status; >+ ret = waitpid(-1, &child_status, 0); >+ if (ret == -1) { >+ perror("waitpid failed"); >+ return false; >+ } >+ } >+ >+ return true; >+} >diff --git a/source3/torture/torture.c b/source3/torture/torture.c >index f0eb059427f..7c3e8c4a5b0 100644 >--- a/source3/torture/torture.c >+++ b/source3/torture/torture.c >@@ -11848,6 +11848,7 @@ static struct { > { "LOCAL-G-LOCK3", run_g_lock3, 0 }, > { "LOCAL-G-LOCK4", run_g_lock4, 0 }, > { "LOCAL-G-LOCK5", run_g_lock5, 0 }, >+ { "LOCAL-G-LOCK6", run_g_lock6, 0 }, > { "LOCAL-CANONICALIZE-PATH", run_local_canonicalize_path, 0 }, > { "qpathinfo-bufsize", run_qpathinfo_bufsize, 0 }, > {NULL, NULL, 0}}; >-- >2.11.0 > > >From 6da584d55e519e77dd610d475d7a26c9b49013cd Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Tue, 14 Aug 2018 13:54:56 +0200 >Subject: [PATCH 2/3] torture3: Extend the g_lock6 test to also cover upgrades > >The fixes for #13195 were incomplete and did not cover upgrades >properly. It's all gone in master with the new code. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13195 > >Signed-off-by: Volker Lendecke <vl@samba.org> >--- > selftest/knownfail.d/local-g-lock6 | 1 + > source3/torture/test_g_lock.c | 16 ++++++++++++++++ > 2 files changed, 17 insertions(+) > create mode 100644 selftest/knownfail.d/local-g-lock6 > >diff --git a/selftest/knownfail.d/local-g-lock6 b/selftest/knownfail.d/local-g-lock6 >new file mode 100644 >index 00000000000..14fd5c869d6 >--- /dev/null >+++ b/selftest/knownfail.d/local-g-lock6 >@@ -0,0 +1 @@ >+^samba3.smbtorture_s3.LOCAL-G-LOCK6.smbtorture >diff --git a/source3/torture/test_g_lock.c b/source3/torture/test_g_lock.c >index 1134e0d0716..b3b0d793fbd 100644 >--- a/source3/torture/test_g_lock.c >+++ b/source3/torture/test_g_lock.c >@@ -779,6 +779,14 @@ bool run_g_lock6(int dummy) > nt_errstr(status)); > return false; > } >+ >+ status = g_lock_lock(ctx, lockname, G_LOCK_READ, >+ (struct timeval) { .tv_sec = 1 }); >+ if (!NT_STATUS_IS_OK(status)) { >+ fprintf(stderr, "g_lock_lock failed: %s\n", >+ nt_errstr(status)); >+ return false; >+ } > } > > close(exit_pipe[1]); >@@ -792,5 +800,13 @@ bool run_g_lock6(int dummy) > } > } > >+ status = g_lock_lock(ctx, lockname, G_LOCK_WRITE, >+ (struct timeval) { .tv_sec = 1 }); >+ if (!NT_STATUS_IS_OK(status)) { >+ fprintf(stderr, "g_lock_lock failed: %s\n", >+ nt_errstr(status)); >+ return false; >+ } >+ > return true; > } >-- >2.11.0 > > >From 77f953381525674b5d5640e7ab272afe828a7767 Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Tue, 14 Aug 2018 14:31:01 +0200 >Subject: [PATCH 3/3] g_lock: Fix lock upgrades > >Master has changed significantly, this is a minimum fix for 4.7 without >cleaning up the code > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13195 > >Signed-off-by: Volker Lendecke <vl@samba.org> >--- > selftest/knownfail.d/local-g-lock6 | 1 - > source3/lib/g_lock.c | 4 ++++ > 2 files changed, 4 insertions(+), 1 deletion(-) > delete mode 100644 selftest/knownfail.d/local-g-lock6 > >diff --git a/selftest/knownfail.d/local-g-lock6 b/selftest/knownfail.d/local-g-lock6 >deleted file mode 100644 >index 14fd5c869d6..00000000000 >--- a/selftest/knownfail.d/local-g-lock6 >+++ /dev/null >@@ -1 +0,0 @@ >-^samba3.smbtorture_s3.LOCAL-G-LOCK6.smbtorture >diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c >index 76b4af5d974..a53f6a16dd0 100644 >--- a/source3/lib/g_lock.c >+++ b/source3/lib/g_lock.c >@@ -329,6 +329,10 @@ static NTSTATUS g_lock_trylock(struct db_record *rec, struct server_id self, > * Delete stale conflicting entry > */ > locks[i] = locks[num_locks-1]; >+ if (my_lock == num_locks-1) { >+ /* We just moved */ >+ my_lock = i; >+ } > num_locks -= 1; > modified = true; > continue; >-- >2.11.0 >
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:
metze
:
review+
Actions:
View
Attachments on
bug 13195
:
13881
|
13882
|
13883
|
13884
| 14421