From owner-svn-src-projects@freebsd.org Tue Jul 3 23:29:19 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 AB17D103489E for ; Tue, 3 Jul 2018 23:29:19 +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 56CF177452; Tue, 3 Jul 2018 23:29:19 +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 3725322D1B; Tue, 3 Jul 2018 23:29:19 +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 w63NTJHj073980; Tue, 3 Jul 2018 23:29:19 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w63NTJth073979; Tue, 3 Jul 2018 23:29:19 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807032329.w63NTJth073979@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Tue, 3 Jul 2018 23:29:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r335918 - projects/pnfs-planb-server/sys/fs/nfsserver X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/pnfs-planb-server/sys/fs/nfsserver X-SVN-Commit-Revision: 335918 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: Tue, 03 Jul 2018 23:29:19 -0000 Author: rmacklem Date: Tue Jul 3 23:29:18 2018 New Revision: 335918 URL: https://svnweb.freebsd.org/changeset/base/335918 Log: For the case where there is a mix of DSs assigned to specific MDS file systems and DSs for all file systems, modify the algorithm that selects a DS to use one assigned to that MDS file system and only use the DSs for all file systems if there is no assigned one. This will allow a system administrator to set some DSs for "all other exported file systems" and only specify MDS file systems for some DSs. This change does not affect the cases where all DSs are assigned to specified file systems or all DSs are for all file systems. Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c Tue Jul 3 23:09:09 2018 (r335917) +++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c Tue Jul 3 23:29:18 2018 (r335918) @@ -3848,7 +3848,7 @@ nfsrv_pnfscreate(struct vnode *vp, struct vattr *vap, NFSPROC_T *p) { struct nfsrvdscreate *dsc, *tdsc; - struct nfsdevice *ds, *mds; + struct nfsdevice *ds, *tds, *fds; struct mount *mp; struct pnfsdsfile *pf, *tpf; struct pnfsdsattr dsattr; @@ -3866,12 +3866,25 @@ nfsrv_pnfscreate(struct vnode *vp, struct vattr *vap, /* Get a DS server directory in a round-robin order. */ mirrorcnt = 1; mp = vp->v_mount; + ds = fds = NULL; NFSDDSLOCK(); - TAILQ_FOREACH(ds, &nfsrv_devidhead, nfsdev_list) { - if (ds->nfsdev_nmp != NULL && (ds->nfsdev_mdsisset == 0 || - (mp->mnt_stat.f_fsid.val[0] == ds->nfsdev_mdsfsid.val[0] && - mp->mnt_stat.f_fsid.val[1] == ds->nfsdev_mdsfsid.val[1]))) - break; + /* + * Search for the first entry that handles this MDS fs, but use the + * first entry for all MDS fs's otherwise. + */ + TAILQ_FOREACH(tds, &nfsrv_devidhead, nfsdev_list) { + if (tds->nfsdev_nmp != NULL) { + if (tds->nfsdev_mdsisset == 0 && ds == NULL) + ds = tds; + else if (tds->nfsdev_mdsisset != 0 && + mp->mnt_stat.f_fsid.val[0] == + tds->nfsdev_mdsfsid.val[0] && + mp->mnt_stat.f_fsid.val[1] == + tds->nfsdev_mdsfsid.val[1]) { + ds = fds = tds; + break; + } + } } if (ds == NULL) { NFSDDSUNLOCK(); @@ -3881,17 +3894,18 @@ nfsrv_pnfscreate(struct vnode *vp, struct vattr *vap, i = dsdir[0] = ds->nfsdev_nextdir; ds->nfsdev_nextdir = (ds->nfsdev_nextdir + 1) % nfsrv_dsdirsize; dvp[0] = ds->nfsdev_dsdir[i]; - mds = TAILQ_NEXT(ds, nfsdev_list); - if (nfsrv_maxpnfsmirror > 1 && mds != NULL) { - TAILQ_FOREACH_FROM(mds, &nfsrv_devidhead, nfsdev_list) { - if (mds->nfsdev_nmp != NULL && - (mds->nfsdev_mdsisset == 0 || - (mp->mnt_stat.f_fsid.val[0] == - mds->nfsdev_mdsfsid.val[0] && + tds = TAILQ_NEXT(ds, nfsdev_list); + if (nfsrv_maxpnfsmirror > 1 && tds != NULL) { + TAILQ_FOREACH_FROM(tds, &nfsrv_devidhead, nfsdev_list) { + if (tds->nfsdev_nmp != NULL && + ((tds->nfsdev_mdsisset == 0 && fds == NULL) || + (tds->nfsdev_mdsisset != 0 && fds != NULL && + mp->mnt_stat.f_fsid.val[0] == + tds->nfsdev_mdsfsid.val[0] && mp->mnt_stat.f_fsid.val[1] == - mds->nfsdev_mdsfsid.val[1]))) { + tds->nfsdev_mdsfsid.val[1]))) { dsdir[mirrorcnt] = i; - dvp[mirrorcnt] = mds->nfsdev_dsdir[i]; + dvp[mirrorcnt] = tds->nfsdev_dsdir[i]; mirrorcnt++; if (mirrorcnt >= nfsrv_maxpnfsmirror) break; @@ -4495,7 +4509,7 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char struct nfsmount *nmp, *newnmp; struct sockaddr *sad; struct sockaddr_in *sin; - struct nfsdevice *ds, *fndds; + struct nfsdevice *ds, *tds, *fndds; struct pnfsdsfile *pf; uint32_t dsdir; int error, fhiszero, fnd, gotone, i, mirrorcnt; @@ -4563,6 +4577,7 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char /* Use the socket address to find the mount point. */ fndds = NULL; NFSDDSLOCK(); + /* Find a match for the IP address. */ TAILQ_FOREACH(ds, &nfsrv_devidhead, nfsdev_list) { if (ds->nfsdev_nmp != NULL) { dvp = ds->nfsdev_dvp; @@ -4570,25 +4585,41 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char if (nmp != ds->nfsdev_nmp) printf("different2 nmp %p %p\n", nmp, ds->nfsdev_nmp); - if (nfsaddr2_match(sad, nmp->nm_nam)) + if (nfsaddr2_match(sad, nmp->nm_nam)) { fndds = ds; - else if (newnmpp != NULL && - newnmp == NULL && - (*newnmpp == NULL || - fndds == NULL) && - (ds->nfsdev_mdsisset == 0 || - (ds->nfsdev_mdsfsid.val[0] == + break; + } + } + } + if (fndds != NULL && newnmpp != NULL && + newnmp == NULL) { + /* Search for a place to make a mirror copy. */ + TAILQ_FOREACH(tds, &nfsrv_devidhead, + nfsdev_list) { + if (tds->nfsdev_nmp != NULL && + fndds != tds && + ((tds->nfsdev_mdsisset == 0 && + fndds->nfsdev_mdsisset == 0) || + (tds->nfsdev_mdsisset != 0 && + fndds->nfsdev_mdsisset != 0 && + tds->nfsdev_mdsfsid.val[0] == mp->mnt_stat.f_fsid.val[0] && - ds->nfsdev_mdsfsid.val[1] == - mp->mnt_stat.f_fsid.val[1]))) - /* - * Return a destination for the - * copy in newnmpp. Choose the - * last valid one before the - * source mirror, so it isn't - * always the first one. - */ - *newnmpp = nmp; + tds->nfsdev_mdsfsid.val[1] == + mp->mnt_stat.f_fsid.val[1]))) { + *newnmpp = tds->nfsdev_nmp; + break; + } + } + if (tds != NULL) { + /* + * Move this entry to the end of the + * list, so it won't be selected as + * easily the next time. + */ + TAILQ_REMOVE(&nfsrv_devidhead, tds, + nfsdev_list); + TAILQ_INSERT_TAIL(&nfsrv_devidhead, tds, + nfsdev_list); } } NFSDDSUNLOCK();