Fix several buffer cache issues related to B_NOCACHE.
* Do not set B_NOCACHE when calling vinvalbuf(... V_SAVE). This will
destroy dirty VM backing store associated with clean buffers before
the VM system has a chance to check for and flush them.
Taken-from: FreeBSD
* Properly set B_NOCACHE when destroying buffers related to truncated data.
* Fix a bug in vnode_pager_setsize() that was recently introduced.
v_filesize was being set before a new/old size comparison, causing a
file truncation to not destroy related VM pages past the new EOF.
* Remove a bogus B_NOCACHE|B_DIRTY test in brelse(). This was originally
intended to be a B_NOCACHE|B_DELWRITE test which then cleared B_NOCACHE,
but now that B_NOCACHE operation has been fixed it really does indicate that
the buffer, its contents, and its backing store are to be destroyed, even
if the buffer is marked B_DELWRI.
Instead of clearing B_NOCACHE when B_DELWRITE is found to be set, clear
B_DELWRITE when B_NOCACHE is found to be set.
Note that B_NOCACHE is still cleared when bdirty() is called in order to
ensure that data is not lost when softupdates and other code do a
'B_NOCACHE + bwrite' sequence. Softupdates can redirty a buffer in its
io completion hook and a write error can also redirty a buffer.
* The VMIO buffer rundown seems to have mophed into a state where the
distinction between NFS and non-NFS buffers can be removed. Remove
the test.