Date: Sun, 19 Apr 2015 19:57:22 -0400 (EDT) From: Rick Macklem <rmacklem@uoguelph.ca> To: FreeBSD Filesystems <freebsd-fs@freebsd.org> Subject: Patch that defines MAXBCACHEBUF separate from MAXBSIZE for review Message-ID: <1552767461.21885039.1429487842728.JavaMail.root@uoguelph.ca> In-Reply-To: <963641485.21885012.1429487839649.JavaMail.root@uoguelph.ca>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] Hi, MAXBSIZE is both the maximum UFS block size and the maximum size of a buffer cache block. This patch defines MAXBCACHEBUF as a separate constant that is the maximum size of a buffer cache block. This allows it to be set on a per-architecture basis and, therefore, can be made larger than MAXBSIZE so that the NFS client can do larger reads/writes, for 64bit architectures. The patch is here for review: https://reviews.freebsd.org/D2330 and is also attached. Since I've never used Phabricator, I suspect it's messed up, but just email if you want to review this or comment and can't do it in phabricator. rick [-- Attachment #2 --] --- kern/vfs_bio.c.savbuf 2015-03-30 21:24:39.000000000 -0400 +++ kern/vfs_bio.c 2015-04-18 17:55:16.000000000 -0400 @@ -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, 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); --- fs/nfsclient/nfs_clvfsops.c.savbuf 2015-04-17 17:25:01.000000000 -0400 +++ fs/nfsclient/nfs_clvfsops.c 2015-04-18 18:02:25.000000000 -0400 @@ -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 --- fs/nfs/nfsport.h.savbuf 2015-03-30 21:51:05.000000000 -0400 +++ fs/nfs/nfsport.h 2015-03-30 21:51:38.000000000 -0400 @@ -952,7 +952,7 @@ struct nfsreq { }; #ifndef NFS_MAXBSIZE -#define NFS_MAXBSIZE MAXBSIZE +#define NFS_MAXBSIZE MAXBCACHEBUF #endif /* --- sys/param.h.savbuf 2015-03-27 22:10:14.000000000 -0400 +++ sys/param.h 2015-04-19 08:51:22.000000000 -0400 @@ -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) /*help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1552767461.21885039.1429487842728.JavaMail.root>
