diff options
author | tjr <tjr@FreeBSD.org> | 2003-07-29 00:17:29 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2003-07-29 00:17:29 +0000 |
commit | f4b299adc08466d37a9882c6460ecce0a1505a45 (patch) | |
tree | 4f9da5e34efed285c8df8fbf5b49b547d23442c5 /sys/nfsclient | |
parent | e669733309fbc4dc64ccfd18e35a59f5075138e7 (diff) | |
download | FreeBSD-src-f4b299adc08466d37a9882c6460ecce0a1505a45.zip FreeBSD-src-f4b299adc08466d37a9882c6460ecce0a1505a45.tar.gz |
Fix a problem that occurs when truncating files on NFSv3 mounts: we need
to set np->n_size back to the desired size again after calling
nfs_meta_setsize(), since it could end up in nfs_loadattrcache() getting
called, which would change n_size back to the value it had before the
truncate request was issued. The result of this bug is that the size info
cached in the nfsnode becomes incorrect, lseek(fd, ofs, SEEK_END) seeks
past the end of the file, stat() returns the wrong size, etc.
PR: 41792
MFC after: 2 weeks
Diffstat (limited to 'sys/nfsclient')
-rw-r--r-- | sys/nfsclient/nfs_vnops.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index 2e4fe05..158e76f 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -662,7 +662,13 @@ nfs_setattr(struct vop_setattr_args *ap) return (error); } } - np->n_vattr.va_size = vap->va_size; + /* + * np->n_size has already been set to vap->va_size + * in nfs_meta_setsize(). We must set it again since + * nfs_loadattrcache() could be called through + * nfs_meta_setsize() and could modify np->n_size. + */ + np->n_vattr.va_size = np->n_size = vap->va_size; }; } else if ((vap->va_mtime.tv_sec != VNOVAL || vap->va_atime.tv_sec != VNOVAL) && (np->n_flag & NMODIFIED) && |