From patchwork Tue Nov 26 18:42:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13886305 X-Patchwork-Delegate: bmarzins@redhat.com 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.subspace.kernel.org (Postfix) with ESMTPS id 5B97D1DF257 for ; Tue, 26 Nov 2024 18:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646555; cv=none; b=Kv76OcBFIJ0Xaty1h/ueOqJErHi526jTlfGbIWUJK5QpbiP2jbDWV7i2PRkqyrzTMG1paeuw5A8LCdq3kBEZfNFEIOhK03aX6D9QJiQMfJQu3DWmtZSL2OXUOeei+YcQ8XC2KYVKYhPxj/SzCNDJzlE0jUc4waqP0XW4rJqdpRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646555; c=relaxed/simple; bh=6cQ8g5agngE9F1hYBInD+R8h3wq9eKkDVcEwJRGfZhI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=JhEuieB3QoLNs/YpRfVDEofnsEy72RRnt9Ag4XzSttoCwFZ4IlRyWev49WIqqlzizisEVnZfA6ZiXBSdlneYl3tQV+ywvCMBf7eqd24PVt6yy6S4OCdiB/NpFKp7bJpEVKObkpAND9RiW9TiwidvWN3P8TIBb6R6qcMOPa1otCo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Q8SyS6lm; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Q8SyS6lm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732646552; h=from:from: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; bh=izF+JieZOO2/P8K937JI/F5JYcLI7jaLo6IhmBqjY8k=; b=Q8SyS6lm0MK5KOHLMR0OBk++YwuH6jWz3fXOzELKYSCPbRsFxg1cpd75wjCXBGSSEr7ns0 +SmSUBG5wpGiQu8X3hN/zTcuOKkKYjb8lUYATy2dU894/8C9HAmQtgh83ID6d39g9NwL5x +JxaG1NEwyCzCUGHqEpxwX655HeLLlg= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-461-y_qjndASPiqNN70YkfGetQ-1; Tue, 26 Nov 2024 13:42:28 -0500 X-MC-Unique: y_qjndASPiqNN70YkfGetQ-1 X-Mimecast-MFC-AGG-ID: y_qjndASPiqNN70YkfGetQ Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C9D591955DC3; Tue, 26 Nov 2024 18:42:26 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 667E71956086; Tue, 26 Nov 2024 18:42:26 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 4AQIgOdJ855484 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 26 Nov 2024 13:42:25 -0500 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4AQIgOX8855483; Tue, 26 Nov 2024 13:42:24 -0500 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v3 01/12] libmultipath: signal device with no table in libmp_mapinfo Date: Tue, 26 Nov 2024 13:42:13 -0500 Message-ID: <20241126184224.855459-2-bmarzins@redhat.com> In-Reply-To: <20241126184224.855459-1-bmarzins@redhat.com> References: <20241126184224.855459-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 3uLoFo6xTek0A1n1P5fJ2ic9AuMob8D-i0llUuTbcdM_1732646546 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true if libmp_mapinfo() is run on a device that has no active table, it will now return with a new exit code, DMP_EMPTY, to signal this. Currently all code paths treat this identically to DMP_NOT_FOUND. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/devmapper.c | 6 ++++-- libmultipath/devmapper.h | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 224be512..33425d02 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -86,6 +86,7 @@ const char *dmp_errstr(int rc) [DMP_OK] = "success", [DMP_NOT_FOUND] = "not found", [DMP_NO_MATCH] = "target type mismatch", + [DMP_EMPTY] = "no target", [DMP_LAST__] = "**invalid**", }; if (rc < 0 || rc > DMP_LAST__) @@ -747,9 +748,9 @@ static int libmp_mapinfo__(int flags, mapid_t id, mapinfo_t info, const char *ma condlog(lvl, "%s: map %s has multiple targets", fname__, map_id); return DMP_NO_MATCH; } - if (!params) { + if (!params || !target_type) { condlog(lvl, "%s: map %s has no targets", fname__, map_id); - return DMP_NOT_FOUND; + return DMP_EMPTY; } if (flags & MAPINFO_TGT_TYPE__) { const char *tgt_type = flags & MAPINFO_MPATH_ONLY ? TGT_MPATH : TGT_PART; @@ -873,6 +874,7 @@ int dm_is_mpath(const char *name) return DM_IS_MPATH_YES; case DMP_NOT_FOUND: case DMP_NO_MATCH: + case DMP_EMPTY: return DM_IS_MPATH_NO; case DMP_ERR: default: diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index 6b3bbad9..23926e3f 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -35,6 +35,7 @@ enum { DMP_OK, DMP_NOT_FOUND, DMP_NO_MATCH, + DMP_EMPTY, DMP_LAST__, }; @@ -105,7 +106,11 @@ typedef struct libmp_map_info { * @returns: * DMP_OK if successful. * DMP_NOT_FOUND if the map wasn't found, or has no or multiple targets. - * DMP_NO_MATCH if the map didn't match @tgt_type (see above). + * DMP_NO_MATCH if the map didn't match @tgt_type (see above) or didn't + * have a multipath uuid prefix. + * DMP_EMPTY if the map has no table. Note. The check for matching uuid + * prefix will happen first, but the check for matching + * tgt_type will happen afterwards. * DMP_ERR if some other error occurred. * * This function obtains the requested information for the device-mapper map From patchwork Tue Nov 26 18:42:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13886297 X-Patchwork-Delegate: bmarzins@redhat.com 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.subspace.kernel.org (Postfix) with ESMTPS id 20C6B1DB55D for ; Tue, 26 Nov 2024 18:42:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646552; cv=none; b=pUqMhqwhNhrpskmdYhy0MyDosFXNJnaK5ZleFi6nKDQ2OgdAM44ZIhymhsioLXsDZ98g7l3ibdTBdje02y+GTuqbp/04YXTHTPymWFZY/Kh9C3McRX/f99bMRR60sC2mff2yx9DPr8d2l9sNmHziGe2IidzRjfK5gxY88Rs8jP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646552; c=relaxed/simple; bh=P8I73uIvErG1CVcnSjIv84jZCfTY/0oo7ixlvdEfgIc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=hLXoP+0WBceIXRxpFWPAe84DhAaV4xugiYV5e5jOpVkIbf508/S6cg+zFdvg8T4KT2jEDaR9J2geOW9dqf2kbUupHvV2cmU3PosMfcgRdRnqLUlva9P015JGHA4FmKaZD/WmdiQh2Z0I4jkZSg7LSPtRBl/pMMEHN995SKlISts= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=c7dbLaVR; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="c7dbLaVR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732646549; h=from:from: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; bh=KtO4U6DgST+uXeO+I3VPivYpV51EwBMvYq0UBnZN7d8=; b=c7dbLaVRuAPzsVwrT2Q09Ke0c/tJCYSsC+DoLxKALYeyQbqdr83IK6zZOVSAjoIusHj6uH rhrB8kBSYtXC2ctYsTudKHnAuSUjsj+mJlrhJxIN3Od+/46Baav0EgytM+9YSuLF9LrhaQ 83woSK/SuGtc2OXsNVUF425Ga5cpLhI= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-487-mEQ3RiCLNG27jD1LzJDfFw-1; Tue, 26 Nov 2024 13:42:27 -0500 X-MC-Unique: mEQ3RiCLNG27jD1LzJDfFw-1 X-Mimecast-MFC-AGG-ID: mEQ3RiCLNG27jD1LzJDfFw Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D9BF81955F3D; Tue, 26 Nov 2024 18:42:26 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9146030001A0; Tue, 26 Nov 2024 18:42:26 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 4AQIgPct855488 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 26 Nov 2024 13:42:25 -0500 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4AQIgPRY855487; Tue, 26 Nov 2024 13:42:25 -0500 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v3 02/12] multipath-tools tests: fix mapinfo tests Date: Tue, 26 Nov 2024 13:42:14 -0500 Message-ID: <20241126184224.855459-3-bmarzins@redhat.com> In-Reply-To: <20241126184224.855459-1-bmarzins@redhat.com> References: <20241126184224.855459-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: s4OECd1P49ecRx0Vyn9xH0gF0jUa6IpW2hkobPIDm44_1732646547 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true From: Martin Wilck Add tests for the check for empty table introduced in ("libmultipath: signal device with no table in libmp_mapinfo"). Signed-off-by: Martin Wilck Signed-off-by: Benjamin Marzinski --- tests/mapinfo.c | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/tests/mapinfo.c b/tests/mapinfo.c index 4362cdb0..ee487989 100644 --- a/tests/mapinfo.c +++ b/tests/mapinfo.c @@ -47,11 +47,13 @@ static const struct dm_info __attribute__((unused)) MPATH_DMI_02 = { .exists = 1, .live_table = 0, .open_count = 1, - .target_count = 1, + .target_count = 0, .major = 254, .minor = 123, }; +#define TGT_ANY "any" + static const char MPATH_NAME_01[] = "mpathx"; static const char MPATH_UUID_01[] = "mpath-3600a098038302d414b2b4d4453474f62"; static const char MPATH_TARGET_01[] = @@ -858,7 +860,7 @@ static void test_mapinfo_good_size(void **state) mock_mapinfo_name_1(DM_DEVICE_STATUS, 1, "foo", 1, 1, 0); WRAP_DM_TASK_GET_INFO(1); WRAP_DM_TASK_GET_INFO(&MPATH_DMI_01); - mock_dm_get_next_target(12345, NULL, MPATH_TARGET_01, NULL); + mock_dm_get_next_target(12345, TGT_ANY, MPATH_TARGET_01, NULL); rc = libmp_mapinfo(DM_MAP_BY_NAME, (mapid_t) { .str = "foo", }, (mapinfo_t) { .size = &size }); @@ -889,13 +891,13 @@ static void test_mapinfo_bad_next_target_02(void **state) mock_mapinfo_name_1(DM_DEVICE_STATUS, 1, "foo", 1, 1, 0); WRAP_DM_TASK_GET_INFO(1); - WRAP_DM_TASK_GET_INFO(&MPATH_DMI_01); + WRAP_DM_TASK_GET_INFO(&MPATH_DMI_02); /* no targets */ - mock_dm_get_next_target(12345, NULL, NULL, NULL); + mock_dm_get_next_target(0, NULL, NULL, NULL); rc = libmp_mapinfo(DM_MAP_BY_NAME, (mapid_t) { .str = "foo", }, (mapinfo_t) { .size = &size }); - assert_int_equal(rc, DMP_NOT_FOUND); + assert_int_equal(rc, DMP_EMPTY); } /* libmp_mapinfo needs to do a DM_DEVICE_STATUS ioctl */ @@ -1049,6 +1051,39 @@ static void test_mapinfo_good_target_type_04(void **state) assert_true(!strcmp(uuid, MPATH_UUID_01)); } +static void test_mapinfo_no_table_01(void **state) +{ + int rc; + struct dm_info dmi = { .suspended = 0 }; + + mock_mapinfo_name_1(DM_DEVICE_STATUS, 1, "foo", 1, 1, 0); + WRAP_DM_TASK_GET_INFO(1); + /* DMI with no live table, MAPINFO_CHECK_UUID not set */ + WRAP_DM_TASK_GET_INFO(&MPATH_DMI_02); + mock_dm_get_next_target(0, NULL, NULL, NULL); + rc = libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_MPATH_ONLY, + (mapid_t) { .str = "foo", }, + (mapinfo_t) { .dmi = &dmi }); + assert_int_equal(rc, DMP_EMPTY); +} + +static void test_mapinfo_no_table_02(void **state) +{ + int rc; + struct dm_info dmi = { .suspended = 0 }; + + mock_mapinfo_name_1(DM_DEVICE_STATUS, 1, "foo", 1, 1, 0); + WRAP_DM_TASK_GET_INFO(1); + /* DMI with no live table, MAPINFO_CHECK_UUID set */ + WRAP_DM_TASK_GET_INFO(&MPATH_DMI_02); + mock_dm_get_next_target(0, NULL, NULL, NULL); + will_return(__wrap_dm_task_get_uuid, MPATH_UUID_01); + rc = libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_CHECK_UUID | MAPINFO_MPATH_ONLY, + (mapid_t) { .str = "foo", }, + (mapinfo_t) { .dmi = &dmi }); + assert_int_equal(rc, DMP_EMPTY); +} + static void test_mapinfo_good_status_01(void **state) { int rc; @@ -1142,7 +1177,7 @@ static void test_mapinfo_bad_task_run_11(void **state) mock_mapinfo_name_1(DM_DEVICE_TABLE, 1, "foo", 1, 1, 0); WRAP_DM_TASK_GET_INFO(1); WRAP_DM_TASK_GET_INFO(&MPATH_DMI_01); - mock_dm_get_next_target(12345, NULL, MPATH_TARGET_01, NULL); + mock_dm_get_next_target(12345, TGT_ANY, MPATH_TARGET_01, NULL); will_return(__wrap_strdup, 1); /* error in 2nd dm_task_run */ mock_mapinfo_name_1(DM_DEVICE_STATUS, 1, "foo", 1, 0, EINVAL); @@ -1384,6 +1419,8 @@ static int test_mapinfo(void) cmocka_unit_test(test_mapinfo_good_target_type_02), cmocka_unit_test(test_mapinfo_good_target_type_03), cmocka_unit_test(test_mapinfo_good_target_type_04), + cmocka_unit_test(test_mapinfo_no_table_01), + cmocka_unit_test(test_mapinfo_no_table_02), cmocka_unit_test(test_mapinfo_good_status_01), cmocka_unit_test(test_mapinfo_bad_get_name_01), cmocka_unit_test(test_mapinfo_bad_get_uuid_01), From patchwork Tue Nov 26 18:42:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13886299 X-Patchwork-Delegate: bmarzins@redhat.com 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.subspace.kernel.org (Postfix) with ESMTPS id 3E9BB1DE2A8 for ; Tue, 26 Nov 2024 18:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646554; cv=none; b=GgoS0uMLAg0j0Z3WmRCFfOOg06XX9S29mwFqUiDr9LKYsTeB0EPvgAWIMYD1mYCe3DwBtc2jHRQmzYHKIuut7RP9D2Qn9CT2ym7R33h8AZxscH9Sjsrl4jnNAlfUY5J/PzMjFQ+O1NNQhgM2fmdkgyeyxZrY1D2pyXKa/yMm6hY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646554; c=relaxed/simple; bh=XUhD4O4t5lAtiOSYesm9OOWKk35/5NlsG2pgIeLPHOs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=m/OB4eqfPTqFRVT+KFqacnbdMNAzrAZtYBCBca9Iiw/Rdhj6xv/MaGzOXEV5XJeMYbl09IjkaMTVRYSJ146MY7kLOqNjekdKjj5wwH1KIQQFpy4hhpq0jO7dvu8eyYF3A/oHkCqeyJJI21eMLWSnmqwX3rtujCdnD7YyTLkm7Xw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DaxY7sRy; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DaxY7sRy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732646551; h=from:from: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; bh=wewTApdoEdysViJ2N/bLQt5p3SE2PNk6llAxlDshnYE=; b=DaxY7sRyrLta2s4GW7qSV1IIEsv33KEvL0Cji8X24cWidsOtx75FsU63v9t0I/vg+3aBCr 4ijLqC1qQrpX6aKMTUVoNZJEB1L8n8da8zPltPJEUg9gaudXewSUYXm5k8m/pXjIe5ZnTF bj2A02vL1Kb3vFYVky7B9HVMPnEvUL8= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-413-VJI6_Ms1N3qW4BidQ7HHsw-1; Tue, 26 Nov 2024 13:42:27 -0500 X-MC-Unique: VJI6_Ms1N3qW4BidQ7HHsw-1 X-Mimecast-MFC-AGG-ID: VJI6_Ms1N3qW4BidQ7HHsw Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E6FFC1955D4D; Tue, 26 Nov 2024 18:42:26 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7F8A41944CC9; Tue, 26 Nov 2024 18:42:26 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 4AQIgPei855492 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 26 Nov 2024 13:42:25 -0500 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4AQIgP7x855491; Tue, 26 Nov 2024 13:42:25 -0500 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v3 03/12] libmultipath: fix removing device after failed creation Date: Tue, 26 Nov 2024 13:42:15 -0500 Message-ID: <20241126184224.855459-4-bmarzins@redhat.com> In-Reply-To: <20241126184224.855459-1-bmarzins@redhat.com> References: <20241126184224.855459-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: YPjQYNe8f3s7p0Y2gW4T-jIf7qqo8m3fOO3Ivmu_JBM_1732646547 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true dm_flush_nap_nosync() only removes a device if it has a multipath table. On failed removes, there is no table, so this function does nothing. Instead, if libmp_mapinfo() returns DMP_EMPTY, then there is an empty map, and it is removed using dm_device_remove(). Also, since there are no longer any callers of dm_flush_map_nosync(), remove it. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/devmapper.c | 7 +++++-- libmultipath/devmapper.h | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 33425d02..42176667 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -557,9 +557,12 @@ int dm_addmap_create (struct multipath *mpp, char * params) * Failing the second part leaves an empty map. Clean it up. */ err = errno; - if (dm_map_present(mpp->alias)) { + if (libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_MPATH_ONLY | + MAPINFO_CHECK_UUID, + (mapid_t) { .str = mpp->alias }, + (mapinfo_t) { .uuid = NULL }) == DMP_EMPTY) { condlog(3, "%s: failed to load map (a path might be in use)", mpp->alias); - dm_flush_map_nosync(mpp->alias); + dm_device_remove(mpp->alias, 0); } if (err != EROFS) { condlog(3, "%s: failed to load map, error %d", diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index 23926e3f..0bd2b907 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -174,7 +174,6 @@ enum { int dm_flush_map__ (const char *mapname, int flags, int retries); #define dm_flush_map(mapname) dm_flush_map__(mapname, DMFL_NEED_SYNC, 0) -#define dm_flush_map_nosync(mapname) dm_flush_map__(mapname, DMFL_NONE, 0) #define dm_suspend_and_flush_map(mapname, retries) \ dm_flush_map__(mapname, DMFL_NEED_SYNC|DMFL_SUSPEND, retries) int dm_flush_map_nopaths(const char * mapname, int deferred_remove); From patchwork Tue Nov 26 18:42:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13886309 X-Patchwork-Delegate: bmarzins@redhat.com 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.subspace.kernel.org (Postfix) with ESMTPS id 53A451DF74F for ; Tue, 26 Nov 2024 18:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646557; cv=none; b=G0WRxKvyMkQpxI3ROldzzSCKfKw4mYGU1Da0MqK4OoC+VXJSDSb9RJHbWCc6xZYS1Opyma2w4wy0iZacPGn8x77ZWo3Dmaa03dIXrn1Y1ugxleTp0SHm4ymtNyMoc7H3xqzH3gJmoE02uS5FfGemKSsmFKin+SO5QADI/fHuSIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646557; c=relaxed/simple; bh=8CqEHJZ8IkdD1jm+3b3+QvLYYU3GJD/yeMPjL/hYofU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=U2zodNUafOzXW3NbXyw780uEiAJfJCiB3rhoR36TlwtUgJiedS0iWqQW73w5gxJ0GjDlFl4OIhGWYKMVNE8IKb/h7klRrFx0pdGpvNTD3P2zxqn6t/vVwhxKoKDlZOJfJuGv1xNJiKeOsSdRV6EChROea8zH6JzuAo2caMPqm24= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZGPqIrIL; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZGPqIrIL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732646553; h=from:from: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; bh=8ODbx21KGX5odUdOUaLqgD30E01W2HFjjeLx8ADhCgs=; b=ZGPqIrIL45yJU3pg8i+kBkZx8hJKVM+S9Qa9nfzDboMMDVL/Jl62BXnGpriUMVHngOm7l0 GG29eH25Nsz+spk6Qoo4wV4kvsxnaIe6rfHUwo9rMI4mc9OvdF+ShtJzk4Qi+MhcOMk9rE rFU0R5QsM0enbp2vxPV60VpSbum42ik= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-140-gzfiGTDTOUuMUprpPRPDUw-1; Tue, 26 Nov 2024 13:42:29 -0500 X-MC-Unique: gzfiGTDTOUuMUprpPRPDUw-1 X-Mimecast-MFC-AGG-ID: gzfiGTDTOUuMUprpPRPDUw Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4207B1955E94; Tue, 26 Nov 2024 18:42:27 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E89061956054; Tue, 26 Nov 2024 18:42:26 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 4AQIgPDg855496 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 26 Nov 2024 13:42:25 -0500 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4AQIgPeB855495; Tue, 26 Nov 2024 13:42:25 -0500 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v3 04/12] libmultipath: set uuid, name, and dmi if a device is found Date: Tue, 26 Nov 2024 13:42:16 -0500 Message-ID: <20241126184224.855459-5-bmarzins@redhat.com> In-Reply-To: <20241126184224.855459-1-bmarzins@redhat.com> References: <20241126184224.855459-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: mVKbasyHqne8ZEMPVFG0bH8u-zJaAJEuUIW8L3QbCPA_1732646547 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true Instead of only setting the uuid, name, and dmi on DMP_OK, return them whenever we find a device, even if that device doesn't match. To make the code simpler, we set these values before checks that could possibly return DMP_ERR. The only caller of libmp_mapinfo() that could update a multipath value incorrectly because of this is update_multipath_table(). Fix that. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/devmapper.c | 47 +++++++++++++++++++------------------- libmultipath/devmapper.h | 5 +++- libmultipath/structs_vec.c | 5 +++- tests/mapinfo.c | 45 +++++++++++++++++++++++++----------- 4 files changed, 63 insertions(+), 39 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 42176667..38c49bd5 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -736,6 +736,29 @@ static int libmp_mapinfo__(int flags, mapid_t id, mapinfo_t info, const char *ma && !(uuid = dm_task_get_uuid(dmt)))) return DMP_ERR; + if (info.name) { + strlcpy(info.name, name, WWID_SIZE); + condlog(4, "%s: %s: name: \"%s\"", fname__, map_id, info.name); + } + if (info.uuid) { + strlcpy(info.uuid, uuid, DM_UUID_LEN); + condlog(4, "%s: %s: uuid: \"%s\"", fname__, map_id, info.uuid); + } + + if (info.dmi) { + memcpy(info.dmi, &dmi, sizeof(*info.dmi)); + condlog(4, "%s: %s %d:%d, %d targets, %s table, %s, %s, %d opened, %u events", + fname__, map_id, + info.dmi->major, info.dmi->minor, + info.dmi->target_count, + info.dmi->live_table ? "live" : + info.dmi->inactive_table ? "inactive" : "no", + info.dmi->suspended ? "suspended" : "active", + info.dmi->read_only ? "ro" : "rw", + info.dmi->open_count, + info.dmi->event_nr); + } + if (flags & MAPINFO_CHECK_UUID && ((flags & MAPINFO_PART_ONLY && !is_mpath_part_uuid(uuid, NULL)) || (!(flags & MAPINFO_PART_ONLY) && !is_mpath_uuid(uuid)))) { @@ -768,40 +791,16 @@ static int libmp_mapinfo__(int flags, mapid_t id, mapinfo_t info, const char *ma /* * Check possible error conditions. - * If error is returned, don't touch any output parameters. */ if ((info.status && !(tmp_status = strdup(params))) || (info.target && !tmp_target && !(tmp_target = strdup(params)))) return DMP_ERR; - if (info.name) { - strlcpy(info.name, name, WWID_SIZE); - condlog(4, "%s: %s: name: \"%s\"", fname__, map_id, info.name); - } - if (info.uuid) { - strlcpy(info.uuid, uuid, DM_UUID_LEN); - condlog(4, "%s: %s: uuid: \"%s\"", fname__, map_id, info.uuid); - } - if (info.size) { *info.size = length; condlog(4, "%s: %s: size: %lld", fname__, map_id, *info.size); } - if (info.dmi) { - memcpy(info.dmi, &dmi, sizeof(*info.dmi)); - condlog(4, "%s: %s %d:%d, %d targets, %s table, %s, %s, %d opened, %u events", - fname__, map_id, - info.dmi->major, info.dmi->minor, - info.dmi->target_count, - info.dmi->live_table ? "live" : - info.dmi->inactive_table ? "inactive" : "no", - info.dmi->suspended ? "suspended" : "active", - info.dmi->read_only ? "ro" : "rw", - info.dmi->open_count, - info.dmi->event_nr); - } - if (info.target) { *info.target = steal_ptr(tmp_target); if (!tgt_set) diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index 0bd2b907..4aeefad1 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -115,7 +115,10 @@ typedef struct libmp_map_info { * * This function obtains the requested information for the device-mapper map * identified by the input parameters. - * Output parameters are only filled in if the return value is DMP_OK. + * If non-NULL, the name, uuid, and dmi output paramters may be filled in for + * any return value besides DMP_NOT_FOUND and will always be filled in for + * return values other than DMP_NOT_FOUND and DMP_ERR. + * The other parameters are only filled in if the return value is DMP_OK. * For target / status / size information, the map's table should contain * only one target (usually multipath or linear). */ diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 5df495b3..d22056ca 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -504,6 +504,8 @@ update_multipath_table (struct multipath *mpp, vector pathvec, int flags) int r = DMP_ERR; char __attribute__((cleanup(cleanup_charp))) *params = NULL; char __attribute__((cleanup(cleanup_charp))) *status = NULL; + /* only set the actual mpp->dmi if libmp_mapinfo returns DMP_OK */ + struct dm_info dmi; unsigned long long size; struct config *conf; @@ -522,7 +524,7 @@ update_multipath_table (struct multipath *mpp, vector pathvec, int flags) .target = ¶ms, .status = &status, .size = &mpp->size, - .dmi = &mpp->dmi, + .dmi = &dmi, }); if (r != DMP_OK) { @@ -531,6 +533,7 @@ update_multipath_table (struct multipath *mpp, vector pathvec, int flags) } else if (size != mpp->size) condlog(0, "%s: size changed from %llu to %llu", mpp->alias, size, mpp->size); + mpp->dmi = dmi; return update_multipath_table__(mpp, pathvec, flags, params, status); } diff --git a/tests/mapinfo.c b/tests/mapinfo.c index ee487989..36511607 100644 --- a/tests/mapinfo.c +++ b/tests/mapinfo.c @@ -451,15 +451,21 @@ static void test_mapinfo_bad_check_uuid_00(void **state) static void test_mapinfo_bad_check_uuid_01(void **state) { int rc; + struct dm_info dmi = { .suspended = 0 }; + char name[WWID_SIZE] = { 0 }; + char uuid[DM_UUID_LEN] = { 0 }; mock_mapinfo_name_1(DM_DEVICE_INFO, 1, "foo", 1, 1, 0); WRAP_DM_TASK_GET_INFO(1); WRAP_DM_TASK_GET_INFO(&MPATH_DMI_01); + will_return(__wrap_dm_task_get_name, MPATH_NAME_01); will_return(__wrap_dm_task_get_uuid, BAD_UUID_01); rc = libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_CHECK_UUID, (mapid_t) { .str = "foo", }, - (mapinfo_t) { .name = NULL }); + (mapinfo_t) { .dmi = &dmi, .name = name, .uuid = uuid }); assert_int_equal(rc, DMP_NO_MATCH); + assert_true(!strcmp(name, MPATH_NAME_01)); + assert_true(!strcmp(uuid, BAD_UUID_01)); } static void test_mapinfo_bad_check_uuid_02(void **state) @@ -887,17 +893,26 @@ static void test_mapinfo_bad_next_target_01(void **state) static void test_mapinfo_bad_next_target_02(void **state) { int rc; - unsigned long long size; + struct dm_info dmi = { .suspended = 0 }; + char name[WWID_SIZE] = { 0 }; + char uuid[DM_UUID_LEN] = { 0 }; + unsigned long long size = 0; mock_mapinfo_name_1(DM_DEVICE_STATUS, 1, "foo", 1, 1, 0); WRAP_DM_TASK_GET_INFO(1); WRAP_DM_TASK_GET_INFO(&MPATH_DMI_02); + will_return(__wrap_dm_task_get_name, MPATH_NAME_01); + will_return(__wrap_dm_task_get_uuid, MPATH_UUID_01); /* no targets */ mock_dm_get_next_target(0, NULL, NULL, NULL); rc = libmp_mapinfo(DM_MAP_BY_NAME, (mapid_t) { .str = "foo", }, - (mapinfo_t) { .size = &size }); + (mapinfo_t) { .dmi = &dmi, .name = name, .uuid = uuid, .size = &size }); assert_int_equal(rc, DMP_EMPTY); + assert_int_equal(size, 0); + assert_memory_equal(&dmi, &MPATH_DMI_02, sizeof(dmi)); + assert_true(!strcmp(name, MPATH_NAME_01)); + assert_true(!strcmp(uuid, MPATH_UUID_01)); } /* libmp_mapinfo needs to do a DM_DEVICE_STATUS ioctl */ @@ -946,10 +961,10 @@ static void test_mapinfo_bad_target_type_03(void **state) (mapid_t) { .str = "foo", }, (mapinfo_t) { .dmi = &dmi, .name = name, .uuid = uuid }); assert_int_equal(rc, DMP_NO_MATCH); - /* make sure memory content is not changed */ - assert_memory_equal(&dmi, &((struct dm_info) { .exists = 0 }), sizeof(dmi)); - assert_memory_equal(&name, &((char[WWID_SIZE]) { 0 }), WWID_SIZE); - assert_memory_equal(&uuid, &((char[DM_UUID_LEN]) { 0 }), DM_UUID_LEN); + /* make sure that the ouput was filled in */ + assert_memory_equal(&dmi, &MPATH_DMI_01, sizeof(dmi)); + assert_true(!strcmp(name, MPATH_NAME_01)); + assert_true(!strcmp(uuid, MPATH_UUID_01)); } static void test_mapinfo_bad_target_type_04(void **state) @@ -1065,23 +1080,32 @@ static void test_mapinfo_no_table_01(void **state) (mapid_t) { .str = "foo", }, (mapinfo_t) { .dmi = &dmi }); assert_int_equal(rc, DMP_EMPTY); + assert_memory_equal(&dmi, &MPATH_DMI_02, sizeof(dmi)); } static void test_mapinfo_no_table_02(void **state) { int rc; struct dm_info dmi = { .suspended = 0 }; + char name[WWID_SIZE] = { 0 }; + char uuid[DM_UUID_LEN] = { 0 }; + unsigned long long size = 0; mock_mapinfo_name_1(DM_DEVICE_STATUS, 1, "foo", 1, 1, 0); WRAP_DM_TASK_GET_INFO(1); /* DMI with no live table, MAPINFO_CHECK_UUID set */ WRAP_DM_TASK_GET_INFO(&MPATH_DMI_02); + will_return(__wrap_dm_task_get_name, MPATH_NAME_01); mock_dm_get_next_target(0, NULL, NULL, NULL); will_return(__wrap_dm_task_get_uuid, MPATH_UUID_01); rc = libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_CHECK_UUID | MAPINFO_MPATH_ONLY, (mapid_t) { .str = "foo", }, - (mapinfo_t) { .dmi = &dmi }); + (mapinfo_t) { .dmi = &dmi, .name = name, .uuid = uuid, .size = &size }); assert_int_equal(rc, DMP_EMPTY); + assert_int_equal(size, 0); + assert_memory_equal(&dmi, &MPATH_DMI_02, sizeof(dmi)); + assert_true(!strcmp(name, MPATH_NAME_01)); + assert_true(!strcmp(uuid, MPATH_UUID_01)); } static void test_mapinfo_good_status_01(void **state) @@ -1121,8 +1145,6 @@ static void test_mapinfo_bad_strdup_01(void **state) (mapinfo_t) { .status = &status, .uuid = uuid, .name = name }); assert_int_equal(rc, DMP_ERR); assert_null(status); - assert_memory_equal(&name, &((char[WWID_SIZE]) { 0 }), WWID_SIZE); - assert_memory_equal(&uuid, &((char[DM_UUID_LEN]) { 0 }), DM_UUID_LEN); } @@ -1284,9 +1306,6 @@ static void test_mapinfo_bad_strdup_02(void **state) assert_int_equal(rc, DMP_ERR); assert_null(status); assert_null(target); - assert_memory_equal(&dmi, &((struct dm_info) { .suspended = 0 }), sizeof(dmi)); - assert_memory_equal(&name, &((char[WWID_SIZE]) { 0 }), WWID_SIZE); - assert_memory_equal(&uuid, &((char[DM_UUID_LEN]) { 0 }), DM_UUID_LEN); } static void test_mapinfo_bad_strdup_03(void **state) From patchwork Tue Nov 26 18:42:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13886301 X-Patchwork-Delegate: bmarzins@redhat.com 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.subspace.kernel.org (Postfix) with ESMTPS id 87A651DE2DB for ; Tue, 26 Nov 2024 18:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646554; cv=none; b=JJQF6WdI50Wr/9u9DScK+4jBK5x7VJrj0RhQFVqid7CiFUXuXUDcC+g4G6VW9p8xtMDogZEUwKNZJIGJPDCD1N31kNZsoWm/eb2e1MqGBtsR21ru7eIGrB0Rof8eF8qkDV8hkdE1nwOktJ6jIG0ihCbFnCsywB5Iia8eGOf59Kc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646554; c=relaxed/simple; bh=ak0leN0EgJu9ciA+tW8RgP47qWw9Vc8aPNm52ewvKUQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=iATPcynn4yI2DhqbW42IdTz5gDLIG/NtGTsWuZwtVbeQ51O/QOXlemHx9bOSQ3cn3f8NSOqvy7ge/B061FE756NViM33vlEkiU8y6uGH/YD954TDtNInbURvMye4ZwMgsdHfjCRBdLJ9uO2a2ReXXXbtPMB0W7dQT6U53JZ9kcE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AMDaOEk9; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AMDaOEk9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732646551; h=from:from: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; bh=GpcRNz/H2CM+kHBs5LD6ztwZ0gQBI9LknPsxoOar7SY=; b=AMDaOEk9QL3+i8PFnxwSgEOqjLl3tpaigBm565xlD/5bd0ZBcNRcrbnzHBdBy5lqXr7ae3 HXTfH84YMWW3rzHKZttGARzknXe9V10w2o2MUJyapzPl7pwvhtesz4ryuPtLTjgkD3Aeqw wn/X9UtdL/K/hAUpJ4LtfmFxdUJcSEY= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-471-TBv0g_xGNZOSQbVvC0I-XA-1; Tue, 26 Nov 2024 13:42:28 -0500 X-MC-Unique: TBv0g_xGNZOSQbVvC0I-XA-1 X-Mimecast-MFC-AGG-ID: TBv0g_xGNZOSQbVvC0I-XA Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5D6B51955F2B; Tue, 26 Nov 2024 18:42:27 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 131DA195E486; Tue, 26 Nov 2024 18:42:26 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 4AQIgPu7855500 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 26 Nov 2024 13:42:25 -0500 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4AQIgPbX855499; Tue, 26 Nov 2024 13:42:25 -0500 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v3 05/12] libmultipath: check table type in dm_find_map_by_wwid Date: Tue, 26 Nov 2024 13:42:17 -0500 Message-ID: <20241126184224.855459-6-bmarzins@redhat.com> In-Reply-To: <20241126184224.855459-1-bmarzins@redhat.com> References: <20241126184224.855459-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: tShW0AOff1rCCXDX7Bp2HrIoDXM_X18ZB8SvSSYZ6Os_1732646547 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true This function is only supposed to work on multipath devices (it adds the multipath uuid prefix to the passed in wwid). Check this, and adapt cli_add_map() to handle the corner case where there is a non-multipath device with a multipath uuid. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/devmapper.c | 2 +- multipathd/cli_handlers.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 38c49bd5..e5f49a5b 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -892,7 +892,7 @@ int dm_find_map_by_wwid(const char *wwid, char *name, struct dm_info *dmi) if (safe_sprintf(tmp, UUID_PREFIX "%s", wwid)) return DMP_ERR; - return libmp_mapinfo(DM_MAP_BY_UUID, + return libmp_mapinfo(DM_MAP_BY_UUID | MAPINFO_MPATH_ONLY, (mapid_t) { .str = tmp }, (mapinfo_t) { .name = name, .dmi = dmi }); } diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 184c3f91..ec330d81 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -725,7 +725,13 @@ cli_add_map (void * v, struct strbuf *reply, void * data) condlog(2, "%s: unknown map.", param); return -ENODEV; } - if (dm_find_map_by_wwid(refwwid, alias, &dmi) != DMP_OK) { + rc = dm_find_map_by_wwid(refwwid, alias, &dmi); + if (rc == DMP_NO_MATCH) { + condlog(2, "%s: wwid %s already in use by non-multipath device %s", + param, refwwid, alias); + return 1; + } + if (rc != DMP_OK) { condlog(3, "%s: map not present. creating", param); if (coalesce_paths(vecs, NULL, refwwid, FORCE_RELOAD_NONE, CMD_NONE) != CP_OK) { From patchwork Tue Nov 26 18:42:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13886304 X-Patchwork-Delegate: bmarzins@redhat.com 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.subspace.kernel.org (Postfix) with ESMTPS id 7A6D11DF25D for ; Tue, 26 Nov 2024 18:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646555; cv=none; b=is2Yd/9V3Oq0ONkzgGf5iYJ8hCqSvCALcOZ6Pd/yvGX+/ey7+OCpGMKTQz2E/jIrKkbm+m4s59W3pilAYV553twKOgpOm/Had1TN/X4zcfYWJkM+UXERgICmWm91EfqZKLmQzDjucEN7ipLVYgxq45/E0uPs1qFYMR5idMx44Xo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646555; c=relaxed/simple; bh=5u1fJfaqTxp5ngofSBsrH3Ty4t5CaaV50Q/BQT6r3qc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=Ep5O8gpn5qO+GJuMOVvOW+jml6jfEgoXGV/89bPl+7YN0ZmL4+U0nB/cXov5u3DSC1SEkZ/eST6580lw1RKzorrKkm2DI/ST40oxxvfmVIH+kA8SLa7kVaw2JoOLj7WFNHtCcxXRSqozblGaZlIBoPC8H5XisFvs160mUkKk43Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=J/PxC6Ze; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="J/PxC6Ze" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732646552; h=from:from: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; bh=HrIsM1M6Hi4v7xXB9cBnBk0Dvf5k+gzPhDBAiU2nhoY=; b=J/PxC6Zet/Fjda66gjsL5n2FTuX9lOthN5VfJ/CwdHpAn18wfFQXdIMdG+x4gSDv/aOA8+ G8FHsMKlwX8TyRuVuq+YJXphtKN09/SsGNPCZHR8mq1QpWnumHSI49ykeFJ6eJHU1P3vNw Gk3+GBrMmZF+AGLvyWxKRvQLgXuD0dk= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-344-jqSfxlWNOEqBIBoDBV-Y1A-1; Tue, 26 Nov 2024 13:42:29 -0500 X-MC-Unique: jqSfxlWNOEqBIBoDBV-Y1A-1 X-Mimecast-MFC-AGG-ID: jqSfxlWNOEqBIBoDBV-Y1A Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4F5F51955F28; Tue, 26 Nov 2024 18:42:27 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0573D195E485; Tue, 26 Nov 2024 18:42:26 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 4AQIgPld855504 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 26 Nov 2024 13:42:25 -0500 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4AQIgP8j855503; Tue, 26 Nov 2024 13:42:25 -0500 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v3 06/12] libmultipath: handle a create corner case for empty devices Date: Tue, 26 Nov 2024 13:42:18 -0500 Message-ID: <20241126184224.855459-7-bmarzins@redhat.com> In-Reply-To: <20241126184224.855459-1-bmarzins@redhat.com> References: <20241126184224.855459-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: MbeuL9sudySzwG-EGLjnucIBuue0tCupxotn8G2aYMA_1732646547 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true Multipath already notices if there is any empty device with the same alias and wwid as a device it is trying to create, and switches to a reload. However, if the empty device has a different alias but the same wwid, instead of reloading and renaming the device like it would for a device with a table. multipath will attempt to create a new device and fail. Fix this by checking for these devices, and doing a reload and rename. Signed-off-by: Benjamin Marzinski --- libmultipath/configure.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index a7257981..d0e9c958 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -835,7 +835,6 @@ int domap(struct multipath *mpp, char *params, int is_daemon) { int r = DOMAP_FAIL; struct config *conf; - char wwid[WWID_SIZE]; /* * last chance to quit before touching the devmaps @@ -846,6 +845,7 @@ int domap(struct multipath *mpp, char *params, int is_daemon) } if (mpp->action == ACT_CREATE) { + char wwid[WWID_SIZE]; int rc = dm_get_wwid(mpp->alias, wwid, sizeof(wwid)); if (rc == DMP_OK && !strncmp(mpp->wwid, wwid, sizeof(wwid))) { @@ -863,7 +863,26 @@ int domap(struct multipath *mpp, char *params, int is_daemon) mpp->action = ACT_REJECT; } } + if (mpp->action == ACT_CREATE) { + char alias[WWID_SIZE]; + int rc = dm_find_map_by_wwid(mpp->wwid, alias, NULL); + if (rc == DMP_NO_MATCH) { + condlog(1, "%s: wwid \"%s\" already in use by non-multipath map \"%s\"", + mpp->alias, mpp->wwid, alias); + mpp->action = ACT_REJECT; + } else if (rc == DMP_OK || rc == DMP_EMPTY) { + /* + * we already handled the case were rc == DMO_OK and + * the alias == mpp->alias above. So the alias must be + * different here. + */ + condlog(3, "%s: map already present with a different name \"%s\". reloading", + mpp->alias, alias); + strlcpy(mpp->alias_old, alias, WWID_SIZE); + mpp->action = ACT_RELOAD_RENAME; + } + } if (mpp->action == ACT_RENAME || mpp->action == ACT_SWITCHPG_RENAME || mpp->action == ACT_RELOAD_RENAME || mpp->action == ACT_RESIZE_RENAME) { From patchwork Tue Nov 26 18:42:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13886308 X-Patchwork-Delegate: bmarzins@redhat.com 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.subspace.kernel.org (Postfix) with ESMTPS id 1BF941DE3D9 for ; Tue, 26 Nov 2024 18:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646556; cv=none; b=Cc80dLRTg4qUhwQa4fijXNYRRyoLU2lakSTrbUGTpL4e5KjTbtst8EHCpvhpgQmFqcYi5Nu4urX22Xiky1l9mTxi+gzEiNYj9quhU14BHSE9fp9T0+OnSg3vZFRUvhtgv9OpQhgZmAJMeF5shjoYIrd9ady/3dbLkiBcXx4pfSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646556; c=relaxed/simple; bh=J3d+yAjAuj16m2elbdgl2lCvpc2kUpSKE3kvY9iKO14=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=RPwDj48BvVQ3L7OQn2Q50QERxo0bkBsevOr+FNPjxIQ36S8s3PPKbJdR4KGYh22GYmxTVfpXABtMtqRO8PvOzHDefVjWcXosfzl1dJ6ZLxUNkRTKc4kxgdGORydkADlH89rtRm/NKmauYgotziBS0ye8bMRS3h0Kmzu0eHqHz5k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=b+m6LXFg; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="b+m6LXFg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732646554; h=from:from: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; bh=B/ZrZErwHwYycc+sEKMeX8EMSHMxC5Zz6MQhc2qdMMo=; b=b+m6LXFgCh3qM58/4eNyPRzAO5GnNxrigcY7ELxmgU4hmw9JE5TMnxUfQFg+g+r1DNJ7Z0 rRFVVoChbsYG3liq5fKvcxKV1XCULiPpaDgk6m3X2U3VixUEl/7Xt+NcGgOYN3RR4qKvXK /u/3AokZLt1gFNwJmL6jQBxUyOfTOWg= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-Iw_2UteAOv646lLSDAxYdw-1; Tue, 26 Nov 2024 13:42:28 -0500 X-MC-Unique: Iw_2UteAOv646lLSDAxYdw-1 X-Mimecast-MFC-AGG-ID: Iw_2UteAOv646lLSDAxYdw Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6E43B1954B1A; Tue, 26 Nov 2024 18:42:27 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2C32A195E483; Tue, 26 Nov 2024 18:42:27 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 4AQIgPkA855508 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 26 Nov 2024 13:42:26 -0500 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4AQIgPLp855507; Tue, 26 Nov 2024 13:42:25 -0500 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v3 07/12] libmultipath: handle empty maps in dm_flush_map__ Date: Tue, 26 Nov 2024 13:42:19 -0500 Message-ID: <20241126184224.855459-8-bmarzins@redhat.com> In-Reply-To: <20241126184224.855459-1-bmarzins@redhat.com> References: <20241126184224.855459-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Nl72__JL7MZcbWqSTM6GCXHlXdbINfwnir9vATMJk4M_1732646547 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true Make dm_flush_map__() remove empty devices, as long as they have valid multipath uuids. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/devmapper.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index e5f49a5b..b0bd0d4f 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -982,11 +982,16 @@ int dm_flush_map__ (const char *mapname, int flags, int retries) int udev_flags = 0; char *params __attribute__((cleanup(cleanup_charp))) = NULL; - if (libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_MPATH_ONLY | MAPINFO_CHECK_UUID, + r = libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_MPATH_ONLY | MAPINFO_CHECK_UUID, (mapid_t) { .str = mapname }, - (mapinfo_t) { .target = ¶ms }) != DMP_OK) + (mapinfo_t) { .target = ¶ms }); + if (r != DMP_OK && r != DMP_EMPTY) return DM_FLUSH_OK; /* nothing to do */ + /* device mapper will not let you resume an empty device */ + if (r == DMP_EMPTY) + flags &= ~DMFL_SUSPEND; + /* if the device currently has no partitions, do not run kpartx on it if you fail to delete it */ if (do_foreach_partmaps(mapname, has_partmap, NULL) == 0) From patchwork Tue Nov 26 18:42:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13886303 X-Patchwork-Delegate: bmarzins@redhat.com 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.subspace.kernel.org (Postfix) with ESMTPS id F0CBE1DEFE1 for ; Tue, 26 Nov 2024 18:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646554; cv=none; b=tJIEvJKqEpzoQ9l86d7a72yJLk0zuuFeYtE4wpBzR/csdg8ybHDGEi7EpjRezw9RTMhm/Fsr5CaATmgLm2gXkLgrjiRgXobd18B56dmqgZs5zeaQEIykCcSoBbYIO3Nnfu1HmoWPMBs+fen4GhXClbcODAgmxHrblX3qwoc6RRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646554; c=relaxed/simple; bh=jj/WwDiwe6CUwOI0g+ZYwSFn/EryoxEKc2+45/SDFoU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=heit5KBuqy4WrAB1DcolAqMzHTWhE/KQ2tq6+pAOR8pWJU2sDJRCelmnYHjD0rIhsCVhmVKW1yWztKQrQjZXIEMXV5i4+WIphh+j66VQpnwHgytCaWRKNsevTRrxWPM6wRgKM0gRevzlHEx60qUnsS4iVMOKximTEyAyHr/Ll/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PYkHJA1D; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PYkHJA1D" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732646552; h=from:from: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; bh=1XxIvS/iz7G5x9/inp7Fy0zDkBgoAJThyhE3IsCkkc4=; b=PYkHJA1DK6M9YIdz/JSa1yOBNy7v3hVCdPBVSGLMklboa9C3Ta9tlinu0QNV82QoPl/XuI /GFOg1R3TUPmUzfdvXeGGM4go0Q0DS8XgzGph+biWnDlDsqPg0DbRXVAkoIdXlk3++Xrl1 ulB1eL6nw2sWhosmKuTjPGg2rRlRVAs= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-493-ryfwwF7oOoyBy7ZBKetJ3Q-1; Tue, 26 Nov 2024 13:42:28 -0500 X-MC-Unique: ryfwwF7oOoyBy7ZBKetJ3Q-1 X-Mimecast-MFC-AGG-ID: ryfwwF7oOoyBy7ZBKetJ3Q Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BDD171955EAD; Tue, 26 Nov 2024 18:42:27 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 74726300019E; Tue, 26 Nov 2024 18:42:27 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 4AQIgQBd855512 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 26 Nov 2024 13:42:26 -0500 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4AQIgQFP855511; Tue, 26 Nov 2024 13:42:26 -0500 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v3 08/12] libmultipath: factor out code to check if a device is a partition Date: Tue, 26 Nov 2024 13:42:20 -0500 Message-ID: <20241126184224.855459-9-bmarzins@redhat.com> In-Reply-To: <20241126184224.855459-1-bmarzins@redhat.com> References: <20241126184224.855459-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 28tMllRSHqRsEO5SJuBB4R2xOXtG6rMNMyL4nAtoCo4_1732646547 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true Move the code to check if a device is a valid partition of a multipath device out into its own function. A future patch will make this code more complicated. No functional changes. Signed-off-by: Benjamin Marzinski --- libmultipath/devmapper.c | 57 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index b0bd0d4f..0df9ee40 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -1318,17 +1318,43 @@ char *dm_mapname(int major, int minor) return strdup(name); } +static bool +is_valid_partmap(const char *name, const char *map_dev_t, + const char *map_uuid) { + int r; + char __attribute__((cleanup(cleanup_charp))) *params = NULL; + char *p; + char part_uuid[DM_UUID_LEN]; + + r = libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_PART_ONLY | MAPINFO_CHECK_UUID, + (mapid_t) { .str = name }, + (mapinfo_t) { .uuid = part_uuid, .target = ¶ms}); + + /* There must be a single linear target */ + if (r != DMP_OK) + return false; + + /* + * and the uuid of the target must be a partition of the uuid of the + * multipath device + */ + if (!is_mpath_part_uuid(part_uuid, map_uuid)) + return false; + + /* and the table must map over the multipath map */ + return ((p = strstr(params, map_dev_t)) && + !isdigit(*(p + strlen(map_dev_t)))); +} + static int do_foreach_partmaps (const char *mapname, int (*partmap_func)(const char *, void *), void *data) { struct dm_task __attribute__((cleanup(cleanup_dm_task))) *dmt = NULL; - char __attribute__((cleanup(cleanup_charp))) *params = NULL; struct dm_names *names; unsigned next = 0; char dev_t[BLK_DEV_SIZE]; - char *p; char map_uuid[DM_UUID_LEN]; struct dm_info info; @@ -1354,35 +1380,10 @@ do_foreach_partmaps (const char *mapname, return 0; do { - char part_uuid[DM_UUID_LEN]; - - if ( - /* - * if there is only a single "linear" target - */ - libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_PART_ONLY | MAPINFO_CHECK_UUID, - (mapid_t) { .str = names->name }, - (mapinfo_t) { - .uuid = part_uuid, - .target = ¶ms, - }) == DMP_OK && - /* - * and the uuid of the target is a partition of the - * uuid of the multipath device - */ - is_mpath_part_uuid(part_uuid, map_uuid) && - - /* - * and the table maps over the multipath map - */ - (p = strstr(params, dev_t)) && - !isdigit(*(p + strlen(dev_t))) && - + if (is_valid_partmap(names->name, dev_t, map_uuid) && (partmap_func(names->name, data) != 0)) return 1; - free(params); - params = NULL; next = names->next; names = (void*) names + next; } while (next); From patchwork Tue Nov 26 18:42:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13886298 X-Patchwork-Delegate: bmarzins@redhat.com 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.subspace.kernel.org (Postfix) with ESMTPS id 20D381D63E8 for ; Tue, 26 Nov 2024 18:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646552; cv=none; b=eHgdLtT7eIlxeXgxqaK6GtVP25b/5FTRUnij3aAKJEz6J+a7E+DkFC2AFZmnpilW0W0HS/kIApMfFxrfGmiVxsMyV68o++NJe1pfEMTb6AbYhLiz1YDZ0/S2Ll6Fup/K4VoEIdWFlLO82lp5nmQWEGBk8zxiDab9Cwt3O7D2H/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646552; c=relaxed/simple; bh=5eXCg4qdYy8ZNFAVf9Cd5x4QgBtBkicMDOAZaOPimuE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=d9Agmtjp+ZWR1aTyMOWWwUcSb6YrrVD+bj/wmPfmbW4X+T2ANjDsbWsCuJuYfCbx+wmuxrFj+peOvvhXsRQqqkBbf54S4clYYXh1vJaLrodYjJyamDmGFJ0cmIRTk9LqIHQBDblxGWFf4vw3QMcnJAbhLcf0yqibWhvzCEy7HgQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=MCybQtzF; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MCybQtzF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732646550; h=from:from: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; bh=vGIRN505w6PKozpr25dQRCf/jCu7829Rd3lDwrAzVdI=; b=MCybQtzFpjvlQJT21tPUVswd/2s1cLbU63nJwmFzobWZkhWKY2f0Qn0+MHrVzyhYuFr+yl ymwQqCguDtj+UTYKZcA/9bR+L6fkZF+6AFuOx/BreQm3hBtc6g7oB9cnmx7ISqBzT0IQFK v0y+BkWdemAoZV5kcElIOOFX1zO+qT4= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-513-JEtDzR8zNlCnwW2ceaWN7A-1; Tue, 26 Nov 2024 13:42:28 -0500 X-MC-Unique: JEtDzR8zNlCnwW2ceaWN7A-1 X-Mimecast-MFC-AGG-ID: JEtDzR8zNlCnwW2ceaWN7A Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D8CC21953944; Tue, 26 Nov 2024 18:42:27 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9884430001A0; Tue, 26 Nov 2024 18:42:27 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 4AQIgQUl855516 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 26 Nov 2024 13:42:26 -0500 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4AQIgQXB855515; Tue, 26 Nov 2024 13:42:26 -0500 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v3 09/12] libmultipath: remove recursive calls in partmap_funcs Date: Tue, 26 Nov 2024 13:42:21 -0500 Message-ID: <20241126184224.855459-10-bmarzins@redhat.com> In-Reply-To: <20241126184224.855459-1-bmarzins@redhat.com> References: <20241126184224.855459-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: y5VndP78V6Dzh0rdekH9-rL6Y8qmEexqfKOmFuIC4fs_1732646548 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true cancel_remove_partmap() and rename_partmap() both could end up calling do_foreach_partmaps() with the partition instead of the original multipath device. This won't ever do anything, since do_foreach_partmaps() checks that it's called with a multipath device. Signed-off-by: Benjamin Marzinski --- libmultipath/devmapper.c | 59 +++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 0df9ee40..751b45d8 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -1421,8 +1421,6 @@ dm_remove_partmaps (const char * mapname, int flags) static int cancel_remove_partmap (const char *name, void *unused __attribute__((unused))) { - if (dm_get_opencount(name)) - dm_cancel_remove_partmaps(name); if (dm_message(name, "@cancel_deferred_remove") != 0) condlog(0, "%s: can't cancel deferred remove: %s", name, strerror(errno)); @@ -1481,6 +1479,34 @@ struct rename_data { char *delim; }; +static int +dm_rename__(const char *old, char *new, int skip_kpartx) +{ + int r = 0; + struct dm_task __attribute__((cleanup(cleanup_dm_task))) *dmt = NULL; + uint32_t cookie = 0; + uint16_t udev_flags = DM_UDEV_DISABLE_LIBRARY_FALLBACK | ((skip_kpartx == SKIP_KPARTX_ON)? MPATH_UDEV_NO_KPARTX_FLAG : 0); + + if (!(dmt = libmp_dm_task_create(DM_DEVICE_RENAME))) + return r; + + if (!dm_task_set_name(dmt, old)) + return r; + + if (!dm_task_set_newname(dmt, new)) + return r; + + if (!dm_task_set_cookie(dmt, &cookie, udev_flags)) + return r; + + r = libmp_dm_task_run(dmt); + if (!r) + dm_log_error(2, DM_DEVICE_RENAME, dmt); + + libmp_udev_wait(cookie); + return r; +} + static int rename_partmap (const char *name, void *data) { @@ -1492,7 +1518,7 @@ rename_partmap (const char *name, void *data) return 0; for (offset = strlen(rd->old); name[offset] && !(isdigit(name[offset])); offset++); /* do nothing */ if (asprintf(&buff, "%s%s%s", rd->new, rd->delim, name + offset) >= 0) { - dm_rename(name, buff, rd->delim, SKIP_KPARTX_OFF); + dm_rename__(name, buff, SKIP_KPARTX_OFF); free(buff); condlog(4, "partition map %s renamed", name); } else @@ -1522,32 +1548,9 @@ dm_rename_partmaps (const char * old, char * new, char *delim) int dm_rename (const char * old, char * new, char *delim, int skip_kpartx) { - int r = 0; - struct dm_task __attribute__((cleanup(cleanup_dm_task))) *dmt = NULL; - uint32_t cookie = 0; - uint16_t udev_flags = DM_UDEV_DISABLE_LIBRARY_FALLBACK | ((skip_kpartx == SKIP_KPARTX_ON)? MPATH_UDEV_NO_KPARTX_FLAG : 0); - if (dm_rename_partmaps(old, new, delim)) - return r; - - if (!(dmt = libmp_dm_task_create(DM_DEVICE_RENAME))) - return r; - - if (!dm_task_set_name(dmt, old)) - return r; - - if (!dm_task_set_newname(dmt, new)) - return r; - - if (!dm_task_set_cookie(dmt, &cookie, udev_flags)) - return r; - - r = libmp_dm_task_run(dmt); - if (!r) - dm_log_error(2, DM_DEVICE_RENAME, dmt); - - libmp_udev_wait(cookie); - return r; + return 0; + return dm_rename__(old, new, skip_kpartx); } void dm_reassign_deps(char *table, const char *dep, const char *newdep) From patchwork Tue Nov 26 18:42:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13886302 X-Patchwork-Delegate: bmarzins@redhat.com 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.subspace.kernel.org (Postfix) with ESMTPS id 88C1F1DE3D9 for ; Tue, 26 Nov 2024 18:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646554; cv=none; b=g7I9ovOzqKVm0/DsMnoDVRMzfIjspcdZ3QwBkkP+mfXXW8nDDf3zzKneCMZGfrWVQxZisWObGDIO/w/nsa6Q5WkQsj6175YDSD3ckdGgOc3YIfq1cLkwQnFMjOffYLd3tDoNeJMLbABImMNRuFlU6ys2fxl79OmhtROsTYCCnEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646554; c=relaxed/simple; bh=rxv/lhjNtXKLxdKMn4Qx7CUIQs+Uimn2lRRa6OK9IvU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=aq8sZP9/8PJdEU7hsOiUJMsuWUTDEvSTgoufgapeMia/7CjieUuXTAa/+ADZP39YCVUZ4b3maRsDGTLxXWqdJv+5TFqb6E5mDlcRD24aWOIrK0d+7kPCSYWOuoZAd7kVRQhloLwv2V1nCAJDBE+q2+Ns1+viLLgPSo1HPqu3sss= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=O9zfNhGg; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="O9zfNhGg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732646551; h=from:from: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; bh=DY8bc34GU0/tnbshqYoGeUcxS87DW1VgPbW8NGk3b2w=; b=O9zfNhGggfYcya6bB0kxcRZ46yDzNJqm4OioOUQPhPWVK/L+K/JT2OpTKmaewAsHgiyVJU zMi3RGrNsluZX6L05O9gIb/sb/M25qbgPbeY+9X3Q+nPKpg+BWBfvnxWLlix4BbkjY7Kk0 viyTb8458zaypad1Tq4QZLHX3m3jLgs= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-0Olx5CJ6PRqS04oA4K34cg-1; Tue, 26 Nov 2024 13:42:29 -0500 X-MC-Unique: 0Olx5CJ6PRqS04oA4K34cg-1 X-Mimecast-MFC-AGG-ID: 0Olx5CJ6PRqS04oA4K34cg Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2F3731955EA7; Tue, 26 Nov 2024 18:42:28 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C392E195E483; Tue, 26 Nov 2024 18:42:27 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 4AQIgQnr855520 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 26 Nov 2024 13:42:26 -0500 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4AQIgQkj855519; Tue, 26 Nov 2024 13:42:26 -0500 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v3 10/12] libmultipath: assume device is in use if dm_get_opencount fails Date: Tue, 26 Nov 2024 13:42:22 -0500 Message-ID: <20241126184224.855459-11-bmarzins@redhat.com> In-Reply-To: <20241126184224.855459-1-bmarzins@redhat.com> References: <20241126184224.855459-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 3TiXlaUbiQTFspfsM9IQkQXSV2v39DDsrDC7NKKTqX4_1732646548 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true If dm_get_opencount() fails, open_count will be negative, which means mpath_in_use() will never fail. However, dm_flush_map__() will eventually fail. There are multiple callers of dm_get_opencount() that run when trying to remove a device. All the others treat a failed call as if the device was in use, including one that will later be called directly on this device. So save ourselves the work, and exit early Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/devmapper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 751b45d8..3667c51b 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -961,6 +961,11 @@ int mpath_in_use(const char *name) { int open_count = dm_get_opencount(name); + if (open_count < 0) { + condlog(0, "%s: %s: failed to get open count, assuming in use", + __func__, name); + return 1; + } if (open_count) { int part_count = 0; From patchwork Tue Nov 26 18:42:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13886306 X-Patchwork-Delegate: bmarzins@redhat.com 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.subspace.kernel.org (Postfix) with ESMTPS id EC8871DF25F for ; Tue, 26 Nov 2024 18:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646555; cv=none; b=qR2uCrm2ne0jFzo3io1vPXnS/jFpJyr/OYAf0JcE7eCRHkkQxh4sXvt8T/KAxrb6dqRCgAF9gwGMcqcnpOdMIPWzKV1npKSoQvZO+T+/4dDfKRwvLg/yZYYrANzdqWcRvpbQekWEsVSq1VMpJEUiGyJ/OWlzatIlkPajXTmwZ44= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646555; c=relaxed/simple; bh=xkwCId5wrc3i3bZnYGvQlf/veAo1bmnMgkpA37Ibxl8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=XpyH0vg7w135MwZxl9dADPbtFeqXOjuxVWzs4ubLPk05NrmBHmGyklEj13bjdgwApE9hywwyZSSX6tFLKUfZS9CtInimiolgyJSd5EjP9VJf1qiIQlWedisiDgVFFnux5PoVb+5ohMUuvXLK7H8AWHEldzGZvml4AHHDECWlpkA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=RaEm44FK; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RaEm44FK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732646552; h=from:from: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; bh=Pq7vOg69WZNVe1bTahY1e9WkEybOPTf4XdE7EPV6W48=; b=RaEm44FKjFcY+Im+OqwRWrqiEMoIALlhgQtE7Pp5OrWA3mYqHdepdQN8Xs5EwrLYrO+gsN HaN4u6xD9pWpiuU8PBRWJOJvAOzgn/G5WjeuwuFghKIbCsDOdh223l8C8M6lAK7OyxROcV kxYcOhN8mB1wrfQTtyxVzFHYN5BI35Y= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-207-bEZrkV8LOiGQePhQLzDkOA-1; Tue, 26 Nov 2024 13:42:29 -0500 X-MC-Unique: bEZrkV8LOiGQePhQLzDkOA-1 X-Mimecast-MFC-AGG-ID: bEZrkV8LOiGQePhQLzDkOA Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3EEDD1955BCF; Tue, 26 Nov 2024 18:42:28 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EA0FD300019E; Tue, 26 Nov 2024 18:42:27 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 4AQIgQVs855524 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 26 Nov 2024 13:42:26 -0500 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4AQIgQLI855523; Tue, 26 Nov 2024 13:42:26 -0500 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v3 11/12] libmultipath: accept empty partitions as valid in do_foreach_partmaps Date: Tue, 26 Nov 2024 13:42:23 -0500 Message-ID: <20241126184224.855459-12-bmarzins@redhat.com> In-Reply-To: <20241126184224.855459-1-bmarzins@redhat.com> References: <20241126184224.855459-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: YVNdb-v5sgxXGCPzCPL6NfNyPctIoavPgDFVHwE8DGA_1732646548 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true If the partition is empty, is_valid_partmap() only checks that the uuid matches the multipath device, since there is no table to check for mapping over the multipath device. The only partmap_func that needs changes to handle empty devices is count_partitions(), which should only count a partition if it has a table (since otherwise it will not have the multipath device open). Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/devmapper.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 3667c51b..c96e4b22 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -944,16 +944,23 @@ has_partmap(const char *name __attribute__((unused)), * This will be called from mpath_in_use, for each partition. * If the partition itself in use, returns 1 immediately, causing * do_foreach_partmaps() to stop iterating and return 1. - * Otherwise, increases the partition count. + * Otherwise, increases the partition count if the partition has a + * table (live or inactive). Devices with no table don't count + * towards the multipath device open count. */ static int count_partitions(const char *name, void *data) { + struct dm_info info; int *ret_count = (int *)data; - int open_count = dm_get_opencount(name); - if (open_count) + if (dm_get_info(name, &info) != DMP_OK) + return 1; + + if (info.open_count) return 1; - (*ret_count)++; + + if (info.live_table || info.inactive_table) + (*ret_count)++; return 0; } @@ -1335,8 +1342,8 @@ is_valid_partmap(const char *name, const char *map_dev_t, (mapid_t) { .str = name }, (mapinfo_t) { .uuid = part_uuid, .target = ¶ms}); - /* There must be a single linear target */ - if (r != DMP_OK) + /* There must be a single linear target or an empty map. */ + if (r != DMP_OK && r != DMP_EMPTY) return false; /* @@ -1346,7 +1353,10 @@ is_valid_partmap(const char *name, const char *map_dev_t, if (!is_mpath_part_uuid(part_uuid, map_uuid)) return false; - /* and the table must map over the multipath map */ + if (r == DMP_EMPTY) + return true; + + /* and if the table isn't empty it must map over the multipath map */ return ((p = strstr(params, map_dev_t)) && !isdigit(*(p + strlen(map_dev_t)))); } From patchwork Tue Nov 26 18:42:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13886307 X-Patchwork-Delegate: bmarzins@redhat.com 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.subspace.kernel.org (Postfix) with ESMTPS id 502D81DF27B for ; Tue, 26 Nov 2024 18:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646555; cv=none; b=Sh+pJprvmhgmZ0IxER/4rvQhET2eq93keRw6f6hvu7x+5BxvAWubVIQGOB2zW6pa87hLLzimYSOuxLKlFB+ZOQTxM68keeeWM5uk4fyweGdpNb0I2sISgEU5LLvnkX5YRk2rgdYCW+M7omnEOSKUGIkZokRvsrd9RPDhaoHehks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732646555; c=relaxed/simple; bh=rIiLbbUT7H9Lh0o0CFq7Vy+5KpS3C/gWag6s792YggA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=kelKCyaFf/r3eDy1ZjB5+GnupawW2OareknGLhZgv/xaehb4kbmk6yrRXOJs9wYmO6TagNvIT774s/oWjNQMbilEdH9URhIZ36Leen569flR5RZKoBpOYkq40wqhygrLhyCcXMaX+cS4t1V/qjdLk0phGGCdGLjs/Qx/5LoJoqw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TrHcjUMJ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TrHcjUMJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732646553; h=from:from: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; bh=EfoinIm5zgtkMK2QuGDp7usZuCqpFZVxx3W5145qfx8=; b=TrHcjUMJdP78QyBP8evJMsR7bOtC+Qcb8tMB3hzn7mKbc0oKG4KHK7pb7/eW2U54eOyuMQ twm+Pg99exOuYba7YZ1ecI8RT3ZUeDqghmdNasgw9AIoIlDmruwuFfgK5Xpop+rQ09XUPr Qoh+rVDbphY0p9Qk3/BVJJLnbvYfK0c= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-197-zAAFNF1kNi6VhtaINQjfbg-1; Tue, 26 Nov 2024 13:42:29 -0500 X-MC-Unique: zAAFNF1kNi6VhtaINQjfbg-1 X-Mimecast-MFC-AGG-ID: zAAFNF1kNi6VhtaINQjfbg Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 89E8E19560B0; Tue, 26 Nov 2024 18:42:28 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 49A80300019E; Tue, 26 Nov 2024 18:42:28 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 4AQIgQ73855528 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 26 Nov 2024 13:42:26 -0500 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4AQIgQvl855527; Tue, 26 Nov 2024 13:42:26 -0500 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v3 12/12] libmultipath: reduce log level for DMP_NOT_FOUND Date: Tue, 26 Nov 2024 13:42:24 -0500 Message-ID: <20241126184224.855459-13-bmarzins@redhat.com> In-Reply-To: <20241126184224.855459-1-bmarzins@redhat.com> References: <20241126184224.855459-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: JAWP9opAxKqATRDsqk4wsh-cTVkplUJpJK9kbrPFSxY_1732646548 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true multipath makes many calls just to check if a device exists. Don't warn on each of these. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/devmapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index c96e4b22..d4dd9540 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -727,7 +727,7 @@ static int libmp_mapinfo__(int flags, mapid_t id, mapinfo_t info, const char *ma condlog(2, "%s: dm_task_get_info() failed for %s ", fname__, map_id); return DMP_ERR; } else if(!dmi.exists) { - condlog(2, "%s: map %s doesn't exist", fname__, map_id); + condlog(3, "%s: map %s doesn't exist", fname__, map_id); return DMP_NOT_FOUND; }