[SCM] Samba Shared Repository - branch v4-5-test updated

Karolin Seeger kseeger at samba.org
Fri Jun 2 12:08:02 UTC 2017


The branch, v4-5-test has been updated
       via  176bc89 s4/torture: test for bug 12798
       via  0e467e8 s3/smbd: fix exclusive lease optimisation
       via  9d6ac5b s3/locking: make find_share_mode_entry public
      from  be632f6 s3: VFS: Catia: Ensure path name is also converted.

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-5-test


- Log -----------------------------------------------------------------
commit 176bc89a97da467c0b98d3c15637b6a267f921b0
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 26 15:35:54 2017 +0200

    s4/torture: test for bug 12798
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12798
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit bd43939ec07a2fc6858d1265fc75a68a7cd96f58)
    
    Autobuild-User(v4-5-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-5-test): Fri Jun  2 14:07:53 CEST 2017 on sn-devel-144

commit 0e467e868b11b970e8d18c6f8e0e6640aaef5395
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 26 11:57:08 2017 +0200

    s3/smbd: fix exclusive lease optimisation
    
    We need to expect any amount of "stat" opens on the file without
    triggering an assert.
    
    This is the correct fix for bug #11844. I guess we haven't seens this
    very often before bug #12766 got fixed, because most clients were using
    LEASES instead of OPLOCKS.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12798
    
    See also:
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11844
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12766
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 19b938e1fa9822ac417a3b3a34519087470d7a18)

commit 9d6ac5b1c2580cce32721153a6531075df062dc4
Author: Ralph Boehme <slow at samba.org>
Date:   Fri May 26 11:35:52 2017 +0200

    s3/locking: make find_share_mode_entry public
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12798
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 9d7739e819d5699209b5eacad4a0e2a8b8da0a86)

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

Summary of changes:
 source3/locking/locking.c    |  2 +-
 source3/locking/proto.h      |  2 ++
 source3/smbd/oplock.c        | 30 +++++++++++++---
 source4/torture/smb2/lease.c | 82 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 111 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index e6d3918..3320e4a 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -858,7 +858,7 @@ bool set_share_mode(struct share_mode_lock *lck, struct files_struct *fsp,
 	return true;
 }
 
-static struct share_mode_entry *find_share_mode_entry(
+struct share_mode_entry *find_share_mode_entry(
 	struct share_mode_lock *lck, files_struct *fsp)
 {
 	struct share_mode_data *d = lck->data;
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index 461f89a..93077ef 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -169,6 +169,8 @@ bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx);
 bool set_share_mode(struct share_mode_lock *lck, struct files_struct *fsp,
 		    uid_t uid, uint64_t mid, uint16_t op_type,
 		    uint32_t lease_idx);
+struct share_mode_entry *find_share_mode_entry(struct share_mode_lock *lck,
+					       files_struct *fsp);
 void remove_stale_share_mode_entries(struct share_mode_data *d);
 bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
 bool mark_share_mode_disconnected(struct share_mode_lock *lck,
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index ff7c037..d30de6a 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -25,6 +25,7 @@
 #include "smbd/globals.h"
 #include "messages.h"
 #include "../librpc/gen_ndr/open_files.h"
+#include "../librpc/gen_ndr/ndr_open_files.h"
 
 /*
  * helper function used by the kernel oplock backends to post the break message
@@ -166,17 +167,38 @@ bool update_num_read_oplocks(files_struct *fsp, struct share_mode_lock *lck)
 	uint32_t i;
 
 	if (fsp_lease_type_is_exclusive(fsp)) {
+		const struct share_mode_entry *e = NULL;
+		uint32_t e_lease_type = 0;
+
 		/*
 		 * If we're fully exclusive, we don't need a brlock entry
 		 */
 		remove_stale_share_mode_entries(d);
 
-		for (i=0; i<d->num_share_modes; i++) {
-			struct share_mode_entry *e = &d->share_modes[i];
-			uint32_t e_lease_type = get_lease_type(d, e);
+		e = find_share_mode_entry(lck, fsp);
+		if (e != NULL) {
+			e_lease_type = get_lease_type(d, e);
+		}
+
+		if (!lease_type_is_exclusive(e_lease_type)) {
+			char *timestr = NULL;
 
-			SMB_ASSERT(lease_type_is_exclusive(e_lease_type));
+			timestr = timeval_string(talloc_tos(),
+						 &fsp->open_time,
+						 true);
+
+			NDR_PRINT_DEBUG(share_mode_data, d);
+			DBG_ERR("file [%s] file_id [%s] gen_id [%lu] "
+				"open_time[%s] lease_type [0x%x] "
+				"oplock_type [0x%x]\n",
+				fsp_str_dbg(fsp),
+				file_id_string_tos(&fsp->file_id),
+				fsp->fh->gen_id, timestr,
+				e_lease_type, fsp->oplock_type);
+
+			smb_panic("Found non-exclusive lease");
 		}
+
 		return true;
 	}
 
diff --git a/source4/torture/smb2/lease.c b/source4/torture/smb2/lease.c
index 6a2e88b..8f8c19f 100644
--- a/source4/torture/smb2/lease.c
+++ b/source4/torture/smb2/lease.c
@@ -989,6 +989,87 @@ done:
 	return ret;
 }
 
+static bool test_lease_statopen2(struct torture_context *tctx,
+				 struct smb2_tree *tree)
+{
+	TALLOC_CTX *mem_ctx = talloc_new(tctx);
+	struct smb2_create io;
+	struct smb2_lease ls;
+	struct smb2_handle h1 = {{0}};
+	struct smb2_handle h2 = {{0}};
+	struct smb2_handle h3 = {{0}};
+	NTSTATUS status;
+	const char *fname = "lease_statopen2.dat";
+	bool ret = true;
+	uint32_t caps;
+
+	caps = smb2cli_conn_server_capabilities(
+		tree->session->transport->conn);
+	if (!(caps & SMB2_CAP_LEASING)) {
+		torture_skip(tctx, "leases are not supported");
+	}
+
+	smb2_util_unlink(tree, fname);
+	ZERO_STRUCT(break_info);
+	tree->session->transport->lease.handler	= torture_lease_handler;
+	tree->session->transport->lease.private_data = tree;
+
+	status = torture_smb2_testfile(tree, fname, &h1);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_create failed\n");
+	smb2_util_close(tree, h1);
+	ZERO_STRUCT(h1);
+
+	/* Open file with RWH lease. */
+	smb2_lease_create_share(&io, &ls, false, fname,
+				smb2_util_share_access("RWD"),
+				LEASE1,
+				smb2_util_lease_state("RWH"));
+	io.in.desired_access = SEC_FILE_WRITE_DATA;
+	status = smb2_create(tree, mem_ctx, &io);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_create failed\n");
+	h1 = io.out.file.handle;
+	CHECK_LEASE(&io, "RWH", true, LEASE1, 0);
+
+	/* Stat open */
+	ZERO_STRUCT(io);
+	io.in.desired_access = FILE_READ_ATTRIBUTES;
+	io.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
+	io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+	io.in.create_disposition = NTCREATEX_DISP_OPEN;
+	io.in.fname = fname;
+	status = smb2_create(tree, mem_ctx, &io);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_create failed\n");
+	h2 = io.out.file.handle;
+
+	/* Open file with RWH lease. */
+	smb2_lease_create_share(&io, &ls, false, fname,
+				smb2_util_share_access("RWD"),
+				LEASE1,
+				smb2_util_lease_state("RWH"));
+	io.in.desired_access = SEC_FILE_WRITE_DATA;
+	status = smb2_create(tree, mem_ctx, &io);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_create failed\n");
+	h3 = io.out.file.handle;
+	CHECK_LEASE(&io, "RWH", true, LEASE1, 0);
+
+done:
+	if (!smb2_util_handle_empty(h3)) {
+		smb2_util_close(tree, h3);
+	}
+	if (!smb2_util_handle_empty(h2)) {
+		smb2_util_close(tree, h2);
+	}
+	if (!smb2_util_handle_empty(h1)) {
+		smb2_util_close(tree, h1);
+	}
+	smb2_util_unlink(tree, fname);
+	talloc_free(mem_ctx);
+	return ret;
+}
 
 static void torture_oplock_break_callback(struct smb2_request *req)
 {
@@ -3901,6 +3982,7 @@ struct torture_suite *torture_smb2_lease_init(void)
 	torture_suite_add_1smb2_test(suite, "nobreakself",
 				     test_lease_nobreakself);
 	torture_suite_add_1smb2_test(suite, "statopen", test_lease_statopen);
+	torture_suite_add_1smb2_test(suite, "statopen2", test_lease_statopen2);
 	torture_suite_add_1smb2_test(suite, "upgrade", test_lease_upgrade);
 	torture_suite_add_1smb2_test(suite, "upgrade2", test_lease_upgrade2);
 	torture_suite_add_1smb2_test(suite, "upgrade3", test_lease_upgrade3);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list