Blame SOURCES/0186-rbd-check-for-exclusive-lock-enabled.patch

c896fb
From 513d210cdbccfdaadb0cf7f09ba97d563aac52bb Mon Sep 17 00:00:00 2001
c896fb
From: Mike Christie <mchristi@redhat.com>
c896fb
Date: Wed, 31 Aug 2016 15:40:16 -0500
c896fb
Subject: [PATCH 10/11] rbd: check for exclusive lock enabled
c896fb
c896fb
Only attach the checker if the rbd image has the exclusive lock
c896fb
enabled.
c896fb
c896fb
Signed-off-by: Mike Christie <mchristi@redhat.com>
c896fb
---
c896fb
 libmultipath/checkers/rbd.c | 14 +++++++++++++-
c896fb
 1 file changed, 13 insertions(+), 1 deletion(-)
c896fb
c896fb
diff --git a/libmultipath/checkers/rbd.c b/libmultipath/checkers/rbd.c
c896fb
index a6f3405..e34bf53 100644
c896fb
--- a/libmultipath/checkers/rbd.c
c896fb
+++ b/libmultipath/checkers/rbd.c
c896fb
@@ -33,6 +33,8 @@ typedef int (thread_fn)(struct rbd_checker_context *ct, char *msg);
c896fb
 
c896fb
 #define RBD_MSG(msg, fmt, args...) snprintf(msg, CHECKER_MSG_LEN, fmt, ##args);
c896fb
 
c896fb
+#define RBD_FEATURE_EXCLUSIVE_LOCK	(1 << 2)
c896fb
+
c896fb
 struct rbd_checker_context {
c896fb
 	int rbd_bus_id;
c896fb
 	char *client_addr;
c896fb
@@ -65,8 +67,9 @@ int libcheck_init(struct checker * c)
c896fb
 	struct udev_device *bus_dev;
c896fb
 	struct udev *udev;
c896fb
 	struct stat sb;
c896fb
-	const char *block_name, *addr, *config_info;
c896fb
+	const char *block_name, *addr, *config_info, *features_str;
c896fb
 	const char *image, *pool, *snap, *username;
c896fb
+	uint64_t features = 0;
c896fb
 	char sysfs_path[PATH_SIZE];
c896fb
 	int ret;
c896fb
 
c896fb
@@ -119,6 +122,15 @@ int libcheck_init(struct checker * c)
c896fb
 	if (!ct->client_addr)
c896fb
 		goto free_dev;
c896fb
 
c896fb
+	features_str = udev_device_get_sysattr_value(bus_dev, "features");
c896fb
+	if (!features_str)
c896fb
+		goto free_addr;
c896fb
+	features = strtoll(features_str, NULL, 16);
c896fb
+	if (!(features & RBD_FEATURE_EXCLUSIVE_LOCK)) {
c896fb
+		condlog(3, "Exclusive lock not set.");
c896fb
+		goto free_addr;
c896fb
+	}
c896fb
+
c896fb
 	config_info = udev_device_get_sysattr_value(bus_dev, "config_info");
c896fb
 	if (!config_info)
c896fb
 		goto free_addr;
c896fb
-- 
c896fb
1.8.3.1
c896fb