Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jun 2017 00:21:08 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r319924 - in projects/pnfs-planb-server-stable11/sys/fs: nfs nfsserver
Message-ID:  <201706140021.v5E0L8WQ067607@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Wed Jun 14 00:21:08 2017
New Revision: 319924
URL: https://svnweb.freebsd.org/changeset/base/319924

Log:
  Add support for atime to the set of attributes updated through the DS file.
  Also add the DS file name to the pnfsd.dsfile attribute, so it will still
  be removed if the FH of the metadata file were to change, due to a
  backup/recovery of the metadata exported directory tree.

Modified:
  projects/pnfs-planb-server-stable11/sys/fs/nfs/nfs_var.h
  projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsrvstate.h
  projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdport.c
  projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdserv.c
  projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdstate.c

Modified: projects/pnfs-planb-server-stable11/sys/fs/nfs/nfs_var.h
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfs/nfs_var.h	Tue Jun 13 23:50:55 2017	(r319923)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfs/nfs_var.h	Wed Jun 14 00:21:08 2017	(r319924)
@@ -109,9 +109,9 @@ int nfsrv_openctrl(struct nfsrv_descript *, vnode_t,
 int nfsrv_opencheck(nfsquad_t, nfsv4stateid_t *, struct nfsstate *,
     vnode_t, struct nfsrv_descript *, NFSPROC_T *, int);
 int nfsrv_openupdate(vnode_t, struct nfsstate *, nfsquad_t,
-    nfsv4stateid_t *, struct nfsrv_descript *, NFSPROC_T *, int *);
+    nfsv4stateid_t *, struct nfsrv_descript *, NFSPROC_T *);
 int nfsrv_delegupdate(struct nfsrv_descript *, nfsquad_t, nfsv4stateid_t *,
-    vnode_t, int, struct ucred *, NFSPROC_T *, int *);
+    vnode_t, int, struct ucred *, NFSPROC_T *);
 int nfsrv_releaselckown(struct nfsstate *, nfsquad_t, NFSPROC_T *);
 void nfsrv_zapclient(struct nfsclient *, NFSPROC_T *);
 int nfssvc_idname(struct nfsd_idargs *);

