Subject: kern/21696 again
To: None <tech-net@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-net
Date: 06/28/2003 18:52:11
--YZ5djTAD1cGYuMQK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
commit back (a bit late, I can't say otherwise) about the problem I explained
in kern/21696 (in a nutshell: nfsrv_commit() may call VOP_FSYNC() with
range past the end of file because of unchecked arguments, triggering
a diagnostic panic later). Based on comments from YAMAMOTO Takashi and
Chuck Silvers here is a new patch, which makes the code return OK to the client
without doing the flush when offset is past the end of file.
The rationale for this (pointed out by Chuck) is that because of races
between the clients, we can expect to have commit requests past the end
of files. This is also why I didn't add messages logs for this, as
suggested by Christos Zoulas.
If noone object, I'll commit this in a few days.
Note that this doesn't address the other issue raised by Chuck: commit and
truncate ops needs to be serialised. I'll let peoples familiar with
vnode locking issues handle it.
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 24 ans d'experience feront toujours la difference
--
--YZ5djTAD1cGYuMQK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="diff.nfs"
Index: nfs_serv.c
===================================================================
RCS file: /cvsroot/src/sys/nfs/nfs_serv.c,v
retrieving revision 1.76
diff -u -r1.76 nfs_serv.c
--- nfs_serv.c 2003/06/09 13:10:31 1.76
+++ nfs_serv.c 2003/06/28 16:42:02
@@ -3135,7 +3135,9 @@
end = (cnt > 0) ? off + cnt : vp->v_size;
if (end < off || end > vp->v_size)
end = vp->v_size;
- error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, procp);
+ if (off < vp->v_size)
+ error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, procp);
+ /* else error == 0, from nfsrv_fhtovp() */
aft_ret = VOP_GETATTR(vp, &aft, cred, procp);
vput(vp);
nfsm_reply(NFSX_V3WCCDATA + NFSX_V3WRITEVERF);
--YZ5djTAD1cGYuMQK--