]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r326070: zfs_write: fix problem with writes appearing to succeed when over quota
authoravg <avg@FreeBSD.org>
Fri, 1 Dec 2017 11:13:58 +0000 (11:13 +0000)
committeravg <avg@FreeBSD.org>
Fri, 1 Dec 2017 11:13:58 +0000 (11:13 +0000)
commitc23f2016751bfe756df71e9c8c847f1922206359
tree6ca269554eec379c4ddf1f24d334177ef72c0bbe
parent301c736a882a41a5d740fe3e9b0058f477e4a45d
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().
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c