From: Mike Christie <mchristi@redhat.com>
To: dm-devel@redhat.com, christophe.varoqui@opensvc.com
Cc: Mike Christie <mchristi@redhat.com>
Subject: [PATCH 1/4] libmultipath: add rbd discovery
Date: Mon, 8 Aug 2016 07:01:47 -0500 [thread overview]
Message-ID: <1470657710-28081-2-git-send-email-mchristi@redhat.com> (raw)
In-Reply-To: <1470657710-28081-1-git-send-email-mchristi@redhat.com>
rbd is a block device interface for Ceph. It does not support
any SCSI commands, so this patch adds bus detection and virtual
vendor/product pathinfo.
Changes since v1:
1. Drop ID_UID use and implemented sysfs getuid support.
Signed-off-by: Mike Christie <mchristi@redhat.com>
---
libmultipath/checkers.h | 1 +
libmultipath/discovery.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++
libmultipath/structs.h | 1 +
3 files changed, 72 insertions(+)
diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h
index ac382d7..8fc8616 100644
--- a/libmultipath/checkers.h
+++ b/libmultipath/checkers.h
@@ -84,6 +84,7 @@ enum path_check_state {
#define EMC_CLARIION "emc_clariion"
#define READSECTOR0 "readsector0"
#define CCISS_TUR "cciss_tur"
+#define RBD "rbd"
#define DEFAULT_CHECKER TUR
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 1fb4db4..61b389f 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -1170,6 +1170,21 @@ scsi_sysfs_pathinfo (struct path * pp, vector hwtable)
}
static int
+rbd_sysfs_pathinfo (struct path * pp, vector hwtable)
+{
+ sprintf(pp->vendor_id, "Ceph");
+ sprintf(pp->product_id, "RBD");
+
+ condlog(3, "%s: vendor = %s product = %s", pp->dev, pp->vendor_id,
+ pp->product_id);
+ /*
+ * set the hwe configlet pointer
+ */
+ pp->hwe = find_hwe(hwtable, pp->vendor_id, pp->product_id, NULL);
+ return 0;
+}
+
+static int
ccw_sysfs_pathinfo (struct path * pp, vector hwtable)
{
struct udev_device *parent;
@@ -1371,6 +1386,8 @@ sysfs_pathinfo(struct path * pp, vector hwtable)
pp->bus = SYSFS_BUS_CCW;
if (!strncmp(pp->dev,"sd", 2))
pp->bus = SYSFS_BUS_SCSI;
+ if (!strncmp(pp->dev,"rbd", 3))
+ pp->bus = SYSFS_BUS_RBD;
if (pp->bus == SYSFS_BUS_UNDEF)
return 0;
@@ -1383,6 +1400,9 @@ sysfs_pathinfo(struct path * pp, vector hwtable)
} else if (pp->bus == SYSFS_BUS_CCISS) {
if (cciss_sysfs_pathinfo(pp, hwtable))
return 1;
+ } else if (pp->bus == SYSFS_BUS_RBD) {
+ if (rbd_sysfs_pathinfo(pp, hwtable))
+ return 1;
}
return 0;
}
@@ -1540,6 +1560,53 @@ get_udev_uid(struct path * pp, char *uid_attribute)
}
static int
+get_rbd_uid(struct path * pp)
+{
+ struct udev_device *rbd_bus_dev;
+ int ret, rbd_bus_id;
+ const char *pool, *image, *snap;
+ char sysfs_path[PATH_SIZE];
+ uint64_t snap_id, max_snap_id = -3;
+
+ ret = sscanf(pp->dev, "rbd%d", &rbd_bus_id);
+ if (ret != 1)
+ return -EINVAL;
+
+ snprintf(sysfs_path, sizeof(sysfs_path), "/sys/bus/rbd/devices/%d",
+ rbd_bus_id);
+ rbd_bus_dev = udev_device_new_from_syspath(udev, sysfs_path);
+ if (!rbd_bus_dev)
+ return -ENODEV;
+
+ ret = -EINVAL;
+ pool = udev_device_get_sysattr_value(rbd_bus_dev, "pool_id");
+ if (!pool)
+ goto free_dev;
+
+ image = udev_device_get_sysattr_value(rbd_bus_dev, "image_id");
+ if (!image)
+ goto free_dev;
+
+ snap = udev_device_get_sysattr_value(rbd_bus_dev, "snap_id");
+ if (!snap)
+ goto free_dev;
+ snap_id = strtoull(snap, NULL, 19);
+ if (snap_id >= max_snap_id)
+ ret = snprintf(pp->wwid, WWID_SIZE, "%s-%s", pool, image);
+ else
+ ret = snprintf(pp->wwid, WWID_SIZE, "%s-%s-%s", pool,
+ image, snap);
+ if (ret >= WWID_SIZE) {
+ condlog(0, "%s: wwid overflow", pp->dev);
+ ret = -EOVERFLOW;
+ }
+
+free_dev:
+ udev_device_unref(rbd_bus_dev);
+ return ret;
+}
+
+static int
get_vpd_uid(struct path * pp)
{
struct udev_device *parent = pp->udev;
@@ -1591,6 +1658,9 @@ get_uid (struct path * pp, int path_state)
} else
len = strlen(pp->wwid);
origin = "callout";
+ } else if (pp->bus == SYSFS_BUS_RBD) {
+ len = get_rbd_uid(pp);
+ origin = "sysfs";
} else {
int retrigger;
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
index a87cda6..cb5d532 100644
--- a/libmultipath/structs.h
+++ b/libmultipath/structs.h
@@ -52,6 +52,7 @@ enum sysfs_buses {
SYSFS_BUS_IDE,
SYSFS_BUS_CCW,
SYSFS_BUS_CCISS,
+ SYSFS_BUS_RBD,
};
enum pathstates {
--
2.7.2
next prev parent reply other threads:[~2016-08-08 12:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-08 12:01 PATCH 0/4] multipath-tools: Ceph rbd support v2 Mike Christie
2016-08-08 12:01 ` Mike Christie [this message]
2016-08-08 12:01 ` [PATCH 2/4] multipath-tools: add checker callout to repair path Mike Christie
2016-08-11 15:50 ` Bart Van Assche
2016-08-11 20:33 ` Mike Christie
2016-08-11 21:41 ` Bart Van Assche
2016-08-12 16:54 ` Mike Christie
2016-08-12 17:10 ` Bart Van Assche
2016-08-14 8:41 ` Mike Christie
2016-08-15 16:24 ` Bart Van Assche
2016-08-08 12:01 ` [PATCH 3/4] multipath-tools: Add rbd checker Mike Christie
2016-08-08 12:01 ` [PATCH 4/4] multipath-tools: Add rbd to the hwtable Mike Christie
2016-08-09 15:36 ` PATCH 0/4] multipath-tools: Ceph rbd support v2 Christophe Varoqui
2016-08-09 18:26 ` Mike Christie
2016-08-10 7:55 ` Christophe Varoqui
2016-08-10 15:42 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1470657710-28081-2-git-send-email-mchristi@redhat.com \
--to=mchristi@redhat.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).