From nobody@FreeBSD.org  Sat Apr 27 04:52:14 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id B29E137B419
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 27 Apr 2002 04:52:13 -0700 (PDT)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g3RBqDm27744;
	Sat, 27 Apr 2002 04:52:13 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200204271152.g3RBqDm27744@freefall.freebsd.org>
Date: Sat, 27 Apr 2002 04:52:13 -0700 (PDT)
From: Robert Morris <rtm@lcs.mit.edu>
To: freebsd-gnats-submit@FreeBSD.org
Subject: NFS client ignores mtime.tv_usec for open/close cache consistency
X-Send-Pr-Version: www-1.0

>Number:         37502
>Category:       kern
>Synopsis:       [nfs] NFS client ignores mtime.tv_usec for open/close cache consistency
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    cel
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Apr 27 05:00:02 PDT 2002
>Closed-Date:    Tue May 23 19:24:43 GMT 2006
>Last-Modified:  Tue May 23 19:24:43 GMT 2006
>Originator:     Robert Morris
>Release:        4.5
>Organization:
MIT/LCS
>Environment:
FreeBSD nephron.lcs.mit.edu 4.5-RELEASE FreeBSD 4.5-RELEASE #3: Thu Apr 11 11:59:46 EDT 2002     rtm@nephron.lcs.mit.edu:/usr/src/sys/compile/PDOS-X23  i386
>Description:
When you open a file, the NFS client code doesn't always
correctly notice whether the file has been changed on the
server, and thus doesn't always correctly ignore stale
cached blocks for that file. The NFS client code looks to
see if the file's mtime has changed, but only checks the
seconds, not the microseconds. So reading a file that changes twice
in rapid succession may yield stale data.
>How-To-Repeat:
Two clients, X and Y, mount the same NFS file system. Do this
sequence all within the same second of time:

X% echo 111 > foo
Y% cat foo
X% echo 222 > foo
Y% cat foo

The correct answer is 222, but you will sometimes get 111.

>Fix:
The following code from nfs_bio.c should check whether the
mtime microseconds (and perhaps file length) have changed,
as well as checking the seconds:

      		error = VOP_GETATTR(vp, &vattr, cred, td);
		if (error)
			return (error);
		if (np->n_mtime != vattr.va_mtime.tv_sec) {
			if (vp->v_type == VDIR)
				nfs_invaldir(vp);
			error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1);

>Release-Note:
>Audit-Trail:

From: Robert Morris <rtm@lcs.mit.edu>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: kern/37502: NFS client ignores mtime.tv_usec for open/close cache consistency
Date: Sat, 27 Apr 2002 04:52:13 -0700 (PDT)

 >Number:         37502
 >Category:       kern
 >Synopsis:       NFS client ignores mtime.tv_usec for open/close cache consistency
 >Confidential:   no
 >Severity:       serious
 >Priority:       medium
 >Responsible:    freebsd-bugs
 >State:          open
 >Quarter:        
 >Keywords:       
 >Date-Required:
 >Class:          sw-bug
 >Submitter-Id:   current-users
 >Arrival-Date:   Sat Apr 27 05:00:02 PDT 2002
 >Closed-Date:
 >Last-Modified:
 >Originator:     Robert Morris
 >Release:        4.5
 >Organization:
 MIT/LCS
 >Environment:
 FreeBSD nephron.lcs.mit.edu 4.5-RELEASE FreeBSD 4.5-RELEASE #3: Thu Apr 11 11:59:46 EDT 2002     rtm@nephron.lcs.mit.edu:/usr/src/sys/compile/PDOS-X23  i386
 >Description:
 When you open a file, the NFS client code doesn't always
 correctly notice whether the file has been changed on the
 server, and thus doesn't always correctly ignore stale
 cached blocks for that file. The NFS client code looks to
 see if the file's mtime has changed, but only checks the
 seconds, not the microseconds. So reading a file that changes twice
 in rapid succession may yield stale data.
 >How-To-Repeat:
 Two clients, X and Y, mount the same NFS file system. Do this
 sequence all within the same second of time:
 
 X% echo 111 > foo
 Y% cat foo
 X% echo 222 > foo
 Y% cat foo
 
 The correct answer is 222, but you will sometimes get 111.
 
 >Fix:
 The following code from nfs_bio.c should check whether the
 mtime microseconds (and perhaps file length) have changed,
 as well as checking the seconds:
 
       		error = VOP_GETATTR(vp, &vattr, cred, td);
 		if (error)
 			return (error);
 		if (np->n_mtime != vattr.va_mtime.tv_sec) {
 			if (vp->v_type == VDIR)
 				nfs_invaldir(vp);
 			error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1);
 
 >Release-Note:
 >Audit-Trail:
 >Unformatted:
 
 To Unsubscribe: send mail to majordomo@FreeBSD.org
 with "unsubscribe freebsd-bugs" in the body of the message
 
Responsible-Changed-From-To: freebsd-bugs->cel 
Responsible-Changed-By: cel 
Responsible-Changed-When: Wed May 10 19:07:41 UTC 2006 
Responsible-Changed-Why:  
cel takes an NFS client bug. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=37502 
State-Changed-From-To: open->closed 
State-Changed-By: cel 
State-Changed-When: Tue May 23 19:23:24 UTC 2006 
State-Changed-Why:  
After a code review in CURRENT, it appears that this issue has already been 
addressed via a macro called NFS_TIMESPEC_COMPARE.  There is one missing 
check in nfs4_readdir() which was probably added after this PR was opened. 
I will submit a fix for this soon. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=37502 
>Unformatted:
