Date: Fri, 9 Oct 2020 20:31:43 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366587 - head/sys/kern Message-ID: <202010092031.099KVhxm040734@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Fri Oct 9 20:31:42 2020 New Revision: 366587 URL: https://svnweb.freebsd.org/changeset/base/366587 Log: vfs: fix a panic when truncating comming from copy_file_range Truncating requires an exclusive lock, but it was not taken if the filesystem indicates support for shared writes. This only concerns ZFS. In particular fixes cp of files which have trailing holes. Reported by: bdrewery Modified: head/sys/kern/vfs_vnops.c Modified: head/sys/kern/vfs_vnops.c ============================================================================== --- head/sys/kern/vfs_vnops.c Fri Oct 9 20:30:27 2020 (r366586) +++ head/sys/kern/vfs_vnops.c Fri Oct 9 20:31:42 2020 (r366587) @@ -2975,18 +2975,22 @@ vn_write_outvp(struct vnode *outvp, char *dat, off_t o bwillwrite(); mp = NULL; error = vn_start_write(outvp, &mp, V_WAIT); - if (error == 0) { + if (error != 0) + break; + if (growfile) { + error = vn_lock(outvp, LK_EXCLUSIVE); + if (error == 0) { + error = vn_truncate_locked(outvp, outoff + xfer, + false, cred); + VOP_UNLOCK(outvp); + } + } else { if (MNT_SHARED_WRITES(mp)) lckf = LK_SHARED; else lckf = LK_EXCLUSIVE; error = vn_lock(outvp, lckf); - } - if (error == 0) { - if (growfile) - error = vn_truncate_locked(outvp, outoff + xfer, - false, cred); - else { + if (error == 0) { error = vn_rdwr(UIO_WRITE, outvp, dat, xfer2, outoff, UIO_SYSSPACE, IO_NODELOCKED, curthread->td_ucred, cred, NULL, curthread);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202010092031.099KVhxm040734>