Date: Fri, 18 Jul 2003 16:41:20 +1000 From: Tim Robbins <tjr@FreeBSD.ORG> To: freebsd-fs@freebsd.org Subject: NFS ftruncate patch for review Message-ID: <20030718064120.GA72366@dilbert.robbins.dropbear.id.au>
next in thread | raw e-mail | index | archive | help
Any comments on this patch? The referenced PR contains more comments and a test program. It's not obvious from the diff, but the changes are to nfs_setattr() in the va_size != VNOVAL && v_type == VREG case. Change 34590 by tjr@tjr_dev on 2003/07/16 04:40:35 Fix a nasty problem when truncating files over NFS that was introduced between FreeBSD 4.4 and 4.5: we need to set np->n_size again after flushing/truncating buffers in case the cache calls nfs_write(). For example, if the file is truncated to 0 bytes, nfs_write() will often detect that the file is being appended to (since the file is 0 bytes long and we're writing to offset 0), so it then updates np->n_size to reflect the size the file was before it was truncated. PR: 41792 Affected files ... ... //depot/user/tjr/freebsd-tjr/src/sys/nfsclient/nfs_vnops.c#7 edit Differences ... ==== //depot/user/tjr/freebsd-tjr/src/sys/nfsclient/nfs_vnops.c#7 (text+ko) ==== @@ -662,7 +662,13 @@ 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_write() could be called when flushing dirty + * buffers, and nfs_write() can 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) &&
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030718064120.GA72366>