[PATCH] fix smb2.replay.replay5 test to work with scale-out shares

Michael Adam obnox at samba.org
Thu Jan 21 20:40:11 UTC 2016


Before that it only worked against CA but non-SO shares.
Review appreciated.

Cheers - Michael
-------------- next part --------------
From cd2a44fc003c103ddd2d1155a3f766c33272d57d Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 15 Jan 2016 17:34:43 +0100
Subject: [PATCH] s4-torture: let smb2.replay.replay5 test deal with scale out
 shares.

Scale out shares don't hand out batch or exclusive oplocks.
Hence no durable handles either.
The important point here is that the behaviour tested
does largely not rely on the fact that we had a durable
handle but that we were using a durable handle create
context to specify a CreateGUID.

Pair-Programmed-With: Guenther Deschner <gd at samba.org>

Signed-off-by: Michael Adam <obnox at samba.org>
Signed-off-by: Guenther Deschner <gd at samba.org>

---
 source4/torture/smb2/replay.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/replay.c b/source4/torture/smb2/replay.c
index 61c947b..e203532 100644
--- a/source4/torture/smb2/replay.c
+++ b/source4/torture/smb2/replay.c
@@ -875,9 +875,12 @@ static bool test_replay5(struct torture_context *tctx, struct smb2_tree *tree)
 	bool ret = true;
 	uint32_t share_capabilities;
 	bool share_is_ca;
+	bool share_is_so;
 	const char *fname = BASEDIR "\\replay5.dat";
 	struct smb2_transport *transport = tree->session->transport;
 	struct smbcli_options options = tree->session->transport->options;
+	uint8_t expect_oplock = smb2_util_oplock_level("b");
+	NTSTATUS expect_status = NT_STATUS_DUPLICATE_OBJECTID;
 
 	if (smbXcli_conn_protocol(transport->conn) < PROTOCOL_SMB3_00) {
 		torture_skip(tctx, "SMB 3.X Dialect family required for "
@@ -885,11 +888,18 @@ static bool test_replay5(struct torture_context *tctx, struct smb2_tree *tree)
 	}
 
 	share_capabilities = smb2cli_tcon_capabilities(tree->smbXcli);
+
 	share_is_ca = share_capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY;
 	if (!share_is_ca) {
 		torture_skip(tctx, "Persistent File Handles not supported");
 	}
 
+	share_is_so = share_capabilities & SMB2_SHARE_CAP_SCALEOUT;
+	if (share_is_so) {
+		expect_oplock = smb2_util_oplock_level("s");
+		expect_status = NT_STATUS_FILE_NOT_AVAILABLE;
+	}
+
 	ZERO_STRUCT(break_info);
 	break_info.tctx = tctx;
 	transport->oplock.handler = torture_oplock_ack_handler;
@@ -917,7 +927,7 @@ static bool test_replay5(struct torture_context *tctx, struct smb2_tree *tree)
 	_h = io.out.file.handle;
 	h = &_h;
 	CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
-	CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b"));
+	CHECK_VAL(io.out.oplock_level, expect_oplock);
 	CHECK_VAL(io.out.durable_open, false);
 	CHECK_VAL(io.out.durable_open_v2, true);
 	CHECK_VAL(io.out.persistent_open, true);
@@ -935,7 +945,7 @@ static bool test_replay5(struct torture_context *tctx, struct smb2_tree *tree)
 
 	/* a re-open of a persistent handle causes an error */
 	status = smb2_create(tree, mem_ctx, &io);
-	CHECK_STATUS(status, NT_STATUS_DUPLICATE_OBJECTID);
+	CHECK_STATUS(status, expect_status);
 
 	/* SMB2_FLAGS_REPLAY_OPERATION must be set to open the Persistent Handle */
 	smb2cli_session_start_replay(tree->session->smbXcli);
@@ -945,7 +955,7 @@ static bool test_replay5(struct torture_context *tctx, struct smb2_tree *tree)
 	CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
 	CHECK_VAL(io.out.durable_open, false);
 	CHECK_VAL(io.out.persistent_open, true);
-	CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b"));
+	CHECK_VAL(io.out.oplock_level, expect_oplock);
 	_h = io.out.file.handle;
 	h = &_h;
 
-- 
2.5.0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20160121/ac7b0e75/signature.sig>


More information about the samba-technical mailing list