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