From owner-svn-src-projects@FreeBSD.ORG Sat Feb 4 03:08:24 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 571A91065674; Sat, 4 Feb 2012 03:08:24 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 453658FC0C; Sat, 4 Feb 2012 03:08:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q1438OKw016461; Sat, 4 Feb 2012 03:08:24 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1438NB5016456; Sat, 4 Feb 2012 03:08:23 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201202040308.q1438NB5016456@svn.freebsd.org> From: Rick Macklem Date: Sat, 4 Feb 2012 03:08:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r230974 - in projects/nfsv4.1-client/sys/fs: nfs nfsclient X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Feb 2012 03:08:24 -0000 Author: rmacklem Date: Sat Feb 4 03:08:23 2012 New Revision: 230974 URL: http://svn.freebsd.org/changeset/base/230974 Log: Replace length with end offset in the nfsclflayout structure and keep the layouts that can be used for writing on a separate list from the ones that are for reading. These changes make it easier to find the correct layout(s) to use for reading or writing from/to the DS. This layout handling code is not yet tested. Modified: projects/nfsv4.1-client/sys/fs/nfs/nfsclstate.h projects/nfsv4.1-client/sys/fs/nfs/nfsproto.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 Feb 4 02:00:33 2012 (r230973) +++ projects/nfsv4.1-client/sys/fs/nfs/nfsclstate.h Sat Feb 4 03:08:23 2012 (r230974) @@ -219,7 +219,8 @@ struct nfscllayout { TAILQ_ENTRY(nfscllayout) nfsly_list; LIST_ENTRY(nfscllayout) nfsly_hash; nfsv4stateid_t nfsly_stateid; - struct nfsclflayouthead nfsly_flay; + struct nfsclflayouthead nfsly_flayread; + struct nfsclflayouthead nfsly_flayrw; struct nfsclclient *nfsly_clp; uint32_t nfsly_refcnt; uint16_t nfsly_retonclose; @@ -229,13 +230,16 @@ struct nfscllayout { /* * MALLOC'd to the correct length to accommodate the file handle list. - * These hang off of nfsly_flay, sorted in increasing offset order. + * These hang off of nfsly_flayread and nfsly_flayrw, sorted in increasing + * offset order. + * The nfsly_flayread list holds the ones with iomode == NFSLAYOUTIOMODE_READ, + * whereas the nfsly_flayrw holds the ones with iomode == NFSLAYOUTIOMODE_RW. */ struct nfsclflayout { LIST_ENTRY(nfsclflayout) nfsfl_list; uint8_t nfsfl_dev[NFSX_V4DEVICEID]; uint64_t nfsfl_off; - uint64_t nfsfl_len; + uint64_t nfsfl_end; uint64_t nfsfl_patoff; uint32_t nfsfl_iomode; uint32_t nfsfl_util; Modified: projects/nfsv4.1-client/sys/fs/nfs/nfsproto.h ============================================================================== --- projects/nfsv4.1-client/sys/fs/nfs/nfsproto.h Sat Feb 4 02:00:33 2012 (r230973) +++ projects/nfsv4.1-client/sys/fs/nfs/nfsproto.h Sat Feb 4 03:08:23 2012 (r230974) @@ -585,6 +585,10 @@ #define NFSDEVICEIDNOTIFY_CHANGEBIT 0x1 #define NFSDEVICEIDNOTIFY_DELETEBIT 0x2 +/* Flags for File Layout. */ +#define NFSFLAYUTIL_DENSE 0x1 +#define NFSFLAYUTIL_COMMIT_THRU_MDS 0x2 + /* Conversion macros */ #define vtonfsv2_mode(t,m) \ txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \ Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c Sat Feb 4 02:00:33 2012 (r230973) +++ projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c Sat Feb 4 03:08:23 2012 (r230974) @@ -4522,6 +4522,7 @@ nfsrpc_layoutget(struct nfsmount *nmp, u struct nfsclflayout *flp, *prevflp, *tflp; int cnt, error, fhcnt, nfhlen, i, j; uint8_t *cp; + uint64_t retlen; flp = NULL; nfscl_reqstart(nd, NFSPROC_LAYOUTGET, nmp, fhp, fhlen, NULL, NULL); @@ -4585,7 +4586,11 @@ printf("fhcnt=%d\n", fhcnt); M_NFSFLAYOUT, M_WAITOK); flp->nfsfl_fhcnt = 0; flp->nfsfl_off = fxdr_hyper(tl); tl += 2; - flp->nfsfl_len = fxdr_hyper(tl); tl += 2; + retlen = fxdr_hyper(tl); tl += 2; + if (flp->nfsfl_off + retlen < flp->nfsfl_off) + flp->nfsfl_end = UINT64_MAX - flp->nfsfl_off; + else + flp->nfsfl_end = flp->nfsfl_off + retlen; flp->nfsfl_iomode = fxdr_unsigned(int, *tl++); printf("layg iom=%d\n", iomode); if (fxdr_unsigned(int, *tl++) != @@ -4619,18 +4624,24 @@ printf("layg iom=%d\n", iomode); NFSM_DISSECT(cp, uint8_t *, NFSM_RNDUP(fhlen)); NFSBCOPY(cp, nfhp->nfh_fh, nfhlen); } - /* Maintain the list in increasing offset order. */ - tflp = LIST_FIRST(flhp); - prevflp = NULL; - while (tflp != NULL && - tflp->nfsfl_off < flp->nfsfl_off) { - prevflp = tflp; - tflp = LIST_NEXT(tflp, nfsfl_list); + if (flp->nfsfl_iomode == iomode) { + /* Keep the list in increasing offset order. */ + tflp = LIST_FIRST(flhp); + prevflp = NULL; + while (tflp != NULL && + tflp->nfsfl_off < flp->nfsfl_off) { + prevflp = tflp; + tflp = LIST_NEXT(tflp, nfsfl_list); + } + if (prevflp == NULL) + LIST_INSERT_HEAD(flhp, flp, nfsfl_list); + else + LIST_INSERT_AFTER(prevflp, flp, + nfsfl_list); + } else { + printf("nfscl_layoutget(): got wrong iomode\n"); + nfscl_freeflayout(flp); } - if (prevflp == NULL) - LIST_INSERT_HEAD(flhp, flp, nfsfl_list); - else - LIST_INSERT_AFTER(prevflp, flp, nfsfl_list); flp = NULL; } } Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c ============================================================================== --- projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c Sat Feb 4 02:00:33 2012 (r230973) +++ projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c Sat Feb 4 03:08:23 2012 (r230974) @@ -4405,6 +4405,7 @@ nfscl_layout(struct nfsmount *nmp, u_int { struct nfsclclient *clp; struct nfscllayout *lyp, *tlyp; + struct nfsclflayout *flp; *lypp = NULL; tlyp = malloc(sizeof(*tlyp) + fhlen - 1, M_NFSLAYOUT, M_WAITOK); @@ -4424,7 +4425,8 @@ nfscl_layout(struct nfsmount *nmp, u_int lyp->nfsly_stateid.other[0] = stateidp->other[0]; lyp->nfsly_stateid.other[1] = stateidp->other[1]; lyp->nfsly_stateid.other[2] = stateidp->other[2]; - LIST_INIT(&lyp->nfsly_flay); + LIST_INIT(&lyp->nfsly_flayread); + LIST_INIT(&lyp->nfsly_flayrw); lyp->nfsly_clp = clp; lyp->nfsly_retonclose = retonclose; lyp->nfsly_refcnt = 1; /* Return with a reference cnt. */ @@ -4444,7 +4446,13 @@ nfscl_layout(struct nfsmount *nmp, u_int } /* Merge the new list of File Layouts into the list. */ - nfscl_mergeflayouts(&lyp->nfsly_flay, fhlp); + flp = LIST_FIRST(fhlp); + if (flp != NULL) { + if (flp->nfsfl_iomode == NFSLAYOUTIOMODE_READ) + nfscl_mergeflayouts(&lyp->nfsly_flayread, fhlp); + else + nfscl_mergeflayouts(&lyp->nfsly_flayrw, fhlp); + } NFSUNLOCKCLSTATE(); if (tlyp != NULL) free(tlyp, M_NFSLAYOUT); @@ -4599,7 +4607,11 @@ nfscl_freelayout(struct nfscllayout *lay { struct nfsclflayout *flp, *nflp; - LIST_FOREACH_SAFE(flp, &layp->nfsly_flay, nfsfl_list, nflp) { + LIST_FOREACH_SAFE(flp, &layp->nfsly_flayread, nfsfl_list, nflp) { + LIST_REMOVE(flp, nfsfl_list); + nfscl_freeflayout(flp); + } + LIST_FOREACH_SAFE(flp, &layp->nfsly_flayrw, nfsfl_list, nflp) { LIST_REMOVE(flp, nfsfl_list); nfscl_freeflayout(flp); }