svn commit: r234778 - in projects/nfsv4.1-client/sys/fs: nfs
nfsclient
Rick Macklem
rmacklem at FreeBSD.org
Sun Apr 29 00:59:39 UTC 2012
Author: rmacklem
Date: Sun Apr 29 00:59:38 2012
New Revision: 234778
URL: http://svn.freebsd.org/changeset/base/234778
Log:
Fix the last byte written field of the layout commit operation
for NFSv4.1 PNFS.
Modified:
projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h
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/nfs_var.h
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h Sat Apr 28 23:13:09 2012 (r234777)
+++ projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h Sun Apr 29 00:59:38 2012 (r234778)
@@ -451,7 +451,7 @@ int nfsrpc_layoutget(struct nfsmount *,
int nfsrpc_getdeviceinfo(struct nfsmount *, uint8_t *, int, uint32_t *,
struct nfscldevinfo **, struct ucred *, NFSPROC_T *);
int nfsrpc_layoutcommit(struct nfsmount *, uint8_t *, int, int,
- uint64_t, uint64_t, nfsv4stateid_t *, int, int, uint8_t *,
+ uint64_t, uint64_t, uint64_t, nfsv4stateid_t *, int, int, uint8_t *,
struct ucred *, NFSPROC_T *, void *);
int nfsrpc_layoutreturn(struct nfsmount *, uint8_t *, int, int, int, uint32_t,
int, uint64_t, uint64_t, nfsv4stateid_t *, int, uint32_t *, struct ucred *,
Modified: projects/nfsv4.1-client/sys/fs/nfs/nfsclstate.h
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfs/nfsclstate.h Sat Apr 28 23:13:09 2012 (r234777)
+++ projects/nfsv4.1-client/sys/fs/nfs/nfsclstate.h Sun Apr 29 00:59:38 2012 (r234778)
@@ -230,6 +230,7 @@ struct nfscllayout {
LIST_ENTRY(nfscllayout) nfsly_hash;
nfsv4stateid_t nfsly_stateid;
uint64_t nfsly_filesid[2];
+ uint64_t nfsly_lastbyte;
struct nfsclflayouthead nfsly_flayread;
struct nfsclflayouthead nfsly_flayrw;
struct nfsclrecalllayouthead nfsly_recall;
Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c Sat Apr 28 23:13:09 2012 (r234777)
+++ projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c Sun Apr 29 00:59:38 2012 (r234778)
@@ -4923,9 +4923,9 @@ nfsmout:
*/
int
nfsrpc_layoutcommit(struct nfsmount *nmp, uint8_t *fh, int fhlen, int reclaim,
- uint64_t off, uint64_t len, nfsv4stateid_t *stateidp, int layouttype,
- int layoutupdatecnt, uint8_t *layp, struct ucred *cred, NFSPROC_T *p,
- void *stuff)
+ uint64_t off, uint64_t len, uint64_t lastbyte, nfsv4stateid_t *stateidp,
+ int layouttype, int layoutupdatecnt, uint8_t *layp, struct ucred *cred,
+ NFSPROC_T *p, void *stuff)
{
uint32_t *tl;
struct nfsrv_descript nfsd, *nd = &nfsd;
@@ -4933,7 +4933,7 @@ nfsrpc_layoutcommit(struct nfsmount *nmp
uint8_t *cp;
nfscl_reqstart(nd, NFSPROC_LAYOUTCOMMIT, nmp, fh, fhlen, NULL, NULL);
- NFSM_BUILD(tl, uint32_t *, 5 * NFSX_UNSIGNED + 2 * NFSX_HYPER +
+ NFSM_BUILD(tl, uint32_t *, 5 * NFSX_UNSIGNED + 3 * NFSX_HYPER +
NFSX_STATEID);
txdr_hyper(off, tl);
tl += 2;
@@ -4947,7 +4947,13 @@ nfsrpc_layoutcommit(struct nfsmount *nmp
*tl++ = stateidp->other[0];
*tl++ = stateidp->other[1];
*tl++ = stateidp->other[2];
- *tl++ = newnfs_false;
+ *tl++ = newnfs_true;
+ if (lastbyte < off)
+ lastbyte = off;
+ else if (lastbyte >= (off + len))
+ lastbyte = off + len - 1;
+ txdr_hyper(lastbyte, tl);
+ tl += 2;
*tl++ = newnfs_false;
*tl++ = txdr_unsigned(layouttype);
*tl = txdr_unsigned(layoutupdatecnt);
@@ -5285,7 +5291,7 @@ nfscl_doiods(vnode_t vp, struct uio *uio
struct nfsclflayout *rflp;
nfsv4stateid_t stateid;
struct ucred *newcred;
- uint64_t len, off, oresid, xfer;
+ uint64_t lastbyte, len, off, oresid, xfer;
int eof, error, iolaymode, recalled;
void *lckp;
@@ -5351,6 +5357,14 @@ if (error == 2) printf("rwacc=0x%x\n", r
must_commit, &eof, &stateid, rwaccess, dip,
rflp, off, xfer, newcred, p);
nfscl_reldevinfo(dip);
+ lastbyte = off + xfer - 1;
+ if (error == 0) {
+ NFSLOCKCLSTATE();
+ if (lastbyte > layp->nfsly_lastbyte)
+ layp->nfsly_lastbyte = lastbyte;
+ NFSUNLOCKCLSTATE();
+printf("lastb=%qd\n", layp->nfsly_lastbyte);
+ }
} else
error = EIO;
if (error == 0)
Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c Sat Apr 28 23:13:09 2012 (r234777)
+++ projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c Sun Apr 29 00:59:38 2012 (r234778)
@@ -4668,6 +4668,7 @@ nfscl_layout(struct nfsmount *nmp, vnode
lyp->nfsly_stateid.other[0] = stateidp->other[0];
lyp->nfsly_stateid.other[1] = stateidp->other[1];
lyp->nfsly_stateid.other[2] = stateidp->other[2];
+ lyp->nfsly_lastbyte = 0;
LIST_INIT(&lyp->nfsly_flayread);
LIST_INIT(&lyp->nfsly_flayrw);
LIST_INIT(&lyp->nfsly_recall);
@@ -5039,7 +5040,7 @@ nfscl_dolayoutcommit(struct nfsmount *nm
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_stateid,
+ 0, flp->nfsfl_off, len, lyp->nfsly_lastbyte, &lyp->nfsly_stateid,
NFSLAYOUT_NFSV4_1_FILES, 0, NULL, cred, p, NULL);
}
@@ -5071,6 +5072,7 @@ tryagain:
if ((flp->nfsfl_flags & NFSFL_WRITTEN) != 0) {
flp->nfsfl_flags &= ~NFSFL_WRITTEN;
NFSUNLOCKCLSTATE();
+printf("do layoutcommit2\n");
nfscl_dolayoutcommit(clp->nfsc_nmp, lyp, flp,
NFSPROCCRED(p), p);
NFSLOCKCLSTATE();
More information about the svn-src-projects
mailing list