Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Jan 2001 11:08:21 -0800 (PST)
From:      Matt Dillon <dillon@earth.backplane.com>
To:        freebsd-stable@FreeBSD.ORG
Subject:   Re: NFSv3 O_EXCL file create - protocol spec & solution (was Re: Bug in NFSv3 client)
Message-ID:  <200101061908.f06J8LI13763@earth.backplane.com>
References:  <20010103155533.B71238@math.uic.edu> <200101032243.f03Mhar51440@earth.backplane.com> <200101032308.f03N84f51776@earth.backplane.com> <200101032322.f03NMTK51973@earth.backplane.com> <200101040754.f047sUW55674@earth.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help
    The fix has been MFCd' to -stable.

    I would like to MFC the fix to 3.x as well since that was what the
    original PR was filed under, but I have no 3.x machines to test it on.
    If someone with a 3.x machine and source tree could test
    the patch included at the end and give me a yah or nay, I'd appreciate it.

    The patch is the same as for 4.x and 5.x except vfs_timestamp() turns 
    into getnanotime().  

    To test, run the patch on a 3.x NFS client.  The NFS server can be any
    FreeBSD release.  Create a file using this program:

#include <stdio.h>
#include <fcntl.h>

int
main(int ac, char **av)
{
    int fd;

    fd = open("test.dat", O_CREAT|O_TRUNC|O_EXCL|O_RDWR, 0644);
    printf("fd = %d\n", fd);
    exit(0);
}

    And then 'ls -lua test.dat'.  To repeat the test, remove test.dat
    and run the program again.  Without the patch the file access time
    shown by ls should be garbage.  With the patch it should be reasonable.

						Thanks,

						-Matt

Index: nfs_vnops.c
===================================================================
RCS file: /home/ncvs/src/sys/nfs/nfs_vnops.c,v
retrieving revision 1.116.2.8
diff -u -r1.116.2.8 nfs_vnops.c
--- nfs_vnops.c	1999/12/12 06:52:34	1.116.2.8
+++ nfs_vnops.c	2001/01/06 19:02:44
@@ -1407,8 +1407,21 @@
 		}
 		if (newvp)
 			vput(newvp);
-	} else if (v3 && (fmode & O_EXCL))
+	} else if (v3 && (fmode & O_EXCL)) {
+		/*
+		 * We are normally called with only a partially initialized
+		 * VAP.  Since the NFSv3 spec says that server may use the
+		 * file attributes to store the verifier, the spec requires
+		 * us to do a SETATTR RPC. FreeBSD servers store the verifier
+		 * in atime, but we can't really assume that all servers will
+		 * so we ensure that our SETATTR sets both atime and mtime.
+		 */
+		if (vap->va_mtime.tv_sec == VNOVAL)
+			getnanotime(&vap->va_mtime);
+		if (vap->va_atime.tv_sec == VNOVAL)
+			vap->va_atime = vap->va_mtime;
 		error = nfs_setattrrpc(newvp, vap, cnp->cn_cred, cnp->cn_proc);
+	}
 	if (!error) {
 		if (cnp->cn_flags & MAKEENTRY)
 			cache_enter(dvp, newvp, cnp);


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101061908.f06J8LI13763>