Re: [newnfs/client] -alldirs: listing files consumes too much memory

From: Rick Macklem <rmacklem_at_uoguelph.ca>
Date: Fri, 17 Jul 2009 15:30:43 -0400 (EDT)
On Thu, 16 Jul 2009, Anonymous wrote:

> Let's create 335 empty files in /blah and try to list them over nfsv3.
>
> # uname -vm
> FreeBSD 8.0-BETA1 #0: Sat Jul  4 03:55:14 UTC 2009     root_at_almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
>
> # mkdir /blah
> # (while [ $((i+=1)) -le 334 ]; do : >/blah/foo_$i; done)
> # echo / -alldirs >/etc/exports
> # /etc/rc.d/nfsd onestart
> # mount -t newnfs -o nfsv3 0:/blah /mnt
>
Ok, I figured it out. I wasn't setting mp->mnt_stat.f_iosize before
getting the root vnode and, as such, getnewvnode() was setting
bo_bsize = 0. That confused getblk(), so it would always end up
returning block0, since it uses bo_bsize for a block calc.

The patch follows, in case you're interested in testing it.
(I'll be queuing this patch up with re_at_ once I've tested it some more.)

Thanks again for pointing the problem out, rick
-- patch for exp. nfs client --
--- fs/nfsclient/nfs_clvfsops.c.sav	2009-07-17 12:18:42.000000000 -0400
+++ fs/nfsclient/nfs_clvfsops.c	2009-07-17 15:09:41.000000000 -0400
_at__at_ -1194,6 +1194,12 _at__at_
  		}
  	}
  	if (nmp->nm_fhsize > 0) {
+		/*
+		 * Set f_iosize to NFS_DIRBLKSIZ so that bo_bsize gets set
+		 * non-zero for the root vnode. f_iosize will be set correctly
+		 * by nfs_statfs() before any I/O occurs.
+		 */
+		mp->mnt_stat.f_iosize = NFS_DIRBLKSIZ;
  		error = ncl_nget(mp, nmp->nm_fh, nmp->nm_fhsize, &np);
  		if (error)
  			goto bad;
Received on Fri Jul 17 2009 - 17:28:08 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:52 UTC