From owner-svn-src-projects@freebsd.org Thu Sep 20 00:27:27 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2DDFA10AB93E for ; Thu, 20 Sep 2018 00:27:27 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D235072A4F; Thu, 20 Sep 2018 00:27:26 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C1B191659C; Thu, 20 Sep 2018 00:27:26 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w8K0RQp0007250; Thu, 20 Sep 2018 00:27:26 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w8K0RPpm007246; Thu, 20 Sep 2018 00:27:25 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201809200027.w8K0RPpm007246@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Thu, 20 Sep 2018 00:27:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r338817 - in projects/nfsv42/sys/fs: nfs nfsserver X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in projects/nfsv42/sys/fs: nfs nfsserver X-SVN-Commit-Revision: 338817 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 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: Thu, 20 Sep 2018 00:27:27 -0000 Author: rmacklem Date: Thu Sep 20 00:27:25 2018 New Revision: 338817 URL: https://svnweb.freebsd.org/changeset/base/338817 Log: Add the Layout stats operation to the NFSv4.2 server. Modified: projects/nfsv42/sys/fs/nfs/nfs_commonsubs.c projects/nfsv42/sys/fs/nfs/nfs_var.h projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c projects/nfsv42/sys/fs/nfsserver/nfs_nfsdsocket.c Modified: projects/nfsv42/sys/fs/nfs/nfs_commonsubs.c ============================================================================== --- projects/nfsv42/sys/fs/nfs/nfs_commonsubs.c Thu Sep 20 00:20:04 2018 (r338816) +++ projects/nfsv42/sys/fs/nfs/nfs_commonsubs.c Thu Sep 20 00:27:25 2018 (r338817) @@ -172,7 +172,7 @@ struct nfsv4_opflag nfsv4_opflag[NFSV42_NOPS] = { { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Deallocate */ { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* IO Advise */ { 0, 1, 0, 1, LK_EXCLUSIVE, 1, 0 }, /* Layout Error */ - { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Layout Stats */ + { 0, 1, 0, 1, LK_EXCLUSIVE, 1, 0 }, /* Layout Stats */ { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Offload Cancel */ { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Offload Status */ { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 }, /* Read Plus */ Modified: projects/nfsv42/sys/fs/nfs/nfs_var.h ============================================================================== --- projects/nfsv42/sys/fs/nfs/nfs_var.h Thu Sep 20 00:20:04 2018 (r338816) +++ projects/nfsv42/sys/fs/nfs/nfs_var.h Thu Sep 20 00:27:25 2018 (r338817) @@ -279,6 +279,8 @@ int nfsrvd_layoutreturn(struct nfsrv_descript *, int, vnode_t, NFSPROC_T *, struct nfsexstuff *); int nfsrvd_layouterror(struct nfsrv_descript *, int, vnode_t, NFSPROC_T *, struct nfsexstuff *); +int nfsrvd_layoutstats(struct nfsrv_descript *, int, + vnode_t, NFSPROC_T *, struct nfsexstuff *); int nfsrvd_teststateid(struct nfsrv_descript *, int, vnode_t, NFSPROC_T *, struct nfsexstuff *); int nfsrvd_notsupp(struct nfsrv_descript *, int, Modified: projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c ============================================================================== --- projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c Thu Sep 20 00:20:04 2018 (r338816) +++ projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c Thu Sep 20 00:27:25 2018 (r338817) @@ -4662,7 +4662,8 @@ nfsrvd_layouterror(struct nfsrv_descript *nd, __unused { uint32_t *tl; nfsv4stateid_t stateid; - int cnt, error = 0, i, opnum, stat; + int cnt, error = 0, i, stat; + int opnum __unused; char devid[NFSX_V4DEVICEID]; uint64_t offset, len; @@ -4713,6 +4714,68 @@ nfsrvd_layouterror(struct nfsrv_descript *nd, __unused if (stat != NFSERR_ACCES && stat != NFSERR_STALE) nfsrv_delds(devid, p); } +nfsmout: + vput(vp); + NFSEXITCODE2(error, nd); + return (error); +} + +/* + * nfsv4 layout stats service + */ +APPLESTATIC int +nfsrvd_layoutstats(struct nfsrv_descript *nd, __unused int isdgram, + vnode_t vp, NFSPROC_T *p, struct nfsexstuff *exp) +{ + uint32_t *tl; + nfsv4stateid_t stateid; + int cnt, error = 0; + int layouttype __unused; + char devid[NFSX_V4DEVICEID] __unused; + uint64_t offset, len, readcount, readbytes, writecount, writebytes + __unused; + + if (nfs_rootfhset == 0 || nfsd_checkrootexp(nd) != 0) { + nd->nd_repstat = NFSERR_WRONGSEC; + goto nfsmout; + } + NFSM_DISSECT(tl, uint32_t *, 6 * NFSX_HYPER + NFSX_STATEID + + NFSX_V4DEVICEID + 2 * NFSX_UNSIGNED); + offset = fxdr_hyper(tl); tl += 2; + len = fxdr_hyper(tl); tl += 2; + stateid.seqid = fxdr_unsigned(uint32_t, *tl++); + NFSBCOPY(tl, stateid.other, NFSX_STATEIDOTHER); + tl += (NFSX_STATEIDOTHER / NFSX_UNSIGNED); + readcount = fxdr_hyper(tl); tl += 2; + readbytes = fxdr_hyper(tl); tl += 2; + writecount = fxdr_hyper(tl); tl += 2; + writebytes = fxdr_hyper(tl); tl += 2; + NFSBCOPY(tl, devid, NFSX_V4DEVICEID); + tl += (NFSX_V4DEVICEID / NFSX_UNSIGNED); + layouttype = fxdr_unsigned(int, *tl++); + cnt = fxdr_unsigned(int, *tl); + error = nfsm_advance(nd, NFSM_RNDUP(cnt), -1); + if (error != 0) + goto nfsmout; + NFSD_DEBUG(4, "layoutstats cnt=%d\n", cnt); + /* + * For the special stateid of other all 0s and seqid == 1, set + * the stateid to the current stateid, if it is set. + */ + if (stateid.seqid == 1 && stateid.other[0] == 0 && + stateid.other[1] == 0 && stateid.other[2] == 0) { + if ((nd->nd_flag & ND_CURSTATEID) != 0) { + stateid = nd->nd_curstateid; + stateid.seqid = 0; + } else { + nd->nd_repstat = NFSERR_BADSTATEID; + goto nfsmout; + } + } + + /* + * No use for the stats for now. + */ nfsmout: vput(vp); NFSEXITCODE2(error, nd); Modified: projects/nfsv42/sys/fs/nfsserver/nfs_nfsdsocket.c ============================================================================== --- projects/nfsv42/sys/fs/nfsserver/nfs_nfsdsocket.c Thu Sep 20 00:20:04 2018 (r338816) +++ projects/nfsv42/sys/fs/nfsserver/nfs_nfsdsocket.c Thu Sep 20 00:27:25 2018 (r338817) @@ -204,7 +204,7 @@ int (*nfsrv4_ops0[NFSV42_NOPS])(struct nfsrv_descript nfsrvd_notsupp, nfsrvd_notsupp, nfsrvd_layouterror, - nfsrvd_notsupp, + nfsrvd_layoutstats, nfsrvd_notsupp, nfsrvd_notsupp, nfsrvd_notsupp,