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

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