MAXBSIZE defines both the largest UFS block size and the
largest size for a buffer in the buffer cache. This patch defines a new constant MAXBCACHEBUF, which is the largest size for a buffer in the buffer cache. Having a separate constant allows MAXBCACHEBUF to be set larger than MAXBSIZE on a per-architecture basis, so that NFS can do larger read/writes for these architectures. It modifies sys/param.h so that BKVASIZE can also be set on a per-architecture basis. A couple of cases where NFS used MAXBSIZE instead of NFS_MAXBSIZE is fixed as well. Differential Revision: https://reviews.freebsd.org/D2330 Reviewed by: mav, kib MFC after: 2 weeks
This commit is contained in:
parent
3cddd28ef1
commit
7cfdc2a7bc
@ -950,7 +950,7 @@ struct nfsreq {
|
||||
};
|
||||
|
||||
#ifndef NFS_MAXBSIZE
|
||||
#define NFS_MAXBSIZE MAXBSIZE
|
||||
#define NFS_MAXBSIZE MAXBCACHEBUF
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -201,16 +201,16 @@ newnfs_iosize(struct nfsmount *nmp)
|
||||
}
|
||||
if (nmp->nm_rsize > maxio || nmp->nm_rsize == 0)
|
||||
nmp->nm_rsize = maxio;
|
||||
if (nmp->nm_rsize > MAXBSIZE)
|
||||
nmp->nm_rsize = MAXBSIZE;
|
||||
if (nmp->nm_rsize > NFS_MAXBSIZE)
|
||||
nmp->nm_rsize = NFS_MAXBSIZE;
|
||||
if (nmp->nm_readdirsize > maxio || nmp->nm_readdirsize == 0)
|
||||
nmp->nm_readdirsize = maxio;
|
||||
if (nmp->nm_readdirsize > nmp->nm_rsize)
|
||||
nmp->nm_readdirsize = nmp->nm_rsize;
|
||||
if (nmp->nm_wsize > maxio || nmp->nm_wsize == 0)
|
||||
nmp->nm_wsize = maxio;
|
||||
if (nmp->nm_wsize > MAXBSIZE)
|
||||
nmp->nm_wsize = MAXBSIZE;
|
||||
if (nmp->nm_wsize > NFS_MAXBSIZE)
|
||||
nmp->nm_wsize = NFS_MAXBSIZE;
|
||||
|
||||
/*
|
||||
* Calculate the size used for io buffers. Use the larger
|
||||
|
@ -805,6 +805,7 @@ bufinit(void)
|
||||
struct buf *bp;
|
||||
int i;
|
||||
|
||||
CTASSERT(MAXBCACHEBUF >= MAXBSIZE);
|
||||
mtx_init(&bqclean, "bufq clean lock", NULL, MTX_DEF);
|
||||
mtx_init(&bqdirty, "bufq dirty lock", NULL, MTX_DEF);
|
||||
mtx_init(&rbreqlock, "runningbufspace lock", NULL, MTX_DEF);
|
||||
@ -846,8 +847,8 @@ bufinit(void)
|
||||
* by the system.
|
||||
*/
|
||||
maxbufspace = (long)nbuf * BKVASIZE;
|
||||
hibufspace = lmax(3 * maxbufspace / 4, maxbufspace - MAXBSIZE * 10);
|
||||
lobufspace = hibufspace - MAXBSIZE;
|
||||
hibufspace = lmax(3 * maxbufspace / 4, maxbufspace - MAXBCACHEBUF * 10);
|
||||
lobufspace = hibufspace - MAXBCACHEBUF;
|
||||
|
||||
/*
|
||||
* Note: The 16 MiB upper limit for hirunningspace was chosen
|
||||
@ -857,9 +858,9 @@ bufinit(void)
|
||||
* The lower 1 MiB limit is the historical upper limit for
|
||||
* hirunningspace.
|
||||
*/
|
||||
hirunningspace = lmax(lmin(roundup(hibufspace / 64, MAXBSIZE),
|
||||
hirunningspace = lmax(lmin(roundup(hibufspace / 64, MAXBCACHEBUF),
|
||||
16 * 1024 * 1024), 1024 * 1024);
|
||||
lorunningspace = roundup((hirunningspace * 2) / 3, MAXBSIZE);
|
||||
lorunningspace = roundup((hirunningspace * 2) / 3, MAXBCACHEBUF);
|
||||
|
||||
/*
|
||||
* Limit the amount of malloc memory since it is wired permanently into
|
||||
@ -3073,8 +3074,9 @@ getblk(struct vnode *vp, daddr_t blkno, int size, int slpflag, int slptimeo,
|
||||
KASSERT((flags & (GB_UNMAPPED | GB_KVAALLOC)) != GB_KVAALLOC,
|
||||
("GB_KVAALLOC only makes sense with GB_UNMAPPED"));
|
||||
ASSERT_VOP_LOCKED(vp, "getblk");
|
||||
if (size > MAXBSIZE)
|
||||
panic("getblk: size(%d) > MAXBSIZE(%d)\n", size, MAXBSIZE);
|
||||
if (size > MAXBCACHEBUF)
|
||||
panic("getblk: size(%d) > MAXBCACHEBUF(%d)\n", size,
|
||||
MAXBCACHEBUF);
|
||||
if (!unmapped_buf_allowed)
|
||||
flags &= ~(GB_UNMAPPED | GB_KVAALLOC);
|
||||
|
||||
|
@ -233,10 +233,19 @@
|
||||
* and may be made smaller at the risk of not being able to use
|
||||
* filesystems which require a block size exceeding MAXBSIZE.
|
||||
*
|
||||
* MAXBCACHEBUF - Maximum size of a buffer in the buffer cache. This must
|
||||
* be >= MAXBSIZE and can be set differently for different
|
||||
* architectures by defining it in <machine/param.h>.
|
||||
* Making this larger allows NFS to do larger reads/writes.
|
||||
*
|
||||
* BKVASIZE - Nominal buffer space per buffer, in bytes. BKVASIZE is the
|
||||
* minimum KVM memory reservation the kernel is willing to make.
|
||||
* Filesystems can of course request smaller chunks. Actual
|
||||
* backing memory uses a chunk size of a page (PAGE_SIZE).
|
||||
* The default value here can be overridden on a per-architecture
|
||||
* basis by defining it in <machine/param.h>. This should
|
||||
* probably be done to increase its value, when MAXBCACHEBUF is
|
||||
* defined as a larger value in <machine/param.h>.
|
||||
*
|
||||
* If you make BKVASIZE too small you risk seriously fragmenting
|
||||
* the buffer KVM map which may slow things down a bit. If you
|
||||
@ -248,7 +257,12 @@
|
||||
* normal UFS filesystem.
|
||||
*/
|
||||
#define MAXBSIZE 65536 /* must be power of 2 */
|
||||
#ifndef MAXBCACHEBUF
|
||||
#define MAXBCACHEBUF MAXBSIZE /* must be a power of 2 >= MAXBSIZE */
|
||||
#endif
|
||||
#ifndef BKVASIZE
|
||||
#define BKVASIZE 16384 /* must be power of 2 */
|
||||
#endif
|
||||
#define BKVAMASK (BKVASIZE-1)
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user