View | Details | Raw Unified | Return to bug 219645 | Differences between
and this patch

Collapse All | Expand All

(-)sys/param.h (-3 / +9 lines)
Lines 244-252 Link Here
244
 *		Filesystems can of course request smaller chunks.  Actual
244
 *		Filesystems can of course request smaller chunks.  Actual
245
 *		backing memory uses a chunk size of a page (PAGE_SIZE).
245
 *		backing memory uses a chunk size of a page (PAGE_SIZE).
246
 *		The default value here can be overridden on a per-architecture
246
 *		The default value here can be overridden on a per-architecture
247
 *		basis by defining it in <machine/param.h>.  This should
247
 *		basis by defining it in <machine/param.h>.
248
 *		probably be done to increase its value, when MAXBCACHEBUF is
249
 *		defined as a larger value in <machine/param.h>.
250
 *
248
 *
251
 *		If you make BKVASIZE too small you risk seriously fragmenting
249
 *		If you make BKVASIZE too small you risk seriously fragmenting
252
 *		the buffer KVM map which may slow things down a bit.  If you
250
 *		the buffer KVM map which may slow things down a bit.  If you
Lines 267-272 Link Here
267
#define BKVAMASK	(BKVASIZE-1)
265
#define BKVAMASK	(BKVASIZE-1)
268
266
269
/*
267
/*
268
 * This variable is tuned via vfs.maxbcachebuf and is set to the value of
269
 * MAXBCACHEBUF by default.
270
 */
271
#ifdef _KERNEL
272
extern int	maxbcachebuf;
273
#endif
274
275
/*
270
 * MAXPATHLEN defines the longest permissible path length after expanding
276
 * MAXPATHLEN defines the longest permissible path length after expanding
271
 * symbolic links. It is used to allocate a temporary buffer from the buffer
277
 * symbolic links. It is used to allocate a temporary buffer from the buffer
272
 * pool in which to do the name expansion, hence should be a power of two,
278
 * pool in which to do the name expansion, hence should be a power of two,
(-)fs/nfs/nfsport.h (-1 / +1 lines)
Lines 1028-1034 struct nfsreq { Link Here
1028
};
1028
};
1029
1029
1030
#ifndef NFS_MAXBSIZE
1030
#ifndef NFS_MAXBSIZE
1031
#define	NFS_MAXBSIZE	MAXBCACHEBUF
1031
#define	NFS_MAXBSIZE	(maxbcachebuf)
1032
#endif
1032
#endif
1033
1033
1034
/*
1034
/*
(-)fs/nfs/nfsproto.h (-1 / +15 lines)
Lines 56-63 Link Here
56
#define	NFS_MAXDGRAMDATA 16384
56
#define	NFS_MAXDGRAMDATA 16384
57
#define	NFS_MAXPATHLEN	1024
57
#define	NFS_MAXPATHLEN	1024
58
#define	NFS_MAXNAMLEN	255
58
#define	NFS_MAXNAMLEN	255
59
/*
60
 * Calculating the maximum XDR overhead for an NFS RPC isn't easy.
61
 * NFS_MAXPKTHDR is antiquated and assumes AUTH_SYS over UDP.
62
 * NFS_MAXXDR should be sufficient for all NFS versions over TCP.
63
 * It includes:
64
 * - Maximum RPC message header. It can include 2 400byte authenticators plus
65
 *   a machine name of unlimited length, although it is usually relatively
66
 *   small.
67
 * - XDR overheads for the NFSv4 compound. This can include Owner and
68
 *   Owner_group strings, which are usually fairly small, but are allowed
69
 *   to be up to 1024 bytes each.
70
 * 4096 is overkill, but should always be sufficient.
71
 */
