The branch, v4-1-test has been updated via e440444 s3-winbindd: Fix DEBUG statement in winbind_msg_offline(). via a15ca71 smbd: Fix a panic when a smb2 brlock times out via c89fb8b selftest: Remove samba3.smb2.lock.*.rw-exclusive from flapping file via 52db703 selftest: Run smb2.lock tests also against AIO share via e9503d4 selftest: Introduce share for testing AIO via 6f46103 s3: Return correct error code from SMB2 AIO read failure via 53bdc43 s3-aio: Use correct locking context for SMB2 via 723d74f s3:smb2_server: avoid calling set_current_user_info() for each request via 2eb171f s3:smb2_server: generate a header blob for the sendfile path via a399931 s3:smb2_server: allocate smbd_smb2_request on talloc_tos() via 79c54dc s3:smb2_server: use tevent_req_notify_callback() in smbd_smb2_request_pending_queue() via 1b3cf43 s3:smb2_server: for performance reasons we use tevent_fd and readv/writev directly via dc55266 s3:smb2_server: fix drain_socket error handling via aa79211 smbd: Always use UCF_PREP_CREATEFILE for filename_convert calls to resolve a path for open. via 564fe6c smbd: change flag name from UCF_CREATING_FILE to UCF_PREP_CREATEFILE via 9859090 smbd: Fix regression for the dropbox case. via 3641751 lib/util: use proper include for struct stat from 180bca8 VERSION: Bump version up to 4.1.4.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-1-test - Log ----------------------------------------------------------------- commit e4404440db3e694a4988725765aa772cc86f2a07 Author: Jan Brummer <jan.brum...@tabos.org> Date: Mon Dec 9 15:22:29 2013 +0100 s3-winbindd: Fix DEBUG statement in winbind_msg_offline(). Guenther BUG: https://bugzilla.samba.org/show_bug.cgi?id=10285 Reviewed-by: Günther Deschner <g...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> Autobuild-User(master): Günther Deschner <g...@samba.org> Autobuild-Date(master): Mon Dec 9 17:28:37 CET 2013 on sn-devel-104 Autobuild-User(v4-1-test): Karolin Seeger <ksee...@samba.org> Autobuild-Date(v4-1-test): Tue Dec 10 15:58:13 CET 2013 on sn-devel-104 commit a15ca71073312def76c3c15429bb9c29f33078f2 Author: Volker Lendecke <v...@samba.org> Date: Thu Dec 5 15:50:58 2013 +0100 smbd: Fix a panic when a smb2 brlock times out Found by Peter Somogyi. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Thu Dec 5 21:21:35 CET 2013 on sn-devel-104 Fix bug #10311 - SMB2 server can panic when a smb2 brlock times out. commit c89fb8b37373efa620165df0092d0cbcb7a1052b Author: Christof Schmitt <c...@samba.org> Date: Thu Dec 5 15:53:47 2013 -0700 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 <c...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Fri Dec 6 05:19:37 CET 2013 on sn-devel-104 (cherry picked from commit 8c3bf7b84950fbb0305bcccd49ecfc202e08901a) The last 5 patches address bug #10310 - Fix AIO with SMB2 and locks. commit 52db7033e374da1c411ca9c9464fc78366a684c7 Author: Christof Schmitt <c...@samba.org> Date: Thu Dec 5 15:22:13 2013 -0700 selftest: Run smb2.lock tests also against AIO share Signed-off-by: Christof Schmitt <c...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit d551d5256f9b1ca57b8018d816ea665c9b847ced) commit e9503d46cf76d96d41050ad3fa2412555d659b5c Author: Christof Schmitt <c...@samba.org> Date: Thu Dec 5 15:20:06 2013 -0700 selftest: Introduce share for testing AIO Signed-off-by: Christof Schmitt <c...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit 63727c15450e1db2be49ade758c369aa4599657a) commit 6f461035f8b21e1e143526581b3256663a579a32 Author: Christof Schmitt <c...@samba.org> Date: Thu Dec 5 16:20:26 2013 -0700 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 <c...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit eadb2a54d1733a482999eb770182156dad1e184d) commit 53bdc43bdf3220519d96cd56e8b4811c24a49515 Author: Christof Schmitt <c...@samba.org> Date: Thu Dec 5 15:57:54 2013 -0700 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 <c...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit dfef0701c398982226dde8a8e15ff97bba0fef53) commit 723d74ff63e0397735013326df93354533db5606 Author: Stefan Metzmacher <me...@samba.org> Date: Tue Nov 19 05:21:05 2013 +0100 s3:smb2_server: avoid calling set_current_user_info() for each request Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: David Disseldorp <dd...@samba.org> Autobuild-User(master): Stefan Metzmacher <me...@samba.org> Autobuild-Date(master): Wed Nov 27 16:31:44 CET 2013 on sn-devel-104 (cherry picked from commit 3cc0651d9feda00b6a04f84b76744b2acc3a0446) The last 6 patches address bug #10298 - smb2_server processing overhead. commit 2eb171ffa8191b590c36f1566b8845e8f5354d42 Author: Stefan Metzmacher <me...@samba.org> Date: Mon Oct 14 14:18:26 2013 +0200 s3:smb2_server: generate a header blob for the sendfile path We need to pass the NBT header, SMB2 header and SMB2 Read header as header blob to SMB_VFS_SENDFILE(). This allows the usage of MSG_SEND or other tricks to avoid multiple TCP packets on the wire. Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: David Disseldorp <dd...@samba.org> (cherry picked from commit 36efaac2597d2d36826c02f23be15e7323b09784) commit a399931c3949c06a978fc392060e9df8bea8be61 Author: Stefan Metzmacher <me...@samba.org> Date: Wed Oct 16 09:15:12 2013 +0200 s3:smb2_server: allocate smbd_smb2_request on talloc_tos() This matches the behavior for smb1 requests and avoids an additional malloc() per request. Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: David Disseldorp <dd...@samba.org> (cherry picked from commit 9d33a3f3e814e2924a423496ccc133c6c73fcd12) commit 79c54dc79842542b2c9f371d485e4642e639fb25 Author: Stefan Metzmacher <me...@samba.org> Date: Sat Oct 12 02:40:12 2013 +0200 s3:smb2_server: use tevent_req_notify_callback() in smbd_smb2_request_pending_queue() If the request is already done we can avoid one iteration of tevent_loop_once(), which means we avoids one talloc_stackframe_pool/talloc_free pair. Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: David Disseldorp <dd...@samba.org> (cherry picked from commit acfd4b068a5b99ac1d3fe716afff34cb7d2a0147) commit 1b3cf43e423afedf33f8db3b4cd8cf26cda6e019 Author: Stefan Metzmacher <me...@samba.org> Date: Mon Oct 14 10:33:57 2013 +0200 s3:smb2_server: for performance reasons we use tevent_fd and readv/writev directly Going via tevent_req_create/talloc_free at multiple layer costs too much cpu cycles per request. I tested downloading a 16GB (sparse) file with smbclient -b1 -mNT1, and -mSMB2_02. Using smb2 max read = 64512, which means smb1 and smb2 will use the same read size. I build with -O3 -g and compared the results with valgrind --tool=callgrind. With -mNT1 the server uses about 2.000.000.000 cpu cycles. This patch reduces the userspace cpu cycles for -mSMB2_02 from about ~ 8.000.000.000 down to ~ 4.000.000.000. Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: David Disseldorp <dd...@samba.org> (cherry picked from commit 4244a2686cddcdc754c284df884ae497afa4053a) commit dc552665b8e41594c4832fe39feda39204d9129c Author: Stefan Metzmacher <me...@samba.org> Date: Mon Oct 14 16:42:55 2013 +0200 s3:smb2_server: fix drain_socket error handling smbd_smb2_request_error_ex() should return NTSTATUS and the caller will terminate the connection. Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: David Disseldorp <dd...@samba.org> (cherry picked from commit 9393e28df59954414313bfae70ffb796d3e332fe) commit aa79211e1947801ba1ae24062784807d5d419a4d Author: Jeremy Allison <j...@samba.org> Date: Tue Dec 3 10:21:16 2013 -0800 smbd: Always use UCF_PREP_CREATEFILE for filename_convert calls to resolve a path for open. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10297 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Mon Dec 9 21:02:21 CET 2013 on sn-devel-104 (cherry picked from commit f98d10af2a05f0261611f4cabdfe274cd9fe91c0) commit 564fe6c8fef23efb8b47859b50f4a7123a59b9e9 Author: Jeremy Allison <j...@samba.org> Date: Tue Dec 3 10:19:09 2013 -0800 smbd: change flag name from UCF_CREATING_FILE to UCF_PREP_CREATEFILE In preparation to using it for all open calls. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10297 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> (cherry picked from commit 874318a97868e08837a1febb1be8e8a167b5ae0f) commit 985909073ee718a10c6328e278bb59698dc92104 Author: Volker Lendecke <v...@samba.org> Date: Tue Dec 3 13:20:17 2013 +0100 smbd: Fix regression for the dropbox case. We need to allow to save a file to a directory with perm -wx. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10297 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit 5b49fe24c906cbae12beff7a1b45de6809258cab) commit 364175140499686c5c49c554a54442e21a74e022 Author: Christian Ambach <a...@samba.org> Date: Mon Nov 18 20:02:41 2013 +0100 lib/util: use proper include for struct stat use <sys/stat.h> instead of forward declaring it This fixes the build on AIX Bug: https://bugzilla.samba.org/show_bug.cgi?id=10276 Signed-off-by: Christian Ambach <a...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> Autobuild-User(master): Christian Ambach <a...@samba.org> Autobuild-Date(master): Thu Nov 21 22:12:45 CET 2013 on sn-devel-104 (cherry picked from commit 4ea92841b72a7b701a7c0fadf63430a7d0a3fac8) ----------------------------------------------------------------------- Summary of changes: lib/util/samba_util.h | 4 +- selftest/flapping | 1 - selftest/target/Samba3.pm | 4 + source3/selftest/tests.py | 4 + source3/smbd/aio.c | 4 +- source3/smbd/filename.c | 10 +- source3/smbd/globals.h | 31 ++- source3/smbd/nttrans.c | 6 +- source3/smbd/process.c | 5 +- source3/smbd/reply.c | 12 +- source3/smbd/smb2_create.c | 3 +- source3/smbd/smb2_lock.c | 2 +- source3/smbd/smb2_read.c | 12 +- source3/smbd/smb2_server.c | 886 +++++++++++++++++++------------------- source3/smbd/smbd.h | 2 +- source3/winbindd/winbindd_dual.c | 2 +- 16 files changed, 508 insertions(+), 480 deletions(-) Changeset truncated at 500 lines: diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index 243ed3e..f52347e 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -27,6 +27,9 @@ /* for TALLOC_CTX */ #include <talloc.h> +/* for struct stat */ +#include <sys/stat.h> + /** * @file * @brief Helpful macros @@ -627,7 +630,6 @@ _PUBLIC_ bool directory_exist(const char *dname); /** Check file permissions. **/ -struct stat; _PUBLIC_ bool file_check_permissions(const char *fname, uid_t uid, mode_t file_perms, diff --git a/selftest/flapping b/selftest/flapping index afeae65..fd2e0c3 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 diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 26f5e92..9a6c86f 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -1105,6 +1105,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 diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index e5ae63e..31a1b67 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -349,6 +349,10 @@ for t in tests: plansmbtorture4testsuite(t, "s3dc", '//$SERVER_IP/nfs4acl_simple -U$USERNAME%$PASSWORD', description='nfs4acl_xattr-simple') plansmbtorture4testsuite(t, "s3dc", '//$SERVER_IP/nfs4acl_special -U$USERNAME%$PASSWORD', description='nfs4acl_xattr-special') plansmbtorture4testsuite(t, "plugin_s4_dc", '//$SERVER_IP/tmpcase -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') 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); diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 68321ee..eaec5b6 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -722,7 +722,10 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx, */ if (errno == EACCES) { - if (ucf_flags & UCF_CREATING_FILE) { + if ((ucf_flags & UCF_PREP_CREATEFILE) == 0) { + status = NT_STATUS_ACCESS_DENIED; + goto fail; + } else { /* * This is the dropbox * behaviour. A dropbox is a @@ -734,11 +737,8 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx, * nevertheless want to allow * users creating a file. */ - status = NT_STATUS_OBJECT_PATH_NOT_FOUND; - } else { - status = NT_STATUS_ACCESS_DENIED; + errno = 0; } - goto fail; } if ((errno != 0) && (errno != ENOENT)) { diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 9ea5e25..df0e524 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -367,6 +367,7 @@ struct smbXsrv_connection { * this session_table is used for SMB1 and SMB2, */ struct smbXsrv_session_table *session_table; + uint64_t last_session_id; /* * this tcon_table is only used for SMB1. */ @@ -467,12 +468,23 @@ NTSTATUS smbXsrv_open_global_traverse( NTSTATUS smbXsrv_open_cleanup(uint64_t persistent_id); +struct smbd_smb2_send_queue { + struct smbd_smb2_send_queue *prev, *next; + + DATA_BLOB *sendfile_header; + struct iovec *vector; + int count; + + TALLOC_CTX *mem_ctx; +}; struct smbd_smb2_request { struct smbd_smb2_request *prev, *next; struct smbd_server_connection *sconn; + struct smbd_smb2_send_queue queue_entry; + /* the session the request operates on, maybe NULL */ struct smbXsrv_session *session; uint64_t last_session_id; @@ -720,7 +732,6 @@ struct smbd_server_connection { * Set by us for CORE protocol. */ int max_send; - uint64_t last_session_tag; } sessions; struct smb_signing_state *signing_state; @@ -740,9 +751,21 @@ struct smbd_server_connection { } locks; } smb1; struct { - struct tevent_queue *recv_queue; - struct tevent_queue *send_queue; - struct tstream_context *stream; + struct smbd_smb2_request_read_state { + struct smbd_smb2_request *req; + struct { + uint8_t nbt[NBT_HDR_SIZE]; + bool done; + } hdr; + struct iovec vector; + bool doing_receivefile; + size_t min_recv_size; + size_t pktlen; + uint8_t *pktbuf; + } request_read_state; + struct smbd_smb2_send_queue *send_queue; + size_t send_queue_len; + struct tevent_fd *fde; bool negprot_2ff; struct { /* The event that makes us process our blocking lock queue */ diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 94be9f6..5a0ac39 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -539,8 +539,7 @@ void reply_ntcreate_and_X(struct smb_request *req) conn, req->flags2 & FLAGS2_DFS_PATHNAMES, fname, - (create_disposition == FILE_CREATE) - ? UCF_CREATING_FILE : 0, + UCF_PREP_CREATEFILE, NULL, &smb_fname); @@ -1077,8 +1076,7 @@ static void call_nt_transact_create(connection_struct *conn, conn, req->flags2 & FLAGS2_DFS_PATHNAMES, fname, - (create_disposition == FILE_CREATE) - ? UCF_CREATING_FILE : 0, + UCF_PREP_CREATEFILE, NULL, &smb_fname); diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 5ef0fd3..706d701 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -1435,10 +1435,10 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req) } } - if (session_tag != sconn->smb1.sessions.last_session_tag) { + if (session_tag != sconn->conn->last_session_id) { struct user_struct *vuser = NULL; - sconn->smb1.sessions.last_session_tag = session_tag; + sconn->conn->last_session_id = session_tag; if (session) { vuser = session->compat; } @@ -3595,7 +3595,6 @@ void smbd_process(struct tevent_context *ev_ctx, sconn->smb1.sessions.done_sesssetup = false; sconn->smb1.sessions.max_send = BUFFER_SIZE; - sconn->smb1.sessions.last_session_tag = UID_FIELD_INVALID; if (!init_dptrs(sconn)) { exit_server("init_dptrs() failed"); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 03c8414..6b926fb 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -1918,8 +1918,7 @@ void reply_open(struct smb_request *req) conn, req->flags2 & FLAGS2_DFS_PATHNAMES, fname, - (create_disposition == FILE_CREATE) - ? UCF_CREATING_FILE : 0, + UCF_PREP_CREATEFILE, NULL, &smb_fname); if (!NT_STATUS_IS_OK(status)) { @@ -2096,8 +2095,7 @@ void reply_open_and_X(struct smb_request *req) conn, req->flags2 & FLAGS2_DFS_PATHNAMES, fname, - (create_disposition == FILE_CREATE) - ? UCF_CREATING_FILE : 0, + UCF_PREP_CREATEFILE, NULL, &smb_fname); if (!NT_STATUS_IS_OK(status)) { @@ -2330,7 +2328,7 @@ void reply_mknew(struct smb_request *req) conn, req->flags2 & FLAGS2_DFS_PATHNAMES, fname, - UCF_CREATING_FILE, + UCF_PREP_CREATEFILE, NULL, &smb_fname); if (!NT_STATUS_IS_OK(status)) { @@ -2471,7 +2469,7 @@ void reply_ctemp(struct smb_request *req) status = filename_convert(ctx, conn, req->flags2 & FLAGS2_DFS_PATHNAMES, fname, - UCF_CREATING_FILE, + UCF_PREP_CREATEFILE, NULL, &smb_fname); if (!NT_STATUS_IS_OK(status)) { @@ -5830,7 +5828,7 @@ void reply_mkdir(struct smb_request *req) status = filename_convert(ctx, conn, req->flags2 & FLAGS2_DFS_PATHNAMES, directory, - UCF_CREATING_FILE, + UCF_PREP_CREATEFILE, NULL, &smb_dname); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c index 4f2edfc..8430bd2 100644 --- a/source3/smbd/smb2_create.c +++ b/source3/smbd/smb2_create.c @@ -846,8 +846,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx, smb1req->conn, smb1req->flags2 & FLAGS2_DFS_PATHNAMES, fname, - (in_create_disposition == FILE_CREATE) ? - UCF_CREATING_FILE : 0, + UCF_PREP_CREATEFILE, NULL, /* ppath_contains_wcards */ &smb_fname); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c index e2ea251..671cd6f 100644 --- a/source3/smbd/smb2_lock.c +++ b/source3/smbd/smb2_lock.c @@ -511,7 +511,7 @@ static bool recalc_smb2_brl_timeout(struct smbd_server_connection *sconn) NULL, next_timeout, brl_timeout_fn, - NULL); + sconn); if (!sconn->smb2.locks.brl_timeout) { return false; } diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c index 41adb03..6478326 100644 --- a/source3/smbd/smb2_read.c +++ b/source3/smbd/smb2_read.c @@ -166,6 +166,7 @@ struct smbd_smb2_read_state { uint32_t in_length; uint64_t in_offset; uint32_t in_minimum; + DATA_BLOB out_headers; DATA_BLOB out_data; uint32_t out_remaining; }; @@ -180,10 +181,10 @@ static int smb2_sendfile_send_data(struct smbd_smb2_read_state *state) ssize_t nread; nread = SMB_VFS_SENDFILE(fsp->conn->sconn->sock, - fsp, - NULL, - in_offset, - in_length); + fsp, + state->smb2req->queue_entry.sendfile_header, + in_offset, + in_length); DEBUG(10,("smb2_sendfile_send_data: SMB_VFS_SENDFILE returned %d on file %s\n", (int)nread, fsp_str_dbg(fsp) )); @@ -301,6 +302,7 @@ static NTSTATUS schedule_smb2_sendfile_read(struct smbd_smb2_request *smb2req, } *state_copy = *state; talloc_set_destructor(state_copy, smb2_sendfile_send_data); + state->smb2req->queue_entry.sendfile_header = &state_copy->out_headers; return NT_STATUS_OK; } @@ -462,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); } diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index b031c6d..e5f7de3 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -30,6 +30,13 @@ #include "../librpc/gen_ndr/krb5pac.h" #include "auth.h" +static void smbd_smb2_connection_handler(struct tevent_context *ev, + struct tevent_fd *fde, + uint16_t flags, + void *private_data); +static NTSTATUS smbd_smb2_io_handler(struct smbd_server_connection *sconn, + uint16_t fde_flags); + #define OUTVEC_ALLOC_SIZE (SMB2_HDR_BODY + 9) static const struct smbd_smb2_dispatch_table { @@ -196,20 +203,9 @@ bool smbd_is_smb2_header(const uint8_t *inbuf, size_t size) static NTSTATUS smbd_initialize_smb2(struct smbd_server_connection *sconn) { - NTSTATUS status; - int ret; - TALLOC_FREE(sconn->smb1.fde); - sconn->smb2.recv_queue = tevent_queue_create(sconn, "smb2 recv queue"); - if (sconn->smb2.recv_queue == NULL) { - return NT_STATUS_NO_MEMORY; - } - - sconn->smb2.send_queue = tevent_queue_create(sconn, "smb2 send queue"); - if (sconn->smb2.send_queue == NULL) { - return NT_STATUS_NO_MEMORY; - } + sconn->smb2.send_queue = NULL; sconn->smb2.seqnum_low = 0; sconn->smb2.seqnum_range = 1; @@ -221,11 +217,14 @@ static NTSTATUS smbd_initialize_smb2(struct smbd_server_connection *sconn) return NT_STATUS_NO_MEMORY; } - ret = tstream_bsd_existing_socket(sconn, sconn->sock, - &sconn->smb2.stream); - if (ret == -1) { - status = map_nt_error_from_unix(errno); - return status; + sconn->smb2.fde = tevent_add_fd(sconn->ev_ctx, + sconn, + sconn->sock, + TEVENT_FD_READ, + smbd_smb2_connection_handler, + sconn); + if (sconn->smb2.fde == NULL) { + return NT_STATUS_NO_MEMORY; } /* Ensure child is set to non-blocking mode */ @@ -270,7 +269,7 @@ static struct smbd_smb2_request *smbd_smb2_request_allocate(TALLOC_CTX *mem_ctx) /* Enable this to find subtle valgrind errors. */ mem_pool = talloc_init("smbd_smb2_request_allocate"); #else - mem_pool = talloc_pool(mem_ctx, 8192); + mem_pool = talloc_tos(); #endif if (mem_pool == NULL) { return NULL; @@ -282,7 +281,9 @@ static struct smbd_smb2_request *smbd_smb2_request_allocate(TALLOC_CTX *mem_ctx) return NULL; } talloc_reparent(mem_pool, mem_ctx, req); +#if 0 TALLOC_FREE(mem_pool); +#endif req->last_session_id = UINT64_MAX; req->last_tid = UINT32_MAX; @@ -1151,10 +1152,9 @@ static struct smbd_smb2_request *dup_smb2_req(const struct smbd_smb2_request *re return newreq; } -static void smbd_smb2_request_writev_done(struct tevent_req *subreq); - static NTSTATUS smb2_send_async_interim_response(const struct smbd_smb2_request *req) { + struct smbd_server_connection *sconn = req->sconn; struct smbXsrv_connection *conn = req->sconn->conn; int first_idx = 1; struct iovec *firsttf = NULL; @@ -1218,50 +1218,27 @@ static NTSTATUS smb2_send_async_interim_response(const struct smbd_smb2_request } } - nreq->subreq = tstream_writev_queue_send(nreq, - nreq->sconn->ev_ctx, - nreq->sconn->smb2.stream, - nreq->sconn->smb2.send_queue, - nreq->out.vector, - nreq->out.vector_count); + nreq->queue_entry.mem_ctx = nreq; + nreq->queue_entry.vector = nreq->out.vector; + nreq->queue_entry.count = nreq->out.vector_count; + DLIST_ADD_END(nreq->sconn->smb2.send_queue, &nreq->queue_entry, NULL); + nreq->sconn->smb2.send_queue_len++; - if (nreq->subreq == NULL) { - return NT_STATUS_NO_MEMORY; + status = smbd_smb2_io_handler(sconn, TEVENT_FD_WRITE); + if (!NT_STATUS_IS_OK(status)) { + return status; } - tevent_req_set_callback(nreq->subreq, - smbd_smb2_request_writev_done, - nreq); - return NT_STATUS_OK; } struct smbd_smb2_request_pending_state { struct smbd_server_connection *sconn; + struct smbd_smb2_send_queue queue_entry; uint8_t buf[NBT_HDR_SIZE + SMB2_TF_HDR_SIZE + SMB2_HDR_BODY + 0x08 + 1]; struct iovec vector[1 + SMBD_SMB2_NUM_IOV_PER_REQ]; }; -static void smbd_smb2_request_pending_writev_done(struct tevent_req *subreq) -{ - struct smbd_smb2_request_pending_state *state = - tevent_req_callback_data(subreq, - struct smbd_smb2_request_pending_state); - struct smbd_server_connection *sconn = state->sconn; - int ret; - int sys_errno; - - ret = tstream_writev_queue_recv(subreq, &sys_errno); - TALLOC_FREE(subreq); - if (ret == -1) { - NTSTATUS status = map_nt_error_from_unix(sys_errno); - smbd_server_connection_terminate(sconn, nt_errstr(status)); - return; - } - -- Samba Shared Repository