9.1-RELEASE nfs client seems to have a problem with dir read (listing) when the system is mounted with nfsv3,rsize=4096,wsize=4096 or nfsv3,rsize=2049,wsize=2048 (may be others sizes too). Some of the file names are missing from the result and others are duplicated. Tried with 7.2-STABLE FreeBSD and Linux 2.6.32.12 as server, same result. The nfs_bug.py works ok under FreeBSD 8.2. Fix: Mounting the nfs dir with defaults does not show the problem. Changing to nfsv2 or other rsize/wsize combinations seem to be ok (i.e. rsize=8192,wsize=8192 looks ok for now). How-To-Repeat: mount -o nfsv3,rsize=4096,wsize=4096 server:/export /mnt Run the python nfs_bug.py program from http://www.delajii.net/mmWiKi/_media/docs:code:nfs_bug.py
Responsible Changed From-To: freebsd-bugs->freebsd-fs Over to maintainer(s).
This still exists in releng/10.2. Any solutions?
I've noticed difference between mounting with wsize and without wsize: # mount -o rsize=2048 10.0.0.2:/home/kh /home/kh/ root@freebsd9:~ # ls -1 /home/kh/fenykepek/20110429 | sort | uniq | wc -l 309 # umount /home/kh/ # mount -o rsize=2048,wsize=2048 10.0.0.2:/home/kh /home/kh/ # ls -1 /home/kh/fenykepek/20110429 | sort | uniq | wc -l 225 Dont know if this helps.
Created attachment 162553 [details] patch to fix this problem I think this patch will fix the problem. When f_iosize which sets bo_bsize is less than the size of a buffer cache buffer problems occur. NFS_DIRBLKSIZ (8K) is the size of the buffer cache blocks used for directories and without this patch, rsize=4096 would set f_iosize->bo_bsize to 4096.
I think the attached patch fixes the problem, which I believe woudl only occur when rsize was set to less than NFS_DIRBLKSIZ (8K).
Seems that for my simple test case it works, it gaves the expected directory listing.
A commit references this bug: Author: rmacklem Date: Tue Nov 17 01:44:26 UTC 2015 New revision: 290970 URL: https://svnweb.freebsd.org/changeset/base/290970 Log: mnt_stat.f_iosize (which is used to set bo_bsize) must be set to the largest size of buffer cache block or the mapping of the buffer is bogus. When a mount with rsize=4096,wsize=4096 was done, f_iosize would be set to 4096. This resulted in corrupted directory data, since the buffer cache block size for directories is NFS_DIRBLKSIZ (8192). This patch fixes the code so that it always sets f_iosize to at least NFS_DIRBLKSIZ. Tested by: krichy@cflinux.hu PR: 177971 MFC after: 2 weeks Changes: head/sys/fs/nfsclient/nfs_clvfsops.c
The patch that fixes this has been committed to stable/10 as r291551 and stable/9 as r291552.