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

Rick Macklem rmacklem at FreeBSD.org
Sat Oct 20 01:48:50 UTC 2012


Author: rmacklem
Date: Sat Oct 20 01:48:49 2012
New Revision: 241761
URL: http://svn.freebsd.org/changeset/base/241761

Log:
  The NFSv4 working group has deprecated the offset and length
  arguments for the NFSv4.1 LayoutCommit operation. As such,
  only one LayoutCommit is required for all layouts for a file.
  This allowed the code to be simplified.

Modified:
  projects/nfsv4.1-client/sys/fs/nfs/nfsclstate.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/nfsclstate.h
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfs/nfsclstate.h	Sat Oct 20 00:28:27 2012	(r241760)
+++ projects/nfsv4.1-client/sys/fs/nfs/nfsclstate.h	Sat Oct 20 01:48:49 2012	(r241761)
@@ -255,6 +255,7 @@ struct nfscllayout {
 #define	NFSLY_RECALLFSID	0x0020
 #define	NFSLY_RECALLALL		0x0040
 #define	NFSLY_RETONCLOSE	0x0080
+#define	NFSLY_WRITTEN		0x0100	/* Has been used to write to a DS. */
 
 /*
  * MALLOC'd to the correct length to accommodate the file handle list.
@@ -282,7 +283,6 @@ struct nfsclflayout {
  * Flags for nfsfl_flags.
  */
 #define	NFSFL_RECALL	0x0001		/* File layout has been recalled */
-#define	NFSFL_WRITTEN	0x0002		/* Has been used to write to a DS. */
 
 /*
  * Structure that is used to store a LAYOUTRECALL.

Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c	Sat Oct 20 00:28:27 2012	(r241760)
+++ projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c	Sat Oct 20 01:48:49 2012	(r241761)
@@ -106,8 +106,8 @@ static int nfsrpc_fillsa(struct nfsmount
     struct nfsclds **, NFSPROC_T *);
 static void nfscl_initsessionslots(struct nfsclsession *);
 static int nfscl_doflayoutio(vnode_t, struct uio *, int *, int *, int *,
-    nfsv4stateid_t *, int, struct nfscldevinfo *, struct nfsclflayout *,
-    uint64_t, uint64_t, struct ucred *, NFSPROC_T *);
+    nfsv4stateid_t *, int, struct nfscldevinfo *, struct nfscllayout *,
+    struct nfsclflayout *, uint64_t, uint64_t, struct ucred *, NFSPROC_T *);
 static int nfsrpc_readds(vnode_t, struct uio *, nfsv4stateid_t *, int *,
     struct nfsclds *, uint64_t, int, struct nfsfh *, struct ucred *,
     NFSPROC_T *);
@@ -5477,7 +5477,7 @@ nfscl_doiods(vnode_t vp, struct uio *uio
 			if (dip != NULL) {
 				error = nfscl_doflayoutio(vp, uiop, iomode,
 				    must_commit, &eof, &stateid, rwaccess, dip,
-				    rflp, off, xfer, newcred, p);
+				    layp, rflp, off, xfer, newcred, p);
 				nfscl_reldevinfo(dip);
 				lastbyte = off + xfer - 1;
 				if (error == 0) {
@@ -5547,8 +5547,8 @@ nfscl_findlayoutforio(struct nfscllayout
 static int
 nfscl_doflayoutio(vnode_t vp, struct uio *uiop, int *iomode, int *must_commit,
     int *eofp, nfsv4stateid_t *stateidp, int rwflag, struct nfscldevinfo *dp,
-    struct nfsclflayout *flp, uint64_t off, uint64_t len, struct ucred *cred,
-    NFSPROC_T *p)
+    struct nfscllayout *lyp, struct nfsclflayout *flp, uint64_t off,
+    uint64_t len, struct ucred *cred, NFSPROC_T *p)
 {
 	uint64_t io_off, rel_off, stripe_unit_size, transfer, xfer;
 	int commit_thru_mds, error = 0, stripe_index, stripe_pos;
@@ -5604,7 +5604,7 @@ nfscl_doflayoutio(vnode_t vp, struct uio
 			    cred, p);
 			if (error == 0) {
 				NFSLOCKCLSTATE();
-				flp->nfsfl_flags |= NFSFL_WRITTEN;
+				lyp->nfsly_flags |= NFSLY_WRITTEN;
 				NFSUNLOCKCLSTATE();
 			}
 		}

Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c	Sat Oct 20 00:28:27 2012	(r241760)
+++ projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c	Sat Oct 20 01:48:49 2012	(r241761)
@@ -164,7 +164,7 @@ static int nfscl_seq(uint32_t, uint32_t)
 static void nfscl_layoutreturn(struct nfsmount *, struct nfscllayout *,
     struct ucred *, NFSPROC_T *);
 static void nfscl_dolayoutcommit(struct nfsmount *, struct nfscllayout *,
-    struct nfsclflayout *, struct ucred *, NFSPROC_T *);
+    struct ucred *, NFSPROC_T *);
 
 static short nfscberr_null[] = {
 	0,
@@ -2452,7 +2452,6 @@ nfscl_renewthread(struct nfsclclient *cl
 	struct nfscllockownerfh *lfhp, *nlfhp;
 	struct nfscllockownerfhhead lfh;
 	struct nfscllayout *lyp, *nlyp;
-	struct nfsclflayout *flp;
 	struct nfscldevinfo *dip, *ndip;
 	struct nfscllayouthead rlh;
 	struct nfsclrecalllayout *recallp;
@@ -2651,23 +2650,15 @@ tryagain2:
 				TAILQ_INSERT_HEAD(&rlh, lyp, nfsly_list);
 
 				/* Handle any layout commits. */
-				if (!NFSHASNOLAYOUTCOMMIT(clp->nfsc_nmp)) {
-					LIST_FOREACH(flp, &lyp->nfsly_flayrw,
-					    nfsfl_list) {
-						if ((flp->nfsfl_flags &
-						    NFSFL_WRITTEN) != 0) {
-							flp->nfsfl_flags &=
-							    ~NFSFL_WRITTEN;
-							NFSUNLOCKCLSTATE();
-							NFSCL_DEBUG(3,
-							   "do layoutcommit\n");
-							nfscl_dolayoutcommit(
-							    clp->nfsc_nmp, lyp,
-							    flp, cred, p);
-							NFSLOCKCLSTATE();
-							goto tryagain2;
-						}
-					}
+				if (!NFSHASNOLAYOUTCOMMIT(clp->nfsc_nmp) &&
+				    (lyp->nfsly_flags & NFSLY_WRITTEN) != 0) {
+					lyp->nfsly_flags &= ~NFSLY_WRITTEN;
+					NFSUNLOCKCLSTATE();
+					NFSCL_DEBUG(3, "do layoutcommit\n");
+					nfscl_dolayoutcommit(clp->nfsc_nmp, lyp,
+					    cred, p);
+					NFSLOCKCLSTATE();
+					goto tryagain2;
 				}
 			}
 		}
