opnsense-src/sys/fs
Rick Macklem a820822ec8 A problem with the old NFS client where large writes to large files
would sometimes result in a corrupted file was reported via email.
This problem appears to have been caused by r251719 (reverting
r251719 fixed the problem). Although I have not been able to
reproduce this problem, I suspect it is caused by another thread
increasing np->n_size after the mtx_unlock(&np->n_mtx) but before
the vnode_pager_setsize() call. Since the np->n_mtx mutex serializes
updates to np->n_size, doing the vnode_pager_setsize() with the
mutex locked appears to avoid the problem.
Unfortunately, vnode_pager_setsize() where the new size is smaller,
cannot be called with a mutex held.
This patch returns the semantics to be close to pre-r251719 (actually
pre-r248567, r248581, r248567 for the new client) such that the call to
vnode_pager_setsize() is only delayed until after the mutex is
unlocked when np->n_size is shrinking. Since the file is growing
when being written, I believe this will fix the corruption.
A better solution might be to replace the mutex with a sleep lock,
but that is a non-trivial conversion, so this fix is hoped to be
sufficient in the meantime.

Reported by:	David G. Lawrence (dg@dglawrence.com)
Tested by:	David G. Lawrence (to be done soon)
Reviewed by:	kib
MFC after:	1 week
2013-07-03 00:19:03 +00:00
..
cd9660 Add currently unused flag argument to the cluster_read(), 2013-03-14 20:28:26 +00:00
deadfs The deadfs VOPs for vop_ioctl and vop_bmap call itself recursively, 2012-09-13 13:05:45 +00:00
devfs - Correct mispellings of the word necessary 2013-04-17 11:42:40 +00:00
ext2fs ext2fs: Use the complete random() range in i_gen. 2013-06-30 00:42:51 +00:00
fdescfs Fix several typos 2013-05-12 16:43:26 +00:00
fifofs I am comparing current pipe code with the one in 8.3-STABLE r236165, 2012-07-31 05:48:35 +00:00
fuse Switch the vm_object mutex to be a rwlock. This will enable in the 2013-03-09 02:32:23 +00:00
msdosfs The fsync(2) call should sync the vnode in such way that even after 2013-05-02 20:00:11 +00:00
nandfs - Convert the bufobj lock to rwlock. 2013-05-31 00:43:41 +00:00
nfs Revamp the old NFS server's File Handle Affinity (FHA) code so that 2013-04-17 21:00:22 +00:00
nfsclient A problem with the old NFS client where large writes to large files 2013-07-03 00:19:03 +00:00
nfsserver - Convert the bufobj lock to rwlock. 2013-05-31 00:43:41 +00:00
nullfs Do not leak the NULLV_NOUNLOCK flag from the nullfs_unlink_lowervp(), 2013-05-21 11:31:56 +00:00
procfs Relax the vm object locking. Use a read lock. 2013-06-05 17:00:10 +00:00
pseudofs Complete MPSAFE VFS interface and remove MNTK_MPSAFE flag. 2012-11-09 18:02:25 +00:00
smbfs Properly use v_data field. This magically worked (even if wrong) until 2013-06-28 20:32:48 +00:00
tmpfs Add missing VM object unlocks in an error case. 2013-06-07 19:42:00 +00:00
udf Add currently unused flag argument to the cluster_read(), 2013-03-14 20:28:26 +00:00
unionfs r16312 is not any longer real since many years (likely since when VFS 2012-11-19 22:43:45 +00:00