don't create local nvme multipath device when enable remove_local_path

(cherry picked from commit b4d3bfa75088df78bd80325a42a75f3773dd8a88)
This commit is contained in:
Lixiaokeng 2022-03-08 11:05:13 +08:00 committed by openeuler-sync-bot
parent a9799bec7b
commit 4b64313446
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>
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
[Author]:chenminhua
---
libmultipath/discovery.c | 124 +++++++++++++++++++++++++++++++++++++++++++++--
libmultipath/discovery.c | 133 +++++++++++++++++++++++++++++++++++++++++++++--
libmultipath/discovery.h | 1 +
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
index ee3290c..c49848e 100644
index ee3290c..f57c072 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -34,6 +34,103 @@
@@ -34,6 +34,112 @@
#include "prioritizers/alua_rtpg.h"
#include "foreign.h"
@ -67,14 +71,23 @@ index ee3290c..c49848e 100644
+ 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
+transport (int h)
+transport(int type, int h)
+{
+ char buff[PATH_SIZE];
+ int len, off;
+ struct stat a_stat;
+
+ if (type != SYSFS_BUS_SCSI) {
+ return 1;
+ }
+
+ /* FC host */
+ strcpy(buff, "/sys");
+ strcat(buff, "/class/fc_host/");
@ -105,7 +118,7 @@ index ee3290c..c49848e 100644
+ return 1;
+ }
+
+ if (transport(pp->sg_id.host_no) == 0) {
+ if (transport(pp->bus, pp->sg_id.host_no) == 0) {
+ return 1;
+ }
+
@ -119,7 +132,7 @@ index ee3290c..c49848e 100644
struct vpd_vendor_page vpd_vendor_pages[VPD_VP_ARRAY_SIZE] = {
[VPD_VP_UNDEF] = { 0x00, "undef" },
[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;
const char * devname;
@ -127,7 +140,7 @@ index ee3290c..c49848e 100644
devname = udev_device_get_sysname(udevice);
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",
major(devnum), minor(devnum));
pp = find_path_by_devt(pathvec, devt);
@ -155,13 +168,13 @@ index ee3290c..c49848e 100644
}
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)
return rc;
+
+ /* 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);
+ return 0;
+ }
@ -181,7 +194,7 @@ index 6444887..a438b44 100644
/*
* discovery bitmask
diff --git a/multipathd/main.c b/multipathd/main.c
index ef14750..41c4258 100644
index 23fb9d4..73f394c 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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
*/
--
1.8.3.1
2.14.3 (Apple Git-98)

View File

@ -2,7 +2,7 @@
Name: multipath-tools
Version: 0.8.4
Release: 12
Release: 13
Summary: Tools to manage multipath devices with the device-mapper
License: GPL-2.0-or-later and LGPL-2.0-only
URL: http://christophe.varoqui.free.fr/
@ -184,6 +184,9 @@ fi
%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
- count pending paths as active on loads