From owner-svn-src-head@freebsd.org Mon Jul 2 19:26:32 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 7CDB51037956; Mon, 2 Jul 2018 19:26:32 +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 2963476807; Mon, 2 Jul 2018 19:26:32 +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 0625211BCE; Mon, 2 Jul 2018 19:26:32 +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 w62JQVac008951; Mon, 2 Jul 2018 19:26:31 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w62JQVHD008950; Mon, 2 Jul 2018 19:26:31 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807021926.w62JQVHD008950@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Mon, 2 Jul 2018 19:26:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335871 - head/usr.sbin/nfsd X-SVN-Group: head X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: head/usr.sbin/nfsd X-SVN-Commit-Revision: 335871 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: Mon, 02 Jul 2018 19:26:32 -0000 Author: rmacklem Date: Mon Jul 2 19:26:31 2018 New Revision: 335871 URL: https://svnweb.freebsd.org/changeset/base/335871 Log: Add an optional feature to the pNFS server. Without this patch, the pNFS server distributes the data storage files across all of the specified DSs. A tester noted that it would be nice if a system administrator could control which DSs are used to store the file data for a given exported MDS file system. This patch adds an optional suffix for each entry in the "-p" option argument that specifies "store file data for this MDS file system" in this DS. The patch should only affect sites using the pNFS server (specified via the "-p" command line option for nfsd. The interface between the nfsd and the kernel has changed with this patch, so anyone using the "-p" option needs to rebuild their nfsd from sources with this patch applied to them. Discussed with: james.rose@framestore.com Modified: head/usr.sbin/nfsd/nfsd.c Modified: head/usr.sbin/nfsd/nfsd.c ============================================================================== --- head/usr.sbin/nfsd/nfsd.c Mon Jul 2 19:21:33 2018 (r335870) +++ head/usr.sbin/nfsd/nfsd.c Mon Jul 2 19:26:31 2018 (r335871) @@ -1180,9 +1180,11 @@ static void parse_dsserver(const char *optionarg, struct nfsd_nfsd_args *nfsdargp) { char *ad, *cp, *cp2, *dsaddr, *dshost, *dspath, *dsvol, nfsprt[9]; + char *mdspath, *mdsp; int ecode; u_int adsiz, dsaddrcnt, dshostcnt, dspathcnt, hostsiz, pathsiz; - size_t dsaddrsiz, dshostsiz, dspathsiz, nfsprtsiz; + u_int mdspathcnt; + size_t dsaddrsiz, dshostsiz, dspathsiz, nfsprtsiz, mdspathsiz; struct addrinfo hints, *ai_tcp; struct sockaddr_in sin; @@ -1206,6 +1208,11 @@ parse_dsserver(const char *optionarg, struct nfsd_nfsd dsaddr = malloc(dsaddrsiz); if (dsaddr == NULL) errx(1, "Out of memory"); + mdspathsiz = 1024; + mdspathcnt = 0; + mdspath = malloc(mdspathsiz); + if (mdspath == NULL) + errx(1, "Out of memory"); /* Put the NFS port# in "." form. */ snprintf(nfsprt, 9, ".%d.%d", 2049 >> 8, 2049 & 0xff); @@ -1227,6 +1234,14 @@ parse_dsserver(const char *optionarg, struct nfsd_nfsd usage(); *dsvol++ = '\0'; + /* Optional path for MDS file system to be stored on DS. */ + mdsp = strchr(dsvol, '#'); + if (mdsp != NULL) { + if (*(mdsp + 1) == '\0' || mdsp <= dsvol) + usage(); + *mdsp++ = '\0'; + } + /* Append this pathname to dspath. */ pathsiz = strlen(dsvol); if (dspathcnt + pathsiz + 1 > dspathsiz) { @@ -1238,6 +1253,23 @@ parse_dsserver(const char *optionarg, struct nfsd_nfsd strcpy(&dspath[dspathcnt], dsvol); dspathcnt += pathsiz + 1; + /* Append this pathname to mdspath. */ + if (mdsp != NULL) + pathsiz = strlen(mdsp); + else + pathsiz = 0; + if (mdspathcnt + pathsiz + 1 > mdspathsiz) { + mdspathsiz *= 2; + mdspath = realloc(mdspath, mdspathsiz); + if (mdspath == NULL) + errx(1, "Out of memory"); + } + if (mdsp != NULL) + strcpy(&mdspath[mdspathcnt], mdsp); + else + mdspath[mdspathcnt] = '\0'; + mdspathcnt += pathsiz + 1; + if (ai_tcp != NULL) freeaddrinfo(ai_tcp); @@ -1290,6 +1322,8 @@ parse_dsserver(const char *optionarg, struct nfsd_nfsd nfsdargp->dnshostlen = dshostcnt; nfsdargp->dspath = dspath; nfsdargp->dspathlen = dspathcnt; + nfsdargp->mdspath = mdspath; + nfsdargp->mdspathlen = mdspathcnt; freeaddrinfo(ai_tcp); }