Make explicit draining the socket on RECVFILE. Add
authorJeremy Allison <jra@samba.org>
Wed, 31 Oct 2007 21:01:35 +0000 (14:01 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 31 Oct 2007 21:01:35 +0000 (14:01 -0700)
capability for large UNIX write if not signing and
recvfile set. Cope with large UNIX write length on
incoming processing. Stevef - we can now test 1-16Mb
writes from CIFFS.
Jeremy.
(This used to be commit 8cf78776b0a44bd026cef3d74eb11cfb415f8303)

source3/lib/recvfile.c
source3/smbd/server.c
source3/smbd/trans2.c
source3/smbd/vfs.c

index a009ce9dd690aa050c99556b007fc01ed23fa6e9..f9788fdefb607457d267a003d0460014a1040781 100644 (file)
@@ -126,20 +126,6 @@ static ssize_t default_sys_recvfile(int fromfd,
 
 #if defined(HAVE_SPLICE_SYSCALL)
 
-#ifdef JRA_SPLICE_TEST
-#include <linux/unistd.h>
-#include <sys/syscall.h>
-
-#define __NR_splice             313
-_syscall6( long, splice,
-               int, fromfd,
-               loff_t *, fromoffset,
-               int, tofd,
-               loff_t *, tooffset,
-               size_t, count,
-               unsigned int, flags);
-#endif
-
 /*
  * Try and use the Linux system call to do this.
  * Remember we only return -1 if the socket read
@@ -168,6 +154,13 @@ ssize_t sys_recvfile(int fromfd,
                                        0);
                if (ret == -1) {
                        if (errno != EINTR) {
+                               if (total_written == 0 &&
+                                               errno == EBADF || errno == EINVAL) {
+                                       return default_sys_recvfile(fromfd,
+                                                               tofd,
+                                                               offset,
+                                                               count);
+                               }
                                break;
                        }
                        continue;
index 25e2d2cb5e5706c78d6dedcc3f29a2d83a4e9f34..bac2d48ad6e4c5021bafae67351a352391f47a75 100644 (file)
@@ -148,7 +148,7 @@ ssize_t receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx,
 {
        /* Size of a WRITEX call (+4 byte len). */
        char writeX_header[4 + STANDARD_WRITE_AND_X_HEADER_SIZE];
-       ssize_t len = smb_len(lenbuf);
+       ssize_t len = smb_len_large(lenbuf); /* Could be a UNIX large writeX. */
        ssize_t toread;
        ssize_t ret;
 
index 7f38d5caa87ca6a02d14df56054a25029def6526..d75f6a29fd645ce8128569b252940d16c5c4fe35 100644 (file)
@@ -2719,6 +2719,10 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                 */
 
                case SMB_QUERY_CIFS_UNIX_INFO:
+               {
+                       bool large_write = lp_min_receive_file_size() &&
+                                               !srv_is_signing_active();
+
                        if (!lp_unix_extensions()) {
                                reply_nterror(req, NT_STATUS_INVALID_LEVEL);
                                return;
@@ -2733,8 +2737,11 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                                        CIFS_UNIX_FCNTL_LOCKS_CAP|
                                        CIFS_UNIX_EXTATTR_CAP|
                                        CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP|
-                                       CIFS_UNIX_LARGE_READ_CAP)));
+                                       CIFS_UNIX_LARGE_READ_CAP|
+                                       large_write ?
+                                       CIFS_UNIX_LARGE_WRITE_CAP : 0)));
                        break;
+               }
 
                case SMB_QUERY_POSIX_FS_INFO:
                {
index 21a12ae766a21b2ef248e9ef89951b577731fc3c..78939881d35e1dffe82fc39b2cc7bd9ee61d7b7f 100644 (file)
@@ -428,15 +428,14 @@ ssize_t vfs_write_data(struct smb_request *req,
 
        if (req && req->unread_bytes) {
                SMB_ASSERT(req->unread_bytes == N);
-               ret = SMB_VFS_RECVFILE(smbd_server_fd(),
+               /* VFS_RECVFILE must drain the socket
+                * before returning. */
+               req->unread_bytes = 0;
+               return SMB_VFS_RECVFILE(smbd_server_fd(),
                                        fsp,
                                        fsp->fh->fd,
                                        (SMB_OFF_T)-1,
                                        N);
-               if (ret != -1) {
-                       req->unread_bytes = 0;
-               }
-               return ret;
        }
 
        while (total < N) {
@@ -463,15 +462,14 @@ ssize_t vfs_pwrite_data(struct smb_request *req,
 
        if (req && req->unread_bytes) {
                SMB_ASSERT(req->unread_bytes == N);
-               ret = SMB_VFS_RECVFILE(smbd_server_fd(),
+               /* VFS_RECVFILE must drain the socket
+                * before returning. */
+               req->unread_bytes = 0;
+               return SMB_VFS_RECVFILE(smbd_server_fd(),
                                        fsp,
                                        fsp->fh->fd,
                                        offset,
                                        N);
-               if (ret != -1) {
-                       req->unread_bytes = 0;
-               }
-               return ret;
        }
 
        while (total < N) {