[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Mon Jan 31 14:56:02 MST 2011


The branch, master has been updated
       via  e18b8c0 Add knownfail for s4 for the new oplock test.
       via  f453235 smbtorture4 test for bug #7928 - Samba problems with kernel oplocks option set to "no"
       via  7690d9d Fix bug #7928 - Samba problems with kernel oplocks option set to "no"
      from  c9027b6 midltests: add todo/midltests-pipe-sync-ndr32-downgrade-02.idl

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e18b8c0730ba800ab2864c65c6cd46aff4848585
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Jan 31 13:08:29 2011 -0800

    Add knownfail for s4 for the new oplock test.
    
    Autobuild-User: Jeremy Allison <jra at samba.org>
    Autobuild-Date: Mon Jan 31 22:55:00 CET 2011 on sn-devel-104

commit f453235ce057339a69398f5c862fdd3e46bd31c4
Author: Pavel Shilovsky <piastry at etersoft.ru>
Date:   Mon Jan 31 12:03:17 2011 -0800

    smbtorture4 test for bug #7928 - Samba problems with kernel oplocks option set to "no"

commit 7690d9d70c2425f6357732c0901d9dd18483e097
Author: Pavel Shilovsky <piastry at etersoft.ru>
Date:   Mon Jan 31 12:00:15 2011 -0800

    Fix bug #7928 - Samba problems with kernel oplocks option set to "no"
    
    We should not grant levelII oplocks on a file with existing
    byte range locks.

-----------------------------------------------------------------------

Summary of changes:
 source3/smbd/open.c          |    5 ++-
 source3/smbd/oplock.c        |   35 ++++++++++++---
 source4/selftest/knownfail   |    1 +
 source4/torture/raw/oplock.c |   95 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 128 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 0de7045..5a725c6 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -2182,7 +2182,10 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
 	 */
 
 	if (!set_file_oplock(fsp, fsp->oplock_type)) {
-		/* Could not get the kernel oplock */
+		/*
+		 * Could not get the kernel oplock or there are byte-range
+		 * locks on the file.
+		 */
 		fsp->oplock_type = NO_OPLOCK;
 	}
 
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index e92fbd4..31cedc4 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -52,19 +52,40 @@ void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp)
 			   msg, MSG_SMB_KERNEL_BREAK_SIZE);
 }
 
