diff options
author | Jeff Layton <jlayton@redhat.com> | 2012-09-18 19:20:35 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-09-24 22:46:31 -0400 |
commit | b8eed28375a43e1c9aaa9d15af2a052aae0d0725 (patch) | |
tree | e63b713d5ae69afee73bf40487e5f067f2a66eb9 /fs/cifs | |
parent | 6f49f46b187df34539f1e5df2469b8a541897700 (diff) |
cifs: cork the socket before a send and uncork it afterward
We want to send SMBs as "atomically" as possible. Prior to sending any
data on the socket, cork it to make sure that no non-full frames go
out. Afterward, uncork it to make sure all of the data gets pushed out
to the wire.
Note that this more or less renders the socket=TCP_NODELAY mount option
obsolete. When TCP_CORK and TCP_NODELAY are used on the same socket,
TCP_NODELAY is essentially ignored.
Acked-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/connect.c | 4 | ||||
-rw-r--r-- | fs/cifs/transport.c | 12 |
2 files changed, 16 insertions, 0 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 549409b1c77..5210bc82b1d 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -1680,6 +1680,10 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, | |||
1680 | if (string == NULL) | 1680 | if (string == NULL) |
1681 | goto out_nomem; | 1681 | goto out_nomem; |
1682 | 1682 | ||
1683 | /* | ||
1684 | * FIXME: since we now cork/uncork the socket while | ||
1685 | * sending, should we deprecate this option? | ||
1686 | */ | ||
1683 | if (strnicmp(string, "TCP_NODELAY", 11) == 0) | 1687 | if (strnicmp(string, "TCP_NODELAY", 11) == 0) |
1684 | vol->sockopt_tcp_nodelay = 1; | 1688 | vol->sockopt_tcp_nodelay = 1; |
1685 | break; | 1689 | break; |
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 766307b725b..8ff4c5f3670 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/net.h> | 27 | #include <linux/net.h> |
28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
29 | #include <linux/freezer.h> | 29 | #include <linux/freezer.h> |
30 | #include <linux/tcp.h> | ||
30 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
31 | #include <asm/processor.h> | 32 | #include <asm/processor.h> |
32 | #include <linux/mempool.h> | 33 | #include <linux/mempool.h> |
@@ -247,12 +248,23 @@ smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst) | |||
247 | int n_vec = rqst->rq_nvec; | 248 | int n_vec = rqst->rq_nvec; |
248 | unsigned int smb_buf_length = get_rfc1002_length(iov[0].iov_base); | 249 | unsigned int smb_buf_length = get_rfc1002_length(iov[0].iov_base); |
249 | size_t total_len; | 250 | size_t total_len; |
251 | struct socket *ssocket = server->ssocket; | ||
252 | int val = 1; | ||
250 | 253 | ||
251 | cFYI(1, "Sending smb: smb_len=%u", smb_buf_length); | 254 | cFYI(1, "Sending smb: smb_len=%u", smb_buf_length); |
252 | dump_smb(iov[0].iov_base, iov[0].iov_len); | 255 | dump_smb(iov[0].iov_base, iov[0].iov_len); |
253 | 256 | ||
257 | /* cork the socket */ | ||
258 | kernel_setsockopt(ssocket, SOL_TCP, TCP_CORK, | ||
259 | (char *)&val, sizeof(val)); | ||
260 | |||
254 | rc = smb_send_kvec(server, iov, n_vec, &total_len); | 261 | rc = smb_send_kvec(server, iov, n_vec, &total_len); |
255 | 262 | ||
263 | /* uncork it */ | ||
264 | val = 0; | ||
265 | kernel_setsockopt(ssocket, SOL_TCP, TCP_CORK, | ||
266 | (char *)&val, sizeof(val)); | ||
267 | |||
256 | if ((total_len > 0) && (total_len != smb_buf_length + 4)) { | 268 | if ((total_len > 0) && (total_len != smb_buf_length + 4)) { |
257 | cFYI(1, "partial send (wanted=%u sent=%zu): terminating " | 269 | cFYI(1, "partial send (wanted=%u sent=%zu): terminating " |
258 | "session", smb_buf_length + 4, total_len); | 270 | "session", smb_buf_length + 4, total_len); |