svn commit: r339247 - head/sys/fs/nfsserver
Rick Macklem
rmacklem at FreeBSD.org
Tue Oct 9 01:10:51 UTC 2018
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 "#<path>" 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 "#<path>" 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();
More information about the svn-src-all
mailing list