From patchwork Wed Nov 27 15:05:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11264381 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61DDA6C1 for ; Wed, 27 Nov 2019 15:23:35 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1EC852053B for ; Wed, 27 Nov 2019 15:23:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NBzB9sED" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EC852053B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574868213; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bPtU4+UzW5/kvqEQITPMiEDyzt3Rcv1stOXCjALK0XQ=; b=NBzB9sEDigegS4i5XG1MAUjUWdLn2a9PjT70joopM362YZ9GZeQ246attzjqm4rZFQfOt7 DNW29T+FkXI0zUf03hnFANSY5hL9ZOWMHSX0Ap/E0e84Heu49CiEfNS/E/Ou3YErA7TgM2 4W0cIWtX6iDBm4K/Voy2GORkV7oLrv8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-2IfeTL8eNB6Bu1Z8WeJxIA-1; Wed, 27 Nov 2019 10:23:31 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D53F0DB60; Wed, 27 Nov 2019 15:23:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B44C45D6C8; Wed, 27 Nov 2019 15:23:24 +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 799B918089CE; Wed, 27 Nov 2019 15:23:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xARFNJHh004681 for ; Wed, 27 Nov 2019 10:23:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1D8182038B9C; Wed, 27 Nov 2019 15:23:19 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 184EB2038B96 for ; Wed, 27 Nov 2019 15:23:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F1A0A91045D for ; Wed, 27 Nov 2019 15:23:18 +0000 (UTC) Received: from m9a0003g.houston.softwaregrp.com (m9a0003g.houston.softwaregrp.com [15.124.64.68]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-293-QUBHsLUVNDqkaaNdORfNmw-1; Wed, 27 Nov 2019 10:23:15 -0500 Received: FROM m9a0003g.houston.softwaregrp.com (15.121.0.190) BY m9a0003g.houston.softwaregrp.com WITH ESMTP; Wed, 27 Nov 2019 15:22:31 +0000 Received: from M9W0068.microfocus.com (2002:f79:bf::f79:bf) by M9W0067.microfocus.com (2002:f79:be::f79:be) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Wed, 27 Nov 2019 15:05:56 +0000 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (15.124.72.14) by M9W0068.microfocus.com (15.121.0.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10 via Frontend Transport; Wed, 27 Nov 2019 15:05:56 +0000 Received: from DM5PR18MB1355.namprd18.prod.outlook.com (10.175.223.16) by DM5PR18MB1052.namprd18.prod.outlook.com (10.168.115.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2474.22; Wed, 27 Nov 2019 15:05:54 +0000 Received: from DM5PR18MB1355.namprd18.prod.outlook.com ([fe80::b08c:34c6:ffb6:641c]) by DM5PR18MB1355.namprd18.prod.outlook.com ([fe80::b08c:34c6:ffb6:641c%12]) with mapi id 15.20.2474.023; Wed, 27 Nov 2019 15:05:54 +0000 From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Thread-Topic: [PATCH v2 5/5] libmultipath: fix ALUA autodetection when paths are down Thread-Index: AQHVpTQqjSdIakixM0+rEY/99CY9rg== Date: Wed, 27 Nov 2019 15:05:53 +0000 Message-ID: <20191127150604.31417-6-martin.wilck@suse.com> References: <20191127150604.31417-1-martin.wilck@suse.com> In-Reply-To: <20191127150604.31417-1-martin.wilck@suse.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM0PR06CA0040.eurprd06.prod.outlook.com (2603:10a6:208:aa::17) To DM5PR18MB1355.namprd18.prod.outlook.com (2603:10b6:3:14a::16) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2.206.153.8] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7fd25ec1-eea5-4e3d-6203-08d7734b4c69 x-ms-traffictypediagnostic: DM5PR18MB1052: x-ld-processed: 856b813c-16e5-49a5-85ec-6f081e13b527,ExtFwd x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:270; x-forefront-prvs: 023495660C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(376002)(396003)(136003)(366004)(39860400002)(346002)(199004)(189003)(66556008)(3846002)(66066001)(256004)(14444005)(81166006)(81156014)(6506007)(8936002)(8676002)(386003)(6486002)(50226002)(86362001)(44832011)(446003)(71190400001)(5660300002)(186003)(26005)(478600001)(4326008)(52116002)(76176011)(64756008)(6116002)(6512007)(6436002)(2616005)(66476007)(7736002)(11346002)(14454004)(110136005)(316002)(102836004)(66946007)(25786009)(54906003)(71200400001)(99286004)(36756003)(2906002)(305945005)(1076003)(66446008); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR18MB1052; H:DM5PR18MB1355.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: blCi+qw5p2188DXKEMFh2tnyT2tN/5wJUgbznvDzxuJmpJbKmFC0YlNHnaczlkz5T1HoIFdxl/IyQEtwh40GfPaRI89kh2sMrO+O6SLlm1odaPK6XYCktQx6UitO5QRz4CNcEE1Ky/JoYl5nGlDhmfC4HsHFGGBzCvh4Vl0jEOjWT786S1BQ3886Wnzs8zcYE8fc8fNC/Ws5VDq852sNZFTH1C3JTZhnZ75DHZmMY0aVlL1e2957Xup4ppoypm5yg23E7wlO7C5u2VyZ+hGfuX/fSOvhvz+4+Jz+W1dUsOtv6bP2lbw9Hz+88fiA5i4BxOAzG40MMh6iE1N3GrZ7SlyGzwM7PDit59QXA84/4IH850hI1mtG834FeCQ70Sy8g7z9MAAajQY4Ff7IGwvb4Jmf2a3XsumdGCtXOvJiJhWuZeiPRps6wvDEoR5wbnZ7 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 7fd25ec1-eea5-4e3d-6203-08d7734b4c69 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2019 15:05:53.9260 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 856b813c-16e5-49a5-85ec-6f081e13b527 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: NcrWTmmdCIxV9BvbXgezt700X46EciDZ/3eGSbb4sIAyuodtiq+bAPLZnJw9SCjqBBa7S3NSxZP93qn04lEujw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR18MB1052 X-OriginatorOrg: suse.com X-MC-Unique: QUBHsLUVNDqkaaNdORfNmw-1 X-MC-Unique: 2IfeTL8eNB6Bu1Z8WeJxIA-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xARFNJHh004681 X-loop: dm-devel@redhat.com Cc: Chongyun Wu , "dm-devel@redhat.com" , Xose Vazquez Perez , Martin Wilck Subject: [dm-devel] [PATCH v2 5/5] libmultipath: fix ALUA autodetection when paths are down 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: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 From: Martin Wilck If a single path was offline when detect_alua() was called, multipathd would assume ALUA was generally unsupported. Fix that by assuming that if at least one path has ALUA support and no path explicitly does not have it, ALUA is supported. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/discovery.c | 22 +++++++++++++++++++++- libmultipath/propsel.c | 20 +++++++++++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 4288c9fd..5f41dcb7 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -871,6 +871,10 @@ get_serial (char * str, int maxlen, int fd) return 1; } +/* + * Side effect: sets pp->tpgs if it could be determined. + * If ALUA calls fail because paths are unreachable, pp->tpgs remains unchanged. + */ static void detect_alua(struct path * pp) { @@ -881,12 +885,28 @@ detect_alua(struct path * pp) if (sysfs_get_timeout(pp, &timeout) <= 0) timeout = DEF_TIMEOUT; - if ((tpgs = get_target_port_group_support(pp, timeout)) <= 0) { + tpgs = get_target_port_group_support(pp, timeout); + if (tpgs == -RTPG_INQUIRY_FAILED) + return; + else if (tpgs <= 0) { pp->tpgs = TPGS_NONE; return; } + + if (pp->fd == -1 || pp->offline) + return; + ret = get_target_port_group(pp, timeout); if (ret < 0 || get_asymmetric_access_state(pp, ret, timeout) < 0) { + int state; + + if (ret == -RTPG_INQUIRY_FAILED) + return; + + state = path_offline(pp); + if (state == PATH_DOWN || state == PATH_PENDING) + return; + pp->tpgs = TPGS_NONE; return; } diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index 27e8d68a..a5fc6ba0 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -432,12 +432,26 @@ int select_hwhandler(struct config *conf, struct multipath *mp) static const char tpgs_origin[]= "(setting: autodetected from TPGS)"; char *dh_state; int i; - bool all_tpgs = true; + bool all_tpgs = true, one_tpgs = false; dh_state = &handler[2]; - vector_foreach_slot(mp->paths, pp, i) - all_tpgs = all_tpgs && (path_get_tpgs(pp) > 0); + /* + * TPGS_UNDEF means that ALUA support couldn't determined either way + * yet, probably because the path was always down. + * If at least one path does have TPGS support, and no path has + * TPGS_NONE, assume that TPGS would be supported by all paths if + * all were up. + */ + vector_foreach_slot(mp->paths, pp, i) { + int tpgs = path_get_tpgs(pp); + + all_tpgs = all_tpgs && tpgs != TPGS_NONE; + one_tpgs = one_tpgs || + (tpgs != TPGS_NONE && tpgs != TPGS_UNDEF); + } + all_tpgs = all_tpgs && one_tpgs; + if (mp->retain_hwhandler != RETAIN_HWHANDLER_OFF) { vector_foreach_slot(mp->paths, pp, i) { if (get_dh_state(pp, dh_state, sizeof(handler) - 2) > 0