| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: nfs_socket.c,v 1.173.4.8 2011/03/29 19:47:37 riz Exp $ */ | | 1 | /* $NetBSD: nfs_socket.c,v 1.173.4.9 2011/04/24 16:23:49 riz Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1989, 1991, 1993, 1995 | | 4 | * Copyright (c) 1989, 1991, 1993, 1995 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Rick Macklem at The University of Guelph. | | 8 | * Rick Macklem at The University of Guelph. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | * | | 33 | * |
34 | * @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95 | | 34 | * @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95 |
35 | */ | | 35 | */ |
36 | | | 36 | |
37 | /* | | 37 | /* |
38 | * Socket operations for use by nfs | | 38 | * Socket operations for use by nfs |
39 | */ | | 39 | */ |
40 | | | 40 | |
41 | #include <sys/cdefs.h> | | 41 | #include <sys/cdefs.h> |
42 | __KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.173.4.8 2011/03/29 19:47:37 riz Exp $"); | | 42 | __KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.173.4.9 2011/04/24 16:23:49 riz Exp $"); |
43 | | | 43 | |
44 | #include "fs_nfs.h" | | 44 | #include "fs_nfs.h" |
45 | #include "opt_nfs.h" | | 45 | #include "opt_nfs.h" |
46 | #include "opt_nfsserver.h" | | 46 | #include "opt_nfsserver.h" |
47 | #include "opt_mbuftrace.h" | | 47 | #include "opt_mbuftrace.h" |
48 | #include "opt_inet.h" | | 48 | #include "opt_inet.h" |
49 | | | 49 | |
50 | #include <sys/param.h> | | 50 | #include <sys/param.h> |
51 | #include <sys/systm.h> | | 51 | #include <sys/systm.h> |
52 | #include <sys/evcnt.h> | | 52 | #include <sys/evcnt.h> |
53 | #include <sys/callout.h> | | 53 | #include <sys/callout.h> |
54 | #include <sys/proc.h> | | 54 | #include <sys/proc.h> |
55 | #include <sys/mount.h> | | 55 | #include <sys/mount.h> |
| @@ -311,51 +311,51 @@ nfs_connect(nmp, rep, l) | | | @@ -311,51 +311,51 @@ nfs_connect(nmp, rep, l) |
311 | } | | 311 | } |
312 | if (nmp->nm_flag & (NFSMNT_SOFT | NFSMNT_INT)) { | | 312 | if (nmp->nm_flag & (NFSMNT_SOFT | NFSMNT_INT)) { |
313 | so->so_rcv.sb_timeo = (5 * hz); | | 313 | so->so_rcv.sb_timeo = (5 * hz); |
314 | so->so_snd.sb_timeo = (5 * hz); | | 314 | so->so_snd.sb_timeo = (5 * hz); |
315 | } else { | | 315 | } else { |
316 | /* | | 316 | /* |
317 | * enable receive timeout to detect server crash and reconnect. | | 317 | * enable receive timeout to detect server crash and reconnect. |
318 | * otherwise, we can be stuck in soreceive forever. | | 318 | * otherwise, we can be stuck in soreceive forever. |
319 | */ | | 319 | */ |
320 | so->so_rcv.sb_timeo = (5 * hz); | | 320 | so->so_rcv.sb_timeo = (5 * hz); |
321 | so->so_snd.sb_timeo = 0; | | 321 | so->so_snd.sb_timeo = 0; |
322 | } | | 322 | } |
323 | if (nmp->nm_sotype == SOCK_DGRAM) { | | 323 | if (nmp->nm_sotype == SOCK_DGRAM) { |
324 | sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2; | | 324 | sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 3; |
325 | rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) + | | 325 | rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) + |
326 | NFS_MAXPKTHDR) * 2; | | 326 | NFS_MAXPKTHDR) * 2; |
327 | } else if (nmp->nm_sotype == SOCK_SEQPACKET) { | | 327 | } else if (nmp->nm_sotype == SOCK_SEQPACKET) { |
328 | sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2; | | 328 | sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 3; |
329 | rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) + | | 329 | rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) + |
330 | NFS_MAXPKTHDR) * 2; | | 330 | NFS_MAXPKTHDR) * 3; |
331 | } else { | | 331 | } else { |
332 | sounlock(so); | | 332 | sounlock(so); |
333 | if (nmp->nm_sotype != SOCK_STREAM) | | 333 | if (nmp->nm_sotype != SOCK_STREAM) |
334 | panic("nfscon sotype"); | | 334 | panic("nfscon sotype"); |
335 | if (so->so_proto->pr_flags & PR_CONNREQUIRED) { | | 335 | if (so->so_proto->pr_flags & PR_CONNREQUIRED) { |
336 | val = 1; | | 336 | val = 1; |
337 | so_setsockopt(NULL, so, SOL_SOCKET, SO_KEEPALIVE, &val, | | 337 | so_setsockopt(NULL, so, SOL_SOCKET, SO_KEEPALIVE, &val, |
338 | sizeof(val)); | | 338 | sizeof(val)); |
339 | } | | 339 | } |
340 | if (so->so_proto->pr_protocol == IPPROTO_TCP) { | | 340 | if (so->so_proto->pr_protocol == IPPROTO_TCP) { |
341 | val = 1; | | 341 | val = 1; |
342 | so_setsockopt(NULL, so, IPPROTO_TCP, TCP_NODELAY, &val, | | 342 | so_setsockopt(NULL, so, IPPROTO_TCP, TCP_NODELAY, &val, |
343 | sizeof(val)); | | 343 | sizeof(val)); |
344 | } | | 344 | } |
345 | sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR + | | 345 | sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR + |
346 | sizeof (u_int32_t)) * 2; | | 346 | sizeof (u_int32_t)) * 3; |
347 | rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR + | | 347 | rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR + |
348 | sizeof (u_int32_t)) * 2; | | 348 | sizeof (u_int32_t)) * 3; |
349 | solock(so); | | 349 | solock(so); |
350 | } | | 350 | } |
351 | error = soreserve(so, sndreserve, rcvreserve); | | 351 | error = soreserve(so, sndreserve, rcvreserve); |
352 | if (error) { | | 352 | if (error) { |
353 | sounlock(so); | | 353 | sounlock(so); |
354 | goto bad; | | 354 | goto bad; |
355 | } | | 355 | } |
356 | so->so_rcv.sb_flags |= SB_NOINTR; | | 356 | so->so_rcv.sb_flags |= SB_NOINTR; |
357 | so->so_snd.sb_flags |= SB_NOINTR; | | 357 | so->so_snd.sb_flags |= SB_NOINTR; |
358 | sounlock(so); | | 358 | sounlock(so); |
359 | | | 359 | |
360 | /* Initialize other non-zero congestion variables */ | | 360 | /* Initialize other non-zero congestion variables */ |
361 | nmp->nm_srtt[0] = nmp->nm_srtt[1] = nmp->nm_srtt[2] = nmp->nm_srtt[3] = | | 361 | nmp->nm_srtt[0] = nmp->nm_srtt[1] = nmp->nm_srtt[2] = nmp->nm_srtt[3] = |