|
|
4ae388 |
From 2fc494b81157059e0be66022f6a2110f1ce179c3 Mon Sep 17 00:00:00 2001
|
|
|
4ae388 |
From: Mike Christie <mchristi@redhat.com>
|
|
|
4ae388 |
Date: Tue, 9 Aug 2016 13:44:10 -0500
|
|
|
4ae388 |
Subject: [PATCH 02/11] libmultipath: add rbd discovery
|
|
|
4ae388 |
|
|
|
4ae388 |
For BZ 1348372 from upstream commit:
|
|
|
4ae388 |
|
|
|
4ae388 |
Commit 152f3f803ee922075e8b25027eb9dc5699f1aefa
|
|
|
4ae388 |
Author: Mike Christie <mchristi@redhat.com>
|
|
|
4ae388 |
Date: Mon Aug 8 07:01:47 2016 -0500
|
|
|
4ae388 |
|
|
|
4ae388 |
libmultipath: add rbd discovery
|
|
|
4ae388 |
|
|
|
4ae388 |
rbd is a block device interface for Ceph. It does not support
|
|
|
4ae388 |
any SCSI commands, so this patch adds bus detection and virtual
|
|
|
4ae388 |
vendor/product pathinfo.
|
|
|
4ae388 |
|
|
|
4ae388 |
--------
|
|
|
4ae388 |
|
|
|
4ae388 |
Porting notes:
|
|
|
4ae388 |
|
|
|
4ae388 |
get_uid() chunk does not match upstream due to rhel not having
|
|
|
4ae388 |
the get uid callout code and sysfs uid detection code.
|
|
|
4ae388 |
|
|
|
4ae388 |
Signed-off-by: Mike Christie <mchristi@redhat.com>
|
|
|
4ae388 |
---
|
|
|
4ae388 |
libmultipath/checkers.h | 1 +
|
|
|
4ae388 |
libmultipath/discovery.c | 116 ++++++++++++++++++++++++++++++++++++++++-------
|
|
|
4ae388 |
libmultipath/structs.h | 1 +
|
|
|
4ae388 |
3 files changed, 101 insertions(+), 17 deletions(-)
|
|
|
4ae388 |
|
|
|
4ae388 |
diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h
|
|
|
4ae388 |
index f6fe326..735bb25 100644
|
|
|
4ae388 |
--- a/libmultipath/checkers.h
|
|
|
4ae388 |
+++ b/libmultipath/checkers.h
|
|
|
4ae388 |
@@ -75,6 +75,7 @@ enum path_check_state {
|
|
|
4ae388 |
#define EMC_CLARIION "emc_clariion"
|
|
|
4ae388 |
#define READSECTOR0 "readsector0"
|
|
|
4ae388 |
#define CCISS_TUR "cciss_tur"
|
|
|
4ae388 |
+#define RBD "rbd"
|
|
|
4ae388 |
|
|
|
4ae388 |
#define DEFAULT_CHECKER DIRECTIO
|
|
|
4ae388 |
|
|
|
4ae388 |
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
|
|
|
4ae388 |
index 7a8282b..1b9f390 100644
|
|
|
4ae388 |
--- a/libmultipath/discovery.c
|
|
|
4ae388 |
+++ b/libmultipath/discovery.c
|
|
|
4ae388 |
@@ -781,6 +781,21 @@ scsi_sysfs_pathinfo (struct path * pp)
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
static int
|
|
|
4ae388 |
+rbd_sysfs_pathinfo (struct path * pp)
|
|
|
4ae388 |
+{
|
|
|
4ae388 |
+ sprintf(pp->vendor_id, "Ceph");
|
|
|
4ae388 |
+ sprintf(pp->product_id, "RBD");
|
|
|
4ae388 |
+
|
|
|
4ae388 |
+ condlog(3, "%s: vendor = %s product = %s", pp->dev, pp->vendor_id,
|
|
|
4ae388 |
+ pp->product_id);
|
|
|
4ae388 |
+ /*
|
|
|
4ae388 |
+ * set the hwe configlet pointer
|
|
|
4ae388 |
+ */
|
|
|
4ae388 |
+ pp->hwe = find_hwe(conf->hwtable, pp->vendor_id, pp->product_id, NULL);
|
|
|
4ae388 |
+ return 0;
|
|
|
4ae388 |
+}
|
|
|
4ae388 |
+
|
|
|
4ae388 |
+static int
|
|
|
4ae388 |
ccw_sysfs_pathinfo (struct path * pp)
|
|
|
4ae388 |
{
|
|
|
4ae388 |
struct udev_device *parent;
|
|
|
4ae388 |
@@ -974,6 +989,8 @@ sysfs_pathinfo(struct path * pp)
|
|
|
4ae388 |
pp->bus = SYSFS_BUS_CCW;
|
|
|
4ae388 |
if (!strncmp(pp->dev,"sd", 2))
|
|
|
4ae388 |
pp->bus = SYSFS_BUS_SCSI;
|
|
|
4ae388 |
+ if (!strncmp(pp->dev,"rbd", 3))
|
|
|
4ae388 |
+ pp->bus = SYSFS_BUS_RBD;
|
|
|
4ae388 |
|
|
|
4ae388 |
if (pp->bus == SYSFS_BUS_UNDEF)
|
|
|
4ae388 |
return 0;
|
|
|
4ae388 |
@@ -986,6 +1003,9 @@ sysfs_pathinfo(struct path * pp)
|
|
|
4ae388 |
} else if (pp->bus == SYSFS_BUS_CCISS) {
|
|
|
4ae388 |
if (cciss_sysfs_pathinfo(pp))
|
|
|
4ae388 |
return 1;
|
|
|
4ae388 |
+ } else if (pp->bus == SYSFS_BUS_RBD) {
|
|
|
4ae388 |
+ if (rbd_sysfs_pathinfo(pp))
|
|
|
4ae388 |
+ return 1;
|
|
|
4ae388 |
}
|
|
|
4ae388 |
return 0;
|
|
|
4ae388 |
}
|
|
|
4ae388 |
@@ -1087,10 +1107,60 @@ get_prio (struct path * pp)
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
static int
|
|
|
4ae388 |
+get_rbd_uid(struct path * pp)
|
|
|
4ae388 |
+{
|
|
|
4ae388 |
+ struct udev_device *rbd_bus_dev;
|
|
|
4ae388 |
+ int ret, rbd_bus_id;
|
|
|
4ae388 |
+ const char *pool, *image, *snap;
|
|
|
4ae388 |
+ char sysfs_path[PATH_SIZE];
|
|
|
4ae388 |
+ uint64_t snap_id, max_snap_id = -3;
|
|
|
4ae388 |
+
|
|
|
4ae388 |
+ ret = sscanf(pp->dev, "rbd%d", &rbd_bus_id);
|
|
|
4ae388 |
+ if (ret != 1)
|
|
|
4ae388 |
+ return -EINVAL;
|
|
|
4ae388 |
+
|
|
|
4ae388 |
+ snprintf(sysfs_path, sizeof(sysfs_path), "/sys/bus/rbd/devices/%d",
|
|
|
4ae388 |
+ rbd_bus_id);
|
|
|
4ae388 |
+ rbd_bus_dev = udev_device_new_from_syspath(conf->udev, sysfs_path);
|
|
|
4ae388 |
+ if (!rbd_bus_dev)
|
|
|
4ae388 |
+ return -ENODEV;
|
|
|
4ae388 |
+
|
|
|
4ae388 |
+ ret = -EINVAL;
|
|
|
4ae388 |
+ pool = udev_device_get_sysattr_value(rbd_bus_dev, "pool_id");
|
|
|
4ae388 |
+ if (!pool)
|
|
|
4ae388 |
+ goto free_dev;
|
|
|
4ae388 |
+
|
|
|
4ae388 |
+ image = udev_device_get_sysattr_value(rbd_bus_dev, "image_id");
|
|
|
4ae388 |
+ if (!image)
|
|
|
4ae388 |
+ goto free_dev;
|
|
|
4ae388 |
+
|
|
|
4ae388 |
+ snap = udev_device_get_sysattr_value(rbd_bus_dev, "snap_id");
|
|
|
4ae388 |
+ if (!snap)
|
|
|
4ae388 |
+ goto free_dev;
|
|
|
4ae388 |
+ snap_id = strtoull(snap, NULL, 19);
|
|
|
4ae388 |
+ if (snap_id >= max_snap_id)
|
|
|
4ae388 |
+ ret = snprintf(pp->wwid, WWID_SIZE, "%s-%s", pool, image);
|
|
|
4ae388 |
+ else
|
|
|
4ae388 |
+ ret = snprintf(pp->wwid, WWID_SIZE, "%s-%s-%s", pool,
|
|
|
4ae388 |
+ image, snap);
|
|
|
4ae388 |
+ if (ret < WWID_SIZE) {
|
|
|
4ae388 |
+ ret = 0;
|
|
|
4ae388 |
+ } else {
|
|
|
4ae388 |
+ condlog(0, "%s: wwid overflow", pp->dev);
|
|
|
4ae388 |
+ ret = -EOVERFLOW;
|
|
|
4ae388 |
+ }
|
|
|
4ae388 |
+
|
|
|
4ae388 |
+free_dev:
|
|
|
4ae388 |
+ udev_device_unref(rbd_bus_dev);
|
|
|
4ae388 |
+ return ret;
|
|
|
4ae388 |
+}
|
|
|
4ae388 |
+
|
|
|
4ae388 |
+static int
|
|
|
4ae388 |
get_uid (struct path * pp)
|
|
|
4ae388 |
{
|
|
|
4ae388 |
char *c;
|
|
|
4ae388 |
const char *value;
|
|
|
4ae388 |
+ int ret;
|
|
|
4ae388 |
|
|
|
4ae388 |
if (!pp->uid_attribute)
|
|
|
4ae388 |
select_getuid(pp);
|
|
|
4ae388 |
@@ -1101,25 +1171,37 @@ get_uid (struct path * pp)
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
memset(pp->wwid, 0, WWID_SIZE);
|
|
|
4ae388 |
- value = udev_device_get_property_value(pp->udev, pp->uid_attribute);
|
|
|
4ae388 |
- if ((!value || strlen(value) == 0) && conf->cmd == CMD_VALID_PATH)
|
|
|
4ae388 |
- value = getenv(pp->uid_attribute);
|
|
|
4ae388 |
- if (value && strlen(value)) {
|
|
|
4ae388 |
- size_t len = WWID_SIZE;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (strlen(value) + 1 > WWID_SIZE) {
|
|
|
4ae388 |
- condlog(0, "%s: wwid overflow", pp->dev);
|
|
|
4ae388 |
- } else {
|
|
|
4ae388 |
- len = strlen(value);
|
|
|
4ae388 |
+ if (pp->bus == SYSFS_BUS_RBD) {
|
|
|
4ae388 |
+ ret = get_rbd_uid(pp);
|
|
|
4ae388 |
+ if (ret) {
|
|
|
4ae388 |
+ condlog(1, "%s: failed to get sysfs uid: %s",
|
|
|
4ae388 |
+ pp->dev, strerror(-ret));
|
|
|
4ae388 |
+ pp->missing_udev_info = INFO_MISSING;
|
|
|
4ae388 |
+ pp->tick = conf->retrigger_delay;
|
|
|
4ae388 |
}
|
|
|
4ae388 |
- strncpy(pp->wwid, value, len);
|
|
|
4ae388 |
- pp->missing_udev_info = INFO_OK;
|
|
|
4ae388 |
- pp->tick = 0;
|
|
|
4ae388 |
} else {
|
|
|
4ae388 |
- condlog(3, "%s: no %s attribute", pp->dev,
|
|
|
4ae388 |
- pp->uid_attribute);
|
|
|
4ae388 |
- pp->missing_udev_info = INFO_MISSING;
|
|
|
4ae388 |
- pp->tick = conf->retrigger_delay;
|
|
|
4ae388 |
+ value = udev_device_get_property_value(pp->udev,
|
|
|
4ae388 |
+ pp->uid_attribute);
|
|
|
4ae388 |
+ if ((!value || strlen(value) == 0) &&
|
|
|
4ae388 |
+ conf->cmd == CMD_VALID_PATH)
|
|
|
4ae388 |
+ value = getenv(pp->uid_attribute);
|
|
|
4ae388 |
+ if (value && strlen(value)) {
|
|
|
4ae388 |
+ size_t len = WWID_SIZE;
|
|
|
4ae388 |
+
|
|
|
4ae388 |
+ if (strlen(value) + 1 > WWID_SIZE) {
|
|
|
4ae388 |
+ condlog(0, "%s: wwid overflow", pp->dev);
|
|
|
4ae388 |
+ } else {
|
|
|
4ae388 |
+ len = strlen(value);
|
|
|
4ae388 |
+ }
|
|
|
4ae388 |
+ strncpy(pp->wwid, value, len);
|
|
|
4ae388 |
+ pp->missing_udev_info = INFO_OK;
|
|
|
4ae388 |
+ pp->tick = 0;
|
|
|
4ae388 |
+ } else {
|
|
|
4ae388 |
+ condlog(3, "%s: no %s attribute", pp->dev,
|
|
|
4ae388 |
+ pp->uid_attribute);
|
|
|
4ae388 |
+ pp->missing_udev_info = INFO_MISSING;
|
|
|
4ae388 |
+ pp->tick = conf->retrigger_delay;
|
|
|
4ae388 |
+ }
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
/* Strip any trailing blanks */
|
|
|
4ae388 |
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
|
|
|
4ae388 |
index b5b4567..e566462 100644
|
|
|
4ae388 |
--- a/libmultipath/structs.h
|
|
|
4ae388 |
+++ b/libmultipath/structs.h
|
|
|
4ae388 |
@@ -52,6 +52,7 @@ enum sysfs_buses {
|
|
|
4ae388 |
SYSFS_BUS_IDE,
|
|
|
4ae388 |
SYSFS_BUS_CCW,
|
|
|
4ae388 |
SYSFS_BUS_CCISS,
|
|
|
4ae388 |
+ SYSFS_BUS_RBD,
|
|
|
4ae388 |
};
|
|
|
4ae388 |
|
|
|
4ae388 |
enum pathstates {
|
|
|
4ae388 |
--
|
|
|
4ae388 |
1.8.3.1
|
|
|
4ae388 |
|