Modified: projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsrvstate.h
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsrvstate.h	Tue Jun 13 23:50:55 2017	(r319923)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfs/nfsrvstate.h	Wed Jun 14 00:21:08 2017	(r319924)
@@ -343,12 +343,13 @@ struct nfsdevice {
 TAILQ_HEAD(nfsdevicehead, nfsdevice);
 
 /*
- * This structure holds the va_size, va_filerev and va_mtime for the DS
- * file and is stored in the metadata file's extended attribute pnfsd.dsattr.
+ * This structure holds the va_size, va_filerev, va_atime and va_mtime for the
+ * DS file and is stored in the metadata file's extended attribute pnfsd.dsattr.
  */
 struct pnfsdsattr {
 	uint64_t	dsa_filerev;
 	uint64_t	dsa_size;
+	struct timespec	dsa_atime;
 	struct timespec	dsa_mtime;
 };
 
@@ -357,8 +358,8 @@ struct pnfsdsattr {
 /*
  * This structure holds the information about the DS file and is stored
  * in the metadata file's extended attribute called pnfsd.dsfile.
- * dsf_nam[0] is defined as the actual length of sa_len for the addr.
  */
+#define	PNFS_FILENAME_LEN	(2 * sizeof(fhandle_t))
 struct pnfsdsfile {
 	fhandle_t	dsf_fh;
 	uint32_t	dsf_dir;
@@ -366,6 +367,7 @@ struct pnfsdsfile {
 		struct sockaddr_in	sin;
 		struct sockaddr_in6	sin6;
 	} dsf_nam;
+	char		dsf_filename[PNFS_FILENAME_LEN + 1];
 };
 #define	dsf_sin		dsf_nam.sin
 #define	dsf_sin6	dsf_nam.sin6

Modified: projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdport.c	Tue Jun 13 23:50:55 2017	(r319923)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdport.c	Wed Jun 14 00:21:08 2017	(r319924)
@@ -97,13 +97,13 @@ extern struct nfsdevicehead nfsrv_devidhead;
 static void nfsrv_pnfscreate(struct vnode *, struct vattr *, struct ucred *,
     NFSPROC_T *);
 static void nfsrv_pnfsremovesetup(struct vnode *, NFSPROC_T *, struct vnode **,
-    fhandle_t *);
-static void nfsrv_pnfsremove(struct vnode *, fhandle_t *, NFSPROC_T *);
+    fhandle_t *, char *);
+static void nfsrv_pnfsremove(struct vnode *, fhandle_t *, char *, NFSPROC_T *);
 static int nfsrv_proxyds(struct nfsrv_descript *, struct vnode *, off_t, int,
     struct ucred *, struct thread *, int, struct mbuf **, char *,
     struct mbuf **, struct nfsvattr *, struct acl *);
-static int nfsrv_dsgetsockmnt(struct vnode *, int, char *, int,
-    NFSPROC_T *, struct vnode **, struct nfsmount **, fhandle_t *, char *);
+static int nfsrv_dsgetsockmnt(struct vnode *, int, char *, int, NFSPROC_T *,
+    struct vnode **, struct nfsmount **, fhandle_t *, char *, char *);
 static int nfsrv_setextattr(struct vnode *, struct nfsvattr *, NFSPROC_T *);
 static int nfsrv_readdsrpc(fhandle_t *, off_t, int, struct ucred *,
     NFSPROC_T *, struct nfsmount *, struct mbuf **, struct mbuf **);
@@ -271,6 +271,7 @@ nfsvno_getattr(struct vnode *vp, struct nfsvattr *nvap
 	    (nd->nd_flag & ND_NFSV4) == 0 ||
 	    NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_CHANGE) ||
 	    NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_SIZE) ||
