kern/135039: mkstemp() fails over NFS when server uses ZFS (7-stable only)

Mike Andrews mandrews at
Thu May 28 19:00:07 UTC 2009

>Number:         135039
>Category:       kern
>Synopsis:       mkstemp() fails over NFS when server uses ZFS (7-stable only)
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 28 19:00:06 UTC 2009
>Originator:     Mike Andrews
>Release:        FreeBSD 7.2-STABLE amd64
Fark, Inc
System: FreeBSD 7.2-STABLE FreeBSD 7.2-STABLE #11: Mon May 25 19:10:00 EDT 2009 mandrews at amd64


	After the recent import of ZFS v13 into 7-STABLE, an mkstemp() call from an NFS client
	to a ZFS-backed NFS server will fail: the syscall returns EIO and the server will have
	created a 0-byte file with 000 permissions.  This breaks not just mktemp but also
	mv, tar, rsync...


	With both client/server running today's 7-STABLE:

	# dd if=/dev/random of=testfile bs=10000 count=1 >/dev/null 2>&1
	# mount another-72-stable-system:/zfs /mnt
	# cp testfile /mnt
	# mv testfile /mnt
	mv: /mnt/testfile: Input/output error
	# mktemp /mnt/testfile2
	mktemp: mkstemp failed on /mnt/testfile2: Input/output error
	# tar cf - testfile | (cd /mnt ; tar xpvf -)
	x testfile: Can't create 'testfile': Input/output error
	tar: Error exit delayed from previous errors.
	# rsync testfile /mnt
	rsync: mkstemp "/mnt/.testfile.0ycr51" failed: Input/output error (5)
	rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]
	# ls -l /mnt/testfile /mnt/.testfile*
	----------  1 root  wheel  0 May 28 14:16 /mnt/.testfile.0ycr51
	----------  1 root  wheel  0 May 28 14:16 /mnt/testfile

	ZFS on-disk format was upgraded to v13, unknown yet whether leaving it at
	v6 would have made a difference, but I suspect not :)

	Everything works as expected if the remote filesystem is UFS2.


	Kip Macy said there's a flags check that is too strict, in email message
	 <3c1674c90905280025i17039257l573838d33d8493fd at>

	Otherwise, use cp and rm instead of mv, or use scp instead of NFS, or use UFS2 on the server


More information about the freebsd-bugs mailing list