From owner-svn-src-head@freebsd.org Tue Jul 10 18:41:17 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 AE8291045152; Tue, 10 Jul 2018 18:41:17 +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 5F777856E2; Tue, 10 Jul 2018 18:41:17 +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 409BC27A70; Tue, 10 Jul 2018 18:41:17 +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 w6AIfHUw031244; Tue, 10 Jul 2018 18:41:17 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6AIfHeM031229; Tue, 10 Jul 2018 18:41:17 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807101841.w6AIfHeM031229@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Tue, 10 Jul 2018 18:41:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336176 - head/usr.sbin/pnfsdskill X-SVN-Group: head X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: head/usr.sbin/pnfsdskill X-SVN-Commit-Revision: 336176 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: Tue, 10 Jul 2018 18:41:17 -0000 Author: rmacklem Date: Tue Jul 10 18:41:16 2018 New Revision: 336176 URL: https://svnweb.freebsd.org/changeset/base/336176 Log: Add a "-f" option to pnfsdskill(8) to force disabling of a DS. The pnfsdskill(8) command will normally fail if there is no valid mirror for the DS to be disabled. However, a system administrator may need to disable a DS which does not have a valid mirror so that the nfsd threads can be terminated. This patch adds a "-f" option to pnfsdskill(8) that uses the kernel changes made by r336141 to implement this "forced" case of disabling a DS. This patch only affects the pNFS server. Modified: head/usr.sbin/pnfsdskill/pnfsdskill.c Modified: head/usr.sbin/pnfsdskill/pnfsdskill.c ============================================================================== --- head/usr.sbin/pnfsdskill/pnfsdskill.c Tue Jul 10 18:00:55 2018 (r336175) +++ head/usr.sbin/pnfsdskill/pnfsdskill.c Tue Jul 10 18:41:16 2018 (r336176) @@ -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); }