From patchwork Mon Aug 22 20:41:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12951374 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8084C32792 for ; Mon, 22 Aug 2022 20:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661200920; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8BnDvdlrSkSRkMPuEs5uT5OlMv5sCL2bwqkKKAda+GY=; b=eZzcRl1HQX3QOAVBbK2FQyavZCfexXPS/bTyq1csHD3hoKAM3pioe7zEkqBfTbgOR7AZdR UJarhkhtDpUEfqsUZARZS7RRVtshXKbh2sFGW5G6U45HWN5Q/l+BXekxlH0nJCzSEaOdGH UST151R0R/IoSjOCB62nUqAsNW6xrGk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-368-4ScJK6j6OtOEDgHwPihZSw-1; Mon, 22 Aug 2022 16:41:57 -0400 X-MC-Unique: 4ScJK6j6OtOEDgHwPihZSw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ABEE1381494B; Mon, 22 Aug 2022 20:41:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88437492C3B; Mon, 22 Aug 2022 20:41:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 51B7C1946A47; Mon, 22 Aug 2022 20:41:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 555621946A47 for ; Mon, 22 Aug 2022 20:41:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 090B0C15BBA; Mon, 22 Aug 2022 20:41:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 05827C15BB3 for ; Mon, 22 Aug 2022 20:41:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E178E185A7BA for ; Mon, 22 Aug 2022 20:41:51 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-599-jCwh0E2-PhaQCb3F9b2kmQ-1; Mon, 22 Aug 2022 16:41:50 -0400 X-MC-Unique: jCwh0E2-PhaQCb3F9b2kmQ-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AA76237339; Mon, 22 Aug 2022 20:41:48 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 75A9813523; Mon, 22 Aug 2022 20:41:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WDspGwzqA2MOAwAAMHmgww (envelope-from ); Mon, 22 Aug 2022 20:41:48 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Mon, 22 Aug 2022 22:41:09 +0200 Message-Id: <20220822204119.20719-2-mwilck@suse.com> In-Reply-To: <20220822204119.20719-1-mwilck@suse.com> References: <20220822204119.20719-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Subject: [dm-devel] [PATCH v2 01/11] multipathd: replace libreadline with getline() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Xose Vazquez Perez Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Hannes Reinecke libreadline changed the license to be incompatible with multipath-tools usage, so replace it with a simple getline(). mwilck: Make this the default option via Makefile.inc; it is used if READLINE is unset. Compiling with READLINE=libreadline or READLINE=libedit remains possible. Signed-off-by: Hannes Reinecke Signed-off-by: Martin Wilck --- Makefile.inc | 4 ++-- multipathd/cli.c | 2 ++ multipathd/uxclnt.c | 50 ++++++++++++++++++++++++++++++--------------- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/Makefile.inc b/Makefile.inc index ad7afd0..0653d21 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -9,10 +9,10 @@ # Uncomment to disable dmevents polling support # ENABLE_DMEVENTS_POLL = 0 # -# Readline library to use, libedit or libreadline +# Readline library to use, libedit, libreadline, or empty # Caution: Using libreadline may make the multipathd binary undistributable, # see https://github.com/opensvc/multipath-tools/issues/36 -READLINE = libedit +READLINE := # List of scsi device handler modules to load on boot, e.g. # SCSI_DH_MODULES_PRELOAD := scsi_dh_alua scsi_dh_rdac diff --git a/multipathd/cli.c b/multipathd/cli.c index fa482a6..cc56950 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -459,6 +459,7 @@ void cli_exit(void) keys = NULL; } +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) static int key_match_fingerprint (struct key * kw, uint64_t fp) { @@ -564,3 +565,4 @@ key_generator (const char * str, int state) */ return ((char *)NULL); } +#endif diff --git a/multipathd/uxclnt.c b/multipathd/uxclnt.c index 251e7d7..b817bea 100644 --- a/multipathd/uxclnt.c +++ b/multipathd/uxclnt.c @@ -30,6 +30,7 @@ #include "defaults.h" #include "vector.h" +#include "util.h" #include "cli.h" #include "uxclnt.h" @@ -77,35 +78,52 @@ static int need_quit(char *str, size_t len) */ static void process(int fd, unsigned int timeout) { - char *line; - char *reply; - int ret; - cli_init(); +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) rl_readline_name = "multipathd"; rl_completion_entry_function = key_generator; - while ((line = readline("multipathd> "))) { - size_t llen = strlen(line); +#endif - if (!llen) { - free(line); + cli_init(); + for(;;) + { + char *line __attribute__((cleanup(cleanup_charp))) = NULL; + char *reply __attribute__((cleanup(cleanup_charp))) = NULL; + ssize_t llen; + int ret; + +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) + line = readline("multipathd> "); + if (!line) + break; + llen = strlen(line); + if (!llen) continue; +#else + size_t lsize = 0; + + fputs("multipathd> ", stdout); + errno = 0; + llen = getline(&line, &lsize, stdin); + if (llen == -1) { + if (errno != 0) + fprintf(stderr, "Error in getline: %m"); + break; } + if (!llen || !strcmp(line, "\n")) + continue; +#endif if (need_quit(line, llen)) break; - if (send_packet(fd, line) != 0) break; + if (send_packet(fd, line) != 0) + break; ret = recv_packet(fd, &reply, timeout); - if (ret != 0) break; + if (ret != 0) + break; print_reply(reply); - - if (line && *line) - add_history(line); - - free(line); - free(reply); } } From patchwork Mon Aug 22 20:41:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12951375 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E635FC3F6B0 for ; Mon, 22 Aug 2022 20:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661200920; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MSNOwsdijvjw0Myd90Dm85fXwCz3AUo9Ev6ip/tUL38=; b=KqOe1r4gWl0Or2gV/kQb8h6TS0k/OCZs5O5N47UpGxCU40n+0B6hCVVjgGZnt81oOE3RPy FibnR9p3z28AlX9dLogq+Ot3Nmb7jvqIr07RoyIBeW5Mpt/o5mlPMIwZrLKcI1jzrDJXge LD3iP/c2I/7xjc3W2BKaWHs2pfApSC0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-368-WInD5OvuPleIj_j6sotIzg-1; Mon, 22 Aug 2022 16:41:57 -0400 X-MC-Unique: WInD5OvuPleIj_j6sotIzg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AB879823F0E; Mon, 22 Aug 2022 20:41:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 238DF2026D64; Mon, 22 Aug 2022 20:41:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 05A9C1946A5C; Mon, 22 Aug 2022 20:41:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 186861946A52 for ; Mon, 22 Aug 2022 20:41:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0D9452166B29; Mon, 22 Aug 2022 20:41:54 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09B132166B26 for ; Mon, 22 Aug 2022 20:41:54 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E271C3C1618B for ; Mon, 22 Aug 2022 20:41:53 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-663-DA0qVT8nNaKJOFCnFla0SQ-1; Mon, 22 Aug 2022 16:41:50 -0400 X-MC-Unique: DA0qVT8nNaKJOFCnFla0SQ-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 047773733A; Mon, 22 Aug 2022 20:41:49 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B358113523; Mon, 22 Aug 2022 20:41:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2Pc3KgzqA2MOAwAAMHmgww (envelope-from ); Mon, 22 Aug 2022 20:41:48 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Mon, 22 Aug 2022 22:41:10 +0200 Message-Id: <20220822204119.20719-3-mwilck@suse.com> In-Reply-To: <20220822204119.20719-1-mwilck@suse.com> References: <20220822204119.20719-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Subject: [dm-devel] [PATCH v2 02/11] .gitignore: ignore generated ABI files X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Xose Vazquez Perez , Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Signed-off-by: Martin Wilck --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 8e09f95..b88608c 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ tests/*.out tests/*.vgr libmultipath/nvme-ioctl.c libmultipath/nvme-ioctl.h +*/*-nv.version +reference-abi From patchwork Mon Aug 22 20:41:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12951380 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D68DC38147 for ; Mon, 22 Aug 2022 20:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661200923; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=v+1peY76Sylmu4WV8v4ecqprU/qpmwDVtnHf2u7zNQo=; b=UwF37uS8RZXrP7wQu2CaUA32ZSXoZ0o6Q4rmUtje9hLwn7tziaN/GL2tNEfUT0fATAmZNl l4RIR9egYXxdMAEaQLEeSM72hIcECWj/wyBAmRI8oGgiT+JZCf62faKyjVG+2vzR2Qpn/e q3uF4CTMmUutDN6EK57p9Cr86ogi4sQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-55-PO3reWM3P3CBNZzU-CEosA-1; Mon, 22 Aug 2022 16:41:59 -0400 X-MC-Unique: PO3reWM3P3CBNZzU-CEosA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 984A41011602; Mon, 22 Aug 2022 20:41:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 861BE2166B26; Mon, 22 Aug 2022 20:41:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 741731946A5B; Mon, 22 Aug 2022 20:41:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 21E0C1946A40 for ; Mon, 22 Aug 2022 20:41:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 13B3C492CA5; Mon, 22 Aug 2022 20:41:56 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 10128492C3B for ; Mon, 22 Aug 2022 20:41:56 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EE87985A59A for ; Mon, 22 Aug 2022 20:41:55 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-134-340sBAufOOW8OLL-0shyXQ-1; Mon, 22 Aug 2022 16:41:51 -0400 X-MC-Unique: 340sBAufOOW8OLL-0shyXQ-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5B7D7202C6; Mon, 22 Aug 2022 20:41:49 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0DE7313523; Mon, 22 Aug 2022 20:41:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oHzNAQ3qA2MOAwAAMHmgww (envelope-from ); Mon, 22 Aug 2022 20:41:49 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Mon, 22 Aug 2022 22:41:11 +0200 Message-Id: <20220822204119.20719-4-mwilck@suse.com> In-Reply-To: <20220822204119.20719-1-mwilck@suse.com> References: <20220822204119.20719-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Subject: [dm-devel] [PATCH v2 03/11] libmultipath: move all reservation key functions to prkey.c X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Xose Vazquez Perez , Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Also make parse_prkey() static, and avoid including libmpathpersist headers in libmultipath. The only exception is now prkey.c, where we pull in some public declarations from mpath_persist.h. Signed-off-by: Martin Wilck --- libmultipath/Makefile | 2 +- libmultipath/dict.c | 16 +------------- libmultipath/dict.h | 2 -- libmultipath/prkey.c | 49 ++++++++++++++++++++++++++++++++++++++++++- libmultipath/prkey.h | 3 +++ libmultipath/util.c | 32 ---------------------------- libmultipath/util.h | 2 -- 7 files changed, 53 insertions(+), 53 deletions(-) diff --git a/libmultipath/Makefile b/libmultipath/Makefile index fb03200..033fc83 100644 --- a/libmultipath/Makefile +++ b/libmultipath/Makefile @@ -8,7 +8,7 @@ DEVLIB = libmultipath.so LIBS = $(DEVLIB).$(SONAME) VERSION_SCRIPT := libmultipath.version -CPPFLAGS += -I$(mpathcmddir) -I$(mpathpersistdir) -I$(nvmedir) +CPPFLAGS += -I$(mpathcmddir) -I$(nvmedir) CFLAGS += $(LIB_CFLAGS) LIBDEPS += -lpthread -ldl -ldevmapper -ludev -L$(mpathcmddir) -lmpathcmd -lurcu -laio diff --git a/libmultipath/dict.c b/libmultipath/dict.c index ad049cc..aa93fe4 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -24,10 +24,10 @@ #include #include #include -#include #include "mpath_cmd.h" #include "dict.h" #include "strbuf.h" +#include "prkey.h" static void do_set_int(vector strvec, void *ptr, int min, int max, const char *file, @@ -1404,20 +1404,6 @@ set_reservation_key(vector strvec, struct be64 *be64_ptr, uint8_t *flags_ptr, return 0; } -int -print_reservation_key(struct strbuf *buff, - struct be64 key, uint8_t flags, int source) -{ - char *flagstr = ""; - if (source == PRKEY_SOURCE_NONE) - return 0; - if (source == PRKEY_SOURCE_FILE) - return append_strbuf_quoted(buff, "file"); - if (flags & MPATH_F_APTPL_MASK) - flagstr = ":aptpl"; - return print_strbuf(buff, "0x%" PRIx64 "%s", get_be64(key), flagstr); -} - static int def_reservation_key_handler(struct config *conf, vector strvec, const char *file, int line_nr) diff --git a/libmultipath/dict.h b/libmultipath/dict.h index d80f990..15d9cba 100644 --- a/libmultipath/dict.h +++ b/libmultipath/dict.h @@ -16,7 +16,5 @@ int print_pgpolicy(struct strbuf *buff, long v); int print_no_path_retry(struct strbuf *buff, long v); int print_undef_off_zero(struct strbuf *buff, long v); int print_dev_loss(struct strbuf *buff, unsigned long v); -int print_reservation_key(struct strbuf *buff, - struct be64 key, uint8_t flags, int source); int print_off_int_undef(struct strbuf *buff, long v); #endif /* _DICT_H */ diff --git a/libmultipath/prkey.c b/libmultipath/prkey.c index d645f81..a215499 100644 --- a/libmultipath/prkey.c +++ b/libmultipath/prkey.c @@ -4,6 +4,7 @@ #include "config.h" #include "util.h" #include "propsel.h" +#include "strbuf.h" #include "prkey.h" #include #include @@ -12,11 +13,57 @@ #include #include #include -#include +/* MPATH_F_APTPL_MASK is publicly defined in mpath_persist.h */ +#include <../libmpathpersist/mpath_persist.h> #define PRKEY_READ 0 #define PRKEY_WRITE 1 +int +print_reservation_key(struct strbuf *buff, + struct be64 key, uint8_t flags, int source) +{ + char *flagstr = ""; + if (source == PRKEY_SOURCE_NONE) + return 0; + if (source == PRKEY_SOURCE_FILE) + return append_strbuf_quoted(buff, "file"); + if (flags & MPATH_F_APTPL_MASK) + flagstr = ":aptpl"; + return print_strbuf(buff, "0x%" PRIx64 "%s", get_be64(key), flagstr); +} + +static int parse_prkey(const char *ptr, uint64_t *prkey) +{ + if (!ptr) + return 1; + if (*ptr == '0') + ptr++; + if (*ptr == 'x' || *ptr == 'X') + ptr++; + if (*ptr == '\0' || strlen(ptr) > 16) + return 1; + if (strlen(ptr) != strspn(ptr, "0123456789aAbBcCdDeEfF")) + return 1; + if (sscanf(ptr, "%" SCNx64 "", prkey) != 1) + return 1; + return 0; +} + +int parse_prkey_flags(const char *ptr, uint64_t *prkey, uint8_t *flags) +{ + char *flagstr; + + flagstr = strchr(ptr, ':'); + *flags = 0; + if (flagstr) { + *flagstr++ = '\0'; + if (strlen(flagstr) == 5 && strcmp(flagstr, "aptpl") == 0) + *flags = MPATH_F_APTPL_MASK; + } + return parse_prkey(ptr, prkey); +} + static int do_prkey(int fd, char *wwid, char *keystr, int cmd) { char buf[4097]; diff --git a/libmultipath/prkey.h b/libmultipath/prkey.h index 6739191..a16de10 100644 --- a/libmultipath/prkey.h +++ b/libmultipath/prkey.h @@ -13,6 +13,9 @@ "# prkey wwid\n" \ "#\n" +int print_reservation_key(struct strbuf *buff, + struct be64 key, uint8_t flags, int source); +int parse_prkey_flags(const char *ptr, uint64_t *prkey, uint8_t *flags); int set_prkey(struct config *conf, struct multipath *mpp, uint64_t prkey, uint8_t sa_flags); int get_prkey(struct config *conf, struct multipath *mpp, uint64_t *prkey, diff --git a/libmultipath/util.c b/libmultipath/util.c index e7e7d4c..6979e74 100644 --- a/libmultipath/util.c +++ b/libmultipath/util.c @@ -13,7 +13,6 @@ #include #include #include -#include #include "util.h" #include "debug.h" @@ -333,37 +332,6 @@ int get_linux_version_code(void) return _linux_version_code; } -int parse_prkey(const char *ptr, uint64_t *prkey) -{ - if (!ptr) - return 1; - if (*ptr == '0') - ptr++; - if (*ptr == 'x' || *ptr == 'X') - ptr++; - if (*ptr == '\0' || strlen(ptr) > 16) - return 1; - if (strlen(ptr) != strspn(ptr, "0123456789aAbBcCdDeEfF")) - return 1; - if (sscanf(ptr, "%" SCNx64 "", prkey) != 1) - return 1; - return 0; -} - -int parse_prkey_flags(const char *ptr, uint64_t *prkey, uint8_t *flags) -{ - char *flagstr; - - flagstr = strchr(ptr, ':'); - *flags = 0; - if (flagstr) { - *flagstr++ = '\0'; - if (strlen(flagstr) == 5 && strcmp(flagstr, "aptpl") == 0) - *flags = MPATH_F_APTPL_MASK; - } - return parse_prkey(ptr, prkey); -} - int safe_write(int fd, const void *buf, size_t count) { while (count > 0) { diff --git a/libmultipath/util.h b/libmultipath/util.h index 5a44018..bede49d 100644 --- a/libmultipath/util.h +++ b/libmultipath/util.h @@ -24,8 +24,6 @@ char *convert_dev(char *dev, int is_path_device); void setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached); int systemd_service_enabled(const char *dev); int get_linux_version_code(void); -int parse_prkey(const char *ptr, uint64_t *prkey); -int parse_prkey_flags(const char *ptr, uint64_t *prkey, uint8_t *flags); int safe_write(int fd, const void *buf, size_t count); void set_max_fds(rlim_t max_fds); int should_exit(void); From patchwork Mon Aug 22 20:41:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12951381 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 565A4C38145 for ; Mon, 22 Aug 2022 20:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661200923; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=o2Zh6nKjyeHfDk2fg51GjklERe7KG2MWp/GD/OBfF60=; b=MjwO/X1ldXtTnRElpKUcJdCrmTBSEE+tGq6UTkFILtfjw6myd474t7n0Lu4dNUkmljZ+aO TSwJpcHdn4XxH/FJYKFQ/8ioyMPqTnZlrv4WdczLvo5LK6Ltu0QZQ6Fvh6gaOOrhj9Y8Lt T0xS5upoP1Z6MrET9REKHdElxcc7KGM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-212-nrVnxOY5Pg2-mo8tcChPhA-1; Mon, 22 Aug 2022 16:41:59 -0400 X-MC-Unique: nrVnxOY5Pg2-mo8tcChPhA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F0CBF8039B0; Mon, 22 Aug 2022 20:41:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEAD240D2830; Mon, 22 Aug 2022 20:41:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C63F41946A67; Mon, 22 Aug 2022 20:41:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DFCA61946A52 for ; Mon, 22 Aug 2022 20:41:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C244B1121315; Mon, 22 Aug 2022 20:41:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BEE291121319 for ; Mon, 22 Aug 2022 20:41:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A50F08117B0 for ; Mon, 22 Aug 2022 20:41:53 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-211-hRZEwb36NMK2vfOsq31byw-1; Mon, 22 Aug 2022 16:41:51 -0400 X-MC-Unique: hRZEwb36NMK2vfOsq31byw-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A2689202ED; Mon, 22 Aug 2022 20:41:49 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 66B9013523; Mon, 22 Aug 2022 20:41:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oJeDFw3qA2MOAwAAMHmgww (envelope-from ); Mon, 22 Aug 2022 20:41:49 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Mon, 22 Aug 2022 22:41:12 +0200 Message-Id: <20220822204119.20719-5-mwilck@suse.com> In-Reply-To: <20220822204119.20719-1-mwilck@suse.com> References: <20220822204119.20719-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Subject: [dm-devel] [PATCH v2 04/11] libmultipath: always set _GNU_SOURCE X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Xose Vazquez Perez , Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck ... not only if dm_task_no_flush is available. Also, look for includes under libmultipath but not under libmpathpersist. Signed-off-by: Martin Wilck --- libmultipath/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libmultipath/Makefile b/libmultipath/Makefile index 033fc83..348af3f 100644 --- a/libmultipath/Makefile +++ b/libmultipath/Makefile @@ -8,7 +8,7 @@ DEVLIB = libmultipath.so LIBS = $(DEVLIB).$(SONAME) VERSION_SCRIPT := libmultipath.version -CPPFLAGS += -I$(mpathcmddir) -I$(nvmedir) +CPPFLAGS += -I$(mpathcmddir) -I$(nvmedir) -D_GNU_SOURCE CFLAGS += $(LIB_CFLAGS) LIBDEPS += -lpthread -ldl -ldevmapper -ludev -L$(mpathcmddir) -lmpathcmd -lurcu -laio @@ -23,7 +23,7 @@ ifdef SYSTEMD endif ifneq ($(call check_func,dm_task_no_flush,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) - CPPFLAGS += -DLIBDM_API_FLUSH -D_GNU_SOURCE + CPPFLAGS += -DLIBDM_API_FLUSH endif ifneq ($(call check_func,dm_task_get_errno,$(DEVMAPPER_INCDIR)/libdevmapper.h),0) From patchwork Mon Aug 22 20:41:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12951376 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 42A1AC32793 for ; Mon, 22 Aug 2022 20:42:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661200921; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=WsxmgyX+H6VI0gd5Fm6gm8sHP13J62r+xb5SyYnOTUQ=; b=Tz98BEJBsR8G2cAWlMCl4+/k+yhUh4Af856XPE5DARNcBsGxHRJA/G/VyQ0h3Tp6ysIdTI twb3liVXIQMN42xhE7pxcs5ccMWld5qS9IfdYWqrqw4Qj2AGGWoFL3DepE1ajzoFPnSodk xrXLRpOW7in6E4qbDI5NTqJS6HzHLmg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-22-xVsAXhomPkOD0IuQ1o1ZRQ-1; Mon, 22 Aug 2022 16:41:57 -0400 X-MC-Unique: xVsAXhomPkOD0IuQ1o1ZRQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC2E23C16191; Mon, 22 Aug 2022 20:41:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A3001121315; Mon, 22 Aug 2022 20:41:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8284B1946A63; Mon, 22 Aug 2022 20:41:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 169F21946A40 for ; Mon, 22 Aug 2022 20:41:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F10464010D42; Mon, 22 Aug 2022 20:41:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EDB6B40C141D for ; Mon, 22 Aug 2022 20:41:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D55213C16187 for ; Mon, 22 Aug 2022 20:41:52 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-373-5uFIHnYFO0uipUgvKDSQZQ-1; Mon, 22 Aug 2022 16:41:51 -0400 X-MC-Unique: 5uFIHnYFO0uipUgvKDSQZQ-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E9B2520337; Mon, 22 Aug 2022 20:41:49 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id AD58113523; Mon, 22 Aug 2022 20:41:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GAXEKA3qA2MOAwAAMHmgww (envelope-from ); Mon, 22 Aug 2022 20:41:49 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Mon, 22 Aug 2022 22:41:13 +0200 Message-Id: <20220822204119.20719-6-mwilck@suse.com> In-Reply-To: <20220822204119.20719-1-mwilck@suse.com> References: <20220822204119.20719-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Subject: [dm-devel] [PATCH v2 05/11] multipath-tools: Makefile: fix dependencies for "install" target X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Xose Vazquez Perez , Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck subdir.install targets should depend on subdir targets. This is cleaner than just having "install" depend on "all". Signed-off-by: Martin Wilck --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 82e0ea3..ffca586 100644 --- a/Makefile +++ b/Makefile @@ -84,7 +84,7 @@ libmultipath/checkers.install \ $(BUILDDIRS.clean): $(MAKE) -C ${@:.clean=} clean -$(BUILDDIRS:=.install): +$(BUILDDIRS:=.install): $(BUILDDIRS) $(MAKE) -C ${@:.install=} install $(BUILDDIRS:=.uninstall): @@ -93,7 +93,7 @@ $(BUILDDIRS:=.uninstall): clean: $(BUILDDIRS.clean) rm -rf abi abi.tar.gz abi-test compile_commands.json -install: all $(BUILDDIRS:=.install) +install: $(BUILDDIRS:=.install) uninstall: $(BUILDDIRS:=.uninstall) test-progs: all From patchwork Mon Aug 22 20:41:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12951378 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29569C28D13 for ; Mon, 22 Aug 2022 20:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661200922; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Yt/Ch5PNOXmmAifp4bYXiBLjs9T65JsGZefSrBBHYFI=; b=TNMkQGNooikv3WW/bSDxb8i1+HFrhXxfcdCROh9tpzkkiuIRlN/GHrnfjMWWeq0NR1tKmU xk15D199VW/leMj5tpFWIBn1toCubEoIHWhhM0Xc29b5QV6v1TgJWq5wl0z3kd1JN2p8TQ vmPZe5Q8CR4sF9vbrEb6+wgzCCLPvrk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-314-V_pjGIhRM-uCbT2hI1Kvrg-1; Mon, 22 Aug 2022 16:41:59 -0400 X-MC-Unique: V_pjGIhRM-uCbT2hI1Kvrg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55FF280252B; Mon, 22 Aug 2022 20:41:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45197141511A; Mon, 22 Aug 2022 20:41:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 359AF1946A47; Mon, 22 Aug 2022 20:41:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 77E2C1946A58 for ; Mon, 22 Aug 2022 20:41:55 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6739640CF8E8; Mon, 22 Aug 2022 20:41:55 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6370240CFD0B for ; Mon, 22 Aug 2022 20:41:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4A6513C16196 for ; Mon, 22 Aug 2022 20:41:55 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-618-twmHiIxgPq2bzJ1vRzF0UQ-1; Mon, 22 Aug 2022 16:41:51 -0400 X-MC-Unique: twmHiIxgPq2bzJ1vRzF0UQ-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3FAF95C4E7; Mon, 22 Aug 2022 20:41:50 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0288D13523; Mon, 22 Aug 2022 20:41:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IOioOg3qA2MOAwAAMHmgww (envelope-from ); Mon, 22 Aug 2022 20:41:49 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Mon, 22 Aug 2022 22:41:14 +0200 Message-Id: <20220822204119.20719-7-mwilck@suse.com> In-Reply-To: <20220822204119.20719-1-mwilck@suse.com> References: <20220822204119.20719-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Subject: [dm-devel] [PATCH v2 06/11] libmultipath checkers/prioritizers: search for includes in libmultipath X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Xose Vazquez Perez , Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Set TOPDIR correctly rather than using hard-coded "../". Also remove duplicate -lmultipath in checkers makefile. Signed-off-by: Martin Wilck --- libmultipath/checkers/Makefile | 7 ++++--- libmultipath/checkers/directio.c | 4 ++-- libmultipath/checkers/tur.c | 8 ++++---- libmultipath/foreign/Makefile | 4 ++-- libmultipath/prioritizers/Makefile | 6 ++++-- libmultipath/prioritizers/alua_rtpg.c | 2 +- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/libmultipath/checkers/Makefile b/libmultipath/checkers/Makefile index 8d8e45e..e1d7904 100644 --- a/libmultipath/checkers/Makefile +++ b/libmultipath/checkers/Makefile @@ -1,12 +1,13 @@ # # Copyright (C) 2003 Christophe Varoqui, # +TOPDIR = ../.. include ../../Makefile.inc -CPPFLAGS += -I.. +CPPFLAGS += -I$(multipathdir) CFLAGS += $(LIB_CFLAGS) -LDFLAGS += -L.. -lmultipath -LIBDEPS = -lmultipath -laio -lpthread -lrt +LDFLAGS += -L$(multipathdir) -lmultipath +LIBDEPS = -laio -lpthread -lrt # If you add or remove a checker also update multipath/multipath.conf.5 LIBS= \ diff --git a/libmultipath/checkers/directio.c b/libmultipath/checkers/directio.c index a326e37..2f3ece0 100644 --- a/libmultipath/checkers/directio.c +++ b/libmultipath/checkers/directio.c @@ -15,8 +15,8 @@ #include #include "checkers.h" -#include "../libmultipath/debug.h" -#include "../libmultipath/time-util.h" +#include "debug.h" +#include "time-util.h" #define AIO_GROUP_SIZE 1024 diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c index 1bcb757..551dc4f 100644 --- a/libmultipath/checkers/tur.c +++ b/libmultipath/checkers/tur.c @@ -19,10 +19,10 @@ #include "checkers.h" -#include "../libmultipath/debug.h" -#include "../libmultipath/sg_include.h" -#include "../libmultipath/util.h" -#include "../libmultipath/time-util.h" +#include "debug.h" +#include "sg_include.h" +#include "util.h" +#include "time-util.h" #define TUR_CMD_LEN 6 #define HEAVY_CHECK_COUNT 10 diff --git a/libmultipath/foreign/Makefile b/libmultipath/foreign/Makefile index 42cea4d..3d4491a 100644 --- a/libmultipath/foreign/Makefile +++ b/libmultipath/foreign/Makefile @@ -4,9 +4,9 @@ TOPDIR=../.. include ../../Makefile.inc -CPPFLAGS += -I.. -I$(nvmedir) +CPPFLAGS += -I$(multipathdir) -I$(nvmedir) CFLAGS += $(LIB_CFLAGS) -LDFLAGS += -L.. +LDFLAGS += -L$(multipathdir) LIBDEPS = -lmultipath -ludev -lpthread -lrt LIBS = libforeign-nvme.so diff --git a/libmultipath/prioritizers/Makefile b/libmultipath/prioritizers/Makefile index a5ab5e1..eb6f03b 100644 --- a/libmultipath/prioritizers/Makefile +++ b/libmultipath/prioritizers/Makefile @@ -1,11 +1,13 @@ # # Copyright (C) 2007 Christophe Varoqui, # +TOPDIR=../.. + include ../../Makefile.inc -CPPFLAGS += -I.. +CPPFLAGS += -I$(multipathdir) CFLAGS += $(LIB_CFLAGS) -LDFLAGS += -L.. +LDFLAGS += -L$(multipathdir) LIBDEPS = -lmultipath -lm -lpthread -lrt # If you add or remove a prioritizer also update multipath/multipath.conf.5 diff --git a/libmultipath/prioritizers/alua_rtpg.c b/libmultipath/prioritizers/alua_rtpg.c index 4db13c2..2db9153 100644 --- a/libmultipath/prioritizers/alua_rtpg.c +++ b/libmultipath/prioritizers/alua_rtpg.c @@ -27,7 +27,7 @@ #include "../structs.h" #include "../prio.h" #include "../discovery.h" -#include "../debug.h" +#include "debug.h" #include "alua_rtpg.h" #define SENSE_BUFF_LEN 32 From patchwork Mon Aug 22 20:41:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12951373 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2BC6EC28D13 for ; Mon, 22 Aug 2022 20:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661200919; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=QLf1N7CwahTQo9tLv4fyp/HgRfnb2xymWuklGQV+uaU=; b=LAtGSWUgYe/Gmxt6toj9gBTt6zg0Ut+oCZdfHwVtq8tgvfGelg+Rm5YN5vx4Q0k1p5D5+A Zhoje6cHlMYniPgtN0UyxUYvsp7fZeTT/B69PI0ADSXzhDeqBYTBkJsdjoCU5Hcxo/vVX8 Blfq8howrL4xvHy3VpN/vDMSRRRD1qA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-206-QQaOawYBP6KtEbC_naW82A-1; Mon, 22 Aug 2022 16:41:57 -0400 X-MC-Unique: QQaOawYBP6KtEbC_naW82A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC24F2999B23; Mon, 22 Aug 2022 20:41:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7481C15BB3; Mon, 22 Aug 2022 20:41:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BF4CD1946A52; Mon, 22 Aug 2022 20:41:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BDB831946A67 for ; Mon, 22 Aug 2022 20:41:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 93427492CA5; Mon, 22 Aug 2022 20:41:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F81E492CA4 for ; Mon, 22 Aug 2022 20:41:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 77049803301 for ; Mon, 22 Aug 2022 20:41:53 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-3-jRqlSxKJPESDT4FvoCTp3Q-1; Mon, 22 Aug 2022 16:41:51 -0400 X-MC-Unique: jRqlSxKJPESDT4FvoCTp3Q-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 857D35CAF5; Mon, 22 Aug 2022 20:41:50 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 48EC913523; Mon, 22 Aug 2022 20:41:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KFc+EA7qA2MOAwAAMHmgww (envelope-from ); Mon, 22 Aug 2022 20:41:50 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Mon, 22 Aug 2022 22:41:15 +0200 Message-Id: <20220822204119.20719-8-mwilck@suse.com> In-Reply-To: <20220822204119.20719-1-mwilck@suse.com> References: <20220822204119.20719-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Subject: [dm-devel] [PATCH v2 07/11] libmultipath: remove weak attribute for {get, put}_multipath_config X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Xose Vazquez Perez , Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck The "weak" attribute was set to make sure that these symbols are overridden by symbols of the same name in the main executable. This is unnecessary, as the standard ELF symbol resolution algorithm ensures this even without the "weak" attribute. See ELF Specification, III.2 Dynamic Linking / Shared Object Dependencies: "The dynamic linker examines the symbol tables with a breadth-first search. That is, it first looks at the symbol table of the executable program itself, then at the symbol tables of the DT_NEEDED entries (in order), then at the second level DT_NEEDED entries, and so on". Signed-off-by: Martin Wilck --- libmultipath/config.c | 4 ++-- libmultipath/config.h | 11 ----------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index a2c79a4..5c5c072 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -82,7 +82,7 @@ struct config *libmp_get_multipath_config(void) } struct config *get_multipath_config(void) - __attribute__((weak, alias("libmp_get_multipath_config"))); + __attribute__((alias("libmp_get_multipath_config"))); void libmp_put_multipath_config(void *conf __attribute__((unused))) { @@ -90,7 +90,7 @@ void libmp_put_multipath_config(void *conf __attribute__((unused))) } void put_multipath_config(void *conf) - __attribute__((weak, alias("libmp_put_multipath_config"))); + __attribute__((alias("libmp_put_multipath_config"))); static int hwe_strmatch (const struct hwentry *hwe1, const struct hwentry *hwe2) diff --git a/libmultipath/config.h b/libmultipath/config.h index fdcdff0..2d00ad2 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -303,17 +303,6 @@ void free_config (struct config * conf); int init_config(const char *file); void uninit_config(void); -/* - * libmultipath provides default implementations of - * get_multipath_config() and put_multipath_config(). - * Applications using these should use init_config(file, NULL) - * to load the configuration, rather than load_config(file). - * Likewise, uninit_config() should be used for teardown, but - * using free_config() for that is supported, too. - * Applications can define their own {get,put}_multipath_config() - * functions, which override the library-internal ones, but - * could still call libmp_{get,put}_multipath_config(). - */ struct config *libmp_get_multipath_config(void); struct config *get_multipath_config(void); void libmp_put_multipath_config(void *); From patchwork Mon Aug 22 20:41:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12951382 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1EC61C32796 for ; Mon, 22 Aug 2022 20:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661200923; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MWEcIHOmck5npfYewlFL7+e43QwZrDFtqMcecoqgzdw=; b=IRDAPhedZoFaE6EnicbfUXD/wUlbv/dHdsabAnSIu306S97tQtlSjIwEB1a9TJmFv2RucT l6wm0mBQGW9Klu9knzh/FiOm68VuuVU9utf+TJWDpkWK+61c4D+HXoge+BzdbORF7hq8f+ lUxrk5KWxI/bfP7Zpk6HAz8uKzfBeLI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-108-IVCsp1_FP_ibbaWSWPSdCQ-1; Mon, 22 Aug 2022 16:41:59 -0400 X-MC-Unique: IVCsp1_FP_ibbaWSWPSdCQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 01B1E3C1619E; Mon, 22 Aug 2022 20:41:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEE7340466B1; Mon, 22 Aug 2022 20:41:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B33B11946A60; Mon, 22 Aug 2022 20:41:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B53E61946A40 for ; Mon, 22 Aug 2022 20:41:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A75E51415133; Mon, 22 Aug 2022 20:41:56 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3438141511A for ; Mon, 22 Aug 2022 20:41:56 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 828B32999B26 for ; Mon, 22 Aug 2022 20:41:56 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-577-L6EP3ChIOZGOVdlwvliZKw-1; Mon, 22 Aug 2022 16:41:52 -0400 X-MC-Unique: L6EP3ChIOZGOVdlwvliZKw-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D9A3637338; Mon, 22 Aug 2022 20:41:50 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9334F13523; Mon, 22 Aug 2022 20:41:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YO1sIg7qA2MOAwAAMHmgww (envelope-from ); Mon, 22 Aug 2022 20:41:50 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Mon, 22 Aug 2022 22:41:16 +0200 Message-Id: <20220822204119.20719-9-mwilck@suse.com> In-Reply-To: <20220822204119.20719-1-mwilck@suse.com> References: <20220822204119.20719-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Subject: [dm-devel] [PATCH v2 08/11] libmultipath: split off libmpathutil X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Xose Vazquez Perez , Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Split libmultipath into two libraries: libmpathutil contains generic utilities that don't relate to device-mapper or multipath specifically. libmultipath retains multipath-specific code. The reason for this change is that we'll create a small client program that takes over the role of "multipath -k", the interactive client. This way multipathd doesn't need to link against libreadline any more. The client only needs functionality from libmpathutil, which doesn't contain code that isn't compliant with GPL-3.0, and can thus be linked to libreadline without conflicts. The new library contains weak implementations of {get,put}_multipath_config, which are meant to be superseded by libmultipath's implementation. In the interactive client, these functions aren't needed. As we now have an ABI between libmpathutil and libmultipath, the ABI must be extended by adding functions from libmpathutil that are used internally by libmultipath. Signed-off-by: Martin Wilck --- Makefile | 4 +- Makefile.inc | 1 + libmpathpersist/Makefile | 6 +- libmpathutil/Makefile | 70 +++++++++++ {libmultipath => libmpathutil}/debug.c | 0 {libmultipath => libmpathutil}/debug.h | 0 libmpathutil/globals.c | 12 ++ libmpathutil/globals.h | 39 ++++++ libmpathutil/libmpathutil.version | 122 +++++++++++++++++++ {libmultipath => libmpathutil}/log.c | 0 {libmultipath => libmpathutil}/log.h | 0 {libmultipath => libmpathutil}/log_pthread.c | 0 {libmultipath => libmpathutil}/log_pthread.h | 0 {libmultipath => libmpathutil}/parser.c | 0 {libmultipath => libmpathutil}/parser.h | 2 +- {libmultipath => libmpathutil}/strbuf.c | 0 {libmultipath => libmpathutil}/strbuf.h | 0 {libmultipath => libmpathutil}/time-util.c | 0 {libmultipath => libmpathutil}/time-util.h | 0 {libmultipath => libmpathutil}/util.c | 0 {libmultipath => libmpathutil}/util.h | 0 {libmultipath => libmpathutil}/uxsock.c | 0 {libmultipath => libmpathutil}/uxsock.h | 0 {libmultipath => libmpathutil}/vector.c | 0 {libmultipath => libmpathutil}/vector.h | 0 libmpathvalid/Makefile | 6 +- libmultipath/Makefile | 15 ++- libmultipath/checkers/Makefile | 4 +- libmultipath/config.h | 3 +- libmultipath/foreign/Makefile | 6 +- libmultipath/libmultipath.version | 41 ------- libmultipath/prioritizers/Makefile | 6 +- mpathpersist/Makefile | 4 +- multipath/Makefile | 6 +- multipathd/Makefile | 12 +- tests/Makefile | 8 +- 36 files changed, 286 insertions(+), 81 deletions(-) create mode 100644 libmpathutil/Makefile rename {libmultipath => libmpathutil}/debug.c (100%) rename {libmultipath => libmpathutil}/debug.h (100%) create mode 100644 libmpathutil/globals.c create mode 100644 libmpathutil/globals.h create mode 100644 libmpathutil/libmpathutil.version rename {libmultipath => libmpathutil}/log.c (100%) rename {libmultipath => libmpathutil}/log.h (100%) rename {libmultipath => libmpathutil}/log_pthread.c (100%) rename {libmultipath => libmpathutil}/log_pthread.h (100%) rename {libmultipath => libmpathutil}/parser.c (100%) rename {libmultipath => libmpathutil}/parser.h (99%) rename {libmultipath => libmpathutil}/strbuf.c (100%) rename {libmultipath => libmpathutil}/strbuf.h (100%) rename {libmultipath => libmpathutil}/time-util.c (100%) rename {libmultipath => libmpathutil}/time-util.h (100%) rename {libmultipath => libmpathutil}/util.c (100%) rename {libmultipath => libmpathutil}/util.h (100%) rename {libmultipath => libmpathutil}/uxsock.c (100%) rename {libmultipath => libmpathutil}/uxsock.h (100%) rename {libmultipath => libmpathutil}/vector.c (100%) rename {libmultipath => libmpathutil}/vector.h (100%) diff --git a/Makefile b/Makefile index ffca586..5851149 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ LIB_BUILDDIRS := \ libmpathcmd \ + libmpathutil \ libmultipath \ libmpathpersist \ libmpathvalid @@ -72,7 +73,8 @@ compile_commands.json: Makefile Makefile.inc $(BUILDDIRS:=/Makefile) $(MAKE) clean bear -- $(MAKE) -libmultipath libdmmp: libmpathcmd +libmpathutil libdmmp: libmpathcmd +libmultipath: libmpathutil libmpathpersist libmpathvalid multipath multipathd: libmultipath libmultipath/prioritizers libmultipath/checkers libmultipath/foreign: libmultipath mpathpersist multipathd: libmpathpersist diff --git a/Makefile.inc b/Makefile.inc index 0653d21..58dcba9 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -86,6 +86,7 @@ libudevdir = $(prefix)/$(SYSTEMDPATH)/udev udevrulesdir = $(libudevdir)/rules.d modulesloaddir = $(prefix)/$(SYSTEMDPATH)/modules-load.d multipathdir = $(TOPDIR)/libmultipath +mpathutildir = $(TOPDIR)/libmpathutil man8dir = $(prefix)/usr/share/man/man8 man5dir = $(prefix)/usr/share/man/man5 man3dir = $(prefix)/usr/share/man/man3 diff --git a/libmpathpersist/Makefile b/libmpathpersist/Makefile index 9843d96..4e1717e 100644 --- a/libmpathpersist/Makefile +++ b/libmpathpersist/Makefile @@ -5,10 +5,10 @@ DEVLIB = libmpathpersist.so LIBS = $(DEVLIB).$(SONAME) VERSION_SCRIPT:= libmpathpersist.version -CFLAGS += $(LIB_CFLAGS) -I$(multipathdir) -I$(mpathpersistdir) -I$(mpathcmddir) -LDFLAGS += -L$(multipathdir) -L$(mpathcmddir) +CFLAGS += $(LIB_CFLAGS) -I$(multipathdir) -I$(mpathutildir) -I$(mpathpersistdir) -I$(mpathcmddir) +LDFLAGS += -L$(multipathdir) -L$(mpathutildir) -L$(mpathcmddir) -LIBDEPS += -lmultipath -lmpathcmd -ldevmapper -lpthread -ldl +LIBDEPS += -lmultipath -lmpathutil -lmpathcmd -ldevmapper -lpthread -ldl OBJS = mpath_persist.o mpath_updatepr.o mpath_pr_ioctl.o mpath_persist_int.o diff --git a/libmpathutil/Makefile b/libmpathutil/Makefile new file mode 100644 index 0000000..fac7276 --- /dev/null +++ b/libmpathutil/Makefile @@ -0,0 +1,70 @@ +# +# Copyright (C) 2003 Christophe Varoqui, +# +include ../Makefile.inc + +SONAME = 0 +DEVLIB = libmpathutil.so +LIBS = $(DEVLIB).$(SONAME) +VERSION_SCRIPT := libmpathutil.version + +CPPFLAGS += -I. -I$(multipathdir) -I$(mpathcmddir) +CFLAGS += $(LIB_CFLAGS) -D_GNU_SOURCE + +LIBDEPS += -lpthread -ldl -ludev -L$(mpathcmddir) -lmpathcmd + +ifdef SYSTEMD + CPPFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) + ifeq ($(shell test $(SYSTEMD) -gt 209 && echo 1), 1) + LIBDEPS += -lsystemd + else + LIBDEPS += -lsystemd-daemon + endif +endif + +# object files referencing MULTIPATH_DIR or CONFIG_DIR +# they need to be recompiled for unit tests + +# other object files +OBJS := parser.o vector.o util.o debug.o time-util.o \ + uxsock.o log_pthread.o log.o strbuf.o globals.o + +all: $(DEVLIB) + +make_static = $(shell sed '/^static/!s/^\([a-z]\{1,\} \)/static \1/' <$1 >$2) + +$(LIBS): $(OBJS) $(VERSION_SCRIPT) + $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ + -Wl,--version-script=$(VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) + +$(DEVLIB): $(LIBS) + $(LN) $(LIBS) $@ + +$(NV_VERSION_SCRIPT): $(VERSION_SCRIPT) + @printf 'NOVERSION {\nglobal:\n' >$@ + @grep -P '^[ \t]+[a-zA-Z_][a-zA-Z0-9_]*;' $< >>$@ + @printf 'local:\n\t*;\n};\n' >>$@ + +$(LIBS:%.so.$(SONAME)=%-nv.so): $(OBJS) $(NV_VERSION_SCRIPT) + $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \ + -Wl,--version-script=$(NV_VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS) + +abi: $(LIBS:%.so.$(SONAME)=%-nv.abi) + +install: all + $(INSTALL_PROGRAM) -d $(DESTDIR)$(syslibdir) + $(INSTALL_PROGRAM) -m 755 $(LIBS) $(DESTDIR)$(syslibdir)/$(LIBS) + $(INSTALL_PROGRAM) -m 755 -d $(DESTDIR)$(libdir) + $(LN) $(LIBS) $(DESTDIR)$(syslibdir)/$(DEVLIB) + +uninstall: + $(RM) $(DESTDIR)$(syslibdir)/$(LIBS) + $(RM) $(DESTDIR)$(syslibdir)/$(DEVLIB) + +clean: dep_clean + $(RM) core *.a *.o *.so *.so.* *.abi nvme-ioctl.c nvme-ioctl.h $(NV_VERSION_SCRIPT) + +include $(wildcard $(OBJS:.o=.d)) + +dep_clean: + $(RM) $(OBJS:.o=.d) diff --git a/libmultipath/debug.c b/libmpathutil/debug.c similarity index 100% rename from libmultipath/debug.c rename to libmpathutil/debug.c diff --git a/libmultipath/debug.h b/libmpathutil/debug.h similarity index 100% rename from libmultipath/debug.h rename to libmpathutil/debug.h diff --git a/libmpathutil/globals.c b/libmpathutil/globals.c new file mode 100644 index 0000000..0c9a5ba --- /dev/null +++ b/libmpathutil/globals.c @@ -0,0 +1,12 @@ +#include +#include +#include "globals.h" + +struct udev __attribute__((weak)) *udev; +struct config __attribute__((weak)) *get_multipath_config(void) +{ + return NULL; +} + +void __attribute__((weak)) put_multipath_config(void *p __attribute__((unused))) +{} diff --git a/libmpathutil/globals.h b/libmpathutil/globals.h new file mode 100644 index 0000000..fab507e --- /dev/null +++ b/libmpathutil/globals.h @@ -0,0 +1,39 @@ +#ifndef _GLOBALS_H +#define _GLOBALS_H + +struct config; + +/** + * extern variable: udev + * + * A &struct udev instance used by libmultipath. libmultipath expects + * a valid, initialized &struct udev in this variable. + * An application can define this variable itself, in which case + * the applications's instance will take precedence. + * The application can initialize and destroy this variable by + * calling libmultipath_init() and libmultipath_exit(), respectively, + * whether or not it defines the variable itself. + * An application can initialize udev with udev_new() before calling + * libmultipath_init(), e.g. if it has to make libudev calls before + * libmultipath calls. If an application wants to keep using the + * udev variable after calling libmultipath_exit(), it should have taken + * an additional reference on it beforehand. This is the case e.g. + * after initializing udev with udev_new(). + */ +extern struct udev *udev; + +/* + * libmultipath provides default implementations of + * get_multipath_config() and put_multipath_config(). + * Applications using these should use init_config(file, NULL) + * to load the configuration, rather than load_config(file). + * Likewise, uninit_config() should be used for teardown, but + * using free_config() for that is supported, too. + * Applications can define their own {get,put}_multipath_config() + * functions, which override the library-internal ones, but + * could still call libmp_{get,put}_multipath_config(). + */ +void put_multipath_config(void *); +struct config *get_multipath_config(void); + +#endif diff --git a/libmpathutil/libmpathutil.version b/libmpathutil/libmpathutil.version new file mode 100644 index 0000000..badeb35 --- /dev/null +++ b/libmpathutil/libmpathutil.version @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2020 SUSE LLC + * SPDX-License-Identifier: GPL-2.0-or-later + * + * libmultipath ABI (libmpathutil part) + * + * libmultipath doesn't have a stable ABI in the usual sense. In particular, + * the library does not attempt to ship different versions of the same symbol + * for backward compatibility. + * + * The ABI versioning only serves to avoid linking with a non-matching ABI, to + * cut down the set of exported symbols, and to describe it. + * The version string is LIBMULTIPATH_$MAJOR.$MINOR.$REL. + * + * Policy: + * + * * Bump $MAJOR for incompatible changes, like: + * - symbols removed + * - parameter list or return values changed for existing functions + * - externally visible data structures changed in incompatible ways + * (like offsets of previously existing struct members) + * In this case, the new version doesn't inherit the previous versions, + * because the new library doesn't provide the full previous ABI any more. + * All predecessors are merged into the new version. + * + * * Bump $MINOR for compatible changes, like adding symbols. + * The new version inherits the previous ones. + * + * * Bump $REL to describe deviations from upstream, e.g. in + * multipath-tools packages shipped by distributions. + * The new version inherits the previous ones. + */ + +/* symbols referenced by multipath and multipathd */ +LIBMULTIPATH_15.0.0 { +global: + alloc_strvec; + append_strbuf_str; + cleanup_charp; + cleanup_mutex; + cleanup_ucharp; + close_fd; + convert_dev; + dlog; + fill_strbuf; + find_slot; + free_scandir_result; + free_strvec; + get_monotonic_time; + get_multipath_config; + get_next_string; + get_strbuf_len; + get_strbuf_str; + is_quote; + log_thread_reset; + log_thread_start; + log_thread_stop; + logsink; + normalize_timespec; + print_strbuf; + pthread_cond_init_mono; + put_multipath_config; + recv_packet; + reset_strbuf; + send_packet; + set_max_fds; + setup_thread_attr; + strchop; + strlcpy; + timespeccmp; + timespecsub; + truncate_strbuf; + udev; + ux_socket_listen; + vector_alloc; + vector_alloc_slot; + vector_del_slot; + vector_free; + vector_reset; + vector_set_slot; + +local: + *; +}; + +/* symbols referenced internally by libmultipath */ +LIBMPATHUTIL_1.0 { + alloc_bitfield; + __append_strbuf_str; + append_strbuf_quoted; + basenamecpy; + cleanup_free_ptr; + devt2devname; + filepresent; + find_keyword; + free_keywords; + get_linux_version_code; + __get_strbuf_buf; + get_word; + _install_keyword; + install_sublevel; + install_sublevel_end; + keyword_alloc; + libmp_verbosity; + _log_bitfield_overflow; + log_safe; + parse_devt; + parse_prkey; + process_file; + safe_write; + set_value; + should_exit; + snprint_keyword; + steal_strbuf_str; + strlcat; + systemd_service_enabled; + validate_config_strvec; + vector_find_or_add_slot; + vector_insert_slot; + vector_move_up; + vector_sort; +}; diff --git a/libmultipath/log.c b/libmpathutil/log.c similarity index 100% rename from libmultipath/log.c rename to libmpathutil/log.c diff --git a/libmultipath/log.h b/libmpathutil/log.h similarity index 100% rename from libmultipath/log.h rename to libmpathutil/log.h diff --git a/libmultipath/log_pthread.c b/libmpathutil/log_pthread.c similarity index 100% rename from libmultipath/log_pthread.c rename to libmpathutil/log_pthread.c diff --git a/libmultipath/log_pthread.h b/libmpathutil/log_pthread.h similarity index 100% rename from libmultipath/log_pthread.h rename to libmpathutil/log_pthread.h diff --git a/libmultipath/parser.c b/libmpathutil/parser.c similarity index 100% rename from libmultipath/parser.c rename to libmpathutil/parser.c diff --git a/libmultipath/parser.h b/libmpathutil/parser.h similarity index 99% rename from libmultipath/parser.h rename to libmpathutil/parser.h index 11ea227..9d9d948 100644 --- a/libmultipath/parser.h +++ b/libmpathutil/parser.h @@ -33,8 +33,8 @@ /* local includes */ #include "vector.h" -#include "config.h" struct strbuf; +struct config; /* Global definitions */ #define EOB "}" diff --git a/libmultipath/strbuf.c b/libmpathutil/strbuf.c similarity index 100% rename from libmultipath/strbuf.c rename to libmpathutil/strbuf.c diff --git a/libmultipath/strbuf.h b/libmpathutil/strbuf.h similarity index 100% rename from libmultipath/strbuf.h rename to libmpathutil/strbuf.h diff --git a/libmultipath/time-util.c b/libmpathutil/time-util.c similarity index 100% rename from libmultipath/time-util.c rename to libmpathutil/time-util.c diff --git a/libmultipath/time-util.h b/libmpathutil/time-util.h similarity index 100% rename from libmultipath/time-util.h rename to libmpathutil/time-util.h diff --git a/libmultipath/util.c b/libmpathutil/util.c similarity index 100% rename from libmultipath/util.c rename to libmpathutil/util.c diff --git a/libmultipath/util.h b/libmpathutil/util.h similarity index 100% rename from libmultipath/util.h rename to libmpathutil/util.h diff --git a/libmultipath/uxsock.c b/libmpathutil/uxsock.c similarity index 100% rename from libmultipath/uxsock.c rename to libmpathutil/uxsock.c diff --git a/libmultipath/uxsock.h b/libmpathutil/uxsock.h similarity index 100% rename from libmultipath/uxsock.h rename to libmpathutil/uxsock.h diff --git a/libmultipath/vector.c b/libmpathutil/vector.c similarity index 100% rename from libmultipath/vector.c rename to libmpathutil/vector.c diff --git a/libmultipath/vector.h b/libmpathutil/vector.h similarity index 100% rename from libmultipath/vector.h rename to libmpathutil/vector.h diff --git a/libmpathvalid/Makefile b/libmpathvalid/Makefile index 0a51925..5dbfb92 100644 --- a/libmpathvalid/Makefile +++ b/libmpathvalid/Makefile @@ -5,11 +5,11 @@ DEVLIB = libmpathvalid.so LIBS = $(DEVLIB).$(SONAME) VERSION_SCRIPT := libmpathvalid.version -CPPFLAGS += -I$(multipathdir) -I$(mpathcmddir) +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(mpathcmddir) CFLAGS += $(LIB_CFLAGS) -LIBDEPS += -lpthread -ldevmapper -ldl -L$(multipathdir) \ - -lmultipath -L$(mpathcmddir) -lmpathcmd -ludev +LIBDEPS += -lpthread -ldevmapper -ldl -L$(multipathdir) -lmultipath \ + -L$(mpathutildir) -lmpathutil -L$(mpathcmddir) -lmpathcmd -ludev OBJS = mpath_valid.o diff --git a/libmultipath/Makefile b/libmultipath/Makefile index 348af3f..3b60a52 100644 --- a/libmultipath/Makefile +++ b/libmultipath/Makefile @@ -8,10 +8,10 @@ DEVLIB = libmultipath.so LIBS = $(DEVLIB).$(SONAME) VERSION_SCRIPT := libmultipath.version -CPPFLAGS += -I$(mpathcmddir) -I$(nvmedir) -D_GNU_SOURCE +CPPFLAGS += -I$(mpathutildir) -I$(mpathcmddir) -I$(nvmedir) -D_GNU_SOURCE CFLAGS += $(LIB_CFLAGS) -LIBDEPS += -lpthread -ldl -ldevmapper -ludev -L$(mpathcmddir) -lmpathcmd -lurcu -laio +LIBDEPS += -lpthread -ldl -ldevmapper -ludev -L$(mpathutildir) -lmpathutil -L$(mpathcmddir) -lmpathcmd -lurcu -laio ifdef SYSTEMD CPPFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) @@ -56,15 +56,14 @@ OBJS-U := prio.o checkers.o foreign.o config.o OBJS-T := $(patsubst %.o,%-test.o,$(OBJS-U)) # other object files -OBJS-O := parser.o vector.o devmapper.o \ - hwtable.o blacklist.o util.o dmparser.o \ +OBJS-O := devmapper.o hwtable.o blacklist.o dmparser.o \ structs.o discovery.o propsel.o dict.o \ - pgpolicies.o debug.o defaults.o uevent.o time-util.o \ - switchgroup.o uxsock.o print.o alias.o log_pthread.o \ - log.o configure.o structs_vec.o sysfs.o \ + pgpolicies.o defaults.o uevent.o \ + switchgroup.o print.o alias.o \ + configure.o structs_vec.o sysfs.o \ lock.o file.o wwids.o prioritizers/alua_rtpg.o prkey.o \ io_err_stat.o dm-generic.o generic.o nvme-lib.o \ - libsg.o valid.o strbuf.o + libsg.o valid.o OBJS := $(OBJS-O) $(OBJS-U) diff --git a/libmultipath/checkers/Makefile b/libmultipath/checkers/Makefile index e1d7904..cfc06e7 100644 --- a/libmultipath/checkers/Makefile +++ b/libmultipath/checkers/Makefile @@ -4,9 +4,9 @@ TOPDIR = ../.. include ../../Makefile.inc -CPPFLAGS += -I$(multipathdir) +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) CFLAGS += $(LIB_CFLAGS) -LDFLAGS += -L$(multipathdir) -lmultipath +LDFLAGS += -L$(multipathdir) -L$(mpathutildir) -lmultipath -lmpathutil LIBDEPS = -laio -lpthread -lrt # If you add or remove a checker also update multipath/multipath.conf.5 diff --git a/libmultipath/config.h b/libmultipath/config.h index 2d00ad2..8794746 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -6,6 +6,7 @@ #include #include #include "byteorder.h" +#include "globals.h" #define ORIGIN_DEFAULT 0 #define ORIGIN_CONFIG 1 @@ -304,9 +305,7 @@ int init_config(const char *file); void uninit_config(void); struct config *libmp_get_multipath_config(void); -struct config *get_multipath_config(void); void libmp_put_multipath_config(void *); -void put_multipath_config(void *); int parse_uid_attrs(char *uid_attrs, struct config *conf); const char *get_uid_attribute_by_attrs(const struct config *conf, diff --git a/libmultipath/foreign/Makefile b/libmultipath/foreign/Makefile index 3d4491a..d0232f2 100644 --- a/libmultipath/foreign/Makefile +++ b/libmultipath/foreign/Makefile @@ -4,10 +4,10 @@ TOPDIR=../.. include ../../Makefile.inc -CPPFLAGS += -I$(multipathdir) -I$(nvmedir) +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(nvmedir) CFLAGS += $(LIB_CFLAGS) -LDFLAGS += -L$(multipathdir) -LIBDEPS = -lmultipath -ludev -lpthread -lrt +LDFLAGS += -L$(multipathdir) -L$(mpathutildir) +LIBDEPS = -lmultipath -lmpathutil -ludev -lpthread -lrt LIBS = libforeign-nvme.so diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version index c1d9b15..1cda40b 100644 --- a/libmultipath/libmultipath.version +++ b/libmultipath/libmultipath.version @@ -42,8 +42,6 @@ global: alloc_path; alloc_path_layout; alloc_path_with_pathinfo; - alloc_strvec; - append_strbuf_str; change_foreign; check_alias_settings; check_daemon; @@ -54,17 +52,11 @@ global: checker_name; checker_state_name; check_foreign; - cleanup_charp; cleanup_lock; - cleanup_mutex; - cleanup_ucharp; - close_fd; coalesce_paths; - convert_dev; count_active_paths; delete_all_foreign; delete_foreign; - dlog; dm_cancel_deferred_remove; dm_enablegroup; dm_fail_path; @@ -99,7 +91,6 @@ global: find_mpe; find_path_by_dev; find_path_by_devt; - find_slot; foreign_multipath_layout; foreign_path_layout; free_config; @@ -107,16 +98,12 @@ global: free_multipathvec; free_path; free_pathvec; - free_strvec; - get_monotonic_time; get_multipath_config; get_multipath_layout; get_path_layout; get_pgpolicy_id; get_refwwid; get_state; - get_strbuf_len; - get_strbuf_str; get_udev_device; get_uid; get_used_hwes; @@ -129,7 +116,6 @@ global: init_prio; io_err_stat_handle_pathfail; is_path_valid; - is_quote; libmp_dm_task_create; libmp_get_version; libmp_get_multipath_config; @@ -140,12 +126,7 @@ global: libmultipath_exit; libmultipath_init; load_config; - log_thread_reset; - log_thread_start; - log_thread_stop; - logsink; need_io_err_check; - normalize_timespec; orphan_path; parse_prkey_flags; pathcount; @@ -156,10 +137,7 @@ global: print_all_paths; print_foreign_topology; _print_multipath_topology; - print_strbuf; - pthread_cond_init_mono; put_multipath_config; - recv_packet; reinstate_paths; remember_wwid; remove_map; @@ -169,20 +147,16 @@ global: remove_wwid; replace_wwids; reset_checker_classes; - reset_strbuf; select_all_tg_pt; select_action; select_find_multipaths_timeout; select_no_path_retry; select_path_group; select_reservation_key; - send_packet; - set_max_fds; set_no_path_retry; set_path_removed; set_prkey; setup_map; - setup_thread_attr; should_multipath; skip_libmp_dm_init; snprint_blacklist_report; @@ -204,16 +178,11 @@ global: stop_io_err_stat_thread; store_path; store_pathinfo; - strchop; - strlcpy; sync_map_state; sysfs_get_size; sysfs_is_multipathed; - timespeccmp; - timespecsub; trigger_path_udev_change; trigger_paths_udev_change; - truncate_strbuf; udev; uevent_dispatch; uevent_get_dm_str; @@ -226,14 +195,7 @@ global: update_multipath_table; update_queue_mode_add_path; update_queue_mode_del_path; - ux_socket_listen; valid_alias; - vector_alloc; - vector_alloc_slot; - vector_del_slot; - vector_free; - vector_reset; - vector_set_slot; verify_paths; /* checkers */ @@ -242,9 +204,7 @@ global: start_checker_thread; /* prioritizers */ - fill_strbuf; get_asymmetric_access_state; - get_next_string; get_prio_timeout; get_target_port_group; get_target_port_group_support; @@ -262,7 +222,6 @@ global: sysfs_get_asymmetric_access_state; /* foreign */ - free_scandir_result; local: *; diff --git a/libmultipath/prioritizers/Makefile b/libmultipath/prioritizers/Makefile index eb6f03b..400f773 100644 --- a/libmultipath/prioritizers/Makefile +++ b/libmultipath/prioritizers/Makefile @@ -5,10 +5,10 @@ TOPDIR=../.. include ../../Makefile.inc -CPPFLAGS += -I$(multipathdir) +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) CFLAGS += $(LIB_CFLAGS) -LDFLAGS += -L$(multipathdir) -LIBDEPS = -lmultipath -lm -lpthread -lrt +LDFLAGS += -L$(multipathdir) -L$(mpathutildir) +LIBDEPS = -lmultipath -lmpathutil -lm -lpthread -lrt # If you add or remove a prioritizer also update multipath/multipath.conf.5 LIBS = \ diff --git a/mpathpersist/Makefile b/mpathpersist/Makefile index 2e4d483..2219c86 100644 --- a/mpathpersist/Makefile +++ b/mpathpersist/Makefile @@ -1,11 +1,11 @@ include ../Makefile.inc -CPPFLAGS += -I$(multipathdir) -I$(mpathpersistdir) +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(mpathpersistdir) CFLAGS += $(BIN_CFLAGS) LDFLAGS += $(BIN_LDFLAGS) LIBDEPS += -L$(mpathpersistdir) -lmpathpersist -L$(multipathdir) -lmultipath \ - -L$(mpathcmddir) -lmpathcmd -lpthread -ldevmapper -ludev + -L$(mpathutildir) -lmpathutil -L$(mpathcmddir) -lmpathcmd -lpthread -ldevmapper -ludev EXEC = mpathpersist diff --git a/multipath/Makefile b/multipath/Makefile index bcb0453..46b7553 100644 --- a/multipath/Makefile +++ b/multipath/Makefile @@ -3,11 +3,11 @@ # include ../Makefile.inc -CPPFLAGS += -I$(multipathdir) -I$(mpathcmddir) +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(mpathcmddir) CFLAGS += $(BIN_CFLAGS) LDFLAGS += $(BIN_LDFLAGS) -LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathcmddir) -lmpathcmd \ - -lpthread -ldevmapper -ldl -ludev +LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathutildir) -lmpathutil \ + -L$(mpathcmddir) -lmpathcmd -lpthread -ldevmapper -ldl -ludev EXEC = multipath diff --git a/multipathd/Makefile b/multipathd/Makefile index 95acd88..7128510 100644 --- a/multipathd/Makefile +++ b/multipathd/Makefile @@ -15,14 +15,16 @@ endif #CPPFLAGS += -D_DEBUG_ #CPPFLAGS += -DLOGDBG -CPPFLAGS += -I$(multipathdir) -I$(mpathpersistdir) -I$(mpathcmddir) -I$(thirdpartydir) \ +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(mpathpersistdir) -I$(mpathcmddir) -I$(thirdpartydir) \ $(shell $(PKGCONFIG) --modversion liburcu 2>/dev/null | \ awk -F. '{ printf("-DURCU_VERSION=0x%06x", 256 * ( 256 * $$1 + $$2) + $$3); }') CFLAGS += $(BIN_CFLAGS) LDFLAGS += $(BIN_LDFLAGS) + +CLI_LIBDEPS := -L$(mpathutildir) -lmpathutil -L$(mpathcmddir) -lmpathcmd -ludev -ldl -lurcu -lpthread LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathpersistdir) -lmpathpersist \ - -L$(mpathcmddir) -lmpathcmd -ludev -ldl -lurcu -lpthread \ - -ldevmapper + -ldevmapper $(CLI_LIBDEPS) + ifeq ($(READLINE),libedit) CPPFLAGS += -DUSE_LIBEDIT @@ -36,9 +38,9 @@ endif ifdef SYSTEMD CPPFLAGS += -DUSE_SYSTEMD=$(SYSTEMD) ifeq ($(shell test $(SYSTEMD) -gt 209 && echo 1), 1) - LIBDEPS += -lsystemd + CLI_LIBDEPS += -lsystemd else - LIBDEPS += -lsystemd-daemon + CLI_LIBDEPS += -lsystemd-daemon endif endif ifeq ($(ENABLE_DMEVENTS_POLL),0) diff --git a/tests/Makefile b/tests/Makefile index 95a9990..7d19b94 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -11,9 +11,9 @@ TEST_MISSING_INITIALIZERS = $(shell \ || echo -Wno-missing-field-initializers) W_MISSING_INITIALIZERS := $(call TEST_MISSING_INITIALIZERS) -CPPFLAGS += -I$(multipathdir) -I$(mpathcmddir) -DTESTCONFDIR=\"$(TESTDIR)/conf.d\" +CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(mpathcmddir) -DTESTCONFDIR=\"$(TESTDIR)/conf.d\" CFLAGS += $(BIN_CFLAGS) -Wno-unused-parameter $(W_MISSING_INITIALIZERS) -LIBDEPS += -L. -L$(mpathcmddir) -lmultipath -lmpathcmd -lcmocka +LIBDEPS += -L. -L $(mpathutildir) -L$(mpathcmddir) -lmultipath -lmpathutil -lmpathcmd -lcmocka TESTS := uevent parser util dmevents hwtable blacklist unaligned vpd pgpolicy \ alias directio valid devt mpathvalid strbuf sysfs @@ -83,11 +83,11 @@ lib/libchecktur.so: %.out: %-test lib/libchecktur.so @echo == running $< == - @LD_LIBRARY_PATH=.:$(mpathcmddir) ./$< >$@ + @LD_LIBRARY_PATH=.:$(mpathutildir):$(mpathcmddir) ./$< >$@ %.vgr: %-test lib/libchecktur.so @echo == running valgrind for $< == - @LD_LIBRARY_PATH=.:$(mpathcmddir) \ + @LD_LIBRARY_PATH=.:$(mpathutildir):$(mpathcmddir) \ valgrind --leak-check=full --error-exitcode=128 ./$< >$@ 2>&1 OBJS = $(TESTS:%=%.o) $(HELPERS) From patchwork Mon Aug 22 20:41:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12951384 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E99D6C32774 for ; Mon, 22 Aug 2022 20:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661200924; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qgDET8VAdD0YW4wQSdSiFpqfEOL3lbV0HoD9nnWZnEI=; b=EAGX1ZPhYbRCfs3QWIr1Q239sPXeA+d22AS/BUwmSy1hCqNInN2GjP9zteaglhhh7QxktA +7ESkh+KAdsePeqBGYftZ1cYd1d5cF29vg+MThi+XdrzU/L7M0pE2o4HSINoP8Bpis5Qbu 1wxhpW9vpQCGlymacPvBLUtfMK8+HPM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-500-XE9-o3wsPaqdGvJTmsGrEw-1; Mon, 22 Aug 2022 16:42:02 -0400 X-MC-Unique: XE9-o3wsPaqdGvJTmsGrEw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 702A485A589; Mon, 22 Aug 2022 20:42:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B881C15BB3; Mon, 22 Aug 2022 20:42:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 48F3F1946A47; Mon, 22 Aug 2022 20:42:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6E4161946A52 for ; Mon, 22 Aug 2022 20:41:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 629272166B29; Mon, 22 Aug 2022 20:41:54 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E9702166B26 for ; Mon, 22 Aug 2022 20:41:54 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4401D3806709 for ; Mon, 22 Aug 2022 20:41:54 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-482-FZhGOu2gN86OUXEv8TJqAA-1; Mon, 22 Aug 2022 16:41:52 -0400 X-MC-Unique: FZhGOu2gN86OUXEv8TJqAA-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3ED80202B8; Mon, 22 Aug 2022 20:41:51 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E570F13523; Mon, 22 Aug 2022 20:41:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mOBBNg7qA2MOAwAAMHmgww (envelope-from ); Mon, 22 Aug 2022 20:41:50 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Mon, 22 Aug 2022 22:41:17 +0200 Message-Id: <20220822204119.20719-10-mwilck@suse.com> In-Reply-To: <20220822204119.20719-1-mwilck@suse.com> References: <20220822204119.20719-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Subject: [dm-devel] [PATCH v2 09/11] multipathc: add new interactive client program X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Xose Vazquez Perez , Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Add a new small program, multipathc, that acts as interactive uxsock client for multipathd. multipathc is the only program that has an interactive mode and can thus link to either libreadline or libedit for command line history. All code depending on libreadline is moved from uxclnt.c and cli.c to multipathc.c. This patch breaks multipathd's interactive mode. It will be restored in the next patch. As multipathc doesn't link to libmultipath, it can link to libreadline without license conflict. Signed-off-by: Martin Wilck --- .gitignore | 1 + multipathd/Makefile | 24 ++-- multipathd/cli.c | 130 ++------------------ multipathd/cli.h | 5 +- multipathd/multipathc.c | 254 ++++++++++++++++++++++++++++++++++++++++ multipathd/uxclnt.c | 126 +------------------- 6 files changed, 293 insertions(+), 247 deletions(-) create mode 100644 multipathd/multipathc.c diff --git a/.gitignore b/.gitignore index b88608c..821c3e6 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ cscope.out kpartx/kpartx multipath/multipath multipathd/multipathd +multipathd/multipathc mpathpersist/mpathpersist abi.tar.gz abi diff --git a/multipathd/Makefile b/multipathd/Makefile index 7128510..19ab2e9 100644 --- a/multipathd/Makefile +++ b/multipathd/Makefile @@ -27,12 +27,12 @@ LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathpersistdir) -lmpathpersist \ ifeq ($(READLINE),libedit) -CPPFLAGS += -DUSE_LIBEDIT -LIBDEPS += -ledit +RL_CPPFLAGS = -DUSE_LIBEDIT +RL_LIBDEPS += -ledit endif ifeq ($(READLINE),libreadline) -CPPFLAGS += -DUSE_LIBREADLINE -LIBDEPS += -lreadline +RL_CPPFLAGS += -DUSE_LIBREADLINE +RL_LIBDEPS += -lreadline endif ifdef SYSTEMD @@ -50,6 +50,8 @@ endif OBJS = main.o pidfile.o uxlsnr.o uxclnt.o cli.o cli_handlers.o waiter.o \ dmevents.o init_unwinder.o +CLI_OBJS = multipathc.o cli.o + ifeq ($(FPIN_SUPPORT),1) OBJS += fpin_handlers.o endif @@ -57,18 +59,26 @@ endif EXEC = multipathd +CLI = multipathc -all : $(EXEC) +all : $(EXEC) $(CLI) $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(EXEC) $(LIBDEPS) +multipathc.o: multipathc.c + $(CC) $(CPPFLAGS) $(RL_CPPFLAGS) $(CFLAGS) -Wno-unused-parameter -c -o $@ $< + +$(CLI): $(CLI_OBJS) + $(CC) $(CFLAGS) $(CLI_OBJS) $(LDFLAGS) -o $@ $(CLI_LIBDEPS) $(RL_LIBDEPS) + cli_handlers.o: cli_handlers.c $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused-parameter -c -o $@ $< install: $(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir) $(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir) + $(INSTALL_PROGRAM) -m 755 $(CLI) $(DESTDIR)$(bindir) ifdef SYSTEMD $(INSTALL_PROGRAM) -d $(DESTDIR)$(unitdir) $(INSTALL_PROGRAM) -m 644 $(EXEC).service $(DESTDIR)$(unitdir) @@ -78,13 +88,13 @@ endif $(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(man8dir) uninstall: - $(RM) $(DESTDIR)$(bindir)/$(EXEC) + $(RM) $(DESTDIR)$(bindir)/$(EXEC) $(DESTDIR)$(bindir)/$(CLI) $(RM) $(DESTDIR)$(man8dir)/$(EXEC).8 $(RM) $(DESTDIR)$(unitdir)/$(EXEC).service $(RM) $(DESTDIR)$(unitdir)/$(EXEC).socket clean: dep_clean - $(RM) core *.o $(EXEC) + $(RM) core *.o $(EXEC) $(CLI) include $(wildcard $(OBJS:.o=.d)) diff --git a/multipathd/cli.c b/multipathd/cli.c index cc56950..d1bfeee 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -11,12 +11,6 @@ #include "parser.h" #include "util.h" #include "version.h" -#ifdef USE_LIBEDIT -#include -#endif -#ifdef USE_LIBREADLINE -#include -#endif #include "mpath_cmd.h" #include "cli.h" @@ -26,6 +20,16 @@ static vector keys; static vector handlers; +vector get_keys(void) +{ + return keys; +} + +vector get_handlers(void) +{ + return handlers; +} + static struct key * alloc_key (void) { @@ -225,8 +229,7 @@ load_keys (void) return 0; } -static struct key * -find_key (const char * str) +struct key *find_key (const char * str) { int i; int len, klen; @@ -323,8 +326,7 @@ out: return r; } -static uint64_t -fingerprint(const struct _vector *vec) +uint64_t fingerprint(const struct _vector *vec) { int i; uint64_t fp = 0; @@ -458,111 +460,3 @@ void cli_exit(void) free_keys(keys); keys = NULL; } - -#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) -static int -key_match_fingerprint (struct key * kw, uint64_t fp) -{ - if (!fp) - return 0; - - return ((fp & kw->code) == kw->code); -} - -/* - * This is the readline completion handler - */ -char * -key_generator (const char * str, int state) -{ - static int index, len, has_param; - static uint64_t rlfp; - struct key * kw; - int i; - struct handler *h; - vector v = NULL; - - if (!state) { - index = 0; - has_param = 0; - rlfp = 0; - len = strlen(str); - int r = get_cmdvec(rl_line_buffer, &v); - /* - * If a word completion is in progress, we don't want - * to take an exact keyword match in the fingerprint. - * For ex "show map[tab]" would validate "map" and discard - * "maps" as a valid candidate. - */ - if (v && len) - vector_del_slot(v, VECTOR_SIZE(v) - 1); - /* - * Clean up the mess if we dropped the last slot of a 1-slot - * vector - */ - if (v && !VECTOR_SIZE(v)) { - vector_free(v); - v = NULL; - } - /* - * If last keyword takes a param, don't even try to guess - */ - if (r == EINVAL) { - has_param = 1; - return (strdup("(value)")); - } - /* - * Compute a command fingerprint to find out possible completions. - * Once done, the vector is useless. Free it. - */ - if (v) { - rlfp = fingerprint(v); - free_keys(v); - } - } - /* - * No more completions for parameter placeholder. - * Brave souls might try to add parameter completion by walking paths and - * multipaths vectors. - */ - if (has_param) - return ((char *)NULL); - /* - * Loop through keywords for completion candidates - */ - vector_foreach_slot_after (keys, kw, index) { - if (!strncmp(kw->str, str, len)) { - /* - * Discard keywords already in the command line - */ - if (key_match_fingerprint(kw, rlfp)) { - struct key * curkw = find_key(str); - if (!curkw || (curkw != kw)) - continue; - } - /* - * Discard keywords making syntax errors. - * - * nfp is the candidate fingerprint we try to - * validate against all known command fingerprints. - */ - uint64_t nfp = rlfp | kw->code; - vector_foreach_slot(handlers, h, i) { - if (!rlfp || ((h->fingerprint & nfp) == nfp)) { - /* - * At least one full command is - * possible with this keyword : - * Consider it validated - */ - index++; - return (strdup(kw->str)); - } - } - } - } - /* - * No more candidates - */ - return ((char *)NULL); -} -#endif diff --git a/multipathd/cli.h b/multipathd/cli.h index a6082ac..cb5bbe2 100644 --- a/multipathd/cli.h +++ b/multipathd/cli.h @@ -151,6 +151,9 @@ void free_keys (vector vec); void free_handlers (void); int cli_init (void); void cli_exit(void); -char * key_generator (const char * str, int state); +uint64_t fingerprint(const struct _vector *vec); +vector get_keys(void); +vector get_handlers(void); +struct key *find_key (const char * str); #endif /* _CLI_H_ */ diff --git a/multipathd/multipathc.c b/multipathd/multipathc.c new file mode 100644 index 0000000..571a182 --- /dev/null +++ b/multipathd/multipathc.c @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2022 SUSE LLC + * SPDX-License-Identifier: GPL-3.0-or-later + */ +#include +#include +#include +#include +#include +#include + +#include "mpath_cmd.h" +#include "uxclnt.h" +#include "vector.h" +#include "uxsock.h" +#include "util.h" +#include "cli.h" + +#ifdef USE_LIBEDIT +#include +#endif +#ifdef USE_LIBREADLINE +#include +#include +#endif +/* + * Versions of libedit prior to 2016 were using a wrong + * prototype for rl_completion_entry_function in readline.h. + * Internally, libedit casts this to the correct type + * (char *)(*)(const char *, int). + * So we simply cast to the wrong prototype here. + * See http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit/readline/readline.h.diff?r1=1.34&r2=1.35 + * Unfortunately, this change isn't reflected in the libedit version. + */ +#ifdef BROKEN_RL_COMPLETION_FUNC +#define RL_COMP_ENTRY_CAST(x) ((int (*)(const char *, int)) (x)) +#else +#define RL_COMP_ENTRY_CAST(x) (x) +#endif + +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) +static int +key_match_fingerprint (struct key * kw, uint64_t fp) +{ + if (!fp) + return 0; + + return ((fp & kw->code) == kw->code); +} + +/* + * This is the readline completion handler + */ +char * +key_generator (const char * str, int state) +{ + static int index, len, has_param; + static uint64_t rlfp; + struct key * kw; + int i; + struct handler *h; + vector v = NULL; + const vector keys = get_keys(); + const vector handlers = get_handlers(); + + if (!state) { + index = 0; + has_param = 0; + rlfp = 0; + len = strlen(str); + int r = get_cmdvec(rl_line_buffer, &v); + /* + * If a word completion is in progress, we don't want + * to take an exact keyword match in the fingerprint. + * For ex "show map[tab]" would validate "map" and discard + * "maps" as a valid candidate. + */ + if (v && len) + vector_del_slot(v, VECTOR_SIZE(v) - 1); + /* + * Clean up the mess if we dropped the last slot of a 1-slot + * vector + */ + if (v && !VECTOR_SIZE(v)) { + vector_free(v); + v = NULL; + } + /* + * If last keyword takes a param, don't even try to guess + */ + if (r == EINVAL) { + has_param = 1; + return (strdup("(value)")); + } + /* + * Compute a command fingerprint to find out possible completions. + * Once done, the vector is useless. Free it. + */ + if (v) { + rlfp = fingerprint(v); + free_keys(v); + } + } + /* + * No more completions for parameter placeholder. + * Brave souls might try to add parameter completion by walking paths and + * multipaths vectors. + */ + if (has_param) + return ((char *)NULL); + /* + * Loop through keywords for completion candidates + */ + vector_foreach_slot_after (keys, kw, index) { + if (!strncmp(kw->str, str, len)) { + /* + * Discard keywords already in the command line + */ + if (key_match_fingerprint(kw, rlfp)) { + struct key * curkw = find_key(str); + if (!curkw || (curkw != kw)) + continue; + } + /* + * Discard keywords making syntax errors. + * + * nfp is the candidate fingerprint we try to + * validate against all known command fingerprints. + */ + uint64_t nfp = rlfp | kw->code; + vector_foreach_slot(handlers, h, i) { + if (!rlfp || ((h->fingerprint & nfp) == nfp)) { + /* + * At least one full command is + * possible with this keyword : + * Consider it validated + */ + index++; + return (strdup(kw->str)); + } + } + } + } + /* + * No more candidates + */ + return ((char *)NULL); +} +#endif + +static void print_reply(char *s) +{ + if (!s) + return; + + if (isatty(1)) { + printf("%s", s); + return; + } + /* strip ANSI color markers */ + while (*s != '\0') { + if ((*s == 0x1b) && (*(s+1) == '[')) + while ((*s++ != 'm') && (*s != '\0')) {}; + putchar(*s++); + } +} + +static int need_quit(char *str, size_t len) +{ + char *ptr, *start; + size_t trimed_len = len; + + for (ptr = str; trimed_len && isspace(*ptr); + trimed_len--, ptr++) + ; + + start = ptr; + + for (ptr = str + len - 1; trimed_len && isspace(*ptr); + trimed_len--, ptr--) + ; + + if ((trimed_len == 4 && !strncmp(start, "exit", 4)) || + (trimed_len == 4 && !strncmp(start, "quit", 4))) + return 1; + + return 0; +} + +/* + * process the client + */ +static void process(int fd, unsigned int timeout) +{ + +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) + rl_readline_name = "multipathd"; + rl_completion_entry_function = RL_COMP_ENTRY_CAST(key_generator); +#endif + + cli_init(); + for(;;) + { + char *line __attribute__((cleanup(cleanup_charp))) = NULL; + char *reply __attribute__((cleanup(cleanup_charp))) = NULL; + ssize_t llen; + int ret; + +#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) + line = readline("multipathd> "); + if (!line) + break; + llen = strlen(line); + if (!llen) + continue; +#else + size_t lsize = 0; + + fputs("multipathd> ", stdout); + errno = 0; + llen = getline(&line, &lsize, stdin); + if (llen == -1) { + if (errno != 0) + fprintf(stderr, "Error in getline: %m"); + break; + } + if (!llen || !strcmp(line, "\n")) + continue; +#endif + + if (need_quit(line, llen)) + break; + + if (send_packet(fd, line) != 0) + break; + ret = recv_packet(fd, &reply, timeout); + if (ret != 0) + break; + + print_reply(reply); + } +} + +int main (void) +{ + int fd = mpath_connect(); + + if (fd == -1) + return 1; + + process(fd, DEFAULT_REPLY_TIMEOUT + 100); + mpath_disconnect(fd); + return 0; +} diff --git a/multipathd/uxclnt.c b/multipathd/uxclnt.c index b817bea..15e1293 100644 --- a/multipathd/uxclnt.c +++ b/multipathd/uxclnt.c @@ -5,128 +5,14 @@ * Copyright (c) 2005 Benjamin Marzinski, Redhat */ #include +#include #include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include - -#ifdef USE_LIBEDIT -#include -#endif -#ifdef USE_LIBREADLINE -#include -#include -#endif #include "mpath_cmd.h" #include "uxsock.h" -#include "defaults.h" - -#include "vector.h" -#include "util.h" -#include "cli.h" #include "uxclnt.h" -static void print_reply(char *s) -{ - if (!s) - return; - - if (isatty(1)) { - printf("%s", s); - return; - } - /* strip ANSI color markers */ - while (*s != '\0') { - if ((*s == 0x1b) && (*(s+1) == '[')) - while ((*s++ != 'm') && (*s != '\0')) {}; - putchar(*s++); - } -} - -static int need_quit(char *str, size_t len) -{ - char *ptr, *start; - size_t trimed_len = len; - - for (ptr = str; trimed_len && isspace(*ptr); - trimed_len--, ptr++) - ; - - start = ptr; - - for (ptr = str + len - 1; trimed_len && isspace(*ptr); - trimed_len--, ptr--) - ; - - if ((trimed_len == 4 && !strncmp(start, "exit", 4)) || - (trimed_len == 4 && !strncmp(start, "quit", 4))) - return 1; - - return 0; -} - -/* - * process the client - */ -static void process(int fd, unsigned int timeout) -{ - -#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) - rl_readline_name = "multipathd"; - rl_completion_entry_function = key_generator; -#endif - - cli_init(); - for(;;) - { - char *line __attribute__((cleanup(cleanup_charp))) = NULL; - char *reply __attribute__((cleanup(cleanup_charp))) = NULL; - ssize_t llen; - int ret; - -#if defined(USE_LIBREADLINE) || defined(USE_LIBEDIT) - line = readline("multipathd> "); - if (!line) - break; - llen = strlen(line); - if (!llen) - continue; -#else - size_t lsize = 0; - - fputs("multipathd> ", stdout); - errno = 0; - llen = getline(&line, &lsize, stdin); - if (llen == -1) { - if (errno != 0) - fprintf(stderr, "Error in getline: %m"); - break; - } - if (!llen || !strcmp(line, "\n")) - continue; -#endif - - if (need_quit(line, llen)) - break; - - if (send_packet(fd, line) != 0) - break; - ret = recv_packet(fd, &reply, timeout); - if (ret != 0) - break; - - print_reply(reply); - } -} - static int process_req(int fd, char * inbuf, unsigned int timeout) { char *reply; @@ -159,13 +45,11 @@ int uxclnt(char * inbuf, unsigned int timeout) int fd, ret = 0; fd = mpath_connect(); - if (fd == -1) - exit(1); + if (fd == -1 || !inbuf) + return 1; + + ret = process_req(fd, inbuf, timeout); - if (inbuf) - ret = process_req(fd, inbuf, timeout); - else - process(fd, timeout); mpath_disconnect(fd); return ret; } From patchwork Mon Aug 22 20:41:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12951383 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0C3FC28D13 for ; Mon, 22 Aug 2022 20:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661200925; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7rwsRzj34ZnYOViN5o7n9RYDFDVorM2voc4CNnZ6VM0=; b=ObDvKi2oARWHNcXtRErC4QjXBJRis2PCOJunxg02vBdI6yBAbBATkcgpVE+Gfs8BDfkpxp GSMLpwdG16QVBix03sISLXIWz/du4U8/09PrAcdtVciKUGvq5frvtUlwK/JVjSs9JuKIXL 7CzlH7p8VmIGusD8+5MYYf0y64M8Dcc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-547-PnfrSRYSNCeWeoiAQ8Gfcg-1; Mon, 22 Aug 2022 16:42:02 -0400 X-MC-Unique: PnfrSRYSNCeWeoiAQ8Gfcg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 59D68802532; Mon, 22 Aug 2022 20:41:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46DCD945D0; Mon, 22 Aug 2022 20:41:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 23C051946A5D; Mon, 22 Aug 2022 20:41:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CDD1D1946A40 for ; Mon, 22 Aug 2022 20:41:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C0695945D7; Mon, 22 Aug 2022 20:41:56 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCAA69458A for ; Mon, 22 Aug 2022 20:41:56 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A0A9B8039A2 for ; Mon, 22 Aug 2022 20:41:56 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-111-0PqSESxSOV2D7rXtfTAgYQ-1; Mon, 22 Aug 2022 16:41:53 -0400 X-MC-Unique: 0PqSESxSOV2D7rXtfTAgYQ-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 841485CAFB; Mon, 22 Aug 2022 20:41:51 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 46B0B13523; Mon, 22 Aug 2022 20:41:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MIedDw/qA2MOAwAAMHmgww (envelope-from ); Mon, 22 Aug 2022 20:41:51 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Mon, 22 Aug 2022 22:41:18 +0200 Message-Id: <20220822204119.20719-11-mwilck@suse.com> In-Reply-To: <20220822204119.20719-1-mwilck@suse.com> References: <20220822204119.20719-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Subject: [dm-devel] [PATCH v2 10/11] multipathd: exec multipathc in interactive mode X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Xose Vazquez Perez , Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck A previous patch disabled interactive mode in multipathd, because uxclnt() would return immediately without an input command With this patch, we reinstate interactive mode for "multipath -k", by just exec()ing the multipathc client. Signed-off-by: Martin Wilck --- multipathd/Makefile | 3 ++- multipathd/main.c | 15 +++++++++++++-- multipathd/multipathc.c | 25 +++++++++++++++++++++---- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/multipathd/Makefile b/multipathd/Makefile index 19ab2e9..8a56304 100644 --- a/multipathd/Makefile +++ b/multipathd/Makefile @@ -17,7 +17,8 @@ endif CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(mpathpersistdir) -I$(mpathcmddir) -I$(thirdpartydir) \ $(shell $(PKGCONFIG) --modversion liburcu 2>/dev/null | \ - awk -F. '{ printf("-DURCU_VERSION=0x%06x", 256 * ( 256 * $$1 + $$2) + $$3); }') + awk -F. '{ printf("-DURCU_VERSION=0x%06x", 256 * ( 256 * $$1 + $$2) + $$3); }') \ + -DBINDIR='"$(bindir)"' CFLAGS += $(BIN_CFLAGS) LDFLAGS += $(BIN_LDFLAGS) diff --git a/multipathd/main.c b/multipathd/main.c index 5a40894..63df643 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -3616,7 +3616,7 @@ main (int argc, char *argv[]) extern char *optarg; extern int optind; int arg; - int err; + int err = 0; int foreground = 0; struct config *conf; char *opt_k_arg = NULL; @@ -3710,7 +3710,18 @@ main (int argc, char *argv[]) } c += snprintf(c, s + CMDSIZE - c, "\n"); } - err = uxclnt(s, uxsock_timeout + 100); + if (!s) { + char tmo_buf[16]; + + snprintf(tmo_buf, sizeof(tmo_buf), "%d", + uxsock_timeout + 100); + if (execl(BINDIR "/multipathc", "multipathc", + tmo_buf, NULL) == -1) { + condlog(0, "ERROR: failed to execute multipathc"); + err = 1; + } + } else + err = uxclnt(s, uxsock_timeout + 100); free_config(conf); return err; } diff --git a/multipathd/multipathc.c b/multipathd/multipathc.c index 571a182..323bd78 100644 --- a/multipathd/multipathc.c +++ b/multipathd/multipathc.c @@ -241,14 +241,31 @@ static void process(int fd, unsigned int timeout) } } -int main (void) +int main (int argc, const char * const argv[]) { - int fd = mpath_connect(); + int fd; + int tmo = DEFAULT_REPLY_TIMEOUT + 100; + char *ep; - if (fd == -1) + if (argc > 2) { + fprintf(stderr, "Usage: %s [timeout]\n", argv[0]); return 1; + } + if (argc == 2) { + tmo = strtol(argv[1], &ep, 10); + if (*argv[1] == '\0' || *ep != '\0') { + fprintf(stderr, "ERROR: invalid timeout value\n"); + return 1; + } + } - process(fd, DEFAULT_REPLY_TIMEOUT + 100); + fd = mpath_connect(); + if (fd == -1) { + fprintf(stderr, "ERROR: failed to connect to multipathd\n"); + return 1; + } + + process(fd, tmo); mpath_disconnect(fd); return 0; } From patchwork Mon Aug 22 20:41:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 12951379 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6A1AC38142 for ; Mon, 22 Aug 2022 20:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661200922; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Ii9nU/n6D4JGf7BizG68vH+e8d6eMPMkxAwaCrDcApA=; b=c2j7kzAFQo7xfqgjgOLyD4LcHYNOgJluOnOMbqP4jbk+UNzuHR/y6FRBKrF5I2jbYxS5VZ MzuW7wKoFDEChx5IvK5tDGSnjVnZWJQQNNoPZ+sRl69g/F1l1+JFsPgcZqFHl5b1fYuixY JMFEJaCpgScxp3mQ41tU8SE9P4mygmg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-438-d3IgRNwGP5apIHcoweykEg-1; Mon, 22 Aug 2022 16:42:01 -0400 X-MC-Unique: d3IgRNwGP5apIHcoweykEg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D8AB1C05159; Mon, 22 Aug 2022 20:41:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C89C492C3B; Mon, 22 Aug 2022 20:41:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0EAA51946A47; Mon, 22 Aug 2022 20:41:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1A33E1946A5A for ; Mon, 22 Aug 2022 20:41:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0098E40334B; Mon, 22 Aug 2022 20:41:58 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F13AC492C3B for ; Mon, 22 Aug 2022 20:41:57 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D938E18E5356 for ; Mon, 22 Aug 2022 20:41:57 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-17-OVS4546yOPKidWhY7xy9rg-1; Mon, 22 Aug 2022 16:41:53 -0400 X-MC-Unique: OVS4546yOPKidWhY7xy9rg-1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C760D37339; Mon, 22 Aug 2022 20:41:51 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8C79913523; Mon, 22 Aug 2022 20:41:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kEG9IA/qA2MOAwAAMHmgww (envelope-from ); Mon, 22 Aug 2022 20:41:51 +0000 From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Mon, 22 Aug 2022 22:41:19 +0200 Message-Id: <20220822204119.20719-12-mwilck@suse.com> In-Reply-To: <20220822204119.20719-1-mwilck@suse.com> References: <20220822204119.20719-1-mwilck@suse.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Subject: [dm-devel] [PATCH v2 11/11] multipathd: fix incompatible pointer type error with libedit X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, Xose Vazquez Perez , Martin Wilck Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Versions of libedit prior to 2016 were using a wrong prototype for rl_completion_entry_function in readline.h. Internally, libedit casts this to the correct type (char *)(*)(const char *, int) (aka CPFunction in libedit). So we simply cast to the wrong prototype here. See http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit/readline/readline.h.diff?r1=1.34&r2=1.35 Signed-off-by: Martin Wilck --- multipathd/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/multipathd/Makefile b/multipathd/Makefile index 8a56304..28ebdc0 100644 --- a/multipathd/Makefile +++ b/multipathd/Makefile @@ -34,6 +34,10 @@ endif ifeq ($(READLINE),libreadline) RL_CPPFLAGS += -DUSE_LIBREADLINE RL_LIBDEPS += -lreadline +# See comment in uxclnt.c +ifeq ($(shell sed -En 's/.*\