From patchwork Thu Jun 22 14:59:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 9804595 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 1183E60329 for ; Thu, 22 Jun 2017 15:04:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00A5A28506 for ; Thu, 22 Jun 2017 15:04:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9746286C2; Thu, 22 Jun 2017 15:04:40 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 29D1528506 for ; Thu, 22 Jun 2017 15:04:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 31F8BBBF68; Thu, 22 Jun 2017 15:04:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 31F8BBBF68 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 31F8BBBF68 Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4D6C60608; Thu, 22 Jun 2017 15:04:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B220C4E988; Thu, 22 Jun 2017 15:04:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5MF0B3V012263 for ; Thu, 22 Jun 2017 11:00:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8B1C8AF920; Thu, 22 Jun 2017 15:00:11 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A2B88AF926; Thu, 22 Jun 2017 15:00:07 +0000 (UTC) Received: from prv3-mh.provo.novell.com (prv3-mh.provo.novell.com [137.65.250.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3CEE8A8343; Thu, 22 Jun 2017 15:00:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3CEE8A8343 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mwilck@suse.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3CEE8A8343 Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (TLS encrypted); Thu, 22 Jun 2017 08:59:53 -0600 From: Martin Wilck To: Christophe Varoqui , Hannes Reinecke Date: Thu, 22 Jun 2017 16:59:11 +0200 Message-Id: <20170622145913.23714-10-mwilck@suse.com> In-Reply-To: <20170622145913.23714-1-mwilck@suse.com> References: <20170622145913.23714-1-mwilck@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 22 Jun 2017 15:00:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 22 Jun 2017 15:00:06 +0000 (UTC) for IP:'137.65.250.26' DOMAIN:'prv3-mh.provo.novell.com' HELO:'prv3-mh.provo.novell.com' FROM:'mwilck@suse.com' RCPT:'' X-RedHat-Spam-Score: -1.501 (BAYES_50, RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.26 prv3-mh.provo.novell.com 137.65.250.26 prv3-mh.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Xose Vazquez Perez Subject: [dm-devel] [PATCH v4 09/11] libmultipath: retain_attached_hw_handler obsolete with 4.3+ 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 22 Jun 2017 15:04:39 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Kernels 4.3 and newer (commit 1bab0de0 "dm-mpath, scsi_dh: don't let dm detach device handlers") imply "retain_attached_hw_handler yes". Clarify this in the propsel code, log messages, and documentation. Signed-off-by: Martin Wilck Reviewed-by: Hannes Reinecke --- libmultipath/configure.c | 3 ++- libmultipath/dmparser.c | 3 ++- libmultipath/propsel.c | 7 ++++++- libmultipath/util.c | 36 ++++++++++++++++++++++++++++++++++++ libmultipath/util.h | 2 ++ multipath/multipath.conf.5 | 15 +++++++++++---- 6 files changed, 59 insertions(+), 7 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index a7f2b443..74b6f52a 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -572,7 +572,8 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) } if (mpp->retain_hwhandler != RETAIN_HWHANDLER_UNDEF && - mpp->retain_hwhandler != cmpp->retain_hwhandler) { + mpp->retain_hwhandler != cmpp->retain_hwhandler && + get_linux_version_code() < KERNEL_VERSION(4, 3, 0)) { mpp->action = ACT_RELOAD; condlog(3, "%s: set ACT_RELOAD (retain_hwhandler change)", mpp->alias); diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c index 1121c715..b647c256 100644 --- a/libmultipath/dmparser.c +++ b/libmultipath/dmparser.c @@ -97,7 +97,8 @@ assemble_map (struct multipath * mp, char * params, int len) } else if (mp->no_path_retry != NO_PATH_RETRY_UNDEF) { add_feature(&f, no_path_retry); } - if (mp->retain_hwhandler == RETAIN_HWHANDLER_ON) + if (mp->retain_hwhandler == RETAIN_HWHANDLER_ON && + get_linux_version_code() < KERNEL_VERSION(4, 3, 0)) add_feature(&f, retain_hwhandler); APPEND(p, end, "%s %s %i %i", f, mp->hwhandler, nr_priority_groups, diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index e885a845..d609394e 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -628,7 +628,12 @@ int select_retain_hwhandler(struct config *conf, struct multipath *mp) if (!VERSION_GE(conf->version, minv_dm_retain)) { mp->retain_hwhandler = RETAIN_HWHANDLER_OFF; - origin = "(setting: WARNING, requires kernel version >= 1.5.0)"; + origin = "(setting: WARNING, requires kernel dm-mpath version >= 1.5.0)"; + goto out; + } + if (get_linux_version_code() >= KERNEL_VERSION(4, 3, 0)) { + mp->retain_hwhandler = RETAIN_HWHANDLER_ON; + origin = "(setting: implied in kernel >= 4.3.0)"; goto out; } mp_set_ovr(retain_hwhandler); diff --git a/libmultipath/util.c b/libmultipath/util.c index b90cd8b0..dff2ed3c 100644 --- a/libmultipath/util.c +++ b/libmultipath/util.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -380,3 +381,38 @@ int systemd_service_enabled(const char *dev) found = systemd_service_enabled_in(dev, "/run"); return found; } + +static int _linux_version_code; +static pthread_once_t _lvc_initialized = PTHREAD_ONCE_INIT; + +/* Returns current kernel version encoded as major*65536 + minor*256 + patch, + * so, for example, to check if the kernel is greater than 2.2.11: + * + * if (get_linux_version_code() > KERNEL_VERSION(2,2,11)) { } + * + * Copyright (C) 1999-2004 by Erik Andersen + * Code copied from busybox (GPLv2 or later) + */ +static void +_set_linux_version_code(void) +{ + struct utsname name; + char *t; + int i, r; + + uname(&name); /* never fails */ + t = name.release; + r = 0; + for (i = 0; i < 3; i++) { + t = strtok(t, "."); + r = r * 256 + (t ? atoi(t) : 0); + t = NULL; + } + _linux_version_code = r; +} + +int get_linux_version_code(void) +{ + pthread_once(&_lvc_initialized, _set_linux_version_code); + return _linux_version_code; +} diff --git a/libmultipath/util.h b/libmultipath/util.h index b087e32e..45291be8 100644 --- a/libmultipath/util.h +++ b/libmultipath/util.h @@ -15,6 +15,8 @@ char *convert_dev(char *dev, int is_path_device); char *parse_uid_attribute_by_attrs(char *uid_attrs, char *path_dev); void setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached); int systemd_service_enabled(const char *dev); +int get_linux_version_code(void); +#define KERNEL_VERSION(maj, min, ptc) ((((maj) * 256) + (min)) * 256 + (ptc)) #define safe_sprintf(var, format, args...) \ snprintf(var, sizeof(var), format, ##args) >= sizeof(var) diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 index b32d0383..3b4e5187 100644 --- a/multipath/multipath.conf.5 +++ b/multipath/multipath.conf.5 @@ -698,15 +698,16 @@ The default is: \fB\fR . .TP .B retain_attached_hw_handler -If set to +(Obsolete for kernels >= 4.3) If set to .I yes and the SCSI layer has already attached a hardware_handler to the device, multipath will not force the device to use the hardware_handler specified by mutipath.conf. If the SCSI layer has not attached a hardware handler, multipath will continue to use its configured hardware handler. .RS -.TP -The default is: \fByes\fR +.PP +The default is: \fByes\fR. Linux kernel 4.3 or newer always behaves as if +\fB"retain_attached_hw_handler yes"\fR was set. .RE . . @@ -1182,8 +1183,14 @@ Active/Standby mode exclusively. .I 1 alua (Hardware-dependent) Hardware handler for SCSI-3 ALUA compatible arrays. -.TP +.PP The default is: \fB\fR +.PP +\fBImportant Note:\fR Linux kernels 4.3 and newer automatically attach a device +handler to known devices (which includes all devices supporting SCSI-3 ALUA) +and disallow changing the handler +afterwards. Setting \fBhardware_handler\fR for such devices on these kernels +has no effect. .RE . .