From owner-svn-src-projects@freebsd.org Mon Jul 9 00:47:37 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 59D121027A95 for ; Mon, 9 Jul 2018 00:47:37 +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 0A45B76332; Mon, 9 Jul 2018 00:47:37 +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 DA8755D58; Mon, 9 Jul 2018 00:47:36 +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 w690laFL020029; Mon, 9 Jul 2018 00:47:36 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w690laLX020028; Mon, 9 Jul 2018 00:47:36 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807090047.w690laLX020028@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Mon, 9 Jul 2018 00:47:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336117 - projects/pnfs-planb-server/usr.bin/pnfsdskill X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/pnfs-planb-server/usr.bin/pnfsdskill X-SVN-Commit-Revision: 336117 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: Mon, 09 Jul 2018 00:47:37 -0000 Author: rmacklem Date: Mon Jul 9 00:47:36 2018 New Revision: 336117 URL: https://svnweb.freebsd.org/changeset/base/336117 Log: Add a -f/--force option to pnfsdskill, so that it disable a DS even if there is no valid mirror for it. This should only be used to facilitate shutting down of the nfsd when DSs have failed. Modified: projects/pnfs-planb-server/usr.bin/pnfsdskill/pnfsdskill.c Modified: projects/pnfs-planb-server/usr.bin/pnfsdskill/pnfsdskill.c ============================================================================== --- projects/pnfs-planb-server/usr.bin/pnfsdskill/pnfsdskill.c Mon Jul 9 00:38:39 2018 (r336116) +++ projects/pnfs-planb-server/usr.bin/pnfsdskill/pnfsdskill.c Mon Jul 9 00:47:36 2018 (r336117) @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -44,6 +45,11 @@ __FBSDID("$FreeBSD$"); static void usage(void); +static struct option longopts[] = { + { "force", no_argument, NULL, 'f' }, + { NULL, 0, NULL, 0 } +}; + /* * This program disables use of a DS mirror. The "dspath" command line * argument must be an exact match for the mounted-on path of the DS. @@ -54,23 +60,39 @@ int main(int argc, char *argv[]) { struct nfsd_pnfsd_args pnfsdarg; + int ch, force; - if (argc != 2) - usage(); if (geteuid() != 0) errx(1, "Must be run as root/su"); + force = 0; + while ((ch = getopt_long(argc, argv, "f", longopts, NULL)) != -1) { + switch (ch) { + case 'f': + force = 1; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + if (argc != 1) + usage(); - pnfsdarg.op = PNFSDOP_DELDSSERVER; - pnfsdarg.dspath = argv[1]; + if (force != 0) + pnfsdarg.op = PNFSDOP_FORCEDELDS; + else + pnfsdarg.op = PNFSDOP_DELDSSERVER; + pnfsdarg.dspath = *argv; if (nfssvc(NFSSVC_PNFSDS, &pnfsdarg) < 0) - err(1, "Can't kill %s", argv[1]); + err(1, "Can't kill %s", *argv); } static void usage(void) { - fprintf(stderr, "pnfsdsfile [filepath]\n"); + fprintf(stderr, "pnfsdsfile [-f] mounted-on-DS-dir\n"); exit(1); }