svn commit: r231005 - in projects/nfsv4.1-client/sys/fs: nfs nfsclient

Rick Macklem rmacklem at FreeBSD.org
Sun Feb 5 03:23:27 UTC 2012


Author: rmacklem
Date: Sun Feb  5 03:23:26 2012
New Revision: 231005
URL: http://svn.freebsd.org/changeset/base/231005

Log:
  Add an argument to nfscl_getstateid() to indicate it if it is being
  called to get a stateid for an I/O operation to be done on a DS.
  This is necessary, since the rules for what kind of stateid that
  can be used is different for a DS than against an MDS/non-MDS NFSv4 server.

Modified:
  projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h
  projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c
  projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c

Modified: projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h	Sun Feb  5 01:57:31 2012	(r231004)
+++ projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h	Sun Feb  5 03:23:26 2012	(r231005)
@@ -460,7 +460,7 @@ int nfsrpc_reclaimcomplete(struct nfsmou
 int nfscl_open(vnode_t, u_int8_t *, int, u_int32_t, int,
     struct ucred *, NFSPROC_T *, struct nfsclowner **, struct nfsclopen **,
     int *, int *, int);
-int nfscl_getstateid(vnode_t, u_int8_t *, int, u_int32_t, struct ucred *,
+int nfscl_getstateid(vnode_t, u_int8_t *, int, u_int32_t, int, struct ucred *,
     NFSPROC_T *, nfsv4stateid_t *, void **);
 void nfscl_ownerrelease(struct nfsclowner *, int, int, int);
 void nfscl_openrelease(struct nfsclopen *, int, int);

Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c	Sun Feb  5 01:57:31 2012	(r231004)
+++ projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c	Sun Feb  5 03:23:26 2012	(r231005)
@@ -1026,7 +1026,7 @@ nfsrpc_setattr(vnode_t vp, struct vattr 
 		if (NFSHASNFSV4(nmp)) {
 			nfhp = VTONFS(vp)->n_fhp;
 			error = nfscl_getstateid(vp, nfhp->nfh_fh,
-			    nfhp->nfh_len, mode, cred, p, &stateid, &lckp);
+			    nfhp->nfh_len, mode, 0, cred, p, &stateid, &lckp);
 			if (error && vnode_vtype(vp) == VREG &&
 			    (mode == NFSV4OPEN_ACCESSWRITE ||
 			     nfstest_openallsetattr)) {
@@ -1043,7 +1043,7 @@ nfsrpc_setattr(vnode_t vp, struct vattr 
 				if (!openerr)
 					(void) nfscl_getstateid(vp,
 					    nfhp->nfh_fh, nfhp->nfh_len,
-					    mode, cred, p, &stateid, &lckp);
+					    mode, 0, cred, p, &stateid, &lckp);
 			}
 		}
 		if (vap != NULL)
@@ -1296,7 +1296,8 @@ nfsrpc_read(vnode_t vp, struct uio *uiop
 		lckp = NULL;
 		if (NFSHASNFSV4(nmp))
 			(void)nfscl_getstateid(vp, nfhp->nfh_fh, nfhp->nfh_len,
-			    NFSV4OPEN_ACCESSREAD, newcred, p, &stateid, &lckp);
+			    NFSV4OPEN_ACCESSREAD, 0, newcred, p, &stateid,
+			    &lckp);
 		error = nfsrpc_readrpc(vp, uiop, newcred, &stateid, p, nap,
 		    attrflagp, stuff);
 		if (error == NFSERR_STALESTATEID || error == NFSERR_BADSESSION)
@@ -1450,7 +1451,8 @@ nfsrpc_write(vnode_t vp, struct uio *uio
 		nostateid = 0;
 		if (NFSHASNFSV4(nmp)) {
 			(void)nfscl_getstateid(vp, nfhp->nfh_fh, nfhp->nfh_len,
-			    NFSV4OPEN_ACCESSWRITE, newcred, p, &stateid, &lckp);
+			    NFSV4OPEN_ACCESSWRITE, 0, newcred, p, &stateid,
+			    &lckp);
 			if (stateid.other[0] == 0 && stateid.other[1] == 0 &&
 			    stateid.other[2] == 0) {
 				nostateid = 1;

Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c	Sun Feb  5 01:57:31 2012	(r231004)
+++ projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c	Sun Feb  5 03:23:26 2012	(r231005)
@@ -461,7 +461,7 @@ nfscl_finddeleg(struct nfsclclient *clp,
  */
 APPLESTATIC int
 nfscl_getstateid(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t mode,
-    struct ucred *cred, NFSPROC_T *p, nfsv4stateid_t *stateidp,
+    int fords, struct ucred *cred, NFSPROC_T *p, nfsv4stateid_t *stateidp,
     void **lckpp)
 {
 	struct nfsclclient *clp;
@@ -476,11 +476,14 @@ nfscl_getstateid(vnode_t vp, u_int8_t *n
 	*lckpp = NULL;
 	/*
 	 * Initially, just set the special stateid of all zeros.
+	 * (Don't do this for a DS, since the special stateid can't be used.)
 	 */
-	stateidp->seqid = 0;
-	stateidp->other[0] = 0;
-	stateidp->other[1] = 0;
-	stateidp->other[2] = 0;
+	if (fords == 0) {
+		stateidp->seqid = 0;
+		stateidp->other[0] = 0;
+		stateidp->other[1] = 0;
+		stateidp->other[2] = 0;
+	}
 	if (vnode_vtype(vp) != VREG)
 		return (EISDIR);
 	np = VTONFS(vp);
@@ -536,7 +539,8 @@ nfscl_getstateid(vnode_t vp, u_int8_t *n
 		lp = NULL;
 		error = nfscl_getopen(&clp->nfsc_owner, nfhp, fhlen, own, own,
 		    mode, &lp, &op);
-		if (error == 0 && lp != NULL) {
+		if (error == 0 && lp != NULL && fords == 0) {
+			/* Don't return a lock stateid for a DS. */
 			stateidp->seqid =
 			    lp->nfsl_stateid.seqid;
 			stateidp->other[0] =


More information about the svn-src-projects mailing list