]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r326070: zfs_write: fix problem with writes appearing to succeed when over quota
authoravg <avg@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 1 Dec 2017 11:14:13 +0000 (11:14 +0000)
committeravg <avg@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 1 Dec 2017 11:14:13 +0000 (11:14 +0000)
commiteb086596e994fa79256949e43396dd340528476f
tree60fa819336ba46d86ea802b143cff64e36a17828
parent32ca75f1107425f25e43110d55c67df32a301091
MFC r326070: zfs_write: fix problem with writes appearing to succeed when over quota

The problem happens when the writes have offsets and sizes aligned with
a filesystem's recordsize (maximum block size).  In this scenario
dmu_tx_assign() would fail because of being over the quota, but the uio
would already be modified in the code path where we copy data from the
uio into a borrowed ARC buffer.  That makes an appearance of a partial
write, so zfs_write() would return success and the uio would be modified
consistently with writing a single block.

That bug can result in a data loss because the writes over the quota
would appear to succeed while the actual data is being discarded.

This commit fixes the bug by ensuring that the uio is not changed until
after all error checks are done.  To achieve that the code now uses
uiocopy() + uioskip() as in the original illumos design.  We can do that
now that uiocopy() has been updated in r326067 to use
vn_io_fault_uiomove().

git-svn-id: svn://svn.freebsd.org/base/stable/10@326428 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c