Date: Tue, 10 Jul 2018 18:41:17 +0000 (UTC) From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336176 - head/usr.sbin/pnfsdskill Message-ID: <201807101841.w6AIfHeM031229@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <err.h> +#include <getopt.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807101841.w6AIfHeM031229>