From nobody@FreeBSD.org  Mon Oct  1 15:27:28 2001
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 B585137B407
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  1 Oct 2001 15:27:28 -0700 (PDT)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.4/8.11.4) id f91MRSJ44207;
	Mon, 1 Oct 2001 15:27:28 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200110012227.f91MRSJ44207@freefall.freebsd.org>
Date: Mon, 1 Oct 2001 15:27:28 -0700 (PDT)
From: Wencheng Chai <wchai@prismedia.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: NFS client modification time resolution is not high enough, which may cause client side cache inconsistent
X-Send-Pr-Version: www-1.0

>Number:         30971
>Category:       kern
>Synopsis:       [nfs] NFS client modification time resolution is not high enough, which may cause client side cache inconsistent
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 01 15:30:00 PDT 2001
>Closed-Date:    Sat Mar 01 19:58:07 UTC 2008
>Last-Modified:  Sat Mar 01 19:58:07 UTC 2008
>Originator:     Wencheng Chai
>Release:        4.1 release
>Organization:
PRISMedia Networks Inc.
>Environment:
>Description:
The NFS client side stores the value of va_mtime only in total number 
of seconds(va_mtime.tv_sec), even the server sends the mtime in term of
seconds and nanoseconds.
>How-To-Repeat:
Two NFS clients mounted from the same exported FS,
Type "touch file1" and "touch file2" from different 
clients simultaneously, then type "ls -l" from the 
first client, the output of "ls" only shows file1.
>Fix:
*** /usr/src/sys/nfs/nfs_bio.c  Tue Aug 21 12:39:09 2001
--- nfs_bio.c   Wed Sep 12 03:45:03 2001
***************
*** 394,410 ****
                        if (error)
                                return (error);
                        np->n_mtime = vattr.va_mtime.tv_sec;
                } else {
                        error = VOP_GETATTR(vp, &vattr, cred, p);
                        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, p, 1);
                                if (error)
                                        return (error);
                                np->n_mtime = vattr.va_mtime.tv_sec;
                        }
                }
        }
--- 394,415 ----
                        if (error)
                                return (error);
                        np->n_mtime = vattr.va_mtime.tv_sec;
+                       np->n_vattr.va_mtime.tv_sec = vattr.va_mtime.tv_sec;
+                       np->n_vattr.va_mtime.tv_nsec = vattr.va_mtime.tv_nsec;
                } else {
                        error = VOP_GETATTR(vp, &vattr, cred, p);
                        if (error)
                                return (error);
!                       if ((np->n_vattr.va_mtime.tv_sec != vattr.va_mtime.tv_se
c)||((np->n_vattr.va_mtime.tv_sec == vattr.va_mtime.tv_sec)&&(np->n_vattr.va_mti
me.tv_nsec != vattr.va_mtime.tv_nsec))) {
                                if (vp->v_type == VDIR)
                                        nfs_invaldir(vp);
                                error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
                                if (error)
                                        return (error);
                                np->n_mtime = vattr.va_mtime.tv_sec;
+                               np->n_vattr.va_mtime.tv_sec = vattr.va_mtime.tv_
sec;
+                               np->n_vattr.va_mtime.tv_nsec = vattr.va_mtime.tv
_nsec;
+
                        }
                }
        }

======================================================================

*** /usr/src/sys/nfs/nfs_subs.c Sat Feb 12 19:32:06 2000
--- nfs_subs.c  Wed Sep 12 03:46:13 2001
***************
*** 1285,1290 ****
--- 1285,1292 ----
                        addaliasu(vp, rdev);
                }
                np->n_mtime = mtime.tv_sec;
+               np->n_vattr.va_mtime.tv_sec = mtime.tv_sec;
+               np->n_vattr.va_mtime.tv_nsec = mtime.tv_nsec;
        }
        vap = &np->n_vattr;
        vap->va_type = vtyp;
***************
*** 1303,1308 ****
--- 1305,1311 ----
                    fp->fa3_fileid.nfsuquad[1]);
                fxdr_nfsv3time(&fp->fa3_atime, &vap->va_atime);
                fxdr_nfsv3time(&fp->fa3_ctime, &vap->va_ctime);
+               fxdr_nfsv3time(&fp->fa3_mtime, &vap->va_mtime);
                vap->va_flags = 0;
                vap->va_filerev = 0;
        } else {
***************
*** 1315,1320 ****
--- 1318,1324 ----
                    * NFS_FABLKSIZE;
                vap->va_fileid = fxdr_unsigned(int32_t, fp->fa2_fileid);
                fxdr_nfsv2time(&fp->fa2_atime, &vap->va_atime);
+               fxdr_nfsv2time(&fp->fa2_mtime, &vap->va_mtime);
                vap->va_flags = 0;
                vap->va_ctime.tv_sec = fxdr_unsigned(u_int32_t,
                    fp->fa2_ctime.nfsv2_sec);

======================================================================
*** /usr/src/sys/nfs/nfs_vnops.c        Tue Aug 21 12:39:09 2001
--- nfs_vnops.c Wed Sep 12 03:48:46 2001
***************
*** 507,523 ****
                        if (error)
                                return (error);
                        np->n_mtime = vattr.va_mtime.tv_sec;
                } else {
                        error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p);
                        if (error)
                                return (error);
