[PATCHES] Fix AIO with SMB2 and locks

Christof Schmitt cs at samba.org
Thu Dec 5 16:44:42 MST 2013


Running the SMB2 lock tests against an AIO enabled share results in:

[1/4 in 0s] samba3.smb2.lock aio(s3dc)
UNEXPECTED(failure): samba3.smb2.lock aio.rw-exclusive(s3dc)
REASON: _StringException: _StringException: ../source4/torture/smb2/lock.c:416: status was NT_STATUS_FILE_LOCK_CONFLICT, expected NT_STATUS_OK: (../source4/torture/smb2/lock.c:416)

The first patch fixes this problem and the second patch fixes an issue with the
SMB2 AIO read error path that came up while debugging this problem. The last
three patches add an AIO share to the testsuite and also run the smb2.lock
tests against that share.

Christof
-------------- next part --------------
>From 18a97d3b6cad9919b6fb6374ed3998e23f50e9d8 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Thu, 5 Dec 2013 15:57:54 -0700
Subject: [PATCH 1/5] s3-aio: Use correct locking context for SMB2

The synchronous SMB2 reads and writes use open_persistent_id. The AIO
codepathes have to use the same, otherwise a write will conflict with a
lock on the same open file.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/smbd/aio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index 24a822e..eec29f6 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -720,7 +720,7 @@ NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	init_strict_lock_struct(fsp, (uint64_t)smbreq->smbpid,
+	init_strict_lock_struct(fsp, fsp->op->global->open_persistent_id,
 		(uint64_t)startpos, (uint64_t)smb_maxcnt, READ_LOCK,
 		&aio_ex->lock);
 
@@ -872,7 +872,7 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
 
 	aio_ex->write_through = write_through;
 
-	init_strict_lock_struct(fsp, (uint64_t)smbreq->smbpid,
+	init_strict_lock_struct(fsp, fsp->op->global->open_persistent_id,
 		in_offset, (uint64_t)in_data.length, WRITE_LOCK,
 		&aio_ex->lock);
 
-- 
1.7.1


>From c1d49abd2c03b70edbed4d28adbdceff7634b02e Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Thu, 5 Dec 2013 16:20:26 -0700
Subject: [PATCH 2/5] s3: Return correct error code from SMB2 AIO read failure

This is similar to commit 27e20d5d60ea8aa526bcb7c2dfc18dd2de0bb97b which
fixed the same case for SMB2 writes: When sending the AIO read fails,
return the real error instead of mapping it to NT_STATUS_FILE_CLOSED.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/smbd/smb2_read.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c
index d6d3d90..6478326 100644
--- a/source3/smbd/smb2_read.c
+++ b/source3/smbd/smb2_read.c
@@ -464,7 +464,7 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
 
 	if (!NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
 		/* Real error in setting up aio. Fail. */
-		tevent_req_nterror(req, NT_STATUS_FILE_CLOSED);
+		tevent_req_nterror(req, status);
 		return tevent_req_post(req, ev);
 	}
 
-- 
1.7.1


>From 9154f59bdee705481632490097cb575c8b1cae81 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Thu, 5 Dec 2013 15:20:06 -0700
Subject: [PATCH 3/5] selftest: Introduce share for testing AIO

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 selftest/target/Samba3.pm |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index ebfabf6..e4a2417 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -1131,6 +1131,10 @@ sub provision($$$$$$)
 	directory mask = 0777
 	force directory mode = 0
 	vfs objects = xattr_tdb
+[aio]
+	copy = tmp
+	aio read size = 1
+	aio write size = 1
 
 [print\$]
 	copy = tmp
-- 
1.7.1


>From 2ad104deb1420fe4b5386d51d7c5c7ba9a9cf3f2 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Thu, 5 Dec 2013 15:22:13 -0700
Subject: [PATCH 4/5] selftest: Run smb2.lock tests also against AIO share

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 source3/selftest/tests.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index df88f9d..b642585 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -355,6 +355,10 @@ for t in tests:
         plansmbtorture4testsuite(t, "s3dc", '//$SERVER_IP/fs_specific -U$USERNAME%$PASSWORD', 'fs_specific')
         plansmbtorture4testsuite(t, "s3dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD')
         plansmbtorture4testsuite(t, "plugin_s4_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD')
+    elif t == "smb2.lock":
+        plansmbtorture4testsuite(t, "s3dc", '//$SERVER_IP/aio -U$USERNAME%$PASSWORD', 'aio')
+        plansmbtorture4testsuite(t, "s3dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD')
+        plansmbtorture4testsuite(t, "plugin_s4_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD')
     else:
         plansmbtorture4testsuite(t, "s3dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD')
         plansmbtorture4testsuite(t, "plugin_s4_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD')
-- 
1.7.1


>From c3149059440298a60de796a0a421fdf86345167f Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Thu, 5 Dec 2013 15:53:47 -0700
Subject: [PATCH 5/5] selftest: Remove samba3.smb2.lock.*.rw-exclusive from flapping file

This test demonstrates a problem with byte range locks and AIO.

Signed-off-by: Christof Schmitt <cs at samba.org>
---
 selftest/flapping |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/selftest/flapping b/selftest/flapping
index d939650..e41c65d 100644
--- a/selftest/flapping
+++ b/selftest/flapping
@@ -16,7 +16,6 @@
 ^samba3.rap.printing # fails sometimes on sn-devel
 ^samba3.rpc.spoolss.printer.*addprinter.print_test # fails on some hosts due to timing issues ?
 ^samba3.rpc.lsa.privileges.lsa.Privileges\(s3dc\) # fails sometimes on sn-devel
-^samba3.smb2.lock.*.rw-exclusive # another intermittent failure
 ^samba4.blackbox.gentest # is flakey due to timing
 ^samba3.smb2.acls.INHERITANCE\(plugin_s4_dc\)  # Seems to flap - succeeds on sn-devel, fails on Fedora 16
 ^samba3.smb2.acls.DYNAMIC\(plugin_s4_dc\)  # Seems to flap - succeeds on sn-devel, fails on Fedora 16
-- 
1.7.1



More information about the samba-technical mailing list