@@ -5154,17 +5145,12 @@ nfscl_layoutreturn(struct nfsmount *nmp,
  */
 static void
 nfscl_dolayoutcommit(struct nfsmount *nmp, struct nfscllayout *lyp,
-    struct nfsclflayout *flp, struct ucred *cred, NFSPROC_T *p)
+    struct ucred *cred, NFSPROC_T *p)
 {
-	uint64_t len;
 	int error;
 
-	if (flp->nfsfl_end == UINT64_MAX)
-		len = UINT64_MAX;
-	else
-		len = flp->nfsfl_end - flp->nfsfl_off;
 	error = nfsrpc_layoutcommit(nmp, lyp->nfsly_fh, lyp->nfsly_fhlen,
-	    0, flp->nfsfl_off, len, lyp->nfsly_lastbyte, &lyp->nfsly_stateid,
+	    0, 0, 0, lyp->nfsly_lastbyte, &lyp->nfsly_stateid,
 	    NFSLAYOUT_NFSV4_1_FILES, 0, NULL, cred, p, NULL);
 	if (error == NFSERR_NOTSUPP) {
 		/* If the server doesn't want it, don't bother doing it. */
@@ -5182,7 +5168,6 @@ nfscl_layoutcommit(vnode_t vp, NFSPROC_T
 {
 	struct nfsclclient *clp;
 	struct nfscllayout *lyp;
-	struct nfsclflayout *flp;
 	struct nfsnode *np = VTONFS(vp);
 	mount_t mp;
 	struct nfsmount *nmp;
@@ -5208,16 +5193,13 @@ nfscl_layoutcommit(vnode_t vp, NFSPROC_T
 		return (EPERM);
 	}
 tryagain:
-	LIST_FOREACH(flp, &lyp->nfsly_flayrw, nfsfl_list) {
-		if ((flp->nfsfl_flags & NFSFL_WRITTEN) != 0) {
-			flp->nfsfl_flags &= ~NFSFL_WRITTEN;
-			NFSUNLOCKCLSTATE();
-			NFSCL_DEBUG(4, "do layoutcommit2\n");
-			nfscl_dolayoutcommit(clp->nfsc_nmp, lyp, flp,
-			    NFSPROCCRED(p), p);
-			NFSLOCKCLSTATE();
-			goto tryagain;
-		}
+	if ((lyp->nfsly_flags & NFSLY_WRITTEN) != 0) {
+		lyp->nfsly_flags &= ~NFSLY_WRITTEN;
+		NFSUNLOCKCLSTATE();
+		NFSCL_DEBUG(4, "do layoutcommit2\n");
+		nfscl_dolayoutcommit(clp->nfsc_nmp, lyp, NFSPROCCRED(p), p);
+		NFSLOCKCLSTATE();
+		goto tryagain;
 	}
 	nfsv4_relref(&lyp->nfsly_lock);
 	NFSUNLOCKCLSTATE();


More information about the svn-src-projects mailing list