!                       if (np->n_mtime != vattr.va_mtime.tv_sec) {
                                if (vp->v_type == VDIR)
                                        np->n_direofoffset = 0;
                                if ((error = nfs_vinvalbuf(vp, V_SAVE,
                                        ap->a_cred, ap->a_p, 1)) == EINTR)
                                        return (error);
                                np->n_mtime = vattr.va_mtime.tv_sec;
                        }
                }
        }
--- 507,528 ----
                        if (error)
                                return (error);
                        np->n_mtime = vattr.va_mtime.tv_sec;
+                       np->n_vattr.va_mtime.tv_sec = vattr.va_mtime.tv_sec;
+                       np->n_vattr.va_mtime.tv_nsec = vattr.va_mtime.tv_nsec;
                } else {
                        error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p);
                        if (error)
                                return (error);
!                       if ((np->n_vattr.va_mtime.tv_sec != vattr.va_mtime.tv_se
c)||((np->n_vattr.va_mtime.tv_sec == vattr.va_mtime.tv_sec)&&(np->n_vattr.va_mti
me.tv_nsec != vattr.va_mtime.tv_nsec))) {
!
                                if (vp->v_type == VDIR)
                                        np->n_direofoffset = 0;
                                if ((error = nfs_vinvalbuf(vp, V_SAVE,
                                        ap->a_cred, ap->a_p, 1)) == EINTR)
                                        return (error);
                                np->n_mtime = vattr.va_mtime.tv_sec;
+                               np->n_vattr.va_mtime.tv_sec = vattr.va_mtime.tv_
sec;
+                               np->n_vattr.va_mtime.tv_nsec = vattr.va_mtime.tv
_nsec;
                        }
                }
        }
***************
*** 1260,1266 ****
                        }
                } else
                    nfsm_loadattr(vp, (struct vattr *)0);
!               if (wccflag)
                    VTONFS(vp)->n_mtime = VTONFS(vp)->n_vattr.va_mtime.tv_sec;
                m_freem(mrep);
                if (error)
--- 1265,1271 ----
                        }
                } else
                    nfsm_loadattr(vp, (struct vattr *)0);
!               if (wccflag)
                    VTONFS(vp)->n_mtime = VTONFS(vp)->n_vattr.va_mtime.tv_sec;
                m_freem(mrep);
                if (error)
***************
*** 2064,2071 ****
                                nfsstats.direofcache_hits++;
                                return (0);
                        }
!               } else if (VOP_GETATTR(vp, &vattr, ap->a_cred, uio->uio_procp) =
= 0 &&
!                       np->n_mtime == vattr.va_mtime.tv_sec) {
                        nfsstats.direofcache_hits++;
                        return (0);
                }
--- 2069,2075 ----
                                nfsstats.direofcache_hits++;
                                return (0);
                        }
!               } else if ((VOP_GETATTR(vp, &vattr, ap->a_cred, uio->uio_procp)
== 0) &&((np->n_vattr.va_mtime.tv_sec != vattr.va_mtime.tv_sec)||((np->n_vattr.v
a_mtime.tv_sec == vattr.va_mtime.tv_sec)&&(np->n_vattr.va_mtime.tv_nsec != vattr
.va_mtime.tv_nsec)))) {
                        nfsstats.direofcache_hits++;
                        return (0);
                }

======================================================================






>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->peter 
Responsible-Changed-By: dougb 
Responsible-Changed-When: Sat Oct 6 15:29:08 PDT 2001 
Responsible-Changed-Why:  

Looks like a job for EvilPete 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=30971 
State-Changed-From-To: open->feedback 
State-Changed-By: kmacy 
State-Changed-When: Fri Nov 16 17:31:12 UTC 2007 
State-Changed-Why:  

Is this still a problem? I haven't seen this. 


Responsible-Changed-From-To: peter->freebsd-bugs 
Responsible-Changed-By: kmacy 
Responsible-Changed-When: Fri Nov 16 17:31:12 UTC 2007 
Responsible-Changed-Why:  

Is this still a problem? I haven't seen this.  

http://www.freebsd.org/cgi/query-pr.cgi?pr=30971 
State-Changed-From-To: feedback->closed 
State-Changed-By: linimon 
State-Changed-When: Sat Mar 1 19:57:43 UTC 2008 
State-Changed-Why:  
Feedback timeout (> 3 months). 

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