59
#define	NFS_MAXPKTHDR	404
72
#define	NFS_MAXPKTHDR	404
60
#define	NFS_MAXPACKET	(NFS_SRVMAXIO + 2048)
73
#define	NFS_MAXXDR	4096
74
#define	NFS_MAXPACKET	(NFS_SRVMAXIO + NFS_MAXXDR)
61
#define	NFS_MINPACKET	20
75
#define	NFS_MINPACKET	20
62
#define	NFS_FABLKSIZE	512	/* Size in bytes of a block wrt fa_blocks */
76
#define	NFS_FABLKSIZE	512	/* Size in bytes of a block wrt fa_blocks */
63
#define	NFSV4_MINORVERSION	0	/* V4 Minor version */
77
#define	NFSV4_MINORVERSION	0	/* V4 Minor version */
(-)fs/nfs/nfs_commonkrpc.c (-4 / +13 lines)
Lines 161-167 newnfs_connect(struct nfsmount *nmp, str Link Here
161
    struct ucred *cred, NFSPROC_T *p, int callback_retry_mult)
161
    struct ucred *cred, NFSPROC_T *p, int callback_retry_mult)
162
{
162
{
163
	int rcvreserve, sndreserve;
163
	int rcvreserve, sndreserve;
164
	int pktscale;
164
	int pktscale, pktscalesav;
165
	struct sockaddr *saddr;
165
	struct sockaddr *saddr;
166
	struct ucred *origcred;
166
	struct ucred *origcred;
167
	CLIENT *client;
167
	CLIENT *client;
Lines 210-215 newnfs_connect(struct nfsmount *nmp, str Link Here
210
		pktscale = 2;
210
		pktscale = 2;
211
	if (pktscale > 64)
211
	if (pktscale > 64)
212
		pktscale = 64;
212
		pktscale = 64;
213
	pktscalesav = pktscale;
213
	/*
214
	/*
214
	 * soreserve() can fail if sb_max is too small, so shrink pktscale
215
	 * soreserve() can fail if sb_max is too small, so shrink pktscale
215
	 * and try again if there is an error.
216
	 * and try again if there is an error.
Lines 228-235 newnfs_connect(struct nfsmount *nmp, str Link Here
228
		goto out;
229
		goto out;
229
	}
230
	}
230
	do {
231
	do {
231
	    if (error != 0 && pktscale > 2)
232
	    if (error != 0 && pktscale > 2) {
233
		if (nmp != NULL && nrp->nr_sotype == SOCK_STREAM &&
234
		    pktscale == pktscalesav)
235
		    printf("Consider increasing kern.ipc.maxsockbuf\n");
232
		pktscale--;
236
		pktscale--;
237
	    }
233
	    if (nrp->nr_sotype == SOCK_DGRAM) {
238
	    if (nrp->nr_sotype == SOCK_DGRAM) {
234
		if (nmp != NULL) {
239
		if (nmp != NULL) {
235
			sndreserve = (NFS_MAXDGRAMDATA + NFS_MAXPKTHDR) *
240
			sndreserve = (NFS_MAXDGRAMDATA + NFS_MAXPKTHDR) *
Lines 243-257 newnfs_connect(struct nfsmount *nmp, str Link Here
243
		if (nrp->nr_sotype != SOCK_STREAM)
248
		if (nrp->nr_sotype != SOCK_STREAM)
244
			panic("nfscon sotype");
249
			panic("nfscon sotype");
245
		if (nmp != NULL) {
250
		if (nmp != NULL) {
246
			sndreserve = (NFS_MAXBSIZE + NFS_MAXPKTHDR +
251
			sndreserve = (NFS_MAXBSIZE + NFS_MAXXDR +
247
			    sizeof (u_int32_t)) * pktscale;
252
			    sizeof (u_int32_t)) * pktscale;
248
			rcvreserve = (NFS_MAXBSIZE + NFS_MAXPKTHDR +
253
			rcvreserve = (NFS_MAXBSIZE + NFS_MAXXDR +
249
			    sizeof (u_int32_t)) * pktscale;
254
			    sizeof (u_int32_t)) * pktscale;
250
		} else {
255
		} else {
251
			sndreserve = rcvreserve = 1024 * pktscale;
256
			sndreserve = rcvreserve = 1024 * pktscale;
252
		}
257
		}
253
	    }
258
	    }
254
	    error = soreserve(so, sndreserve, rcvreserve);
259
	    error = soreserve(so, sndreserve, rcvreserve);
260
	    if (error != 0 && nmp != NULL && nrp->nr_sotype == SOCK_STREAM &&
261
		pktscale <= 2)
262
		printf("Must increase kern.ipc.maxsockbuf or reduce"
263
		    " rsize, wsize\n");
255
	} while (error != 0 && pktscale > 2);
264
	} while (error != 0 && pktscale > 2);
256
	soclose(so);
265
	soclose(so);
257
	if (error) {
266
	if (error) {
(-)fs/nfsclient/nfs_clrpcops.c (-4 / +23 lines)
Lines 4703-4709 nfsrpc_createsession(struct nfsmount *nm Link Here
4703
    struct nfssockreq *nrp, uint32_t sequenceid, int mds, struct ucred *cred,
4703
    struct nfssockreq *nrp, uint32_t sequenceid, int mds, struct ucred *cred,
4704
    NFSPROC_T *p)
4704
    NFSPROC_T *p)
4705
{
4705
{
4706
	uint32_t crflags, *tl;
4706
	uint32_t crflags, maxval, *tl;
4707
	struct nfsrv_descript nfsd;
4707
	struct nfsrv_descript nfsd;
4708
	struct nfsrv_descript *nd = &nfsd;
4708
	struct nfsrv_descript *nd = &nfsd;
4709
	int error, irdcnt;
4709
	int error, irdcnt;
Lines 4721-4728 nfsrpc_createsession(struct nfsmount *nm Link Here
4721
	/* Fill in fore channel attributes. */
4721
	/* Fill in fore channel attributes. */
4722
	NFSM_BUILD(tl, uint32_t *, 7 * NFSX_UNSIGNED);
4722
	NFSM_BUILD(tl, uint32_t *, 7 * NFSX_UNSIGNED);
4723
	*tl++ = 0;				/* Header pad size */
4723
	*tl++ = 0;				/* Header pad size */
4724
	*tl++ = txdr_unsigned(100000);		/* Max request size */
4724
	*tl++ = txdr_unsigned(nmp->nm_wsize + NFS_MAXXDR);/* Max request size */
4725
	*tl++ = txdr_unsigned(100000);		/* Max response size */
4725
	*tl++ = txdr_unsigned(nmp->nm_rsize + NFS_MAXXDR);/* Max reply size */
4726
	*tl++ = txdr_unsigned(4096);		/* Max response size cached */
4726
	*tl++ = txdr_unsigned(4096);		/* Max response size cached */
4727
	*tl++ = txdr_unsigned(20);		/* Max operations */
4727
	*tl++ = txdr_unsigned(20);		/* Max operations */
4728
	*tl++ = txdr_unsigned(64);		/* Max slots */
4728
	*tl++ = txdr_unsigned(64);		/* Max slots */
Lines 4769-4775 nfsrpc_createsession(struct nfsmount *nm Link Here
4769
4769
4770
		/* Get the fore channel slot count. */
4770
		/* Get the fore channel slot count. */
4771
		NFSM_DISSECT(tl, uint32_t *, 7 * NFSX_UNSIGNED);
4771
		NFSM_DISSECT(tl, uint32_t *, 7 * NFSX_UNSIGNED);
4772
		tl += 3;		/* Skip the other counts. */		
4772
		tl++;			/* Skip the header pad size. */
4773
4774
		/* Make sure nm_wsize is small enough. */
4775
		maxval = fxdr_unsigned(uint32_t, *tl++);
4776
		while (maxval < nmp->nm_wsize + NFS_MAXXDR) {
4777
			if (nmp->nm_wsize > 8096)
4778
				nmp->nm_wsize /= 2;
4779
			else
4780
				break;
4781
		}
4782
4783
		/* Make sure nm_rsize is small enough. */
4784
		maxval = fxdr_unsigned(uint32_t, *tl++);
4785
		while (maxval < nmp->nm_rsize + NFS_MAXXDR) {
4786
			if (nmp->nm_rsize > 8096)
4787
				nmp->nm_rsize /= 2;
4788
			else
4789
				break;
4790
		}
4791
4773
		sep->nfsess_maxcache = fxdr_unsigned(int, *tl++);
4792
		sep->nfsess_maxcache = fxdr_unsigned(int, *tl++);
4774
		tl++;
4793
		tl++;
4775
		sep->nfsess_foreslots = fxdr_unsigned(uint16_t, *tl++);
4794
		sep->nfsess_foreslots = fxdr_unsigned(uint16_t, *tl++);
(-)kern/vfs_bio.c (-7 / +34 lines)
Lines 131-136 static void bufkva_reclaim(vmem_t *, int Link Here
131
static void bufkva_free(struct buf *);
131
static void bufkva_free(struct buf *);
132
static int buf_import(void *, void **, int, int);
132
static int buf_import(void *, void **, int, int);
133
static void buf_release(void *, void **, int);
133
static void buf_release(void *, void **, int);
134
static void maxbcachebuf_adjust(void);
134
135
135
#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
136
#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
136
    defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
137
    defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
Lines 245-250 SYSCTL_LONG(_vfs, OID_AUTO, barrierwrite Link Here
245
SYSCTL_INT(_vfs, OID_AUTO, unmapped_buf_allowed, CTLFLAG_RD,
246
SYSCTL_INT(_vfs, OID_AUTO, unmapped_buf_allowed, CTLFLAG_RD,
246
    &unmapped_buf_allowed, 0,
247
    &unmapped_buf_allowed, 0,
247
    "Permit the use of the unmapped i/o");
248
    "Permit the use of the unmapped i/o");
249
int maxbcachebuf = MAXBCACHEBUF;
250
SYSCTL_INT(_vfs, OID_AUTO, maxbcachebuf, CTLFLAG_RDTUN, &maxbcachebuf, 0,
251
    "Maximum size of a buffer cache block");
248
252
249
/*
253
/*
250
 * This lock synchronizes access to bd_request.
254
 * This lock synchronizes access to bd_request.
Lines 847-852 bd_wakeup(void) Link Here
847
}
851
}
848
852
849
/*
853
/*
854
 * Adjust the maxbcachbuf tunable.
855
 */
856
static void
857
maxbcachebuf_adjust(void)
858
{
859
	int i;
860
861
	/*
862
	 * maxbcachebuf must be a power of 2 >= MAXBSIZE.
863
	 */
864
	i = 2;
865
	while (i * 2 <= maxbcachebuf)
866
		i *= 2;
867
	maxbcachebuf = i;
868
	if (maxbcachebuf < MAXBSIZE)
869
		maxbcachebuf = MAXBSIZE;
870
	if (maxbcachebuf != MAXBCACHEBUF)
871
		printf("maxbcachebuf=%d\n", maxbcachebuf);
872
}
873
874
/*
850
 * bd_speedup - speedup the buffer cache flushing code
875
 * bd_speedup - speedup the buffer cache flushing code
851
 */
876
 */
852
void
877
void
Lines 893-898 kern_vfs_bio_buffer_alloc(caddr_t v, lon Link Here
893
	 */
918
	 */
894
	physmem_est = physmem_est * (PAGE_SIZE / 1024);
919
	physmem_est = physmem_est * (PAGE_SIZE / 1024);
895
920
921
	maxbcachebuf_adjust();
896
	/*
922
	/*
897
	 * The nominal buffer size (and minimum KVA allocation) is BKVASIZE.
923
	 * The nominal buffer size (and minimum KVA allocation) is BKVASIZE.
898
	 * For the first 64MB of ram nominally allocate sufficient buffers to
924
	 * For the first 64MB of ram nominally allocate sufficient buffers to
Lines 1003-1009 bufinit(void) Link Here
1003
	struct buf *bp;
1029
	struct buf *bp;
1004
	int i;
1030
	int i;
1005
1031
1006
	CTASSERT(MAXBCACHEBUF >= MAXBSIZE);
1032
	KASSERT(maxbcachebuf >= MAXBSIZE,
1033
	    ("maxbcachebuf must be >= MAXBSIZE\n"));
1007
	mtx_init(&bqlocks[QUEUE_DIRTY], "bufq dirty lock", NULL, MTX_DEF);
1034
	mtx_init(&bqlocks[QUEUE_DIRTY], "bufq dirty lock", NULL, MTX_DEF);
1008
	mtx_init(&bqlocks[QUEUE_EMPTY], "bufq empty lock", NULL, MTX_DEF);
1035
	mtx_init(&bqlocks[QUEUE_EMPTY], "bufq empty lock", NULL, MTX_DEF);
1009
	for (i = QUEUE_CLEAN; i < QUEUE_CLEAN + CLEAN_QUEUES; i++)
1036
	for (i = QUEUE_CLEAN; i < QUEUE_CLEAN + CLEAN_QUEUES; i++)
Lines 1050-1056 bufinit(void) Link Here
1050
	 * PAGE_SIZE.
1077
	 * PAGE_SIZE.
1051
	 */
1078
	 */
1052
	maxbufspace = (long)nbuf * BKVASIZE;
1079
	maxbufspace = (long)nbuf * BKVASIZE;
1053
	hibufspace = lmax(3 * maxbufspace / 4, maxbufspace - MAXBCACHEBUF * 10);
1080
	hibufspace = lmax(3 * maxbufspace / 4, maxbufspace - maxbcachebuf * 10);
1054
	lobufspace = (hibufspace / 20) * 19; /* 95% */
1081
	lobufspace = (hibufspace / 20) * 19; /* 95% */
1055
	bufspacethresh = lobufspace + (hibufspace - lobufspace) / 2;
1082
	bufspacethresh = lobufspace + (hibufspace - lobufspace) / 2;
1056
1083
Lines 1062-1070 bufinit(void) Link Here
1062
	 * The lower 1 MiB limit is the historical upper limit for
1089
	 * The lower 1 MiB limit is the historical upper limit for
1063
	 * hirunningspace.
1090
	 * hirunningspace.
1064
	 */
1091
	 */
1065
	hirunningspace = lmax(lmin(roundup(hibufspace / 64, MAXBCACHEBUF),
1092
	hirunningspace = lmax(lmin(roundup(hibufspace / 64, maxbcachebuf),
1066
	    16 * 1024 * 1024), 1024 * 1024);
1093
	    16 * 1024 * 1024), 1024 * 1024);
1067
	lorunningspace = roundup((hirunningspace * 2) / 3, MAXBCACHEBUF);
1094
	lorunningspace = roundup((hirunningspace * 2) / 3, maxbcachebuf);
1068
1095
1069
	/*
1096
	/*
1070
	 * Limit the amount of malloc memory since it is wired permanently into
1097
	 * Limit the amount of malloc memory since it is wired permanently into
Lines 3484-3492 getblk(struct vnode *vp, daddr_t blkno, Link Here
3484
	KASSERT((flags & (GB_UNMAPPED | GB_KVAALLOC)) != GB_KVAALLOC,
3511
	KASSERT((flags & (GB_UNMAPPED | GB_KVAALLOC)) != GB_KVAALLOC,
3485
	    ("GB_KVAALLOC only makes sense with GB_UNMAPPED"));
3512
	    ("GB_KVAALLOC only makes sense with GB_UNMAPPED"));
3486
	ASSERT_VOP_LOCKED(vp, "getblk");
3513
	ASSERT_VOP_LOCKED(vp, "getblk");
3487
	if (size > MAXBCACHEBUF)
3514
	if (size > maxbcachebuf)
3488
		panic("getblk: size(%d) > MAXBCACHEBUF(%d)\n", size,
3515
		panic("getblk: size(%d) > maxbcachebuf(%d)\n", size,
3489
		    MAXBCACHEBUF);
3516
		    maxbcachebuf);
3490
	if (!unmapped_buf_allowed)
3517
	if (!unmapped_buf_allowed)
3491
		flags &= ~(GB_UNMAPPED | GB_KVAALLOC);
3518
		flags &= ~(GB_UNMAPPED | GB_KVAALLOC);
3492
3519

Return to bug 219645