+	    NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEACCESS) ||
 	    NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEMODIFY))) {
 		error = nfsrv_proxyds(nd, vp, 0, 0, nd->nd_cred, p,
 		    NFSPROC_GETATTR, NULL, NULL, NULL, &na, NULL);
@@ -287,6 +288,7 @@ nfsvno_getattr(struct vnode *vp, struct nfsvattr *nvap
 	 * replace them.
 	 */
 	if (gotattr != 0) {
+		nvap->na_atime = na.na_atime;
 		nvap->na_mtime = na.na_mtime;
 		nvap->na_filerev = na.na_filerev;
 		nvap->na_size = na.na_size;
@@ -427,6 +429,7 @@ nfsvno_setattr(struct vnode *vp, struct nfsvattr *nvap
 	    nvap->na_vattr.va_gid != (gid_t)VNOVAL ||
 	    nvap->na_vattr.va_size != VNOVAL ||
 	    nvap->na_vattr.va_mode != (mode_t)VNOVAL ||
+	    nvap->na_vattr.va_atime.tv_sec != VNOVAL ||
 	    nvap->na_vattr.va_mtime.tv_sec != VNOVAL)) {
 		/* For a pNFS server, set the attributes on the DS file. */
 		error = nfsrv_proxyds(NULL, vp, 0, 0, cred, p, NFSPROC_SETATTR,
@@ -1194,6 +1197,7 @@ nfsvno_removesub(struct nameidata *ndp, int is_v4, str
 	struct vnode *vp, *dsdvp;
 	fhandle_t fh;
 	int error = 0;
+	char fname[PNFS_FILENAME_LEN + 1];
 
 	vp = ndp->ni_vp;
 	dsdvp = NULL;
@@ -1202,12 +1206,12 @@ nfsvno_removesub(struct nameidata *ndp, int is_v4, str
 	else if (is_v4)
 		error = nfsrv_checkremove(vp, 1, p);
 	if (error == 0)
-		nfsrv_pnfsremovesetup(vp, p, &dsdvp, &fh);
+		nfsrv_pnfsremovesetup(vp, p, &dsdvp, &fh, fname);
 	if (!error)
 		error = VOP_REMOVE(ndp->ni_dvp, vp, &ndp->ni_cnd);
 	if (dsdvp != NULL) {
 		if (error == 0)
-			nfsrv_pnfsremove(dsdvp, &fh, p);
+			nfsrv_pnfsremove(dsdvp, &fh, fname, p);
 		NFSVOPUNLOCK(dsdvp, 0);
 	}
 	if (ndp->ni_dvp == vp)
@@ -1272,6 +1276,7 @@ nfsvno_rename(struct nameidata *fromndp, struct nameid
 	struct vnode *fvp, *tvp, *tdvp, *dsdvp;
 	fhandle_t fh;
 	int error = 0;
+	char fname[PNFS_FILENAME_LEN + 1];
 
 	dsdvp = NULL;
 	fvp = fromndp->ni_vp;
@@ -1349,7 +1354,7 @@ nfsvno_rename(struct nameidata *fromndp, struct nameid
 		nfsd_recalldelegation(fvp, p);
 	}
 	if (error == 0 && tvp != NULL) {
-		nfsrv_pnfsremovesetup(tvp, p, &dsdvp, &fh);
+		nfsrv_pnfsremovesetup(tvp, p, &dsdvp, &fh, fname);
 		NFSD_DEBUG(4, "nfsvno_rename: pnfsremovesetup"
 		    " dsdvp=%p\n", dsdvp);
 	}
@@ -1378,7 +1383,7 @@ out:
 	 */
 	if (dsdvp != NULL) {
 		if (error == 0) {
-			nfsrv_pnfsremove(dsdvp, &fh, p);
+			nfsrv_pnfsremove(dsdvp, &fh, fname, p);
 			NFSD_DEBUG(4, "nfsvno_rename: pnfsremove\n");
 		}
 		NFSVOPUNLOCK(dsdvp, 0);
@@ -3641,7 +3646,6 @@ nfsrv_pnfscreate(struct vnode *vp, struct vattr *vap, 
 	} else
 		printf("pNFS: pnfscreate vnlock=%d\n", error);
 	NFSFREECRED(tcred);
-	nfsvno_relpathbuf(&named);
 	if (error == 0) {
 		pf = NULL;
 		np = VTONFS(nvp);
@@ -3661,12 +3665,15 @@ nfsrv_pnfscreate(struct vnode *vp, struct vattr *vap, 
 		if (error == 0) {
 			dsattr.dsa_filerev = va.va_filerev;
 			dsattr.dsa_size = va.va_size;
+			dsattr.dsa_atime = va.va_atime;
 			dsattr.dsa_mtime = va.va_mtime;
 			pf = malloc(sizeof(*pf), M_TEMP, M_WAITOK | M_ZERO);
 			pf->dsf_dir = dsdir;
 			NFSBCOPY(np->n_fhp->nfh_fh, &pf->dsf_fh, NFSX_MYFH);
 			NFSBCOPY(nmp->nm_nam, &pf->dsf_sin,
 			    nmp->nm_nam->sa_len);
+			NFSBCOPY(named.ni_cnd.cn_nameptr, pf->dsf_filename,
+			    sizeof(pf->dsf_filename));
 			error = vn_start_write(vp, &mp, V_WAIT);
 		} else
 			printf("pNFS: pnfscreate can't get DS attr=%d\n",
@@ -3689,6 +3696,7 @@ nfsrv_pnfscreate(struct vnode *vp, struct vattr *vap, 
 		free(pf, M_TEMP);
 	} else
 		printf("pNFS: pnfscreate=%d\n", error);
+	nfsvno_relpathbuf(&named);
 }
 
 /*
@@ -3698,7 +3706,7 @@ nfsrv_pnfscreate(struct vnode *vp, struct vattr *vap, 
  */
 static void
 nfsrv_pnfsremovesetup(struct vnode *vp, NFSPROC_T *p, struct vnode **dvpp,
-    fhandle_t *fhp)
+    fhandle_t *fhp, char *fname)
 {
 	struct vnode *dvp;
 	struct nfsmount *nmp;
@@ -3732,7 +3740,7 @@ nfsrv_pnfsremovesetup(struct vnode *vp, NFSPROC_T *p, 
 	buf = malloc(buflen, M_TEMP, M_WAITOK);
 	/* Get the directory vnode for the DS mount and the file handle. */
 	error = nfsrv_dsgetsockmnt(vp, LK_EXCLUSIVE, buf, buflen, p, &dvp,
-	    &nmp, NULL, NULL);
+	    &nmp, NULL, NULL, fname);
 	if (error == 0) {
 		error = nfsvno_getfh(vp, fhp, p);
 		if (error != 0) {
@@ -3752,7 +3760,7 @@ nfsrv_pnfsremovesetup(struct vnode *vp, NFSPROC_T *p, 
  * removed to set up the dvp and fill in the FH.
  */
 static void
-nfsrv_pnfsremove(struct vnode *dvp, fhandle_t *fhp, NFSPROC_T *p)
+nfsrv_pnfsremove(struct vnode *dvp, fhandle_t *fhp, char *fname, NFSPROC_T *p)
 {
 	struct vnode *nvp;
 	struct nameidata named;
@@ -3770,7 +3778,8 @@ nfsrv_pnfsremove(struct vnode *dvp, fhandle_t *fhp, NF
 	named.ni_cnd.cn_flags = ISLASTCN | LOCKPARENT | LOCKLEAF | SAVENAME;
 	nfsvno_setpathbuf(&named, &bufp, &hashp);
 	named.ni_cnd.cn_nameptr = bufp;
-	named.ni_cnd.cn_namelen = nfsrv_putfhname(fhp, bufp);
+	named.ni_cnd.cn_namelen = strlen(fname);
+	strlcpy(bufp, fname, NAME_MAX);
 	NFSD_DEBUG(4, "nfsrv_pnfsremove: filename=%s\n", bufp);
 	error = VOP_LOOKUP(dvp, &nvp, &named.ni_cnd);
 	NFSD_DEBUG(4, "nfsrv_pnfsremove: aft LOOKUP=%d\n", error);
@@ -3881,6 +3890,7 @@ nfsrv_proxyds(struct nfsrv_descript *nd, struct vnode 
 			NFSBCOPY(buf, &dsattr, buflen);
 			nap->na_filerev = dsattr.dsa_filerev;
 			nap->na_size = dsattr.dsa_size;
+			nap->na_atime = dsattr.dsa_atime;
 			nap->na_mtime = dsattr.dsa_mtime;
 		}
 
@@ -3900,7 +3910,7 @@ nfsrv_proxyds(struct nfsrv_descript *nd, struct vnode 
 	if (error == 0) {
 		buflen = 1024;
 		error = nfsrv_dsgetsockmnt(vp, LK_SHARED, buf, buflen, p,
-		    &dvp, &nmp, &fh, NULL);
+		    &dvp, &nmp, &fh, NULL, NULL);
 		if (error != 0)
 			printf("pNFS: proxy getextattr sockaddr=%d\n", error);
 	} else
@@ -3939,7 +3949,7 @@ nfsrv_proxyds(struct nfsrv_descript *nd, struct vnode 
 static int
 nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char *buf, int buflen,
     NFSPROC_T *p, struct vnode **dvpp, struct nfsmount **nmpp, fhandle_t *fhp,
-    char *devid)
+    char *devid, char *fnamep)
 {
 	struct vnode *dvp;
 	struct nfsmount *nmp;
@@ -3995,6 +4005,9 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char 
 		}
 		if (fhp != NULL)
 			NFSBCOPY(&pf->dsf_fh, fhp, NFSX_MYFH);
+		if (fnamep != NULL)
+			strlcpy(fnamep, pf->dsf_filename,
+			    sizeof(pf->dsf_filename));
 	} else
 		NFSD_DEBUG(4, "nfsrv_dsgetsockmnt err=%d\n", error);
 	return (error);
@@ -4014,6 +4027,7 @@ nfsrv_setextattr(struct vnode *vp, struct nfsvattr *na
 	if (error == 0) {
 		dsattr.dsa_filerev = nap->na_filerev;
 		dsattr.dsa_size = nap->na_size;
+		dsattr.dsa_atime = nap->na_atime;
 		dsattr.dsa_mtime = nap->na_mtime;
 		error = vn_extattr_set(vp, IO_NODELOCKED,
 		    EXTATTR_NAMESPACE_SYSTEM, "pnfsd.dsattr",
@@ -4185,6 +4199,7 @@ nfsrv_writedsrpc(fhandle_t *fhp, off_t off, int len, s
 	NFSZERO_ATTRBIT(&attrbits);
 	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_SIZE);
 	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_CHANGE);
+	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEACCESS);
 	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEMODIFY);
 	NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
 	*tl = txdr_unsigned(NFSV4OP_GETATTR);
@@ -4223,8 +4238,8 @@ nfsrv_writedsrpc(fhandle_t *fhp, off_t off, int len, s
 	/* We have no use for the Write Verifier since we use FileSync. */
 
 	/*
-	 * Get the Change and Modify Time attributes and set on the
-	 * Metadata file, so its attributes will be what the file's
+	 * Get the Change, Size, Access Time and Modify Time attributes and set
+	 * on the Metadata file, so its attributes will be what the file's
 	 * would be if it had been written.
 	 */
 	if (error == 0) {
@@ -4271,10 +4286,11 @@ nfsrv_setattrdsrpc(fhandle_t *fhp, struct ucred *cred,
 	nfsm_stateidtom(nd, &st, NFSSTATEID_PUTSTATEID);
 	nfscl_fillsattr(nd, &nap->na_vattr, vp, NFSSATTR_FULL, 0);
 
-	/* Do a Getattr for Size, Change and Modify Time. */
+	/* Do a Getattr for Size, Change, Access Time and Modify Time. */
 	NFSZERO_ATTRBIT(&attrbits);
 	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_SIZE);
 	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_CHANGE);
+	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEACCESS);
 	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEMODIFY);
 	NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
 	*tl = txdr_unsigned(NFSV4OP_GETATTR);
@@ -4307,8 +4323,8 @@ nfsrv_setattrdsrpc(fhandle_t *fhp, struct ucred *cred,
 	if (nd->nd_repstat != 0)
 		error = nd->nd_repstat;
 	/*
-	 * Get the Change and Modify Time attributes and set on the
-	 * Metadata file, so its attributes will be what the file's
+	 * Get the Change, Size, Access Time and Modify Time attributes and set
+	 * on the Metadata file, so its attributes will be what the file's
 	 * would be if it had been written.
 	 */
 	if (error == 0) {
@@ -4392,6 +4408,7 @@ nfsrv_getattrdsrpc(fhandle_t *fhp, struct ucred *cred,
 	NFSZERO_ATTRBIT(&attrbits);
 	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_SIZE);
 	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_CHANGE);
+	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEACCESS);
 	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEMODIFY);
 	(void) nfsrv_putattrbit(nd, &attrbits);
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
@@ -4429,7 +4446,7 @@ nfsrv_dsgetdevandfh(struct vnode *vp, NFSPROC_T *p, fh
 	buflen = 1024;
 	buf = malloc(buflen, M_TEMP, M_WAITOK);
 	error = nfsrv_dsgetsockmnt(vp, 0, buf, buflen, p, NULL, NULL, fhp,
-	    devid);
+	    devid, NULL);
 	free(buf, M_TEMP);
 	return (error);
 }

Modified: projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdserv.c
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdserv.c	Tue Jun 13 23:50:55 2017	(r319923)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdserv.c	Wed Jun 14 00:21:08 2017	(r319924)
@@ -3161,7 +3161,7 @@ nfsrvd_close(struct nfsrv_descript *nd, __unused int i
 {
 	u_int32_t *tl;
 	struct nfsstate st, *stp = &st;
-	int error = 0, writeacc;
+	int error = 0;
 	nfsv4stateid_t stateid;
 	nfsquad_t clientid;
 	struct nfsvattr na;
@@ -3204,11 +3204,9 @@ nfsrvd_close(struct nfsrv_descript *nd, __unused int i
 		nd->nd_flag |= ND_IMPLIEDCLID;
 		nd->nd_clientid.qval = clientid.qval;
 	}
-	nd->nd_repstat = nfsrv_openupdate(vp, stp, clientid, &stateid, nd, p,
-	    &writeacc);
+	nd->nd_repstat = nfsrv_openupdate(vp, stp, clientid, &stateid, nd, p);
 	/* For pNFS, update the attributes. */
-	if (writeacc != 0)
-		nfsrv_updatemdsattr(vp, &na, p);
+	nfsrv_updatemdsattr(vp, &na, p);
 	vput(vp);
 	if (!nd->nd_repstat) {
 		/*
@@ -3262,7 +3260,7 @@ nfsrvd_delegpurge(struct nfsrv_descript *nd, __unused 
 		nd->nd_clientid.qval = clientid.qval;
 	}
 	nd->nd_repstat = nfsrv_delegupdate(nd, clientid, NULL, NULL,
-	    NFSV4OP_DELEGPURGE, nd->nd_cred, p, NULL);
+	    NFSV4OP_DELEGPURGE, nd->nd_cred, p);
 nfsmout:
 	NFSEXITCODE2(error, nd);
 	return (error);
@@ -3276,7 +3274,7 @@ nfsrvd_delegreturn(struct nfsrv_descript *nd, __unused
     vnode_t vp, NFSPROC_T *p, __unused struct nfsexstuff *exp)
 {
 	u_int32_t *tl;
-	int error = 0, writeacc;
+	int error = 0;
 	nfsv4stateid_t stateid;
 	nfsquad_t clientid;
 	struct nfsvattr na;
@@ -3298,10 +3296,9 @@ nfsrvd_delegreturn(struct nfsrv_descript *nd, __unused
 		nd->nd_clientid.qval = clientid.qval;
 	}
 	nd->nd_repstat = nfsrv_delegupdate(nd, clientid, &stateid, vp,
-	    NFSV4OP_DELEGRETURN, nd->nd_cred, p, &writeacc);
+	    NFSV4OP_DELEGRETURN, nd->nd_cred, p);
 	/* For pNFS, update the attributes. */
-	if (writeacc != 0)
-		nfsrv_updatemdsattr(vp, &na, p);
+	nfsrv_updatemdsattr(vp, &na, p);
 nfsmout:
 	vput(vp);
 	NFSEXITCODE2(error, nd);
@@ -3365,8 +3362,7 @@ nfsrvd_openconfirm(struct nfsrv_descript *nd, __unused
 		nd->nd_flag |= ND_IMPLIEDCLID;
 		nd->nd_clientid.qval = clientid.qval;
 	}
-	nd->nd_repstat = nfsrv_openupdate(vp, stp, clientid, &stateid, nd, p,
-	    NULL);
+	nd->nd_repstat = nfsrv_openupdate(vp, stp, clientid, &stateid, nd, p);
 	if (!nd->nd_repstat) {
 		NFSM_BUILD(tl, u_int32_t *, NFSX_STATEID);
 		*tl++ = txdr_unsigned(stateid.seqid);
@@ -3469,7 +3465,7 @@ nfsrvd_opendowngrade(struct nfsrv_descript *nd, __unus
 	}
 	if (!nd->nd_repstat)
 		nd->nd_repstat = nfsrv_openupdate(vp, stp, clientid, &stateid,
-		    nd, p, NULL);
+		    nd, p);
 	if (!nd->nd_repstat) {
 		/* For NFSv4.1, set the Current StateID. */
 		if ((nd->nd_flag & ND_NFSV41) != 0) {

Modified: projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdstate.c	Tue Jun 13 23:50:55 2017	(r319923)
+++ projects/pnfs-planb-server-stable11/sys/fs/nfsserver/nfs_nfsdstate.c	Wed Jun 14 00:21:08 2017	(r319924)
@@ -90,6 +90,11 @@ SYSCTL_INT(_vfs_nfsd, OID_AUTO, allowreadforwriteopen,
     &nfsrv_allowreadforwriteopen, 0,
     "Allow Reads to be done with Write Access StateIDs");
 
+static int	nfsrv_pnfsatime = 0;
+SYSCTL_INT(_vfs_nfsd, OID_AUTO, pnfsgetatime, CTLFLAG_RW,
+    &nfsrv_pnfsatime, 0,
+    "For pNFS service, do Getattr ops to keep atime up-to-date");
+
 /*
  * Hash lists for nfs V4.
  */
@@ -3286,8 +3291,7 @@ out:
  */
 APPLESTATIC int
 nfsrv_openupdate(vnode_t vp, struct nfsstate *new_stp, nfsquad_t clientid,
-    nfsv4stateid_t *stateidp, struct nfsrv_descript *nd, NFSPROC_T *p,
-    int *retwriteaccessp)
+    nfsv4stateid_t *stateidp, struct nfsrv_descript *nd, NFSPROC_T *p)
 {
 	struct nfsstate *stp, *ownerstp;
 	struct nfsclient *clp;
@@ -3390,12 +3394,6 @@ nfsrv_openupdate(vnode_t vp, struct nfsstate *new_stp,
 	} else if (new_stp->ls_flags & NFSLCK_CLOSE) {
 		ownerstp = stp->ls_openowner;
 		lfp = stp->ls_lfp;
-		if (retwriteaccessp != NULL) {
-			if ((stp->ls_flags & NFSLCK_WRITEACCESS) != 0)
-				*retwriteaccessp = 1;
-			else
-				*retwriteaccessp = 0;
-		}
 		if (nfsrv_dolocallocks != 0 && !LIST_EMPTY(&stp->ls_open)) {
 			/* Get the lf lock */
 			nfsrv_locklf(lfp);
@@ -3452,7 +3450,7 @@ out:
 APPLESTATIC int
 nfsrv_delegupdate(struct nfsrv_descript *nd, nfsquad_t clientid,
     nfsv4stateid_t *stateidp, vnode_t vp, int op, struct ucred *cred,
-    NFSPROC_T *p, int *retwriteaccessp)
+    NFSPROC_T *p)
 {
 	struct nfsstate *stp;
 	struct nfsclient *clp;
@@ -3517,12 +3515,6 @@ nfsrv_delegupdate(struct nfsrv_descript *nd, nfsquad_t
 			error = NFSERR_BADSTATEID;
 			goto out;
 		}
-		if (retwriteaccessp != NULL) {
-			if ((stp->ls_flags & NFSLCK_DELEGWRITE) != 0)
-				*retwriteaccessp = 1;
-			else
-				*retwriteaccessp = 0;
-		}
 		nfsrv_freedeleg(stp);
 	} else {
 		nfsrv_freedeleglist(&clp->lc_olddeleg);
@@ -6846,8 +6838,8 @@ nfsrv_checkdsattr(struct nfsrv_descript *nd, vnode_t v
 	lhyp = NFSLAYOUTHASH(&fh);
 	NFSLOCKLAYOUT(lhyp);
 	LIST_FOREACH(lyp, &lhyp->list, lay_list) {
-		if (NFSBCMP(&lyp->lay_fh, &fh, sizeof(fh)) == 0 && lyp->lay_rw
-		    != 0) {
+		if (NFSBCMP(&lyp->lay_fh, &fh, sizeof(fh)) == 0 && (lyp->lay_rw
+		    != 0 || (lyp->lay_read != 0 && nfsrv_pnfsatime != 0))) {
 			if (clidcnt < NFSCLIDVECSIZE)
 				clid[clidcnt].qval = lyp->lay_clientid.qval;
 			clidcnt++;



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