From owner-svn-src-projects@freebsd.org Sat Jun 30 19:50:26 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 2F908FD5BBF for ; Sat, 30 Jun 2018 19:50:26 +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 CDDDD8A228; Sat, 30 Jun 2018 19:50:25 +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 AAE9E14589; Sat, 30 Jun 2018 19:50:25 +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 w5UJoPLp037857; Sat, 30 Jun 2018 19:50:25 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5UJoPOS037856; Sat, 30 Jun 2018 19:50:25 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201806301950.w5UJoPOS037856@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Sat, 30 Jun 2018 19:50:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r335824 - projects/pnfs-planb-server/usr.bin/pnfsdsfile X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/pnfs-planb-server/usr.bin/pnfsdsfile X-SVN-Commit-Revision: 335824 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: Sat, 30 Jun 2018 19:50:26 -0000 Author: rmacklem Date: Sat Jun 30 19:50:25 2018 New Revision: 335824 URL: https://svnweb.freebsd.org/changeset/base/335824 Log: Add a "-m" option to pnfsdsfile that can be used by a sysadmin to prep a file on the MDS exported tree to be mirrored. It simply add entrie(s) with an IP address of 0.0.0.0, so pnfsdscopymr -r will mirror it. Modified: projects/pnfs-planb-server/usr.bin/pnfsdsfile/pnfsdsfile.c Modified: projects/pnfs-planb-server/usr.bin/pnfsdsfile/pnfsdsfile.c ============================================================================== --- projects/pnfs-planb-server/usr.bin/pnfsdsfile/pnfsdsfile.c Sat Jun 30 19:36:02 2018 (r335823) +++ projects/pnfs-planb-server/usr.bin/pnfsdsfile/pnfsdsfile.c Sat Jun 30 19:50:25 2018 (r335824) @@ -50,6 +50,7 @@ static void usage(void); static struct option longopts[] = { { "changeds", required_argument, NULL, 'c' }, + { "mirror", required_argument, NULL, 'm' }, { "quiet", no_argument, NULL, 'q' }, { "zerods", required_argument, NULL, 'r' }, { "ds", required_argument, NULL, 's' }, @@ -71,27 +72,27 @@ main(int argc, char *argv[]) struct sockaddr_in6 *sin6, adsin6; char hostn[2 * NI_MAXHOST + 2], *cp; struct pnfsdsfile dsfile[NFSDEV_MAXMIRRORS]; - int ch, dosetxattr, i, mirrorcnt, quiet, zerods, zerofh; + int ch, dosetxattr, i, mirrorcnt, mirrorit, quiet, zerods, zerofh; in_port_t tport; ssize_t xattrsize, xattrsize2; zerods = 0; zerofh = 0; + mirrorit = 0; quiet = 0; dosetxattr = 0; res = NULL; newres = NULL; cp = NULL; - while ((ch = getopt_long(argc, argv, "c:qr:s:z", longopts, NULL)) != -1) - { + while ((ch = getopt_long(argc, argv, "c:m:qr:s:z", longopts, NULL)) != + -1) { switch (ch) { case 'c': /* Replace the first DS server with the second one. */ - if (zerofh != 0 || zerods != 0) - errx(1, "-c, -r and -z are mutually " - "exclusive"); - if (res != NULL) - errx(1, "-c and -s are mutually exclusive"); + if (zerofh != 0 || zerods != 0 || mirrorit != 0 || + newres != NULL || res != NULL) + errx(1, "-c, -m, -r, -s and -z are mutually " + "exclusive and only can be used once"); strlcpy(hostn, optarg, 2 * NI_MAXHOST + 2); cp = strchr(hostn, ','); if (cp == NULL) @@ -103,31 +104,44 @@ main(int argc, char *argv[]) if (getaddrinfo(cp, NULL, NULL, &newres) != 0) errx(1, "Can't get IP# for %s", cp); break; + case 'm': + /* Add 0.0.0.0 entries up to mirror level. */ + if (zerofh != 0 || zerods != 0 || mirrorit != 0 || + newres != NULL || res != NULL) + errx(1, "-c, -m, -r, -s and -z are mutually " + "exclusive and only can be used once"); + mirrorit = atoi(optarg); + if (mirrorit < 2 || mirrorit > NFSDEV_MAXMIRRORS) + errx(1, "-m %d out of range", mirrorit); + break; case 'q': quiet = 1; break; case 'r': /* Reset the DS server in a mirror with 0.0.0.0. */ - if (zerofh != 0 || res != NULL || newres != NULL) - errx(1, "-r and -s, -z or -c are mutually " - "exclusive"); + if (zerofh != 0 || zerods != 0 || mirrorit != 0 || + newres != NULL || res != NULL) + errx(1, "-c, -m, -r, -s and -z are mutually " + "exclusive and only can be used once"); zerods = 1; /* Translate the server name to an IP address. */ if (getaddrinfo(optarg, NULL, NULL, &res) != 0) errx(1, "Can't get IP# for %s", optarg); break; case 's': - if (res != NULL) - errx(1, "-s, -c and -r are mutually " - "exclusive"); /* Translate the server name to an IP address. */ + if (zerofh != 0 || zerods != 0 || mirrorit != 0 || + newres != NULL || res != NULL) + errx(1, "-c, -m, -r, -s and -z are mutually " + "exclusive and only can be used once"); if (getaddrinfo(optarg, NULL, NULL, &res) != 0) errx(1, "Can't get IP# for %s", optarg); break; case 'z': - if (newres != NULL || zerods != 0) - errx(1, "-c, -r and -z are mutually " - "exclusive"); + if (zerofh != 0 || zerods != 0 || mirrorit != 0 || + newres != NULL || res != NULL) + errx(1, "-c, -m, -r, -s and -z are mutually " + "exclusive and only can be used once"); zerofh = 1; break; default: @@ -309,8 +323,26 @@ main(int argc, char *argv[]) dsfile[i].dsf_filename); } } + /* Add entrie(s) with IP address set to 0.0.0.0, as required. */ + for (i = mirrorcnt; i < mirrorit; i++) { + dsfile[i] = dsfile[0]; + dsfile[i].dsf_sin.sin_family = AF_INET; + dsfile[i].dsf_sin.sin_len = sizeof(struct sockaddr_in); + dsfile[i].dsf_sin.sin_addr.s_addr = 0; + dsfile[i].dsf_sin.sin_port = 0; + if (quiet == 0) { + /* Print out the 0.0.0.0 entry. */ + printf("\t0.0.0.0\tds%d/%s", dsfile[i].dsf_dir, + dsfile[i].dsf_filename); + } + } + if (mirrorit > mirrorcnt) { + xattrsize = mirrorit * sizeof(struct pnfsdsfile); + dosetxattr = 1; + } if (quiet == 0) printf("\n"); + if (dosetxattr != 0 && extattr_set_file(*argv, EXTATTR_NAMESPACE_SYSTEM, "pnfsd.dsfile", dsfile, xattrsize) != xattrsize) err(1, "Can't set pnfsd.dsfile");