From patchwork Mon Jun 30 05:13:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 4445681 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C95C8BEECB for ; Mon, 30 Jun 2014 05:18:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF2F420328 for ; Mon, 30 Jun 2014 05:18:41 +0000 (UTC) Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mail.kernel.org (Postfix) with ESMTP id EF84F202F8 for ; Mon, 30 Jun 2014 05:18:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5U5FOdk014328; Mon, 30 Jun 2014 01:15:25 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s5U5EFxN026057 for ; Mon, 30 Jun 2014 01:14:15 -0400 Received: from dhcp80-209.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5U5EEnG023387 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 30 Jun 2014 01:14:14 -0400 Received: from dhcp80-209.msp.redhat.com (localhost [127.0.0.1]) by dhcp80-209.msp.redhat.com (8.14.7/8.14.7) with ESMTP id s5U5EDMF005126; Mon, 30 Jun 2014 00:14:14 -0500 Received: (from bmarzins@localhost) by dhcp80-209.msp.redhat.com (8.14.7/8.14.7/Submit) id s5U5EDMB005125; Mon, 30 Jun 2014 00:14:13 -0500 From: Benjamin Marzinski To: device-mapper development Date: Mon, 30 Jun 2014 00:13:56 -0500 Message-Id: <1404105243-5071-6-git-send-email-bmarzins@redhat.com> In-Reply-To: <1404105243-5071-1-git-send-email-bmarzins@redhat.com> References: <1404105243-5071-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: dm-devel@redhat.com Cc: Christophe Varoqui Subject: [dm-devel] [PATCH 05/12] allow users to add wwids to /etc/multipath/wwids with -a X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The patch adds a "-a" option to multipath, that allows it to add wwids to the /etc/multipath wwids file. Signed-off-by: Benjamin Marzinski --- libmultipath/config.h | 1 + multipath/main.c | 17 +++++++++++++++-- multipath/multipath.8 | 5 ++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/libmultipath/config.h b/libmultipath/config.h index eb23820..ac7c58e 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -30,6 +30,7 @@ enum mpath_cmds { CMD_VALID_PATH, CMD_REMOVE_WWID, CMD_RESET_WWIDS, + CMD_ADD_WWID, }; struct hwentry { diff --git a/multipath/main.c b/multipath/main.c index 54b2a74..157475e 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -84,7 +84,7 @@ usage (char * progname) { fprintf (stderr, VERSION_STRING); fprintf (stderr, "Usage:\n"); - fprintf (stderr, " %s [-c|-w|-W] [-d] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname); + fprintf (stderr, " %s [-a|-c|-w|-W] [-d] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname); fprintf (stderr, " %s -l|-ll|-f [-v lvl] [-b fil] [dev]\n", progname); fprintf (stderr, " %s -F [-v lvl]\n", progname); fprintf (stderr, " %s -t\n", progname); @@ -97,6 +97,7 @@ usage (char * progname) " -ll show multipath topology (maximum info)\n" \ " -f flush a multipath device map\n" \ " -F flush all multipath device maps\n" \ + " -a add a device wwid to the wwids file\n" \ " -c check if a device should be a path in a multipath device\n" \ " -q allow queue_if_no_path when multipathd is not running\n"\ " -d dry run, do not create or update devmaps\n" \ @@ -295,6 +296,15 @@ configure (void) } goto out; } + if (conf->cmd == CMD_ADD_WWID) { + r = remember_wwid(refwwid); + if (r == 0) + printf("wwid '%s' added\n", refwwid); + else + printf("failed adding '%s' to wwids file\n", + refwwid); + goto out; + } condlog(3, "scope limited to %s", refwwid); if (conf->cmd == CMD_VALID_PATH) { if (check_wwids_file(refwwid, 0) == 0){ @@ -435,7 +445,7 @@ main (int argc, char *argv[]) if (load_config(DEFAULT_CONFIGFILE, udev)) exit(1); - while ((arg = getopt(argc, argv, ":dchl::FfM:v:p:b:BrtqwW")) != EOF ) { + while ((arg = getopt(argc, argv, ":adchl::FfM:v:p:b:BrtqwW")) != EOF ) { switch(arg) { case 1: printf("optarg : %s\n",optarg); break; @@ -505,6 +515,9 @@ main (int argc, char *argv[]) case 'W': conf->cmd = CMD_RESET_WWIDS; break; + case 'a': + conf->cmd = CMD_ADD_WWID; + break; case ':': fprintf(stderr, "Missing option argument\n"); usage(argv[0]); diff --git a/multipath/multipath.8 b/multipath/multipath.8 index a2262ac..b6479b1 100644 --- a/multipath/multipath.8 +++ b/multipath/multipath.8 @@ -8,7 +8,7 @@ multipath \- Device mapper target autoconfig .RB [\| \-b\ \c .IR bindings_file \|] .RB [\| \-d \|] -.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-w | \-W \|] +.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-a | \-w | \-W \|] .RB [\| \-p\ \c .BR failover | multibus | group_by_serial | group_by_prio | group_by_node_name \|] .RB [\| device \|] @@ -68,6 +68,9 @@ check if a block device should be a path in a multipath device .B \-q allow device tables with queue_if_no_path when multipathd is not running .TP +.B \-a +add the wwid for the specified device to the wwids file +.TP .B \-w remove the wwid for the specified device from the wwids file .TP