From owner-svn-src-head@freebsd.org Tue Oct 9 01:10:50 2018 Return-Path: Delivered-To: svn-src-head@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 B772D10AD8B0; Tue, 9 Oct 2018 01:10:50 +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 8A87B896BD; Tue, 9 Oct 2018 01:10:50 +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 859572717; Tue, 9 Oct 2018 01:10:50 +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 w991Ao43003007; Tue, 9 Oct 2018 01:10:50 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w991Aoip003006; Tue, 9 Oct 2018 01:10:50 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201810090110.w991Aoip003006@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Tue, 9 Oct 2018 01:10:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339247 - head/sys/fs/nfsserver X-SVN-Group: head X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: head/sys/fs/nfsserver X-SVN-Commit-Revision: 339247 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Oct 2018 01:10:51 -0000 Author: rmacklem Date: Tue Oct 9 01:10:50 2018 New Revision: 339247 URL: https://svnweb.freebsd.org/changeset/base/339247 Log: Fix the pNFS server's reporting of disk space usage for the "#" case. The pNFS server would report the total disk space used and free for all of the DSs, even when certain DSs are assigned to the file system via the "#" suffix used in the "nfsd -p" option argument. This patch fixes this case. It only reports usage for the file system that the argument vnode resides on. This is consistent with the non-pNFS NFSv4 server. In NFSv4 it is possible to have subtrees on other file systems, but these are not included in the usage information for NFSv4. Approved by: re (gjb) Modified: head/sys/fs/nfsserver/nfs_nfsdport.c Modified: head/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- head/sys/fs/nfsserver/nfs_nfsdport.c Mon Oct 8 23:23:09 2018 (r339246) +++ head/sys/fs/nfsserver/nfs_nfsdport.c Tue Oct 9 01:10:50 2018 (r339247) @@ -133,7 +133,7 @@ static void nfsrv_pnfssetfh(struct vnode *, struct pnf static int nfsrv_dsremove(struct vnode *, char *, struct ucred *, NFSPROC_T *); static int nfsrv_dssetacl(struct vnode *, struct acl *, struct ucred *, NFSPROC_T *); -static int nfsrv_pnfsstatfs(struct statfs *); +static int nfsrv_pnfsstatfs(struct statfs *, struct mount *); int nfs_pnfsio(task_fn_t *, void *); @@ -1593,7 +1593,7 @@ nfsvno_statfs(struct vnode *vp, struct statfs *sf) if (nfsrv_devidcnt > 0) { /* For a pNFS service, get the DS numbers. */ tsf = malloc(sizeof(*tsf), M_TEMP, M_WAITOK | M_ZERO); - error = nfsrv_pnfsstatfs(tsf); + error = nfsrv_pnfsstatfs(tsf, vp->v_mount); if (error != 0) { free(tsf, M_TEMP); tsf = NULL; @@ -1774,7 +1774,7 @@ nfsvno_fillattr(struct nfsrv_descript *nd, struct moun NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_SPACEFREE) || NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_SPACETOTAL))) { sf = malloc(sizeof(*sf), M_TEMP, M_WAITOK | M_ZERO); - error = nfsrv_pnfsstatfs(sf); + error = nfsrv_pnfsstatfs(sf, mp); if (error != 0) { free(sf, M_TEMP); sf = NULL; @@ -5578,7 +5578,7 @@ nfsrv_killrpcs(struct nfsmount *nmp) * receive the total for all DSs. */ static int -nfsrv_pnfsstatfs(struct statfs *sf) +nfsrv_pnfsstatfs(struct statfs *sf, struct mount *mp) { struct statfs *tsf; struct nfsdevice *ds; @@ -5595,11 +5595,28 @@ nfsrv_pnfsstatfs(struct statfs *sf) tdvpp = dvpp; i = 0; NFSDDSLOCK(); + /* First, search for matches for same file system. */ TAILQ_FOREACH(ds, &nfsrv_devidhead, nfsdev_list) { - if (ds->nfsdev_nmp != NULL) { + if (ds->nfsdev_nmp != NULL && ds->nfsdev_mdsisset != 0 && + ds->nfsdev_mdsfsid.val[0] == mp->mnt_stat.f_fsid.val[0] && + ds->nfsdev_mdsfsid.val[1] == mp->mnt_stat.f_fsid.val[1]) { if (++i > nfsrv_devidcnt) break; *tdvpp++ = ds->nfsdev_dvp; + } + } + /* + * If no matches for same file system, total all servers not assigned + * to a file system. + */ + if (i == 0) { + TAILQ_FOREACH(ds, &nfsrv_devidhead, nfsdev_list) { + if (ds->nfsdev_nmp != NULL && + ds->nfsdev_mdsisset == 0) { + if (++i > nfsrv_devidcnt) + break; + *tdvpp++ = ds->nfsdev_dvp; + } } } NFSDDSUNLOCK();