!93 [sync] PR-87: 当使能remove_local_path时,不在nvme设备上创建dm设备。

From: @openeuler-sync-bot 
Reviewed-by: @liuzhiqiang26 
Signed-off-by: @liuzhiqiang26
This commit is contained in:
openeuler-ci-bot 2022-03-08 13:38:42 +00:00 committed by Gitee
commit d979e09c29
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 32 additions and 16 deletions

View File

@ -1,21 +1,25 @@
From a1461cbfa7ea2bccef20eb2f5275648452ee050c Mon Sep 17 00:00:00 2001 From ebb976fb0e46657f7f9133d406934730154c8777 Mon Sep 17 00:00:00 2001
From: chenminhua <chenminhua1@huawei.com> From: chenminhua <chenminhua1@huawei.com>
Date: Mon, 2 Apr 2018 04:01:04 -0400 Date: Mon, 2 Apr 2018 04:01:04 -0400
Subject: [PATCH] 1hostos-patch-upgrade:0330 hotpatch modify Subject: [PATCH] remove local disk from pathvec
Here we provide a multipath_private.conf to enable remove_local_disk.
When enable remove_local_disk, the multipath devices are only created
on fc or iscsi devices.
[Changelog]:add upgrade path [Changelog]:add upgrade path
[Author]:chenminhua [Author]:chenminhua
--- ---
libmultipath/discovery.c | 124 +++++++++++++++++++++++++++++++++++++++++++++-- libmultipath/discovery.c | 133 +++++++++++++++++++++++++++++++++++++++++++++--
libmultipath/discovery.h | 1 + libmultipath/discovery.h | 1 +
multipathd/main.c | 4 ++ multipathd/main.c | 4 ++
3 files changed, 124 insertions(+), 5 deletions(-) 3 files changed, 133 insertions(+), 5 deletions(-)
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index ee3290c..c49848e 100644 index ee3290c..f57c072 100644
--- a/libmultipath/discovery.c --- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c +++ b/libmultipath/discovery.c
@@ -34,6 +34,103 @@ @@ -34,6 +34,112 @@
#include "prioritizers/alua_rtpg.h" #include "prioritizers/alua_rtpg.h"
#include "foreign.h" #include "foreign.h"
@ -67,14 +71,23 @@ index ee3290c..c49848e 100644
+ return should_remove_local_disk; + return should_remove_local_disk;
+} +}
+ +
+/* Filter the local disks and remove them from pathvec */ +/* Filter the local disks and remove them from pathvec.
+ * When bus type is SCSI and device type is (fc or scsi),
+ * return 0. This means the path is not local disk.
+ * When enable remove_local_disk, multipath only supports
+ * iscsi and fc device.
+ */
+static int +static int
+transport (int h) +transport(int type, int h)
+{ +{
+ char buff[PATH_SIZE]; + char buff[PATH_SIZE];
+ int len, off; + int len, off;
+ struct stat a_stat; + struct stat a_stat;
+ +
+ if (type != SYSFS_BUS_SCSI) {
+ return 1;
+ }
+
+ /* FC host */ + /* FC host */
+ strcpy(buff, "/sys"); + strcpy(buff, "/sys");
+ strcat(buff, "/class/fc_host/"); + strcat(buff, "/class/fc_host/");
@ -105,7 +118,7 @@ index ee3290c..c49848e 100644
+ return 1; + return 1;
+ } + }
+ +
+ if (transport(pp->sg_id.host_no) == 0) { + if (transport(pp->bus, pp->sg_id.host_no) == 0) {
+ return 1; + return 1;
+ } + }
+ +
@ -119,7 +132,7 @@ index ee3290c..c49848e 100644
struct vpd_vendor_page vpd_vendor_pages[VPD_VP_ARRAY_SIZE] = { struct vpd_vendor_page vpd_vendor_pages[VPD_VP_ARRAY_SIZE] = {
[VPD_VP_UNDEF] = { 0x00, "undef" }, [VPD_VP_UNDEF] = { 0x00, "undef" },
[VPD_VP_HP3PAR] = { 0xc0, "hp3par" }, [VPD_VP_HP3PAR] = { 0xc0, "hp3par" },
@@ -124,6 +221,7 @@ path_discover (vector pathvec, struct config * conf, @@ -124,6 +230,7 @@ path_discover (vector pathvec, struct config * conf,
{ {
struct path * pp; struct path * pp;
const char * devname; const char * devname;
@ -127,7 +140,7 @@ index ee3290c..c49848e 100644
devname = udev_device_get_sysname(udevice); devname = udev_device_get_sysname(udevice);
if (!devname) if (!devname)
@@ -137,12 +235,22 @@ path_discover (vector pathvec, struct config * conf, @@ -137,12 +244,22 @@ path_discover (vector pathvec, struct config * conf,
snprintf(devt, BLK_DEV_SIZE, "%d:%d", snprintf(devt, BLK_DEV_SIZE, "%d:%d",
major(devnum), minor(devnum)); major(devnum), minor(devnum));
pp = find_path_by_devt(pathvec, devt); pp = find_path_by_devt(pathvec, devt);
@ -155,13 +168,13 @@ index ee3290c..c49848e 100644
} }
static void cleanup_udev_enumerate_ptr(void *arg) static void cleanup_udev_enumerate_ptr(void *arg)
@@ -2091,6 +2199,12 @@ int pathinfo(struct path *pp, struct config *conf, int mask) @@ -2091,6 +2208,12 @@ int pathinfo(struct path *pp, struct config *conf, int mask)
if (rc != PATHINFO_OK) if (rc != PATHINFO_OK)
return rc; return rc;
+ +
+ /* free local device */ + /* free local device */
+ if (get_should_remove_local_disk() && transport(pp->sg_id.host_no)) { + if (get_should_remove_local_disk() && transport(pp->bus, pp->sg_id.host_no)) {
+ condlog(3, "%s is a local device", pp->dev); + condlog(3, "%s is a local device", pp->dev);
+ return 0; + return 0;
+ } + }
@ -181,7 +194,7 @@ index 6444887..a438b44 100644
/* /*
* discovery bitmask * discovery bitmask
diff --git a/multipathd/main.c b/multipathd/main.c diff --git a/multipathd/main.c b/multipathd/main.c
index ef14750..41c4258 100644 index 23fb9d4..73f394c 100644
--- a/multipathd/main.c --- a/multipathd/main.c
+++ b/multipathd/main.c +++ b/multipathd/main.c
@@ -943,6 +943,10 @@ ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map) @@ -943,6 +943,10 @@ ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map)
@ -196,5 +209,5 @@ index ef14750..41c4258 100644
* need path UID to go any further * need path UID to go any further
*/ */
-- --
1.8.3.1 2.14.3 (Apple Git-98)

View File

@ -2,7 +2,7 @@
Name: multipath-tools Name: multipath-tools
Version: 0.8.4 Version: 0.8.4
Release: 12 Release: 13
Summary: Tools to manage multipath devices with the device-mapper Summary: Tools to manage multipath devices with the device-mapper
License: GPL-2.0-or-later and LGPL-2.0-only License: GPL-2.0-or-later and LGPL-2.0-only
URL: http://christophe.varoqui.free.fr/ URL: http://christophe.varoqui.free.fr/
@ -184,6 +184,9 @@ fi
%changelog %changelog
* Tue Mar 8 2022 lixiaokeng<lixiaokeng@huawei.com> - 0.8.4-13
- don't create local nvme multipath device when enable remove_local_path
* Thu Nov 25 2021 lixiaokeng<lixiaokeng@huawei.com> - 0.8.4-12 * Thu Nov 25 2021 lixiaokeng<lixiaokeng@huawei.com> - 0.8.4-12
- count pending paths as active on loads - count pending paths as active on loads