Revert "HACK: libcli/smb/smbXcli_base: splice write" master-io-uring
authorStefan Metzmacher <metze@samba.org>
Mon, 23 May 2022 14:07:37 +0000 (16:07 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 8 Feb 2023 09:28:43 +0000 (10:28 +0100)
This reverts commit a5f9a090eacd3ccc2921f9d586fce97c8af79557.

libcli/smb/smbXcli_base.c

index cab880bf8985e0a7b27d1e6e546472a18690bcde..097e3f1cc24da3f07cfec2405df7e99066984406 100644 (file)
@@ -39,9 +39,6 @@
 #include <gnutls/gnutls.h>
 #include <gnutls/crypto.h>
 
-static int static_fake_fd = -1;
-static int pipe_fds[2];
-
 struct smbXcli_conn;
 struct smbXcli_req;
 struct smbXcli_session;
@@ -222,7 +219,6 @@ struct smbXcli_tcon {
 };
 
 struct smbXcli_req_state {
-       bool do_splice;
        struct tevent_context *ev;
        struct smbXcli_conn *conn;
        struct smbXcli_session *session; /* maybe NULL */
@@ -3169,7 +3165,6 @@ NTSTATUS smb2cli_req_compound_submit(struct tevent_req **reqs,
        uint64_t encryption_session_id = 0;
        uint64_t nonce_high = UINT64_MAX;
        uint64_t nonce_low = UINT64_MAX;
-       uint16_t opcode;
 
        /*
         * 1 for the nbt length, optional TRANSFORM
@@ -3266,6 +3261,7 @@ NTSTATUS smb2cli_req_compound_submit(struct tevent_req **reqs,
                int hdr_iov;
                size_t reqlen;
                bool ret;
+               uint16_t opcode;
                uint64_t avail;
                uint16_t charge;
                uint16_t credits;
@@ -3469,12 +3465,6 @@ skip_credits:
                state->conn->dispatch_incoming = smb2cli_conn_dispatch_incoming;
        }
 
-       opcode = SVAL(state->smb2.hdr, SMB2_HDR_OPCODE);
-       if (opcode == SMB2_OP_WRITE) {
-               num_iov--;
-               state->do_splice = true;
-       }
-
        subreq = writev_send(state, state->ev, state->conn->outgoing,
                             state->conn->sock_fd, false, iov, num_iov);
        if (subreq == NULL) {
@@ -3541,7 +3531,7 @@ static void smb2cli_req_writev_done(struct tevent_req *subreq)
        struct smbXcli_req_state *state =
                tevent_req_data(req,
                struct smbXcli_req_state);
-       ssize_t nwritten, tosend;
+       ssize_t nwritten;
        int err;
 
        state->write_req = NULL;
@@ -3554,56 +3544,6 @@ static void smb2cli_req_writev_done(struct tevent_req *subreq)
                smbXcli_conn_disconnect(state->conn, status);
                return;
        }
-
-       if (!state->do_splice) {
-               return;
-       }
-
-       set_blocking(state->conn->sock_fd, true);
-
-       tosend = state->smb2.dyn_len;
-
-       while (tosend > 0) {
-               ssize_t nread, towrite;
-               off_t off = 0;
-
-//             DBG_ERR("tosend [%zd]\n", tosend);
-               nread = splice(static_fake_fd,
-                              &off,
-                              pipe_fds[1],
-                              NULL,
-                              MIN(tosend, 8*1024*1024),
-                              SPLICE_F_MOVE);
-               if (nread == -1) {
-                       NTSTATUS status = map_nt_error_from_unix_common(err);
-                       DBG_ERR("splice failed %s\n", nt_errstr(status));
-                       smbXcli_conn_disconnect(state->conn, status);
-                       return;
-               }
-
-               towrite = nread;
-               while (towrite > 0) {
-//                     DBG_ERR("towrite [%zd]\n", towrite);
-                       nwritten = splice(pipe_fds[0],
-                                         NULL,
-                                         state->conn->sock_fd,
-                                         NULL,
-                                         towrite,
-                                         SPLICE_F_MOVE);
-                       if (nwritten == -1) {
-                               NTSTATUS status = map_nt_error_from_unix_common(err);
-                               DBG_ERR("splice failed %s\n", nt_errstr(status));
-                               smbXcli_conn_disconnect(state->conn, status);
-                               return;
-                       }
-                       towrite -= nwritten;
-               }
-               tosend -= nread;
-       }
-
-//     DBG_ERR("DONE\n");
-       set_blocking(state->conn->sock_fd, false);
-       state->do_splice = false;
 }
 
 static struct smbXcli_session* smbXcli_session_by_uid(struct smbXcli_conn *conn,
@@ -5656,24 +5596,6 @@ NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
        NTSTATUS status = NT_STATUS_NO_MEMORY;
        bool ok;
 
-       if (static_fake_fd == -1) {
-               int ret;
-
-//             static_fake_fd = open("/etc/hosts", O_RDONLY);
-               static_fake_fd = open("/srv/samba/test/1gfile", O_RDONLY);
-               if (static_fake_fd == -1) {
-                       status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
-                       goto fail;
-               }
-               ret = pipe(pipe_fds);
-               if (ret != 0) {
-                       status = map_nt_error_from_unix_common(errno);
-                       goto fail;
-               }
-               ret = fcntl(pipe_fds[1], F_SETPIPE_SZ, 8*1024*1024);
-               SMB_ASSERT(ret >= 8*1024*1024);
-       }
-
        if (smbXcli_conn_has_async_calls(conn)) {
                /*
                 * Can't use sync call while an async call is in flight