From: Anton Blanchard <anton@linuxcare.com.au>
To: "Gord R. Lamb" <glamb@lcis.dyndns.org>
Cc: Jeremy Jackson <jeremy.jackson@sympatico.ca>,
linux-kernel@vger.kernel.org
Subject: Re: Samba performance / zero-copy network I/O
Date: Sat, 17 Feb 2001 19:17:47 +1100 [thread overview]
Message-ID: <20010217191746.B2484@linuxcare.com> (raw)
In-Reply-To: <3A8AEDB9.59721801@sympatico.ca> <Pine.LNX.4.32.0102141548440.27843-100000@localhost.localdomain>
In-Reply-To: <Pine.LNX.4.32.0102141548440.27843-100000@localhost.localdomain>; from glamb@lcis.dyndns.org on Wed, Feb 14, 2001 at 03:53:02PM -0500
> Hmm. Yeah, I think that may be one of the problems (Intel's card isn't
> supported afaik; if I have to I'll switch to 3com, or hopelessly try to
> implement support). I'm looking for a patch to implement sendfile in
> Samba, as Alan suggested. That seems like a good first step.
As Alan said, the smb protocol is pretty ugly. This patch makes samba use
sendfile for unchained read_and_X replies. I could hook this into some of
the other *read* replies but this is the one smbtorture uses so it served my
purpose. Of course this is against the current CVS head, not some wimpy
stable branch. :)
I still need to write some code to make this safe (things will break badly
if multiple clients hit the same file and one of them truncates at just the
right time).
In my tests, this only improved things by a couple of percent because we do
so many other things than just serving files in real life (well if you can
call netbench land real life).
Anton
diff -u -u -r1.195 includes.h
--- source/include/includes.h 2000/12/06 00:05:14 1.195
+++ source/include/includes.h 2001/01/26 05:38:51
@@ -871,7 +871,8 @@
/* default socket options. Dave Miller thinks we should default to TCP_NODELAY
given the socket IO pattern that Samba uses */
-#ifdef TCP_NODELAY
+
+#if 0
#define DEFAULT_SOCKET_OPTIONS "TCP_NODELAY"
#else
#define DEFAULT_SOCKET_OPTIONS ""
diff -u -u -r1.257 reply.c
--- source/smbd/reply.c 2001/01/24 19:34:53 1.257
+++ source/smbd/reply.c 2001/01/26 05:38:53
@@ -2383,6 +2391,51 @@
END_PROFILE(SMBreadX);
return(ERROR(ERRDOS,ERRlock));
}
+
+#if 1
+ /* We can use sendfile if it is not chained */
+ if (CVAL(inbuf,smb_vwv0) == 0xFF) {
+ off_t tmpoffset;
+ struct stat buf;
+ int flags = 0;
+
+ nread = smb_maxcnt;
+
+ fstat(fsp->fd, &buf);
+ if (startpos > buf.st_size)
+ return(UNIXERROR(ERRDOS,ERRnoaccess));
+ if (nread > (buf.st_size - startpos))
+ nread = (buf.st_size - startpos);
+
+ SSVAL(outbuf,smb_vwv5,nread);
+ SSVAL(outbuf,smb_vwv6,smb_offset(data,outbuf));
+ SSVAL(smb_buf(outbuf),-2,nread);
+ CVAL(outbuf,smb_vwv0) = 0xFF;
+ set_message(outbuf,12,nread,False);
+
+#define MSG_MORE 0x8000
+ if (nread > 0)
+ flags = MSG_MORE;
+ if (send(smbd_server_fd(), outbuf, data - outbuf, flags) == -1)
+ DEBUG(0,("reply_read_and_X: send ERROR!\n"));
+
+ tmpoffset = startpos;
+ while(nread) {
+ int nwritten;
+ nwritten = sendfile(smbd_server_fd(), fsp->fd, &tmpoffset, nread);
+ if (nwritten == -1)
+ DEBUG(0,("reply_read_and_X: sendfile ERROR!\n"));
+
+ if (!nwritten)
+ break;
+
+ nread -= nwritten;
+ }
+
+ return -1;
+ }
+#endif
+
nread = read_file(fsp,data,startpos,smb_maxcnt);
if (nread < 0) {
next prev parent reply other threads:[~2001-02-17 8:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-02-14 20:14 Samba performance / zero-copy network I/O Gord R. Lamb
2001-02-14 20:29 ` Alan Cox
2001-02-14 20:42 ` Jeremy Jackson
2001-02-14 20:53 ` Gord R. Lamb
2001-02-14 22:40 ` Tom Sightler
2001-02-16 2:24 ` Gord R. Lamb
2001-02-16 14:51 ` Andrew Morton
2001-02-16 20:49 ` Tom Sightler
2001-02-17 8:17 ` Anton Blanchard [this message]
2001-02-19 16:47 ` Gord R. Lamb
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010217191746.B2484@linuxcare.com \
--to=anton@linuxcare.com.au \
--cc=glamb@lcis.dyndns.org \
--cc=jeremy.jackson@sympatico.ca \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox