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

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