+static bool file_has_brlocks(files_struct *fsp)
+{
+	struct byte_range_lock *br_lck;
+
+	br_lck = brl_get_locks_readonly(fsp);
+	if (!br_lck)
+		return false;
+
+	return br_lck->num_locks > 0 ? true : false;
+}
+
 /****************************************************************************
- Attempt to set an oplock on a file. Always succeeds if kernel oplocks are
- disabled (just sets flags). Returns True if oplock set.
+ Attempt to set an oplock on a file. Succeeds if kernel oplocks are
+ disabled (just sets flags) and no byte-range locks in the file. Returns True
+ if oplock set.
 ****************************************************************************/
 
 bool set_file_oplock(files_struct *fsp, int oplock_type)
 {
-	if ((fsp->oplock_type == LEVEL_II_OPLOCK)
-	    && koplocks && !(koplocks->flags & KOPLOCKS_LEVEL2_SUPPORTED)) {
-		DEBUG(10, ("Refusing level2 oplock, kernel oplocks don't "
-			   "support them\n"));
-		return false;
+	if (fsp->oplock_type == LEVEL_II_OPLOCK) {
+		if (lp_locking(fsp->conn->params) && file_has_brlocks(fsp)) {
+			DEBUG(10, ("Refusing level2 oplock because of "
+				   "byte-range locks on the file\n"));
+			return false;
+		}
+
+		if (koplocks &&
+		    !(koplocks->flags & KOPLOCKS_LEVEL2_SUPPORTED)) {
+			DEBUG(10, ("Refusing level2 oplock, kernel oplocks "
+				   "don't support them\n"));
+			return false;
+		}
 	}
+
 	if ((fsp->oplock_type != NO_OPLOCK) &&
 	    (fsp->oplock_type != FAKE_LEVEL_II_OPLOCK) &&
 	    koplocks &&
diff --git a/source4/selftest/knownfail b/source4/selftest/knownfail
index 29ee5b7..aff03a5 100644
--- a/source4/selftest/knownfail
+++ b/source4/selftest/knownfail
@@ -62,6 +62,7 @@ samba4.raw.lock.*.async # bug 6960
 samba4.smb2.lock.*.multiple-unlock # bug 6959
 samba4.raw.sfileinfo.*.end-of-file # bug 6962
 samba4.raw.oplock.*.batch22 # bug 6963
+samba4.raw.oplock.*.brl4 # bug 7928
 samba4.raw.lock.*.zerobyteread # bug 6974
 samba4.smb2.lock.*.zerobyteread # bug 6974
 samba4.raw.streams.*.delete
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c
index 962235c..b120dad 100644
--- a/source4/torture/raw/oplock.c
+++ b/source4/torture/raw/oplock.c
@@ -3856,6 +3856,100 @@ done:
 }
 
 /*
+ * Open a file with an exclusive oplock from the 1st client and acquire a
+ * brl. Then open the same file from the 2nd client that should give oplock
+ * break with level2 to the 1st and return no oplock to the 2nd.
+ */
+static bool test_raw_oplock_brl4(struct torture_context *tctx,
+				 struct smbcli_state *cli1,
+				 struct smbcli_state *cli2)
+{
+	const char *fname = BASEDIR "\\test_batch_brl.dat";
+	bool ret = true;
+	uint8_t buf[1000];
+	bool correct = true;
+	union smb_open io;
+	NTSTATUS status;
+	uint16_t fnum = 0;
+	uint16_t fnum2 = 0;
+
+	if (!torture_setup_dir(cli1, BASEDIR)) {
+		return false;
+	}
+
+	/* cleanup */
+	smbcli_unlink(cli1->tree, fname);
+
+	smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given,
+			      cli1->tree);
+
+	/*
+	  base ntcreatex parms
+	*/
+	io.generic.level = RAW_OPEN_NTCREATEX;
+	io.ntcreatex.in.root_fid.fnum = 0;
+	io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ |
+				      SEC_RIGHTS_FILE_WRITE;
+	io.ntcreatex.in.alloc_size = 0;
+	io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+	io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
+				       NTCREATEX_SHARE_ACCESS_WRITE;
+	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+	io.ntcreatex.in.create_options = 0;
+	io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+	io.ntcreatex.in.security_flags = 0;
+	io.ntcreatex.in.fname = fname;
+
+	torture_comment(tctx, "open with exclusive oplock\n");
+	io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+		NTCREATEX_FLAGS_REQUEST_OPLOCK;
+
+	status = smb_raw_open(cli1->tree, tctx, &io);
+
+	CHECK_STATUS(tctx, status, NT_STATUS_OK);
+	fnum = io.ntcreatex.out.file.fnum;
+	CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN);
+
+	/* create a file with bogus data */
+	memset(buf, 0, sizeof(buf));
+
+	if (smbcli_write(cli1->tree, fnum, 0, buf, 0, sizeof(buf)) !=
+			 sizeof(buf))
+	{
+		torture_comment(tctx, "Failed to create file\n");
+		correct = false;
+		goto done;
+	}
+
+	status = smbcli_lock(cli1->tree, fnum, 0, 1, 0, WRITE_LOCK);
+	CHECK_STATUS(tctx, status, NT_STATUS_OK);
+
+	torture_comment(tctx, "a 2nd open should give a break to the 1st\n");
+	ZERO_STRUCT(break_info);
+
+	status = smb_raw_open(cli2->tree, tctx, &io);
+
+	CHECK_STATUS(tctx, status, NT_STATUS_OK);
+	CHECK_VAL(break_info.count, 1);
+	CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
+	CHECK_VAL(break_info.failures, 0);
+	CHECK_VAL(break_info.fnum, fnum);
+
+	torture_comment(tctx, "and return no oplock to the 2nd\n");
+	fnum2 = io.ntcreatex.out.file.fnum;
+	CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN);
+
+	smbcli_close(cli1->tree, fnum);
+	smbcli_close(cli2->tree, fnum2);
+
+done:
+	smb_raw_exit(cli1->session);
+	smb_raw_exit(cli2->session);
+	smbcli_deltree(cli1->tree, BASEDIR);
+	return ret;
+}
+
+/*
    basic testing of oplocks
 */
 struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx)
@@ -3900,6 +3994,7 @@ struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx)
 	torture_suite_add_2smb_test(suite, "brl1", test_raw_oplock_brl1);
 	torture_suite_add_1smb_test(suite, "brl2", test_raw_oplock_brl2);
 	torture_suite_add_1smb_test(suite, "brl3", test_raw_oplock_brl3);
+	torture_suite_add_2smb_test(suite, "brl4", test_raw_oplock_brl4);
 
 	return suite;
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list