From patchwork Wed Aug 31 21:44:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 9307895 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4869860487 for ; Wed, 31 Aug 2016 21:47:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 421BD29125 for ; Wed, 31 Aug 2016 21:47:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36A2B29132; Wed, 31 Aug 2016 21:47:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E286629125 for ; Wed, 31 Aug 2016 21:47:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7VLjBJq041279; Wed, 31 Aug 2016 17:45:11 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u7VLiYcY032253 for ; Wed, 31 Aug 2016 17:44:34 -0400 Received: from rh2.redhat.com (vpn-59-101.rdu2.redhat.com [10.10.59.101]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7VLiVdD017155; Wed, 31 Aug 2016 17:44:34 -0400 From: Mike Christie To: dm-devel@redhat.com, christophe.varoqui@opensvc.com Date: Wed, 31 Aug 2016 16:44:29 -0500 Message-Id: <1472679870-25654-4-git-send-email-mchristi@redhat.com> In-Reply-To: <1472679870-25654-1-git-send-email-mchristi@redhat.com> References: <1472679870-25654-1-git-send-email-mchristi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: dm-devel@redhat.com Cc: Mike Christie Subject: [dm-devel] [PATCH 3/4] rbd: check for exclusive lock enabled X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Virus-Scanned: ClamAV using ClamSMTP Only attach the checker if the rbd image has the exclusive lock enabled. Signed-off-by: Mike Christie --- libmultipath/checkers/rbd.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libmultipath/checkers/rbd.c b/libmultipath/checkers/rbd.c index 6542bdb..175c4a6 100644 --- a/libmultipath/checkers/rbd.c +++ b/libmultipath/checkers/rbd.c @@ -33,6 +33,8 @@ typedef int (thread_fn)(struct rbd_checker_context *ct, char *msg); #define RBD_MSG(msg, fmt, args...) snprintf(msg, CHECKER_MSG_LEN, fmt, ##args); +#define RBD_FEATURE_EXCLUSIVE_LOCK (1 << 2) + struct rbd_checker_context { int rbd_bus_id; char *client_addr; @@ -65,8 +67,9 @@ int libcheck_init(struct checker * c) struct udev_device *bus_dev; struct udev *udev; struct stat sb; - const char *block_name, *addr, *config_info; + const char *block_name, *addr, *config_info, *features_str; const char *image, *pool, *snap, *username; + uint64_t features = 0; char sysfs_path[PATH_SIZE]; int ret; @@ -119,6 +122,15 @@ int libcheck_init(struct checker * c) if (!ct->client_addr) goto free_dev; + features_str = udev_device_get_sysattr_value(bus_dev, "features"); + if (!features_str) + goto free_addr; + features = strtoll(features_str, NULL, 16); + if (!(features & RBD_FEATURE_EXCLUSIVE_LOCK)) { + condlog(3, "Exclusive lock not set."); + goto free_addr; + } + config_info = udev_device_get_sysattr_value(bus_dev, "config_info"); if (!config_info) goto free_addr;