From patchwork Thu Sep 12 21:49:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802722 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03C131C2439 for ; Thu, 12 Sep 2024 21:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177797; cv=none; b=QJVM4VdARELL68zOyaJsh8Fh63duCqAluMWlt9vcxHiZR7zcAhi9hPw5mKdI5S9QDOG42JHhx0YkdHqjZQgLuUnfmvaZW8v+C4R+PWFttEcQkvFWq4jtLvDpCt5rdfyACE5xnSj2OyL0ypbs1zqdsV3Ql+urQMyVS9dJdOr35aA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177797; c=relaxed/simple; bh=tYS1aUdpLqdn9TSCtaH626/ztonfRm8T1JOz6o3Z288=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IOMF1/oVtXBOyDHWIn+SUPXntK678AsNgnkqlMK4D2QnQ2W8tqDucUdwa6USUG1FsFCi4JBphPV6EsMRTzmkr4zvnfG3/hsxkTKs9YEvcTnOL6m/HI2pcSxwoEyPvs8R77iCwEKUX5pGzWIng0CO4cpnfnJz7p5GiVtCXyKFO+U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=jBwlyTrd; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jBwlyTrd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177795; h=from:from: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; bh=BDs4Ab4sntfhFq67+vC9RSYHdbn5srY/bQCUjqCeUGw=; b=jBwlyTrd7W01zE5/Vsx38aIKCVJXdgCuF3DpFR2hqHQZjNTeVgWoaxfLSsXXBLAAQ4Wm3R Si+jn1VnLnuQIVCmpOchnVO6X6rZqidGcPjK5vC8TBW5zLs0ewMUUAEn1ZuiLdPp5kKNly 7dIfDBilIy5uS+Ha8DFysiez+IUlDeY= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-204-gsTrolgGMTmdRZoYbaLLZA-1; Thu, 12 Sep 2024 17:49:51 -0400 X-MC-Unique: gsTrolgGMTmdRZoYbaLLZA-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DEA2C1956048; Thu, 12 Sep 2024 21:49:50 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2688D3001D10; Thu, 12 Sep 2024 21:49:50 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnmNa783854 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:48 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnmba783853; Thu, 12 Sep 2024 17:49:48 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 01/22] libmultipath: store checker_check() result in checker struct Date: Thu, 12 Sep 2024 17:49:26 -0400 Message-ID: <20240912214947.783819-2-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com checker_check() is now a void function that stores the path state in the checker struct. It can be retrieved later using checker_get_state(). Right now, this is called immediately after checker_check(), but in the future, it can be deferred to another time. Signed-off-by: Benjamin Marzinski --- libmultipath/checkers.c | 26 +++++++++++++------------- libmultipath/checkers.h | 4 +++- libmultipath/discovery.c | 3 ++- libmultipath/propsel.c | 1 + 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c index fdb91e17..c4918d28 100644 --- a/libmultipath/checkers.c +++ b/libmultipath/checkers.c @@ -299,28 +299,28 @@ void checker_put (struct checker * dst) free_checker_class(src); } -int checker_check (struct checker * c, int path_state) +int checker_get_state(struct checker *c) { - int r; + return c ? c->path_state : PATH_UNCHECKED; +} +void checker_check (struct checker * c, int path_state) +{ if (!c) - return PATH_WILD; + return; c->msgid = CHECKER_MSGID_NONE; if (c->disable) { c->msgid = CHECKER_MSGID_DISABLED; - return PATH_UNCHECKED; - } - if (!strncmp(c->cls->name, NONE, 4)) - return path_state; - - if (c->fd < 0) { + c->path_state = PATH_UNCHECKED; + } else if (!strncmp(c->cls->name, NONE, 4)) { + c->path_state = path_state; + } else if (c->fd < 0) { c->msgid = CHECKER_MSGID_NO_FD; - return PATH_WILD; + c->path_state = PATH_WILD; + } else { + c->path_state = c->cls->check(c); } - r = c->cls->check(c); - - return r; } const char *checker_name(const struct checker *c) diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h index 102351f6..6e54d8f0 100644 --- a/libmultipath/checkers.h +++ b/libmultipath/checkers.h @@ -123,6 +123,7 @@ struct checker { int fd; unsigned int timeout; int disable; + int path_state; short msgid; /* checker-internal extra status */ void * context; /* store for persistent data */ void ** mpcontext; /* store for persistent data shared @@ -169,7 +170,8 @@ struct checker_context { }; int start_checker_thread (pthread_t *thread, const pthread_attr_t *attr, struct checker_context *ctx); -int checker_check (struct checker *, int); +int checker_get_state(struct checker *c); +void checker_check (struct checker *, int); int checker_is_sync(const struct checker *); const char *checker_name (const struct checker *); void reset_checker_classes(void); diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index e94705bf..5648be60 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -2007,7 +2007,8 @@ get_state (struct path * pp, struct config *conf, int daemon, int oldstate) checker_set_async(c); else checker_set_sync(c); - state = checker_check(c, oldstate); + checker_check(c, oldstate); + state = checker_get_state(c); condlog(3, "%s: %s state = %s", pp->dev, checker_name(c), checker_state_name(state)); if (state != PATH_UP && state != PATH_GHOST && diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index a3fce203..ad771d35 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -700,6 +700,7 @@ out: condlog(3, "%s: path_checker = %s %s", pp->dev, checker_name(c), origin); c->timeout = pp->checker_timeout; + c->path_state = PATH_UNCHECKED; return 0; } From patchwork Thu Sep 12 21:49:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802711 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B6821AD25C for ; Thu, 12 Sep 2024 21:49:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177795; cv=none; b=RdYQ3IRxaCqSg3CBlnLdLIg5GhnEi0hwxau0CgOQmwU763hFhjFezUv7PKtYVikvyxBy9pXpLIwH+Ar85/q8Bxo2PQmKQLPjgi19lPQ/Ga7bIy5I4ob6jK9l6g2iCuXQ9TOJXinPyEHxyQ9VWs/yqvzwsF4y1dpGb/+BJsXBFrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177795; c=relaxed/simple; bh=vIAcuVFqBqZFDp5s3U8YZDkhvPVhMgHVNLHpEoMttMY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iJEwh4qNTmDvOES7enk+Kp6xg66c4LUrF6DZE6lBU1UpoNk9wgRkrg9W4XOhU8OIIySPNTxDRCdz4SAfMh9AQhp+HWTKe9Hsy8QT06le/IFmq7ornaBPuoAETVS8/n3/7z1kopW/8HfF59gSqfD8D39IWXFnDvlu8KghiDeURKY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ALZjjyS+; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ALZjjyS+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177793; h=from:from: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; bh=B4v6gzKlDdY7pFVvU8nqDcBNEI0j08uWzi4XYoOh0t0=; b=ALZjjyS+9nvruAVZnztteHSVpctW04BWuLSn1Ni1C62dH9hFpMLRxt+j6O7Aqp0YuFz9Cd JvMOxfNKGjneCFuP8DhQ5p0OW7CLe1nhecD/zWv2agmvcTnGsXOHe3WiMqkomhGMukCSA3 iIR2cVKVsFmB1qYDCp5s52LKRUFR92k= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-ZPcQ1l4oN0ifS6yuCy1riQ-1; Thu, 12 Sep 2024 17:49:52 -0400 X-MC-Unique: ZPcQ1l4oN0ifS6yuCy1riQ-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CFA201955D45; Thu, 12 Sep 2024 21:49:50 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3167D19560A1; Thu, 12 Sep 2024 21:49:50 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnmbO783858 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:48 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnm7e783857; Thu, 12 Sep 2024 17:49:48 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 02/22] libmultipath: add missing checker function prototypes Date: Thu, 12 Sep 2024 17:49:27 -0400 Message-ID: <20240912214947.783819-3-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Signed-off-by: Benjamin Marzinski --- libmultipath/checkers.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h index 6e54d8f0..fb1160af 100644 --- a/libmultipath/checkers.h +++ b/libmultipath/checkers.h @@ -188,6 +188,9 @@ int libcheck_check(struct checker *); int libcheck_init(struct checker *); void libcheck_free(struct checker *); void *libcheck_thread(struct checker_context *ctx); +void libcheck_reset(void); +int libcheck_mp_init(struct checker *); + /* * msgid => message map. From patchwork Thu Sep 12 21:49:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802720 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C87231C233E for ; Thu, 12 Sep 2024 21:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177797; cv=none; b=lJQG8Itchrz0nmueiHQVrt/ebexfJkxLGpyCntlT1FeIWr5wDAbZ/TDC4r2j/36UiP94PERtukbKpJhsy8ToxLX3t8QEOzraLN6VCgSSNKsy1WPlm/JODwA0vZgr0Sxkax4KK3SA7d3+r4M0hdTfzfxI2jMQ2z0LaCFvfU6c6bs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177797; c=relaxed/simple; bh=LigvlYlkSVSBcyEuvhiP082jSwuwz6D06YhkSkrLlBs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JH3wzN4l68imkNgDXpICyjBRGuww50HWby+7uhJ84qh6QwpajNoF4sCU5sQTTBD6SOMB/d0XNrXJvKMhKNxqerZuSTOkk6lOLD5qPuLSf14RP+99QNLNjO+CWCdGEBvEUWjyFTwCnQzAsDIIL5uuvPI42KuFPAB+6ntSaWEDRpM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LEfy2mER; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LEfy2mER" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177794; h=from:from: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; bh=/mDcvK52Xq8n7eJMs62ES4ylrn4J1JrMbQyAQBEQ7HQ=; b=LEfy2mERv4pIihPsvCFmRPHq9MsTQbjnAqdMfndrR+DXxns6q2e4Ny0O0Z0bDsjp0DZlTj 02GdyiwpYL2kIt6Ixxd9MgpnoS9gRe3qGfCmkzIihhpIEQhkxcK9OTN+8ltqd5T7xaZIUX f0qCDnsUVU9gCl4cJJmkI6lfRXVOgi0= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-651-uNZ4z4AtOK6KpG8HAXqCMA-1; Thu, 12 Sep 2024 17:49:51 -0400 X-MC-Unique: uNZ4z4AtOK6KpG8HAXqCMA-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C852319560AE; Thu, 12 Sep 2024 21:49:50 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3A171195609F; Thu, 12 Sep 2024 21:49:50 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnm8Q783862 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:48 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnm4u783861; Thu, 12 Sep 2024 17:49:48 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 03/22] libmultipath: split out the code to wait for pending checkers Date: Thu, 12 Sep 2024 17:49:28 -0400 Message-ID: <20240912214947.783819-4-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This patch adds a new optional symbol for the dynamic path checker libraries, libcheck_pending. This is currently unused, but can be called on pending checkers to check if they've completed and return their value. The "tur" and "directio" checkers are the only ones which can return PATH_PENDING. They now implement libcheck_pending() as a wrapper around the code that libcheck_check uses to wait for pending paths, which has been broken out into its own function. Signed-off-by: Benjamin Marzinski --- libmultipath/checkers.c | 4 +- libmultipath/checkers.h | 1 + libmultipath/checkers/directio.c | 86 ++++++++++++++++++++++---------- libmultipath/checkers/tur.c | 65 ++++++++++++++++-------- 4 files changed, 109 insertions(+), 47 deletions(-) diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c index c4918d28..298aec78 100644 --- a/libmultipath/checkers.c +++ b/libmultipath/checkers.c @@ -26,6 +26,7 @@ struct checker_class { void (*free)(struct checker *); /* to free the context */ void (*reset)(void); /* to reset the global variables */ void *(*thread)(void *); /* async thread entry point */ + int (*pending)(struct checker *); /* to recheck pending paths */ const char **msgtable; short msgtable_size; }; @@ -180,7 +181,8 @@ static struct checker_class *add_checker_class(const char *name) c->mp_init = (int (*)(struct checker *)) dlsym(c->handle, "libcheck_mp_init"); c->reset = (void (*)(void)) dlsym(c->handle, "libcheck_reset"); c->thread = (void *(*)(void*)) dlsym(c->handle, "libcheck_thread"); - /* These 3 functions can be NULL. call dlerror() to clear out any + c->pending = (int (*)(struct checker *)) dlsym(c->handle, "libcheck_pending"); + /* These 4 functions can be NULL. call dlerror() to clear out any * error string */ dlerror(); diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h index fb1160af..b2342a1b 100644 --- a/libmultipath/checkers.h +++ b/libmultipath/checkers.h @@ -190,6 +190,7 @@ void libcheck_free(struct checker *); void *libcheck_thread(struct checker_context *ctx); void libcheck_reset(void); int libcheck_mp_init(struct checker *); +int libcheck_pending(struct checker *c); /* diff --git a/libmultipath/checkers/directio.c b/libmultipath/checkers/directio.c index 8e87878b..3f88b40d 100644 --- a/libmultipath/checkers/directio.c +++ b/libmultipath/checkers/directio.c @@ -288,14 +288,36 @@ get_events(struct aio_group *aio_grp, struct timespec *timeout) return got_events; } +static void +check_pending(struct directio_context *ct, struct timespec endtime) +{ + int r; + struct timespec currtime, timeout; + + while(1) { + get_monotonic_time(&currtime); + timespecsub(&endtime, &currtime, &timeout); + if (timeout.tv_sec < 0) + timeout.tv_sec = timeout.tv_nsec = 0; + + r = get_events(ct->aio_grp, &timeout); + + if (ct->req->state != PATH_PENDING) { + ct->running = 0; + return; + } else if (r == 0 || + (timeout.tv_sec == 0 && timeout.tv_nsec == 0)) + return; + } +} + static int check_state(int fd, struct directio_context *ct, int sync, int timeout_secs) { struct timespec timeout = { .tv_nsec = 1000 }; struct stat sb; int rc; - long r; - struct timespec currtime, endtime; + struct timespec endtime; if (fstat(fd, &sb) == 0) { LOG(4, "called for %x", (unsigned) sb.st_rdev); @@ -330,21 +352,11 @@ check_state(int fd, struct directio_context *ct, int sync, int timeout_secs) endtime.tv_sec += timeout.tv_sec; endtime.tv_nsec += timeout.tv_nsec; normalize_timespec(&endtime); - while(1) { - r = get_events(ct->aio_grp, &timeout); - if (ct->req->state != PATH_PENDING) { - ct->running = 0; - return ct->req->state; - } else if (r == 0 || - (timeout.tv_sec == 0 && timeout.tv_nsec == 0)) - break; + check_pending(ct, endtime); + if (ct->req->state != PATH_PENDING) + return ct->req->state; - get_monotonic_time(&currtime); - timespecsub(&endtime, &currtime, &timeout); - if (timeout.tv_sec < 0) - timeout.tv_sec = timeout.tv_nsec = 0; - } if (ct->running > timeout_secs || sync) { struct io_event event; @@ -360,17 +372,9 @@ check_state(int fd, struct directio_context *ct, int sync, int timeout_secs) return rc; } -int libcheck_check (struct checker * c) +static void set_msgid(struct checker *c, int state) { - int ret; - struct directio_context * ct = (struct directio_context *)c->context; - - if (!ct) - return PATH_UNCHECKED; - - ret = check_state(c->fd, ct, checker_is_sync(c), c->timeout); - - switch (ret) + switch (state) { case PATH_UNCHECKED: c->msgid = MSG_DIRECTIO_UNKNOWN; @@ -387,5 +391,37 @@ int libcheck_check (struct checker * c) default: break; } +} + +int libcheck_pending(struct checker *c) +{ + struct timespec endtime; + struct directio_context *ct = (struct directio_context *)c->context; + + /* The if path checker isn't running, just return the exiting value. */ + if (!ct || !ct->running) + return c->path_state; + + if (ct->req->state == PATH_PENDING) { + get_monotonic_time(&endtime); + check_pending(ct, endtime); + } else + ct->running = 0; + set_msgid(c, ct->req->state); + + return ct->req->state; +} + +int libcheck_check (struct checker * c) +{ + int ret; + struct directio_context * ct = (struct directio_context *)c->context; + + if (!ct) + return PATH_UNCHECKED; + + ret = check_state(c->fd, ct, checker_is_sync(c), c->timeout); + set_msgid(c, ret); + return ret; } diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c index a2905af5..95af5214 100644 --- a/libmultipath/checkers/tur.c +++ b/libmultipath/checkers/tur.c @@ -323,6 +323,49 @@ static int tur_check_async_timeout(struct checker *c) return (now.tv_sec > ct->time); } +int check_pending(struct checker *c, struct timespec endtime) +{ + struct tur_checker_context *ct = c->context; + int r, tur_status = PATH_PENDING; + + pthread_mutex_lock(&ct->lock); + + for (r = 0; + r == 0 && ct->state == PATH_PENDING && + ct->msgid == MSG_TUR_RUNNING; + r = pthread_cond_timedwait(&ct->active, &ct->lock, &endtime)); + + if (!r) { + tur_status = ct->state; + c->msgid = ct->msgid; + } + pthread_mutex_unlock(&ct->lock); + if (tur_status == PATH_PENDING && c->msgid == MSG_TUR_RUNNING) { + condlog(4, "%d:%d : tur checker still running", + major(ct->devt), minor(ct->devt)); + } else { + int running = uatomic_xchg(&ct->running, 0); + if (running) + pthread_cancel(ct->thread); + ct->thread = 0; + } + + return tur_status; +} + +int libcheck_pending(struct checker *c) +{ + struct timespec endtime; + struct tur_checker_context *ct = c->context; + + /* The if path checker isn't running, just return the exiting value. */ + if (!ct || !ct->thread) + return c->path_state; + + get_monotonic_time(&endtime); + return check_pending(c, endtime); +} + int libcheck_check(struct checker * c) { struct tur_checker_context *ct = c->context; @@ -437,27 +480,7 @@ int libcheck_check(struct checker * c) return tur_check(c->fd, c->timeout, &c->msgid); } tur_timeout(&tsp); - pthread_mutex_lock(&ct->lock); - - for (r = 0; - r == 0 && ct->state == PATH_PENDING && - ct->msgid == MSG_TUR_RUNNING; - r = pthread_cond_timedwait(&ct->active, &ct->lock, &tsp)); - - if (!r) { - tur_status = ct->state; - c->msgid = ct->msgid; - } - pthread_mutex_unlock(&ct->lock); - if (tur_status == PATH_PENDING && c->msgid == MSG_TUR_RUNNING) { - condlog(4, "%d:%d : tur checker still running", - major(ct->devt), minor(ct->devt)); - } else { - int running = uatomic_xchg(&ct->running, 0); - if (running) - pthread_cancel(ct->thread); - ct->thread = 0; - } + tur_status = check_pending(c, tsp); } return tur_status; From patchwork Thu Sep 12 21:49:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802713 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EF851BE857 for ; Thu, 12 Sep 2024 21:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177796; cv=none; b=ec8hPcqJVlvLgQnsuuC8f+Hp7n84Wrq78oBPBWJPGwktnvLBEvrkYe+QGGc5mKd1pdcEiWo+ZrMA2GQwVtFQtHlrqQxR5NFQKoGArfut8F1FEMGVYPSLtUPiRfU+bY/QHgZlazGacp2ZgLzWfCHKQdUoVf4jrzXn7kouIsYtcME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177796; c=relaxed/simple; bh=mNhx5foSdprYf+W9AtXLA6jKptGbj0duXgocYH8bztA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bymISHzhl64x+vRoQ3X3xKHjfAvAVhji5Vj+HXhJm+QioDgViFsKqWmMmV7VWOSKAWzAv1kfAxty4lqqePZ8s01UZLR4UoWv8IZn/Bcik+CfJoyS6SLnNvoNwcqjQp3ZqQvUILE6jJro5i/qehP57DCpa5AW0N7z5gntJe7/Q0k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ncue/thW; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ncue/thW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177793; h=from:from: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; bh=FPyLfModveUIFPuQao0TnbyWKj2lX+5T9968yaSAwBs=; b=Ncue/thWo9v6igUT2ikxeXO4/db1ezLUqFlhqx6z4+OZ5JJSH2ypDAm2LmCEpWvZYcz9wb WxpIJy+f3XZbfNfI1DLFBngMGhjajGVnJAYkDcAgCsz+MZRoBJxMjOiUCfFXFYLedvPvaM OeZM18L5CsKvSoDD4WtzdyYvQaWxBrA= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-490-sf3nCLYWOTuTOD31aOEfAA-1; Thu, 12 Sep 2024 17:49:52 -0400 X-MC-Unique: sf3nCLYWOTuTOD31aOEfAA-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 472821956048; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AB2B419560B7; Thu, 12 Sep 2024 21:49:50 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnnGk783866 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:49 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnnwn783865; Thu, 12 Sep 2024 17:49:49 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 04/22] libmultipath: remove pending wait code from libcheck_check calls Date: Thu, 12 Sep 2024 17:49:29 -0400 Message-ID: <20240912214947.783819-5-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com When the tur and directio checkers start an asynchronous checker, they now immediately return with the path in PATH_PENDING, instead of waiting in checker_check(). Instead the wait now happens in checker_get_state(). Additionally, the directio checker now waits for 1 ms, like the tur checker does. Also like the tur checker it now only waits once. If it is still pending after the first call to checker_get_state(). It will not wait at all on future calls, and will just process the already completed IOs. Signed-off-by: Benjamin Marzinski --- libmultipath/checkers.c | 7 +++- libmultipath/checkers/directio.c | 57 +++++++++++++++++--------------- libmultipath/checkers/tur.c | 13 +++----- 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c index 298aec78..ce3e48bd 100644 --- a/libmultipath/checkers.c +++ b/libmultipath/checkers.c @@ -303,7 +303,12 @@ void checker_put (struct checker * dst) int checker_get_state(struct checker *c) { - return c ? c->path_state : PATH_UNCHECKED; + if (!c || !c->cls) + return PATH_UNCHECKED; + if (c->path_state != PATH_PENDING || !c->cls->pending) + return c->path_state; + c->path_state = c->cls->pending(c); + return c->path_state; } void checker_check (struct checker * c, int path_state) diff --git a/libmultipath/checkers/directio.c b/libmultipath/checkers/directio.c index 3f88b40d..904e3071 100644 --- a/libmultipath/checkers/directio.c +++ b/libmultipath/checkers/directio.c @@ -60,10 +60,11 @@ const char *libcheck_msgtable[] = { #define LOG(prio, fmt, args...) condlog(prio, "directio: " fmt, ##args) struct directio_context { - int running; + unsigned int running; int reset_flags; struct aio_group *aio_grp; struct async_req *req; + struct timespec endtime; }; static struct aio_group * @@ -314,19 +315,16 @@ check_pending(struct directio_context *ct, struct timespec endtime) static int check_state(int fd, struct directio_context *ct, int sync, int timeout_secs) { - struct timespec timeout = { .tv_nsec = 1000 }; struct stat sb; int rc; + struct io_event event; struct timespec endtime; if (fstat(fd, &sb) == 0) { LOG(4, "called for %x", (unsigned) sb.st_rdev); } - if (sync > 0) { + if (sync > 0) LOG(4, "called in synchronous mode"); - timeout.tv_sec = timeout_secs; - timeout.tv_nsec = 0; - } if (ct->running) { if (ct->req->state != PATH_PENDING) { @@ -345,31 +343,26 @@ check_state(int fd, struct directio_context *ct, int sync, int timeout_secs) LOG(3, "io_submit error %i", -rc); return PATH_UNCHECKED; } + get_monotonic_time(&ct->endtime); + ct->endtime.tv_nsec += 1000 * 1000; + normalize_timespec(&ct->endtime); } ct->running++; + if (!sync) + return PATH_PENDING; get_monotonic_time(&endtime); - endtime.tv_sec += timeout.tv_sec; - endtime.tv_nsec += timeout.tv_nsec; + endtime.tv_sec += timeout_secs; normalize_timespec(&endtime); check_pending(ct, endtime); if (ct->req->state != PATH_PENDING) return ct->req->state; - if (ct->running > timeout_secs || sync) { - struct io_event event; - - LOG(3, "abort check on timeout"); - - io_cancel(ct->aio_grp->ioctx, &ct->req->io, &event); - rc = PATH_DOWN; - } else { - LOG(4, "async io pending"); - rc = PATH_PENDING; - } + LOG(3, "abort check on timeout"); - return rc; + io_cancel(ct->aio_grp->ioctx, &ct->req->io, &event); + return PATH_DOWN; } static void set_msgid(struct checker *c, int state) @@ -395,21 +388,31 @@ static void set_msgid(struct checker *c, int state) int libcheck_pending(struct checker *c) { - struct timespec endtime; + int rc; + struct io_event event; struct directio_context *ct = (struct directio_context *)c->context; /* The if path checker isn't running, just return the exiting value. */ if (!ct || !ct->running) return c->path_state; - if (ct->req->state == PATH_PENDING) { - get_monotonic_time(&endtime); - check_pending(ct, endtime); - } else + if (ct->req->state == PATH_PENDING) + check_pending(ct, ct->endtime); + else ct->running = 0; - set_msgid(c, ct->req->state); + rc = ct->req->state; + if (rc == PATH_PENDING) { + if (ct->running > c->timeout) { + LOG(3, "abort check on timeout"); + io_cancel(ct->aio_grp->ioctx, &ct->req->io, &event); + rc = PATH_DOWN; + } + else + LOG(4, "async io pending"); + } + set_msgid(c, rc); - return ct->req->state; + return rc; } int libcheck_check (struct checker * c) diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c index 95af5214..81db565b 100644 --- a/libmultipath/checkers/tur.c +++ b/libmultipath/checkers/tur.c @@ -58,6 +58,7 @@ struct tur_checker_context { int msgid; struct checker_context ctx; unsigned int nr_timeouts; + struct timespec endtime; }; int libcheck_init (struct checker * c) @@ -323,7 +324,7 @@ static int tur_check_async_timeout(struct checker *c) return (now.tv_sec > ct->time); } -int check_pending(struct checker *c, struct timespec endtime) +int check_pending(struct checker *c) { struct tur_checker_context *ct = c->context; int r, tur_status = PATH_PENDING; @@ -333,7 +334,7 @@ int check_pending(struct checker *c, struct timespec endtime) for (r = 0; r == 0 && ct->state == PATH_PENDING && ct->msgid == MSG_TUR_RUNNING; - r = pthread_cond_timedwait(&ct->active, &ct->lock, &endtime)); + r = pthread_cond_timedwait(&ct->active, &ct->lock, &ct->endtime)); if (!r) { tur_status = ct->state; @@ -355,21 +356,18 @@ int check_pending(struct checker *c, struct timespec endtime) int libcheck_pending(struct checker *c) { - struct timespec endtime; struct tur_checker_context *ct = c->context; /* The if path checker isn't running, just return the exiting value. */ if (!ct || !ct->thread) return c->path_state; - get_monotonic_time(&endtime); - return check_pending(c, endtime); + return check_pending(c); } int libcheck_check(struct checker * c) { struct tur_checker_context *ct = c->context; - struct timespec tsp; pthread_attr_t attr; int tur_status, r; @@ -479,8 +477,7 @@ int libcheck_check(struct checker * c) " sync mode", major(ct->devt), minor(ct->devt)); return tur_check(c->fd, c->timeout, &c->msgid); } - tur_timeout(&tsp); - tur_status = check_pending(c, tsp); + tur_timeout(&ct->endtime); } return tur_status; From patchwork Thu Sep 12 21:49:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802715 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7178E1C1ACC for ; Thu, 12 Sep 2024 21:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177796; cv=none; b=cTI6CV278SPy6jfRDA7U5SJxrVPCc9bv1xzd9AJGKQlFwsfG+hJ5x5DYGCz1KuEFbgL/jpdraYn99QgKnO/yAtjjnTbWaltJTf7kBQ5KbqsYtfsUZPaLYG/DbeGCUZVDCLucMQOff2XTy6XZVO+OXslS7Uk6j7evKJS7pxVp/R8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177796; c=relaxed/simple; bh=HjsidXyHncVuVcoUhj/v+RQMj5H35XGqzYAhoc9rOEY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Wrv2SwAUuOt7Y+LO3mKHjXdrY6F7LqFe3QSJ9u8lkcWiMAyM++fH1O6xPhJXwtRCDQkZBV+fAkBb/F2CdjB+XzAkFBhzdjtpT4BNmfg+kSOa2o6pHHZ0BblO7aLXmN+9g8m7esrZirqTT4eWqM+dzMXg6vxewy6bDxoImgJAGSI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NK39oiDr; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NK39oiDr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177793; h=from:from: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; bh=2NrmMnGC9nChy1RlylNLY5mK0TQQv3mYIJriRvmT16Q=; b=NK39oiDremhYLxCPm85P5bZQ1za2RYcIZuJifj3m/N1BqgwRI43AhZDsWOTU38dbMosCPY DbzRSvBvC+JwHzut+8GEYePuBhGVi+qN/pBizAToVGnGOhYftU84/JxuIObSJm0KvkLnky //Mg8igTvewEihT0+2flm8rn2q94fJI= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-yKEUd2m8NhKFVeKi-avFXA-1; Thu, 12 Sep 2024 17:49:52 -0400 X-MC-Unique: yKEUd2m8NhKFVeKi-avFXA-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 45F2619560AF; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A96A23001D16; Thu, 12 Sep 2024 21:49:50 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnnTT783870 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:49 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnnOB783869; Thu, 12 Sep 2024 17:49:49 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 05/22] multipath-tools tests: fix up directio tests Date: Thu, 12 Sep 2024 17:49:30 -0400 Message-ID: <20240912214947.783819-6-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Make the directio tests work with libcheck_pending() being separate from libcheck_check Signed-off-by: Benjamin Marzinski --- tests/directio.c | 133 +++++++++++++++++++++++++++++------------------ 1 file changed, 82 insertions(+), 51 deletions(-) diff --git a/tests/directio.c b/tests/directio.c index 763929e5..2e22f831 100644 --- a/tests/directio.c +++ b/tests/directio.c @@ -219,13 +219,22 @@ static void return_io_getevents_nr(struct timespec *ts, int nr, ev_off += i; } -void do_check_state(struct checker *c, int sync, int timeout, int chk_state) +void do_check_state(struct checker *c, int sync, int chk_state) { struct directio_context * ct = (struct directio_context *)c->context; if (!ct->running) will_return(__wrap_io_submit, 1); - assert_int_equal(check_state(test_fd, ct, sync, timeout), chk_state); + assert_int_equal(check_state(test_fd, ct, sync, c->timeout), chk_state); + if (sync) { + assert_int_equal(ev_off, 0); + memset(mock_events, 0, sizeof(mock_events)); + } +} + +void do_libcheck_pending(struct checker *c, int chk_state) +{ + assert_int_equal(libcheck_pending(c), chk_state); assert_int_equal(ev_off, 0); memset(mock_events, 0, sizeof(mock_events)); } @@ -245,12 +254,13 @@ void do_libcheck_reset(int nr_aio_grps) assert_int_equal(ioctx_count, 0); } -static void do_libcheck_init(struct checker *c, int blocksize, +static void do_libcheck_init(struct checker *c, int blocksize, int timeout, struct async_req **req) { struct directio_context * ct; c->fd = test_fd; + c->timeout = timeout; wrap_will_return(WRAP_IOCTL, blocksize); assert_int_equal(libcheck_init(c), 0); ct = (struct directio_context *)c->context; @@ -305,7 +315,7 @@ static void test_init_reset_init(void **state) assert_true(list_empty(&aio_grp_list)); will_return(__wrap_io_setup, 0); - do_libcheck_init(&c, 4096, NULL); + do_libcheck_init(&c, 4096, 0, NULL); aio_grp = get_aio_grp(&c); check_aio_grp(aio_grp, 1, 0); list_for_each_entry(tmp_grp, &aio_grp_list, node) @@ -314,7 +324,7 @@ static void test_init_reset_init(void **state) check_aio_grp(aio_grp, 0, 0); do_libcheck_reset(1); will_return(__wrap_io_setup, 0); - do_libcheck_init(&c, 4096, NULL); + do_libcheck_init(&c, 4096, 0, NULL); aio_grp = get_aio_grp(&c); check_aio_grp(aio_grp, 1, 0); list_for_each_entry(tmp_grp, &aio_grp_list, node) @@ -340,11 +350,11 @@ static void test_init_free(void **state) struct directio_context * ct; if (i % 3 == 0) - do_libcheck_init(&c[i], 512, NULL); + do_libcheck_init(&c[i], 512, 0, NULL); else if (i % 3 == 1) - do_libcheck_init(&c[i], 1024, NULL); + do_libcheck_init(&c[i], 1024, 0, NULL); else - do_libcheck_init(&c[i], 4096, NULL); + do_libcheck_init(&c[i], 4096, 0, NULL); ct = (struct directio_context *)c[i].context; assert_non_null(ct->aio_grp); if ((i & 1023) == 0) @@ -385,7 +395,7 @@ static void test_multi_init_free(void **state) for (count = 0, i = 0; i < 4096; count++) { /* usually init, but occasionally free checkers */ if (count == 0 || (count % 5 != 0 && count % 7 != 0)) { - do_libcheck_init(&c[i], 4096, NULL); + do_libcheck_init(&c[i], 4096, 0, NULL); i++; } else { i--; @@ -404,7 +414,7 @@ static void test_multi_init_free(void **state) i--; libcheck_free(&c[i]); } else { - do_libcheck_init(&c[i], 4096, NULL); + do_libcheck_init(&c[i], 4096, 0, NULL); i++; } } @@ -420,9 +430,9 @@ static void test_check_state_simple(void **state) assert_true(list_empty(&aio_grp_list)); will_return(__wrap_io_setup, 0); - do_libcheck_init(&c, 4096, &req); + do_libcheck_init(&c, 4096, 30, &req); return_io_getevents_nr(NULL, 1, &req, &res); - do_check_state(&c, 1, 30, PATH_UP); + do_check_state(&c, 1, PATH_UP); libcheck_free(&c); do_libcheck_reset(1); } @@ -435,10 +445,10 @@ static void test_check_state_timeout(void **state) assert_true(list_empty(&aio_grp_list)); will_return(__wrap_io_setup, 0); - do_libcheck_init(&c, 4096, NULL); + do_libcheck_init(&c, 4096, 30, NULL); aio_grp = get_aio_grp(&c); return_io_getevents_none(); - do_check_state(&c, 1, 30, PATH_DOWN); + do_check_state(&c, 1, PATH_DOWN); check_aio_grp(aio_grp, 1, 0); libcheck_free(&c); do_libcheck_reset(1); @@ -452,16 +462,20 @@ static void test_check_state_async_timeout(void **state) assert_true(list_empty(&aio_grp_list)); will_return(__wrap_io_setup, 0); - do_libcheck_init(&c, 4096, NULL); + do_libcheck_init(&c, 4096, 3, NULL); aio_grp = get_aio_grp(&c); + do_check_state(&c, 0, PATH_PENDING); return_io_getevents_none(); - do_check_state(&c, 0, 3, PATH_PENDING); + do_libcheck_pending(&c, PATH_PENDING); + do_check_state(&c, 0, PATH_PENDING); return_io_getevents_none(); - do_check_state(&c, 0, 3, PATH_PENDING); + do_libcheck_pending(&c, PATH_PENDING); + do_check_state(&c, 0, PATH_PENDING); return_io_getevents_none(); - do_check_state(&c, 0, 3, PATH_PENDING); + do_libcheck_pending(&c, PATH_PENDING); + do_check_state(&c, 0, PATH_PENDING); return_io_getevents_none(); - do_check_state(&c, 0, 3, PATH_DOWN); + do_libcheck_pending(&c, PATH_DOWN); check_aio_grp(aio_grp, 1, 0); libcheck_free(&c); do_libcheck_reset(1); @@ -477,14 +491,16 @@ static void test_free_with_pending(void **state) assert_true(list_empty(&aio_grp_list)); will_return(__wrap_io_setup, 0); - do_libcheck_init(&c[0], 4096, &req); - do_libcheck_init(&c[1], 4096, NULL); + do_libcheck_init(&c[0], 4096, 30, &req); + do_libcheck_init(&c[1], 4096, 30, NULL); aio_grp = get_aio_grp(c); + do_check_state(&c[0], 0, PATH_PENDING); + do_check_state(&c[1], 0, PATH_PENDING); return_io_getevents_none(); - do_check_state(&c[0], 0, 30, PATH_PENDING); + do_libcheck_pending(&c[0], PATH_PENDING); return_io_getevents_nr(NULL, 1, &req, &res); return_io_getevents_none(); - do_check_state(&c[1], 0, 30, PATH_PENDING); + do_libcheck_pending(&c[1], PATH_PENDING); assert_true(is_checker_running(&c[0])); assert_true(is_checker_running(&c[1])); check_aio_grp(aio_grp, 2, 0); @@ -505,9 +521,10 @@ static void test_orphaned_aio_group(void **state) assert_true(list_empty(&aio_grp_list)); will_return(__wrap_io_setup, 0); for (i = 0; i < AIO_GROUP_SIZE; i++) { - do_libcheck_init(&c[i], 4096, NULL); + do_libcheck_init(&c[i], 4096, 30, NULL); + do_check_state(&c[i], 0, PATH_PENDING); return_io_getevents_none(); - do_check_state(&c[i], 0, 30, PATH_PENDING); + do_libcheck_pending(&c[i], PATH_PENDING); } aio_grp = get_aio_grp(c); check_aio_grp(aio_grp, AIO_GROUP_SIZE, 0); @@ -539,19 +556,19 @@ static void test_timeout_cancel_failed(void **state) assert_true(list_empty(&aio_grp_list)); will_return(__wrap_io_setup, 0); for (i = 0; i < 2; i++) - do_libcheck_init(&c[i], 4096, &reqs[i]); + do_libcheck_init(&c[i], 4096, 30, &reqs[i]); aio_grp = get_aio_grp(c); return_io_getevents_none(); - do_check_state(&c[0], 1, 30, PATH_DOWN); + do_check_state(&c[0], 1, PATH_DOWN); assert_true(is_checker_running(&c[0])); check_aio_grp(aio_grp, 2, 0); return_io_getevents_none(); - do_check_state(&c[0], 1, 30, PATH_DOWN); + do_check_state(&c[0], 1, PATH_DOWN); assert_true(is_checker_running(&c[0])); return_io_getevents_nr(NULL, 1, &reqs[0], &res[0]); return_io_getevents_nr(NULL, 1, &reqs[1], &res[1]); - do_check_state(&c[1], 1, 30, PATH_UP); - do_check_state(&c[0], 1, 30, PATH_UP); + do_check_state(&c[1], 1, PATH_UP); + do_check_state(&c[0], 1, PATH_UP); for (i = 0; i < 2; i++) { assert_false(is_checker_running(&c[i])); libcheck_free(&c[i]); @@ -571,28 +588,37 @@ static void test_async_timeout_cancel_failed(void **state) assert_true(list_empty(&aio_grp_list)); will_return(__wrap_io_setup, 0); for (i = 0; i < 2; i++) - do_libcheck_init(&c[i], 4096, &reqs[i]); + do_libcheck_init(&c[i], 4096, 2, &reqs[i]); + do_check_state(&c[0], 0, PATH_PENDING); + do_check_state(&c[1], 0, PATH_PENDING); return_io_getevents_none(); - do_check_state(&c[0], 0, 2, PATH_PENDING); + do_libcheck_pending(&c[0], PATH_PENDING); return_io_getevents_none(); - do_check_state(&c[1], 0, 2, PATH_PENDING); + do_libcheck_pending(&c[1], PATH_PENDING); + do_check_state(&c[0], 0, PATH_PENDING); + do_check_state(&c[1], 0, PATH_PENDING); return_io_getevents_none(); - do_check_state(&c[0], 0, 2, PATH_PENDING); + do_libcheck_pending(&c[0], PATH_PENDING); return_io_getevents_none(); - do_check_state(&c[1], 0, 2, PATH_PENDING); + do_libcheck_pending(&c[1], PATH_PENDING); + do_check_state(&c[0], 0, PATH_PENDING); + do_check_state(&c[1], 0, PATH_PENDING); return_io_getevents_none(); - do_check_state(&c[0], 0, 2, PATH_DOWN); + do_libcheck_pending(&c[0], PATH_DOWN); if (!test_dev) { /* can't pick which even gets returned on real devices */ return_io_getevents_nr(NULL, 1, &reqs[1], &res[1]); - do_check_state(&c[1], 0, 2, PATH_UP); + do_libcheck_pending(&c[1], PATH_UP); } + do_check_state(&c[0], 0, PATH_PENDING); return_io_getevents_none(); - do_check_state(&c[0], 0, 2, PATH_DOWN); + do_libcheck_pending(&c[0], PATH_DOWN); assert_true(is_checker_running(&c[0])); + do_check_state(&c[1], 0, PATH_PENDING); + do_check_state(&c[0], 0, PATH_PENDING); return_io_getevents_nr(NULL, 2, reqs, res); - do_check_state(&c[1], 0, 2, PATH_UP); - do_check_state(&c[0], 0, 2, PATH_UP); + do_libcheck_pending(&c[1], PATH_UP); + do_libcheck_pending(&c[0], PATH_UP); for (i = 0; i < 2; i++) { assert_false(is_checker_running(&c[i])); libcheck_free(&c[i]); @@ -612,15 +638,17 @@ static void test_orphan_checker_cleanup(void **state) assert_true(list_empty(&aio_grp_list)); will_return(__wrap_io_setup, 0); for (i = 0; i < 2; i++) - do_libcheck_init(&c[i], 4096, &reqs[i]); + do_libcheck_init(&c[i], 4096, 30, &reqs[i]); aio_grp = get_aio_grp(c); + do_check_state(&c[0], 0, PATH_PENDING); return_io_getevents_none(); - do_check_state(&c[0], 0, 30, PATH_PENDING); + do_libcheck_pending(&c[0], PATH_PENDING); check_aio_grp(aio_grp, 2, 0); libcheck_free(&c[0]); check_aio_grp(aio_grp, 2, 1); + do_check_state(&c[1], 0, PATH_PENDING); return_io_getevents_nr(NULL, 2, reqs, res); - do_check_state(&c[1], 0, 2, PATH_UP); + do_libcheck_pending(&c[1], PATH_UP); check_aio_grp(aio_grp, 1, 0); libcheck_free(&c[1]); check_aio_grp(aio_grp, 0, 0); @@ -636,10 +664,11 @@ static void test_orphan_reset_cleanup(void **state) assert_true(list_empty(&aio_grp_list)); will_return(__wrap_io_setup, 0); - do_libcheck_init(&c, 4096, NULL); + do_libcheck_init(&c, 4096, 30, NULL); orphan_aio_grp = get_aio_grp(&c); + do_check_state(&c, 0, PATH_PENDING); return_io_getevents_none(); - do_check_state(&c, 0, 30, PATH_PENDING); + do_libcheck_pending(&c, PATH_PENDING); check_aio_grp(orphan_aio_grp, 1, 0); libcheck_free(&c); check_aio_grp(orphan_aio_grp, 1, 1); @@ -671,10 +700,10 @@ static void test_check_state_blksize(void **state) assert_true(list_empty(&aio_grp_list)); will_return(__wrap_io_setup, 0); for (i = 0; i < 3; i++) - do_libcheck_init(&c[i], blksize[i], &reqs[i]); + do_libcheck_init(&c[i], blksize[i], 30, &reqs[i]); for (i = 0; i < 3; i++) { return_io_getevents_nr(NULL, 1, &reqs[i], &res[i]); - do_check_state(&c[i], 1, 30, chk_state[i]); + do_check_state(&c[i], 1, chk_state[i]); } for (i = 0; i < 3; i++) { assert_false(is_checker_running(&c[i])); @@ -695,19 +724,21 @@ static void test_check_state_async(void **state) assert_true(list_empty(&aio_grp_list)); will_return(__wrap_io_setup, 0); for (i = 0; i < 257; i++) - do_libcheck_init(&c[i], 4096, &reqs[i]); + do_libcheck_init(&c[i], 4096, 30, &reqs[i]); for (i = 0; i < 256; i++) { + do_check_state(&c[i], 0, PATH_PENDING); return_io_getevents_none(); - do_check_state(&c[i], 0, 30, PATH_PENDING); + do_libcheck_pending(&c[i], PATH_PENDING); assert_true(is_checker_running(&c[i])); } + do_check_state(&c[256], 0, PATH_PENDING); return_io_getevents_nr(&full_timeout, 256, reqs, res); return_io_getevents_nr(NULL, 1, &reqs[256], &res[256]); - do_check_state(&c[256], 0, 30, PATH_UP); + do_libcheck_pending(&c[256], PATH_UP); assert_false(is_checker_running(&c[256])); libcheck_free(&c[256]); for (i = 0; i < 256; i++) { - do_check_state(&c[i], 0, 30, PATH_UP); + do_check_state(&c[i], 0, PATH_UP); assert_false(is_checker_running(&c[i])); libcheck_free(&c[i]); } From patchwork Thu Sep 12 21:49:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802714 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 717E51C1AD6 for ; Thu, 12 Sep 2024 21:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177796; cv=none; b=t8ivIQ408Z15nyaiOJET2RXdY5mxu2ZGNwj5R8i4fL8c9z2ovvNilBLxW3C1PM87ABOYwR4ep7C/lxiujoagWe4rUajSFXvq4fBMjIOjYaM7OxoqaVqT7SVwJvJRGuoVG+jvUU9Mn9KHN8+x0DyPFPXd+97Hj2Hc4P8N+u9yCrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177796; c=relaxed/simple; bh=OB3JZ1UIfv1ZzdmlPUpOVfCAjrP9Oe7Bq5b99mSvztw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U3D90knvt/R5nrrC19T0LTVYqxTyZKlQz2gxqIk47O6wwq0+36YAQE3PD9aM28e35on5+YRIGQEqDHfW8FWlYpOKUygqxVwx01OL+6HWo73TqTXpz+OHvZ98rzev8brd5rGYml43leW2e/5Ng5fY4if1tyH3papoU7lQMknrjUc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=h26G/AvE; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="h26G/AvE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177793; h=from:from: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; bh=zoXQhxfJi57TpV1HibV10MGdfraWJnozoF5K1JuvKGc=; b=h26G/AvEPiL3tV7DuWjL6Goluo6EDiIjeLzY3dGRiO+alZFG3DYEX1hV5kzcXgpAybo1OH zxesh0+0jc5ZV6UZ24ymHoXiEzrXJSqV+F19rZl3GZESLsnTrlxOU0PqeZFuSPCz4OMb1/ vdUwag/T1JWFV3G3ZA/kRZHTiv5k/WY= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-63-WxqNb94YPd2oxII5ay1fNg-1; Thu, 12 Sep 2024 17:49:52 -0400 X-MC-Unique: WxqNb94YPd2oxII5ay1fNg-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 602F919560B1; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DA6333001D17; Thu, 12 Sep 2024 21:49:50 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnng8783874 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:49 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnnO6783873; Thu, 12 Sep 2024 17:49:49 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 06/22] libmultipath: split get_state into two functions Date: Thu, 12 Sep 2024 17:49:31 -0400 Message-ID: <20240912214947.783819-7-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com get_state() is now split into start_checker(), which runs the checker but doesn't wait for async checkers, and get_state(), which returns the state from the checker, after waiting for async checkers if necessary. Signed-off-by: Benjamin Marzinski --- libmultipath/discovery.c | 22 ++++++++++++++++------ libmultipath/discovery.h | 4 +++- libmultipath/libmultipath.version | 1 + multipathd/main.c | 4 +++- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 5648be60..e0f46ff2 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -1974,30 +1974,29 @@ cciss_ioctl_pathinfo(struct path *pp) } int -get_state (struct path * pp, struct config *conf, int daemon, int oldstate) +start_checker (struct path * pp, struct config *conf, int daemon, int oldstate) { struct checker * c = &pp->checker; - int state; if (!checker_selected(c)) { if (daemon) { if (pathinfo(pp, conf, DI_SYSFS) != PATHINFO_OK) { condlog(3, "%s: couldn't get sysfs pathinfo", pp->dev); - return PATH_UNCHECKED; + return -1; } } select_detect_checker(conf, pp); select_checker(conf, pp); if (!checker_selected(c)) { condlog(3, "%s: No checker selected", pp->dev); - return PATH_UNCHECKED; + return -1; } checker_set_fd(c, pp->fd); if (checker_init(c, pp->mpp?&pp->mpp->mpcontext:NULL)) { checker_clear(c); condlog(3, "%s: checker init failed", pp->dev); - return PATH_UNCHECKED; + return -1; } } if (pp->mpp && !c->mpcontext) @@ -2008,6 +2007,15 @@ get_state (struct path * pp, struct config *conf, int daemon, int oldstate) else checker_set_sync(c); checker_check(c, oldstate); + return 0; +} + +int +get_state (struct path * pp) +{ + struct checker * c = &pp->checker; + int state; + state = checker_get_state(c); condlog(3, "%s: %s state = %s", pp->dev, checker_name(c), checker_state_name(state)); @@ -2455,7 +2463,9 @@ int pathinfo(struct path *pp, struct config *conf, int mask) if (mask & DI_CHECKER) { if (path_state == PATH_UP) { - int newstate = get_state(pp, conf, 0, path_state); + int newstate = PATH_UNCHECKED; + if (start_checker(pp, conf, 0, path_state) == 0) + newstate = get_state(pp); if (newstate != PATH_PENDING || pp->state == PATH_UNCHECKED || pp->state == PATH_WILD) diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h index c93abf1c..f3e0c618 100644 --- a/libmultipath/discovery.h +++ b/libmultipath/discovery.h @@ -34,7 +34,9 @@ int path_discovery (vector pathvec, int flag); int path_get_tpgs(struct path *pp); /* This function never returns TPGS_UNDEF */ int do_tur (char *); int path_offline (struct path *); -int get_state (struct path * pp, struct config * conf, int daemon, int state); +int start_checker(struct path * pp, struct config * conf, int daemon, + int state); +int get_state(struct path * pp); int get_vpd_sgio (int fd, int pg, int vend_id, char * str, int maxlen); int pathinfo (struct path * pp, struct config * conf, int mask); int alloc_path_with_pathinfo (struct config *conf, struct udev_device *udevice, diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version index 21d48da6..bb34d9e8 100644 --- a/libmultipath/libmultipath.version +++ b/libmultipath/libmultipath.version @@ -160,6 +160,7 @@ global: remove_wwid; replace_wwids; reset_checker_classes; + start_checker; select_all_tg_pt; select_action; select_find_multipaths_timeout; diff --git a/multipathd/main.c b/multipathd/main.c index 1b7fd04f..4f752adb 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2324,7 +2324,9 @@ check_path_state(struct path *pp) if (newstate == PATH_UP) { conf = get_multipath_config(); pthread_cleanup_push(put_multipath_config, conf); - newstate = get_state(pp, conf, 1, newstate); + newstate = PATH_UNCHECKED; + if (start_checker(pp, conf, 1, newstate) == 0) + newstate = get_state(pp); pthread_cleanup_pop(1); } else { checker_clear_message(&pp->checker); From patchwork Thu Sep 12 21:49:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802718 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 717401C1AC6 for ; Thu, 12 Sep 2024 21:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177797; cv=none; b=C23Dgjz5yAO8E8PqDY2H7n6zi7745VuhtNTTigmo3rX4+SgSBryu/vjz2C4zsc5vA7N7vsIXKdtcld9YPuzFaLgPDDGk76IFSJQtfkJuBDtJOMr20MAQnj/97kFY8XMzoUvQh2Z6Z0CYvtVBY5FLy1W+SYKug8lxNPtGmWZSwC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177797; c=relaxed/simple; bh=pB7RFvTcOCjLybdBa23bTC+Rorj0hoXsQZaJdWHP+d8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uoKsFZmMw/ZxkRS+B7LqdJJoFcYcD1qcXVX4MdrVPK3IcYYzqi39hwqd3GXrbPUMFAYNivKNWHOQnNKWayR77q3qhsIOXGQmGtFNX+nqMz5tf1DujOJ0LxN+odtCP2YnGr8njXDsIDE20AtPeCbUoXbHhlu26Hjg47adCzH2VY0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Nsr/8v2z; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Nsr/8v2z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177793; h=from:from: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; bh=V1E0W6RuS23a/FDSURsTn9ZFCbkr9dYsPDja6DWbMNE=; b=Nsr/8v2zPWWXtmUCFuhbz1jRFXij+XyMsL14/Qed1tvV2bC5id9H1iXlQ+buhBrh2LlTD/ mKcXGa33AnD1v3/rCiXbN279FkiA4Y4aWjqWuK7RkHdLX2qLy/0+lqfHVeGzgC5r4GvPko ryt750v1hPS2TdELDh49ql0nmksnMEM= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-653-xeJvg__hPg60WJ6W8YlF8g-1; Thu, 12 Sep 2024 17:49:52 -0400 X-MC-Unique: xeJvg__hPg60WJ6W8YlF8g-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 82AC31955D44; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 21C4F1956052; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnnl2783878 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:49 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnneW783877; Thu, 12 Sep 2024 17:49:49 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 07/22] libmultipath: change path_offline to path_sysfs_state Date: Thu, 12 Sep 2024 17:49:32 -0400 Message-ID: <20240912214947.783819-8-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Instead of pp->offline being a binary value, change it to show the actual result of looking at the sysfs state, and rename it to pp->sysfs_state. Also change the function name from path_offline() to path_sysfs_state(). Adapt the tests for pp->offline. This should not change how multipath currently works. pp->sysfs_state will be used in future patches. Signed-off-by: Benjamin Marzinski --- libmultipath/discovery.c | 65 ++++++++++++++++--------------- libmultipath/discovery.h | 2 +- libmultipath/libmultipath.version | 2 +- libmultipath/print.c | 2 +- libmultipath/structs.h | 2 +- multipathd/main.c | 4 +- 6 files changed, 40 insertions(+), 37 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index e0f46ff2..6ccdfa0b 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -1076,18 +1076,16 @@ detect_alua(struct path * pp) return; } - if (pp->fd == -1 || pp->offline) + if (pp->fd == -1 || pp->sysfs_state == PATH_DOWN) return; ret = get_target_port_group(pp); if (ret < 0 || get_asymmetric_access_state(pp, ret) < 0) { - int state; - if (ret == -RTPG_INQUIRY_FAILED) return; - state = path_offline(pp); - if (state != PATH_UP) + path_sysfs_state(pp); + if (pp->sysfs_state != PATH_UP) return; pp->tpgs = TPGS_NONE; @@ -1800,7 +1798,7 @@ common_sysfs_pathinfo (struct path * pp) } int -path_offline (struct path * pp) +path_sysfs_state(struct path * pp) { struct udev_device * parent; char buff[SCSI_STATE_SIZE]; @@ -1814,7 +1812,8 @@ path_offline (struct path * pp) subsys_type = "nvme"; } else { - return PATH_UP; + pp->sysfs_state = PATH_UP; + goto out; } parent = pp->udev; @@ -1827,16 +1826,18 @@ path_offline (struct path * pp) if (!parent) { condlog(1, "%s: failed to get sysfs information", pp->dev); - return PATH_REMOVED; + pp->sysfs_state = PATH_REMOVED; + goto out; } memset(buff, 0x0, SCSI_STATE_SIZE); err = sysfs_attr_get_value(parent, "state", buff, sizeof(buff)); if (!sysfs_attr_value_ok(err, sizeof(buff))) { if (err == -ENXIO) - return PATH_REMOVED; + pp->sysfs_state = PATH_REMOVED; else - return PATH_DOWN; + pp->sysfs_state = PATH_DOWN; + goto out; } @@ -1844,31 +1845,34 @@ path_offline (struct path * pp) if (pp->bus == SYSFS_BUS_SCSI) { if (!strncmp(buff, "offline", 7)) { - pp->offline = 1; - return PATH_DOWN; + pp->sysfs_state = PATH_DOWN; + goto out; + } else if (!strncmp(buff, "blocked", 7) || + !strncmp(buff, "quiesce", 7)) { + pp->sysfs_state = PATH_PENDING; + goto out; + } else if (!strncmp(buff, "running", 7)) { + pp->sysfs_state = PATH_UP; + goto out; } - pp->offline = 0; - if (!strncmp(buff, "blocked", 7) || - !strncmp(buff, "quiesce", 7)) - return PATH_PENDING; - else if (!strncmp(buff, "running", 7)) - return PATH_UP; } else if (pp->bus == SYSFS_BUS_NVME) { if (!strncmp(buff, "dead", 4)) { - pp->offline = 1; - return PATH_DOWN; + pp->sysfs_state = PATH_DOWN; + goto out; + } else if (!strncmp(buff, "new", 3) || + !strncmp(buff, "deleting", 8)) { + pp->sysfs_state = PATH_PENDING; + goto out; + } else if (!strncmp(buff, "live", 4)) { + pp->sysfs_state = PATH_UP; + goto out; } - pp->offline = 0; - if (!strncmp(buff, "new", 3) || - !strncmp(buff, "deleting", 8)) - return PATH_PENDING; - else if (!strncmp(buff, "live", 4)) - return PATH_UP; } - - return PATH_DOWN; + pp->sysfs_state = PATH_DOWN; +out: + return pp->sysfs_state; } static int @@ -2052,8 +2056,7 @@ get_prio (struct path * pp) old_prio = pp->priority; pp->priority = prio_getprio(p, pp); if (pp->priority < 0) { - /* this changes pp->offline, but why not */ - int state = path_offline(pp); + int state = path_sysfs_state(pp); if (state == PATH_DOWN || state == PATH_PENDING) { pp->priority = old_prio; @@ -2424,7 +2427,7 @@ int pathinfo(struct path *pp, struct config *conf, int mask) return PATHINFO_SKIPPED; } - path_state = path_offline(pp); + path_state = path_sysfs_state(pp); if (path_state == PATH_REMOVED) goto blank; else if (mask & DI_NOIO) { diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h index f3e0c618..7d42eae5 100644 --- a/libmultipath/discovery.h +++ b/libmultipath/discovery.h @@ -33,7 +33,7 @@ struct config; int path_discovery (vector pathvec, int flag); int path_get_tpgs(struct path *pp); /* This function never returns TPGS_UNDEF */ int do_tur (char *); -int path_offline (struct path *); +int path_sysfs_state(struct path *); int start_checker(struct path * pp, struct config * conf, int daemon, int state); int get_state(struct path * pp); diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version index bb34d9e8..6439d3a7 100644 --- a/libmultipath/libmultipath.version +++ b/libmultipath/libmultipath.version @@ -146,7 +146,7 @@ global: path_discovery; path_get_tpgs; pathinfo; - path_offline; + path_sysfs_state; print_all_paths; print_foreign_topology; print_multipath_topology__; diff --git a/libmultipath/print.c b/libmultipath/print.c index e536c5c0..00c03ace 100644 --- a/libmultipath/print.c +++ b/libmultipath/print.c @@ -514,7 +514,7 @@ snprint_offline (struct strbuf *buff, const struct path * pp) { if (!pp || !pp->mpp) return append_strbuf_str(buff, "unknown"); - else if (pp->offline) + else if (pp->sysfs_state == PATH_DOWN) return append_strbuf_str(buff, "offline"); else return append_strbuf_str(buff, "running"); diff --git a/libmultipath/structs.h b/libmultipath/structs.h index 074faca6..d8231e95 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -362,7 +362,7 @@ struct path { unsigned int tick; unsigned int pending_ticks; int bus; - int offline; + int sysfs_state; int state; int dmstate; int chkrstate; diff --git a/multipathd/main.c b/multipathd/main.c index 4f752adb..33a57041 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -96,7 +96,7 @@ void * mpath_pr_event_handler_fn (void * ); do { \ if (pp->mpp && checker_selected(&pp->checker) && \ lvl <= libmp_verbosity) { \ - if (pp->offline) \ + if (pp->sysfs_state == PATH_DOWN) \ condlog(lvl, "%s: %s - path offline", \ pp->mpp->alias, pp->dev); \ else { \ @@ -2320,7 +2320,7 @@ check_path_state(struct path *pp) int newstate; struct config *conf; - newstate = path_offline(pp); + newstate = path_sysfs_state(pp); if (newstate == PATH_UP) { conf = get_multipath_config(); pthread_cleanup_push(put_multipath_config, conf); From patchwork Thu Sep 12 21:49:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802726 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 172831C2435 for ; Thu, 12 Sep 2024 21:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177798; cv=none; b=qczvd2/0yRU+Iw6sU6KiZZOcRUE8Ff5E5R9DN+OEc0tYcfNdNsT+J+87tp9fwjOelrwzs6cMqxiOYcROP73w9nc+sW83+NpDO8DnV5wY3nB1E1PTDtpYM2TsS9w36cKqIWIBXU+GKaXvT5YZyJKCJxWLiSZvuzIniRDT5fNZIso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177798; c=relaxed/simple; bh=smN+wu34rAq4qoUCYwTNmbPA5KTag/DrsdSqQRnpuWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ypr+mCBe1Oi5LzCpTmf0dMeX0YfTBYY+LxKiNKvoa9ig8LJPHAnWcIgvh/EQxw0rtTkZXREZUBFOVCvjtJVBB1dtHK1tPwVNCCG6EIDd7VRv4Wg5bpTDGmlKbU0mQEYCtWkmYXKJK8U7irKiswb+aZ1gCIbfP2TRRblBaJRj0C8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=cFxzVeVV; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cFxzVeVV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177796; h=from:from: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; bh=NFbDgk8oB3v3MPRY+piYm83FOIpNcrF6rflRXU47oJE=; b=cFxzVeVVwEyleaXeyf0CSXbMRNnGsrrSC7aNsAjyZI4iD7Af/Nvh2k3jWo/QWJ4bM8f4Y3 gWSIab2wPE41BYdltMuag2ztYRjSiLY2m8JWbQagt+VQQ81eR901D1FCPA/XNvAwEL8GXp pEXRG2ORGl4fVYexhFd8UM3YyhaXRAA= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-jSbDrFo5PeO0_-014P-EDg-1; Thu, 12 Sep 2024 17:49:52 -0400 X-MC-Unique: jSbDrFo5PeO0_-014P-EDg-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A6ED11955F56; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3804719560B8; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnnx8783882 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:49 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnnxb783881; Thu, 12 Sep 2024 17:49:49 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 08/22] multipathd: split check_path_state into two functions Date: Thu, 12 Sep 2024 17:49:33 -0400 Message-ID: <20240912214947.783819-9-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com check_path_state() is now split into start_path_check(), which calls path_sysfs_state() and if the path is up also calls start_checker(), and get_new_state() which gets the new state from either pp->sysfs_state or get_state(). Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 33a57041..16c0531e 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2314,25 +2314,31 @@ should_skip_path(struct path *pp){ return 0; } -static int -check_path_state(struct path *pp) +static void +start_path_check(struct path *pp) { - int newstate; struct config *conf; - newstate = path_sysfs_state(pp); - if (newstate == PATH_UP) { + if (path_sysfs_state(pp) == PATH_UP) { conf = get_multipath_config(); pthread_cleanup_push(put_multipath_config, conf); - newstate = PATH_UNCHECKED; - if (start_checker(pp, conf, 1, newstate) == 0) - newstate = get_state(pp); + start_checker(pp, conf, 1, PATH_UNCHECKED); pthread_cleanup_pop(1); } else { checker_clear_message(&pp->checker); condlog(3, "%s: state %s, checker not called", - pp->dev, checker_state_name(newstate)); + pp->dev, checker_state_name(pp->sysfs_state)); } +} + +static int +get_new_state(struct path *pp) +{ + int newstate = pp->sysfs_state; + struct config *conf; + + if (newstate == PATH_UP) + newstate = get_state(pp); /* * Wait for uevent for removed paths; * some LLDDs like zfcp keep paths unavailable @@ -2413,7 +2419,8 @@ do_check_path (struct vectors * vecs, struct path * pp) pp->checkint = checkint; }; - newstate = check_path_state(pp); + start_path_check(pp); + newstate = get_new_state(pp); if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) return CHECK_PATH_SKIPPED; /* @@ -2752,7 +2759,8 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, } } - newstate = check_path_state(pp); + start_path_check(pp); + newstate = get_new_state(pp); if (!strlen(pp->wwid) && (pp->initialized == INIT_FAILED || pp->initialized == INIT_NEW) && From patchwork Thu Sep 12 21:49:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802724 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1E6C1C245D for ; Thu, 12 Sep 2024 21:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177798; cv=none; b=F1gehKWEYtCAKtpz10uHqNqhNZrMWXLg+Xlm2fLmi3w6XTfxtx8B3pwQVgMmFpXk6rnOq93dknJm/lxwBM5JJchNv6rNtCdg0npDHZpcyISy6znqGiBHJDfoTzvtNixIAsWezB6/H65A5BzAYGSOvpGdRDKtIDCe2V2ZIbrAKr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177798; c=relaxed/simple; bh=Blw0nCgWLhnWMWKVt2wzy6jr9/h6zFwr37wpNmiGqcs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZXbfxiZxOWao5QRDxm4KcfFIlAcphnOMygxPlQHZnlnVTuC2vnming6JIQlv9XRmv/w2ua6rUq1Vbk09GvmC/G1cV5s/6dX36Kzv3X7NMwqUYv26K34JsGc8IqDJNunAr7qpoft8+vqjh+b420NRoA08x2kc0BOXMvdbBIkHgcs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=QV4zPnJV; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QV4zPnJV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177795; h=from:from: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; bh=QhD8Yt5oy3YgpyM1C0TKAHGvFsZXD1j/bcSirkGBL5g=; b=QV4zPnJVMalII2CND/euSTtiQXC+/0zkG+kGYKYAOhqV/oEpaRpA/lOTDv0g4WsQYlrDvD k/HoM3LPeaEXVi23g2pQvealXh2X/hP904tVpvhxpfxZ4UNgjw7dMbVyAD/Ux5pmsV4Ua8 NsftzXfV6Aom4RjAhAAzCuuQBzmJDYs= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-57xIIO_gObm5wVRFQQhS0w-1; Thu, 12 Sep 2024 17:49:52 -0400 X-MC-Unique: 57xIIO_gObm5wVRFQQhS0w-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C39C51955F06; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7601C195609F; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnnIO783886 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:50 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnn5M783885; Thu, 12 Sep 2024 17:49:49 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 09/22] multipathd: split do_checker_path Date: Thu, 12 Sep 2024 17:49:34 -0400 Message-ID: <20240912214947.783819-10-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Move the code that starts the path checker from do_check_path() into check_path(), rename the remainder of do_check_path() to update_path_state() and call that from check_path(). Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 16c0531e..9319751e 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2396,7 +2396,7 @@ enum check_path_return { }; static int -do_check_path (struct vectors * vecs, struct path * pp) +update_path_state (struct vectors * vecs, struct path * pp) { int newstate; int new_path_up = 0; @@ -2414,12 +2414,6 @@ do_check_path (struct vectors * vecs, struct path * pp) marginal_pathgroups = conf->marginal_pathgroups; put_multipath_config(conf); - if (pp->checkint == CHECKINT_UNDEF) { - condlog(0, "%s: BUG: checkint is not set", pp->dev); - pp->checkint = checkint; - }; - - start_path_check(pp); newstate = get_new_state(pp); if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) return CHECK_PATH_SKIPPED; @@ -2639,7 +2633,7 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks, time_t start_secs) { int r; - unsigned int adjust_int, max_checkint; + unsigned int adjust_int, checkint, max_checkint; struct config *conf; time_t next_idx, goal_idx; @@ -2652,14 +2646,21 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks, return CHECK_PATH_SKIPPED; conf = get_multipath_config(); + checkint = conf->checkint; max_checkint = conf->max_checkint; adjust_int = conf->adjust_int; put_multipath_config(conf); - r = do_check_path(vecs, pp); + if (pp->checkint == CHECKINT_UNDEF) { + condlog(0, "%s: BUG: checkint is not set", pp->dev); + pp->checkint = checkint; + } + + start_path_check(pp); + r = update_path_state(vecs, pp); /* - * do_check_path() removed or orphaned the path. + * update_path() removed or orphaned the path. */ if (r == CHECK_PATH_REMOVED || !pp->mpp) return r; From patchwork Thu Sep 12 21:49:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802716 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 369721C2306 for ; Thu, 12 Sep 2024 21:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177796; cv=none; b=RdObIbC0YL24qcP+Yh2wLYKtq/Met7WKJ/s0NyFlber/iPnjzP6yT2YGopw9SYrWj4FYCPEyamkj/sczEGwYnFJ1rNvnX+8XxLSnHTYP9JyMztY5vpszqdZp/wrRbi3VKZyQZpj93uyCoprd18F9AOX79EpqsBd7dAl/QroamPU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177796; c=relaxed/simple; bh=lIHZa46l+fVmxWH1Q9g2bjtL3LGgJPU1EyzSPRCpukc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FMrRnDRSjvGHfRfO9rgYZdBs9Jd3XBKMhg212GBczWL6Iy0oRKQttDdIv0/eoK5uG56w5rYSkTgKQAoQyZrlGWcegGgMVYnyZ+KGucJIk3OjcTZR6LB96Jo+yBoGSSnMdAu25vrb/W9CqfHT6u70b+BPrydxvvjzjn+cGG2V7ns= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dgfmM8ji; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dgfmM8ji" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177794; h=from:from: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; bh=lNW+vKsnviMXzfCwBVqMLMtLSeJ6VBSHg6WHCreLcOg=; b=dgfmM8jisv5xjJjKQ63Ub12gaU20fPTbPNzZAbGHy7cbOcJ5mzlLJZ0PcrbzmyAYkn6Viz BvAqd4G47S5JsEFBMAtlozE1fp7bUCLwvIFX2FTs77ToVbGDCkFuugkVb/JqDasq08AtUc BOeoFCkQVGxQ9cki94KlEYBYSe0p/LA= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-159-pbCR2WnaPKOqcr1XXOYJrg-1; Thu, 12 Sep 2024 17:49:52 -0400 X-MC-Unique: pbCR2WnaPKOqcr1XXOYJrg-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F37141955F2C; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6417E19560AA; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnohV783890 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:50 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnoYF783889; Thu, 12 Sep 2024 17:49:50 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 10/22] multipathd: split check_path into two functions Date: Thu, 12 Sep 2024 17:49:35 -0400 Message-ID: <20240912214947.783819-11-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Split out the code that updates a path's state and sets up the next check time into its own function, update_path(). Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 9319751e..8bfb166d 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2390,6 +2390,7 @@ sync_mpp(struct vectors * vecs, struct multipath *mpp, unsigned int ticks) } enum check_path_return { + CHECK_PATH_STARTED, CHECK_PATH_CHECKED, CHECK_PATH_SKIPPED, CHECK_PATH_REMOVED, @@ -2629,13 +2630,10 @@ update_path_state (struct vectors * vecs, struct path * pp) } static int -check_path (struct vectors * vecs, struct path * pp, unsigned int ticks, - time_t start_secs) +check_path (struct path * pp, unsigned int ticks) { - int r; - unsigned int adjust_int, checkint, max_checkint; + unsigned int checkint; struct config *conf; - time_t next_idx, goal_idx; if (pp->initialized == INIT_REMOVED) return CHECK_PATH_SKIPPED; @@ -2647,8 +2645,6 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks, conf = get_multipath_config(); checkint = conf->checkint; - max_checkint = conf->max_checkint; - adjust_int = conf->adjust_int; put_multipath_config(conf); if (pp->checkint == CHECKINT_UNDEF) { @@ -2657,6 +2653,17 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks, } start_path_check(pp); + return CHECK_PATH_STARTED; +} + +static int +update_path(struct vectors * vecs, struct path * pp, time_t start_secs) +{ + int r; + unsigned int adjust_int, max_checkint; + struct config *conf; + time_t next_idx, goal_idx; + r = update_path_state(vecs, pp); /* @@ -2685,6 +2692,10 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks, if (pp->tick == 1) return r; + conf = get_multipath_config(); + max_checkint = conf->max_checkint; + adjust_int = conf->adjust_int; + put_multipath_config(conf); /* * every mpp has a goal_idx in the range of * 0 <= goal_idx < conf->max_checkint @@ -2818,8 +2829,10 @@ check_paths(struct vectors *vecs, unsigned int ticks, int *num_paths_p) if (!pp->mpp || pp->is_checked) continue; pp->is_checked = true; - rc = check_path(vecs, pp, ticks, - start_time.tv_sec); + rc = check_path(pp, ticks); + if (rc == CHECK_PATH_STARTED) + rc = update_path(vecs, pp, + start_time.tv_sec); if (rc == CHECK_PATH_CHECKED) (*num_paths_p)++; if (++paths_checked % 128 == 0) From patchwork Thu Sep 12 21:49:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802717 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 904061C230A for ; Thu, 12 Sep 2024 21:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177797; cv=none; b=HbifBIooLw6lf0HUtSBzN1TrqW4QL+CulAFZVY9+Io7WTEu6iOc7yvwRUU+dQpFPQNN+WW2GjBWarRFXJDP61AhwC3CRNkojuwN5k+XMjUhKR9MOy7vrxu0JofOH9KumT0HEAFcW9Q2t/w1Q+EpaYE+0p+ABugnXGNAt7Ir8Y4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177797; c=relaxed/simple; bh=M7Ks5a71QDUir1ROh+1SuByoBTc0ThXPTn7NNlORqcw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KiXVSyzG4F5CeKnqeQa+3uIB3dOKFJWFUPeqfAOPELI4fiCpinfTd3m8gJZUN3aD6nWaAr0Od/Xk7myWzNBy4mDnH6McHmE42EE65KRJK49WMHeImlbXbtl3xb7dqZE97sGzubnS56+1pdmL7KUavnMvn4GW6BV2cD57gmIuAFI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ihhf8frU; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ihhf8frU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177794; h=from:from: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; bh=oxg1C3U5wSMVff0orqU2t3FNL/fWpy3LM88dts9YQ70=; b=Ihhf8frUhfVne1w0x/OJhT2f0uUgGmjeQFLmd1euJP96J4eFxLNmOQtITTFrXpCMR9JdIn Qo6VuEl2zuS9uN+I69Q9HugV84NPCg8lQR5rQOtqLU4hZHDNKLK1Skf1h5ufdLGbfxen16 hL3QqS5AHJDXyBMM+Jux4ihDs9CX8Ig= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-512-9DLOIw96O8iOOkI35whOTQ-1; Thu, 12 Sep 2024 17:49:53 -0400 X-MC-Unique: 9DLOIw96O8iOOkI35whOTQ-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4AB4E19560B5; Thu, 12 Sep 2024 21:49:52 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A9C4219560B7; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnowk783894 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:50 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnoWO783893; Thu, 12 Sep 2024 17:49:50 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 11/22] multipathd: split handle_uninitialized_path into two functions Date: Thu, 12 Sep 2024 17:49:36 -0400 Message-ID: <20240912214947.783819-12-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Split handle_uninitialized_path() into check_uninitialized_path, which handles udev retriggers for INIT_MISSING_UDEV paths and starts the path checker for INIT_FAILED and INIT_NEW paths, and update_uninitialized_path() which gets the path checker result and reruns pathinfo if the path is up. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 8bfb166d..45d40559 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2718,13 +2718,10 @@ update_path(struct vectors * vecs, struct path * pp, time_t start_secs) } static int -handle_uninitialized_path(struct vectors * vecs, struct path * pp, - unsigned int ticks) +check_uninitialized_path(struct path * pp, unsigned int ticks) { - int newstate; int retrigger_tries; struct config *conf; - int ret; if (pp->initialized != INIT_NEW && pp->initialized != INIT_FAILED && pp->initialized != INIT_MISSING_UDEV) @@ -2772,6 +2769,15 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, } start_path_check(pp); + return CHECK_PATH_STARTED; +} + +static int +update_uninitialized_path(struct vectors * vecs, struct path * pp) +{ + int newstate, ret; + struct config *conf; + newstate = get_new_state(pp); if (!strlen(pp->wwid) && @@ -2862,7 +2868,9 @@ next_mpp: continue; pp->is_checked = true; - rc = handle_uninitialized_path(vecs, pp, ticks); + rc = check_uninitialized_path(pp, ticks); + if (rc == CHECK_PATH_STARTED) + rc = update_uninitialized_path(vecs, pp); if (rc == CHECK_PATH_REMOVED) i--; else if (rc == CHECK_PATH_CHECKED) From patchwork Thu Sep 12 21:49:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802733 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AE0AA5F for ; Thu, 12 Sep 2024 21:50:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177853; cv=none; b=Q5hdu+XaDhdAgsHfh+xSLRP7anBhBsqIxSUD7c9gPHoa5GzS4v/Ifly+5fH24mnIRq9P0QnQAh/r8Myx7LlaTrIL2VkVluw8HqVJZTDXdfmQpuJEZUcEXiBFBXeUmLBcHtfvxNC2jA2uwA43dfcbb9PDvaLoDpnLs8YqAF4xFrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177853; c=relaxed/simple; bh=zXdyT0MEdD7O/I9l7zNSmAF7f87G9yXE/ZnfBPsvgQ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oBnecuHBTWri6xySKIutLs09W9M0zOLqk4OaxSmQXLfUwE+GTDPwcw/I2aai/7ulWX+Hd7Iw6bPgeevD/BcvfkedQQEmpoNFi01tfh/z05pwgW28NkGOZAZjWFPvrNPOdwEY+e36q8lf+orCQx3jT2zwqElvmPmnfXzy9X3lBNI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SFbztTRT; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SFbztTRT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177851; h=from:from: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; bh=O/B/N4wI+Yf+gIJsmNzdZQcoRS1s3MNByHLVgSCAt50=; b=SFbztTRTGyKbw5vT0JHs6oqv7vhBnFDzSUKTjfqMKQ5/29q/x1pAj8wCT8FMBIU88wwuQ3 A0aZquU9EygwBaV7ccVyAiYpm6I8VbDZslfCKYC+L7ZnJKlnppMQdD54avZCtu4CA+OkWu Tnbvur4MerfWPzxda+uA5y+L4kMUWfk= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-csnj8K6zP3m1Vtzr_a8BkQ-1; Thu, 12 Sep 2024 17:49:53 -0400 X-MC-Unique: csnj8K6zP3m1Vtzr_a8BkQ-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3B4961956089; Thu, 12 Sep 2024 21:49:52 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B2D961956052; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnoZb783898 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:50 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnoSm783897; Thu, 12 Sep 2024 17:49:50 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 12/22] multipathd: split check_paths into two functions Date: Thu, 12 Sep 2024 17:49:37 -0400 Message-ID: <20240912214947.783819-13-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Instead of checking and updating each path, the checkerloop now starts the checkers on all the paths in check_paths(), and then goes back and updates all the paths in update_paths(). Since the async checkers use an absolute time to wait for before returning PATH_PENDING, only one checker actually needs to be waited for in update_paths(). The rest will already have reached their timeout when update_path() is called for them. The check_paths() and update_paths() loop over the pathvec instead of looping through the multipath device paths to avoid having to restart checking of the device paths when the multipath device needs to be resynced while updating the paths. Signed-off-by: Benjamin Marzinski --- libmultipath/structs.h | 10 +++- multipathd/main.c | 105 +++++++++++++++++++---------------------- 2 files changed, 57 insertions(+), 58 deletions(-) diff --git a/libmultipath/structs.h b/libmultipath/structs.h index d8231e95..af8e31e9 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -314,6 +314,14 @@ enum recheck_wwid_states { RECHECK_WWID_ON = YNU_YES, }; +enum check_path_states { + CHECK_PATH_UNCHECKED, + CHECK_PATH_STARTED, + CHECK_PATH_CHECKED, + CHECK_PATH_SKIPPED, + CHECK_PATH_REMOVED, +}; + struct vpd_vendor_page { int pg; const char *name; @@ -395,7 +403,7 @@ struct path { int fast_io_fail; unsigned int dev_loss; int eh_deadline; - bool is_checked; + enum check_path_states is_checked; bool can_use_env_uid; unsigned int checker_timeout; /* configlet pointers */ diff --git a/multipathd/main.c b/multipathd/main.c index 45d40559..9519b6c5 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2389,13 +2389,6 @@ sync_mpp(struct vectors * vecs, struct multipath *mpp, unsigned int ticks) do_sync_mpp(vecs, mpp); } -enum check_path_return { - CHECK_PATH_STARTED, - CHECK_PATH_CHECKED, - CHECK_PATH_SKIPPED, - CHECK_PATH_REMOVED, -}; - static int update_path_state (struct vectors * vecs, struct path * pp) { @@ -2735,6 +2728,7 @@ check_uninitialized_path(struct path * pp, unsigned int ticks) conf = get_multipath_config(); retrigger_tries = conf->retrigger_tries; pp->tick = conf->max_checkint; + pp->checkint = conf->checkint; put_multipath_config(conf); if (pp->initialized == INIT_MISSING_UDEV) { @@ -2778,6 +2772,10 @@ update_uninitialized_path(struct vectors * vecs, struct path * pp) int newstate, ret; struct config *conf; + if (pp->initialized != INIT_NEW && pp->initialized != INIT_FAILED && + pp->initialized != INIT_MISSING_UDEV) + return CHECK_PATH_SKIPPED; + newstate = get_new_state(pp); if (!strlen(pp->wwid) && @@ -2807,80 +2805,69 @@ update_uninitialized_path(struct vectors * vecs, struct path * pp) enum checker_state { CHECKER_STARTING, - CHECKER_RUNNING, + CHECKER_CHECKING_PATHS, + CHECKER_UPDATING_PATHS, CHECKER_FINISHED, }; static enum checker_state -check_paths(struct vectors *vecs, unsigned int ticks, int *num_paths_p) +check_paths(struct vectors *vecs, unsigned int ticks) { unsigned int paths_checked = 0; struct timespec diff_time, start_time, end_time; - struct multipath *mpp; struct path *pp; - int i, rc; + int i; get_monotonic_time(&start_time); - vector_foreach_slot(vecs->mpvec, mpp, i) { - struct pathgroup *pgp; - struct path *pp; - int j, k; - bool check_for_waiters = false; - /* maps can be rechecked, so this is not always 0 */ - int synced_count = mpp->synced_count; - - vector_foreach_slot (mpp->pg, pgp, j) { - vector_foreach_slot (pgp->paths, pp, k) { - if (!pp->mpp || pp->is_checked) - continue; - pp->is_checked = true; - rc = check_path(pp, ticks); - if (rc == CHECK_PATH_STARTED) - rc = update_path(vecs, pp, - start_time.tv_sec); - if (rc == CHECK_PATH_CHECKED) - (*num_paths_p)++; - if (++paths_checked % 128 == 0) - check_for_waiters = true; - /* - * mpp has been removed or resynced. Path may - * have been removed. - */ - if (VECTOR_SLOT(vecs->mpvec, i) != mpp || - synced_count != mpp->synced_count) { - i--; - goto next_mpp; - } - } - } -next_mpp: - if (check_for_waiters && + vector_foreach_slot(vecs->pathvec, pp, i) { + if (pp->is_checked != CHECK_PATH_UNCHECKED) + continue; + if (pp->mpp) + pp->is_checked = check_path(pp, ticks); + else + pp->is_checked = check_uninitialized_path(pp, ticks); + if (++paths_checked % 128 == 0 && (lock_has_waiters(&vecs->lock) || waiting_clients())) { get_monotonic_time(&end_time); timespecsub(&end_time, &start_time, &diff_time); if (diff_time.tv_sec > 0) - return CHECKER_RUNNING; + return CHECKER_CHECKING_PATHS; } } + return CHECKER_UPDATING_PATHS; +} + +static enum checker_state +update_paths(struct vectors *vecs, int *num_paths_p, time_t start_secs) +{ + unsigned int paths_checked = 0; + struct timespec diff_time, start_time, end_time; + struct path *pp; + int i, rc; + + get_monotonic_time(&start_time); + vector_foreach_slot(vecs->pathvec, pp, i) { - if (pp->mpp || pp->is_checked) + if (pp->is_checked != CHECK_PATH_STARTED) continue; - pp->is_checked = true; - - rc = check_uninitialized_path(pp, ticks); - if (rc == CHECK_PATH_STARTED) + if (pp->mpp) + rc = update_path(vecs, pp, start_secs); + else rc = update_uninitialized_path(vecs, pp); if (rc == CHECK_PATH_REMOVED) i--; - else if (rc == CHECK_PATH_CHECKED) - (*num_paths_p)++; + else { + pp->is_checked = rc; + if (rc == CHECK_PATH_CHECKED) + (*num_paths_p)++; + } if (++paths_checked % 128 == 0 && (lock_has_waiters(&vecs->lock) || waiting_clients())) { get_monotonic_time(&end_time); timespecsub(&end_time, &start_time, &diff_time); if (diff_time.tv_sec > 0) - return CHECKER_RUNNING; + return CHECKER_UPDATING_PATHS; } } return CHECKER_FINISHED; @@ -2948,10 +2935,14 @@ checkerloop (void *ap) vector_foreach_slot(vecs->mpvec, mpp, i) sync_mpp(vecs, mpp, ticks); vector_foreach_slot(vecs->pathvec, pp, i) - pp->is_checked = false; - checker_state = CHECKER_RUNNING; + pp->is_checked = CHECK_PATH_UNCHECKED; + checker_state = CHECKER_CHECKING_PATHS; } - checker_state = check_paths(vecs, ticks, &num_paths); + if (checker_state == CHECKER_CHECKING_PATHS) + checker_state = check_paths(vecs, ticks); + if (checker_state == CHECKER_UPDATING_PATHS) + checker_state = update_paths(vecs, &num_paths, + start_time.tv_sec); lock_cleanup_pop(vecs->lock); if (checker_state != CHECKER_FINISHED) { /* Yield to waiters */ From patchwork Thu Sep 12 21:49:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802719 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B04351C2312 for ; Thu, 12 Sep 2024 21:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177797; cv=none; b=Ha781uo7n032yglw/c93KRL9mjB5Mb/wISk7UcWdGAEDjBUjzKvQYox4Y52hNs4cXOYUFpyVT5SOljSThCHLNmMBF6I4f57y7h9nr+90eiAbULNEEcoWBv9G5J/t1dPqI0+68xfP4f4lhMW97URdIR7kDP4lOMpiD0O5lMc+xzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177797; c=relaxed/simple; bh=DDfnlkaZBqE2LpxfKNDfXX5jqzbipAmDkcK/YcyUhcA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PyjzWliXWaMvtv3MYWB9MRjTmSSkU2JxoYrRG8KvWq7g1kTczFJ6DllbkHrdJa8FhGzTrDWfNMdrj7Umvh9therDrpbgyUvy60JNu3wFxcmba+KP4OPc+qn9qtxvOQMe0lHkjZCvLKMmJk1l9sDnvQ5WN4GwEze44zDSpaE9BUI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=i2FHOlUT; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i2FHOlUT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177794; h=from:from: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; bh=erxQeCT3mdSDpilKavOeZS/q3ySPGvf3uapierN7GHk=; b=i2FHOlUTn6wncugdbNFoGzep7rxQJ1/mSA8Seu90LKgVf5amN5mlq3vInlmiZ5JU4fiO9A l/hYvpVpbm8JNAV9ZfMUeH55CPgjZGuNguKRAhCkwKhEyw+T6rEJqbcfhyGtaRxDQS/pJH bmf2X59CT09J3yQovX4tT6SR4HIBOo0= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-hyObDgQyPEGxcSsq1G9iEA-1; Thu, 12 Sep 2024 17:49:53 -0400 X-MC-Unique: hyObDgQyPEGxcSsq1G9iEA-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6F2CA19560B8; Thu, 12 Sep 2024 21:49:52 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 048D11956096; Thu, 12 Sep 2024 21:49:51 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnoCI783902 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:50 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnoR6783901; Thu, 12 Sep 2024 17:49:50 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 13/22] multipathd: fix "fail path" and "reinstate path" commands Date: Thu, 12 Sep 2024 17:49:38 -0400 Message-ID: <20240912214947.783819-14-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Now that multipathd can drop the vecs lock and sleep in-between when the checker runs and when the path gets updated, it is possible for the user to either fail or reinstate the path in this window. If a path gets manually failed in the window between when the checker starts and the path is updated, the checker will have already been started, on the path, and if multipathd read the results like normal, it could simply reinstate the path. To avoid this, when a path checker is disabled, the checker path_state and message are updated, just like they are when checker_check() is run on a disabled path, so that when checker_get_state() is called, it will always return the same results for a disabled checker, regardless of when it was disabled. Reinstating the path doesn't cause many problems, but still can be improved. Since the checker was disabled when it would have been started, it didn't run during this cycle, only the kernel state will get updated. The rest of the path update changes won't happen until the next time the checker runs. This is the case regardless of whether or not the path was reinstated in the window between when the checker starts and the path is updated. To make reinstated paths get updated sooner, pp->tick is now set to 1 when the path is reinstated. Signed-off-by: Benjamin Marzinski --- libmultipath/checkers.c | 2 ++ multipathd/cli_handlers.c | 1 + 2 files changed, 3 insertions(+) diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c index ce3e48bd..f3e98352 100644 --- a/libmultipath/checkers.c +++ b/libmultipath/checkers.c @@ -251,6 +251,8 @@ void checker_disable (struct checker * c) if (!c) return; c->disable = 1; + c->msgid = CHECKER_MSGID_DISABLED; + c->path_state = PATH_UNCHECKED; } int checker_init (struct checker * c, void ** mpctxt_addr) diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 42603544..184c3f91 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -1108,6 +1108,7 @@ cli_reinstate(void * v, struct strbuf *reply, void * data) pp->mpp->alias, pp->dev_t); checker_enable(&pp->checker); + pp->tick = 1; return dm_reinstate_path(pp->mpp->alias, pp->dev_t); } From patchwork Thu Sep 12 21:49:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802731 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C72F81C2DC6 for ; Thu, 12 Sep 2024 21:49:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177800; cv=none; b=PmXbpDNc+BLcz2vax2FupdviWN1Pe3Q80t7h2L52jpFjVPKOh/i4OKS+axfSB1sNUjxM3N9KlFU5u8e1i2NOl817mrMCZ7cL+Ka/QjfQqTqPnfLR7pXlttrbhDO+YleQ2BxnxqNumc3xnH1cD0ta0tQlfLATLT6VnXS71yM6HUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177800; c=relaxed/simple; bh=Fl6VC3BoQB8azv6QD2y91I6l3L+mwdlq6YS6nDY+yFs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QkEsAdiKSVLJ3lYAKmHOmGbbwaq/wOsCLyTUkTRtWbWH1SOugNI46m5jtmQsRK+zhKXyQ52uf18bBlrFvD8lq+nhhn4d5C24Q57QmWW0XepORRyQpwBoK2eP99kYD0PWjgfZhjuyieuCRgJsdFzjElQm2B2230cM3RPNG5fR4gg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Md/Unbdl; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Md/Unbdl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177796; h=from:from: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; bh=RG+0/fvmOk/1FDx7VOybO3KvD/kxhaNATCSWSCMZqEM=; b=Md/Unbdl4ao2Dq74Uihb0MfCuEH9bxcarODNQLp2GxHR8Ztlw6QBGzUHI8ssUzWCP+nzR9 iTNbhUw4bvOaptAe4mURY6elXAKxgX/lkF8Y9qUwqH4Xsc2Gwg4CH/1QxeTNbmc+DLZ5WI 0oYep9IOilL4z2VBTKKvkwPLGqbZCKo= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-cIQFMsH0MXSJKTu1yurHJQ-1; Thu, 12 Sep 2024 17:49:53 -0400 X-MC-Unique: cIQFMsH0MXSJKTu1yurHJQ-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6DD8E1955D4B; Thu, 12 Sep 2024 21:49:52 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2ADF31955DC9; Thu, 12 Sep 2024 21:49:52 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnob0783906 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:50 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLno7j783905; Thu, 12 Sep 2024 17:49:50 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 14/22] multipathd: update priority once after updating all paths Date: Thu, 12 Sep 2024 17:49:39 -0400 Message-ID: <20240912214947.783819-15-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Instead of updating the path priorities and possibly reloading the multipath device when each path is updated, wait till all paths have been updated, and then go through the multipath devices updating the priorities once, reloading if necessary. Signed-off-by: Benjamin Marzinski --- libmultipath/structs.h | 9 +++ multipathd/main.c | 169 ++++++++++++++++++++++++++--------------- 2 files changed, 118 insertions(+), 60 deletions(-) diff --git a/libmultipath/structs.h b/libmultipath/structs.h index af8e31e9..1f531d30 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -318,6 +318,7 @@ enum check_path_states { CHECK_PATH_UNCHECKED, CHECK_PATH_STARTED, CHECK_PATH_CHECKED, + CHECK_PATH_NEW_UP, CHECK_PATH_SKIPPED, CHECK_PATH_REMOVED, }; @@ -421,6 +422,13 @@ enum prflag_value { PRFLAG_SET, }; +enum prio_update_type { + PRIO_UPDATE_NONE, + PRIO_UPDATE_NORMAL, + PRIO_UPDATE_NEW_PATH, + PRIO_UPDATE_MARGINAL, +}; + struct multipath { char wwid[WWID_SIZE]; char alias_old[WWID_SIZE]; @@ -464,6 +472,7 @@ struct multipath { int queue_mode; unsigned int sync_tick; int synced_count; + enum prio_update_type prio_update; uid_t uid; gid_t gid; mode_t mode; diff --git a/multipathd/main.c b/multipathd/main.c index 9519b6c5..3cda3c18 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1996,15 +1996,13 @@ mpvec_garbage_collector (struct vectors * vecs) * best pathgroup, and this is the first path in the pathgroup to come back * up, then switch to this pathgroup */ static int -followover_should_failback(struct path * pp) +do_followover_should_failback(struct path * pp) { struct pathgroup * pgp; struct path *pp1; int i; - if (pp->mpp->pgfailback != -FAILBACK_FOLLOWOVER || - !pp->mpp->pg || !pp->pgindex || - pp->pgindex != pp->mpp->bestpg) + if (!pp->pgindex || pp->pgindex != pp->mpp->bestpg) return 0; pgp = VECTOR_SLOT(pp->mpp->pg, pp->pgindex - 1); @@ -2017,6 +2015,26 @@ followover_should_failback(struct path * pp) return 1; } +static int +followover_should_failback(struct multipath *mpp) +{ + struct path *pp; + struct pathgroup * pgp; + int i, j; + + if (mpp->pgfailback != -FAILBACK_FOLLOWOVER || !mpp->pg) + return 0; + + vector_foreach_slot (mpp->pg, pgp, i) { + vector_foreach_slot (pgp->paths, pp, j) { + if (pp->is_checked == CHECK_PATH_NEW_UP && + do_followover_should_failback(pp)) + return 1; + } + } + return 0; +} + static void missing_uev_wait_tick(struct vectors *vecs) { @@ -2132,41 +2150,53 @@ partial_retrigger_tick(vector pathvec) } } -static int update_prio(struct path *pp, int force_refresh_all) +static bool update_prio(struct multipath *mpp, bool refresh_all) { int oldpriority; - struct path *pp1; + struct path *pp; struct pathgroup * pgp; - int i, j, changed = 0; + int i, j; + bool changed = false; + bool skipped_path = false; struct config *conf; - oldpriority = pp->priority; - if (pp->state != PATH_DOWN) { - conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); - pathinfo(pp, conf, DI_PRIO); - pthread_cleanup_pop(1); + vector_foreach_slot (mpp->pg, pgp, i) { + vector_foreach_slot (pgp->paths, pp, j) { + if (pp->state == PATH_DOWN) + continue; + if (!refresh_all && + pp->is_checked != CHECK_PATH_CHECKED) { + skipped_path = true; + continue; + } + oldpriority = pp->priority; + conf = get_multipath_config(); + pthread_cleanup_push(put_multipath_config, conf); + pathinfo(pp, conf, DI_PRIO); + pthread_cleanup_pop(1); + if (pp->priority != oldpriority) + changed = true; + } } - - if (pp->priority != oldpriority) - changed = 1; - else if (!force_refresh_all) - return 0; - - vector_foreach_slot (pp->mpp->pg, pgp, i) { - vector_foreach_slot (pgp->paths, pp1, j) { - if (pp1 == pp || pp1->state == PATH_DOWN) + if (!changed || !skipped_path) + return changed; + /* + * If a path changed priorities, refresh the priorities of any + * paths we skipped + */ + vector_foreach_slot (mpp->pg, pgp, i) { + vector_foreach_slot (pgp->paths, pp, j) { + if (pp->state == PATH_DOWN) + continue; + if (pp->is_checked == CHECK_PATH_CHECKED) continue; - oldpriority = pp1->priority; conf = get_multipath_config(); pthread_cleanup_push(put_multipath_config, conf); - pathinfo(pp1, conf, DI_PRIO); + pathinfo(pp, conf, DI_PRIO); pthread_cleanup_pop(1); - if (pp1->priority != oldpriority) - changed = 1; } } - return changed; + return true; } static int reload_map(struct vectors *vecs, struct multipath *mpp, @@ -2393,14 +2423,12 @@ static int update_path_state (struct vectors * vecs, struct path * pp) { int newstate; - int new_path_up = 0; int chkr_new_path_up = 0; int disable_reinstate = 0; int oldchkrstate = pp->chkrstate; unsigned int checkint, max_checkint; struct config *conf; - int marginal_pathgroups, marginal_changed = 0; - bool need_reload; + int marginal_pathgroups; conf = get_multipath_config(); checkint = conf->checkint; @@ -2462,7 +2490,7 @@ update_path_state (struct vectors * vecs, struct path * pp) } if (!pp->marginal) { pp->marginal = 1; - marginal_changed = 1; + pp->mpp->prio_update = PRIO_UPDATE_MARGINAL; } } else { if (pp->marginal || pp->state == PATH_DELAYED) @@ -2470,7 +2498,7 @@ update_path_state (struct vectors * vecs, struct path * pp) pp->dev); if (marginal_pathgroups && pp->marginal) { pp->marginal = 0; - marginal_changed = 1; + pp->mpp->prio_update = PRIO_UPDATE_MARGINAL; } } } @@ -2537,7 +2565,8 @@ update_path_state (struct vectors * vecs, struct path * pp) */ if (!disable_reinstate) reinstate_path(pp); - new_path_up = 1; + if (pp->mpp->prio_update != PRIO_UPDATE_MARGINAL) + pp->mpp->prio_update = PRIO_UPDATE_NEW_PATH; if (oldchkrstate != PATH_UP && oldchkrstate != PATH_GHOST) chkr_new_path_up = 1; @@ -2588,38 +2617,48 @@ update_path_state (struct vectors * vecs, struct path * pp) LOG_MSG(2, pp); } } - + if (pp->mpp->prio_update == PRIO_UPDATE_NONE && + (newstate == PATH_UP || newstate == PATH_GHOST)) + pp->mpp->prio_update = PRIO_UPDATE_NORMAL; pp->state = newstate; + return chkr_new_path_up ? CHECK_PATH_NEW_UP : CHECK_PATH_CHECKED; +} - if (pp->mpp->wait_for_udev) - return CHECK_PATH_CHECKED; - /* - * path prio refreshing - */ - condlog(4, "path prio refresh"); - - if (marginal_changed) { - update_prio(pp, 1); - reload_and_sync_map(pp->mpp, vecs); - } else if (update_prio(pp, new_path_up) && - pp->mpp->pgpolicyfn == (pgpolicyfn *)group_by_prio && - pp->mpp->pgfailback == -FAILBACK_IMMEDIATE) { +static int +update_mpp_prio(struct vectors *vecs, struct multipath *mpp) +{ + bool need_reload, changed; + enum prio_update_type prio_update = mpp->prio_update; + mpp->prio_update = PRIO_UPDATE_NONE; + + if (mpp->wait_for_udev || prio_update == PRIO_UPDATE_NONE) + return 0; + condlog(4, "prio refresh"); + + changed = update_prio(mpp, prio_update != PRIO_UPDATE_NORMAL); + if (prio_update == PRIO_UPDATE_MARGINAL) + return reload_and_sync_map(mpp, vecs); + if (changed && mpp->pgpolicyfn == (pgpolicyfn *)group_by_prio && + mpp->pgfailback == -FAILBACK_IMMEDIATE) { condlog(2, "%s: path priorities changed. reloading", - pp->mpp->alias); - reload_and_sync_map(pp->mpp, vecs); - } else if (need_switch_pathgroup(pp->mpp, &need_reload)) { - if (pp->mpp->pgfailback > 0 && - (new_path_up || pp->mpp->failback_tick <= 0)) - pp->mpp->failback_tick = pp->mpp->pgfailback + 1; - else if (pp->mpp->pgfailback == -FAILBACK_IMMEDIATE || - (chkr_new_path_up && followover_should_failback(pp))) { + mpp->alias); + return reload_and_sync_map(mpp, vecs); + } + if (need_switch_pathgroup(mpp, &need_reload)) { + if (mpp->pgfailback > 0 && + (prio_update == PRIO_UPDATE_NEW_PATH || + mpp->failback_tick <= 0)) + mpp->failback_tick = mpp->pgfailback + 1; + else if (mpp->pgfailback == -FAILBACK_IMMEDIATE || + (prio_update == PRIO_UPDATE_NEW_PATH && + followover_should_failback(mpp))) { if (need_reload) - reload_and_sync_map(pp->mpp, vecs); + return reload_and_sync_map(mpp, vecs); else - switch_pathgroup(pp->mpp); + switch_pathgroup(mpp); } } - return CHECK_PATH_CHECKED; + return 0; } static int @@ -2859,7 +2898,7 @@ update_paths(struct vectors *vecs, int *num_paths_p, time_t start_secs) i--; else { pp->is_checked = rc; - if (rc == CHECK_PATH_CHECKED) + if (rc == CHECK_PATH_CHECKED || rc == CHECK_PATH_NEW_UP) (*num_paths_p)++; } if (++paths_checked % 128 == 0 && @@ -2932,8 +2971,10 @@ checkerloop (void *ap) vector_foreach_slot(vecs->mpvec, mpp, i) mpp->synced_count = 0; if (checker_state == CHECKER_STARTING) { - vector_foreach_slot(vecs->mpvec, mpp, i) + vector_foreach_slot(vecs->mpvec, mpp, i) { sync_mpp(vecs, mpp, ticks); + mpp->prio_update = PRIO_UPDATE_NONE; + } vector_foreach_slot(vecs->pathvec, pp, i) pp->is_checked = CHECK_PATH_UNCHECKED; checker_state = CHECKER_CHECKING_PATHS; @@ -2943,6 +2984,14 @@ checkerloop (void *ap) if (checker_state == CHECKER_UPDATING_PATHS) checker_state = update_paths(vecs, &num_paths, start_time.tv_sec); + if (checker_state == CHECKER_FINISHED) { + vector_foreach_slot(vecs->mpvec, mpp, i) { + if (update_mpp_prio(vecs, mpp) == 2) { + /* multipath device deleted */ + i--; + } + } + } lock_cleanup_pop(vecs->lock); if (checker_state != CHECKER_FINISHED) { /* Yield to waiters */ From patchwork Thu Sep 12 21:49:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802728 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12E421C233E for ; Thu, 12 Sep 2024 21:49:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177799; cv=none; b=fJzm6koxWSC51W4fybvZu9hhPJjcaRxg49KjKWHSdW+URmS/qNAMQmbWdw8niLngUiAGbxr8F4xXhvqVHszmypQ/j4Gs93DT0bGjDrRHz+n77V7Rv9M8R2a800X2F8gH9j1bXGqeMNppjRd6D/xAFpgjOnCB+61HFxQbeZBnJZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177799; c=relaxed/simple; bh=nBAbawU13rHbn0wEyOtko4v85E22fr8wXL99qhRkffA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kRddQdygAaGf9yvUvmBV84cOupLx8qvh+6w0WNe18I27e5RgiAFKabAKlcS0FIQKvMzVGiJ+9ejy+8ulYt9/xYeXnJxwFBXs3OzX+y3KAezIiULeZSzsX8Z8ktI76cnFN2xsp3uEdmR2WfpAvWvaKKkR6smwdPoPwsgDVKwfr9M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=HI06eQPX; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HI06eQPX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177796; h=from:from: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; bh=6QypsCPFPC6HaEOH3iL+JGWsgJ69mI4wi8sgy5TpmlI=; b=HI06eQPXebzaa1oP4DhkIeOHDLEl0XnhD/qqqjNwL7M4s5myvTPw5N6i0YGugfW0ShCy4O OFEZmklf/WfQrODTxQoCkJvBSKl6/xiS8nC/dNkPABucIAVjfuWKbM7X4DX/79zoL7M1A6 loP2jfaKUYcyyJMQOYUcibezOlX3ndU= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-544-rSjbzSXfNri9jLQjATxC0w-1; Thu, 12 Sep 2024 17:49:53 -0400 X-MC-Unique: rSjbzSXfNri9jLQjATxC0w-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B162F1955F41; Thu, 12 Sep 2024 21:49:52 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4F86F19560B7; Thu, 12 Sep 2024 21:49:52 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnoSt783910 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:50 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnoL4783909; Thu, 12 Sep 2024 17:49:50 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 15/22] multipathd: simplify checking for followover_should_failback Date: Thu, 12 Sep 2024 17:49:40 -0400 Message-ID: <20240912214947.783819-16-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com The code needs to check that pp->pgindex equals pp->mpp->bestpg and that they aren't both 0 (which is an invalid pathgroup id). Since we're already checking that they are equal, we only need to check one of them to see if it's non-zero. Instead of checking if pp->pgindex is non-zero for every path, just check mpp->bestpg once for the multipath device and return immediately if it's zero. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 3cda3c18..75bc0620 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2002,7 +2002,7 @@ do_followover_should_failback(struct path * pp) struct path *pp1; int i; - if (!pp->pgindex || pp->pgindex != pp->mpp->bestpg) + if (pp->pgindex != pp->mpp->bestpg) return 0; pgp = VECTOR_SLOT(pp->mpp->pg, pp->pgindex - 1); @@ -2022,7 +2022,7 @@ followover_should_failback(struct multipath *mpp) struct pathgroup * pgp; int i, j; - if (mpp->pgfailback != -FAILBACK_FOLLOWOVER || !mpp->pg) + if (mpp->pgfailback != -FAILBACK_FOLLOWOVER || !mpp->pg || !mpp->bestpg) return 0; vector_foreach_slot (mpp->pg, pgp, i) { From patchwork Thu Sep 12 21:49:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802729 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E0121C2439 for ; Thu, 12 Sep 2024 21:49:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177799; cv=none; b=QXQYw7rf8prjUrbifFDXyRXkvncgKB6ly8O0Y2vVXEHp34TOh/yCTlIBXWc4jj6x1vJeII5MZ+hnsxs+Qe5cMywveEuoNx84kLHe1SZg8g8XhP0oswzP/fAxGdZh0f6o3wGK6UmR/jNCSohp/tI8wgd4RyNwxz5xQxLmVXh+Bs4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177799; c=relaxed/simple; bh=oUUQxL8lngai9HYI1KI075A71/0yKOuieuGB/uQh2uk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g9uDnakmmpfd3RBBDgBzgZge0d2hcOtaOtF5ZVrIBHehfpFtSGmj0WO4BpY4LtqO4ItbaSDlLvZFeUerZ+uHWsB/DGRIqxLMwv49vLOkEsGrwruCC28qrpYJOOTc8lxtdSxrYQL2SKUgO0rNF6y1reIfz9HH9MVhmfjgPGjenb0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=HZ7BNoFC; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HZ7BNoFC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177797; h=from:from: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; bh=tFjAkU37RT/OVZVw7Ccd/QYvoq1tLMhDHEEoekJ8nCY=; b=HZ7BNoFCnX2NKLvK5OPScYPrcJ1NiAHCjZM+ejEHpQiynp6zmaVf1UPuDKt8NWRT2hv7Uh YNhz2bGaySJjpulXwljJHRX8bUS/AKKVibOIG1pKPnywQwKkFzIULdnOkW9Wtp+6qFv+fa aTGXirzR0+V9CEJftOklD+qIuVQsit4= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-518-nREQADmyNwqKj5UrY9OUiw-1; Thu, 12 Sep 2024 17:49:53 -0400 X-MC-Unique: nREQADmyNwqKj5UrY9OUiw-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E4BE81955D45; Thu, 12 Sep 2024 21:49:52 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7AEDD19560B9; Thu, 12 Sep 2024 21:49:52 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnpV8783914 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:51 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnp7A783913; Thu, 12 Sep 2024 17:49:51 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 16/22] multipathd: only refresh prios on PATH_UP and PATH_GHOST Date: Thu, 12 Sep 2024 17:49:41 -0400 Message-ID: <20240912214947.783819-17-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com The way that multipathd was handling priority refreshes had some issues. Some of the multipath prioritizers can hang when run on a failed path. Multipathd was only skipping paths in PATH_DOWN, but there are other states where the prioritizer is also likely to hang, such as PATH_TIMEOUT, PATH_SHAKY, and to a lesser extent, PATH_DELAYED. Also, before the recent patch splitting the priority updating from the path checking, multipathd wasn't consistent with which states would cause paths to get their priorities updated. If a path changed its state to anything other than PATH_UP or PATH_GHOST, it wouldn't get its priority updated. But if a path kept the same state its priority would get updated as long at the state wasn't PATH_DOWN. For safety's sake, a path's priority should only get refreshed when its in the PATH_UP or PATH_GHOST state. This shouldn't cause problems. Only paths that are in the PATH_UP or PATH_GHOST state are usable by the kenel and contibute to the pathgroup's priority. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 75bc0620..91806e9d 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2162,7 +2162,7 @@ static bool update_prio(struct multipath *mpp, bool refresh_all) vector_foreach_slot (mpp->pg, pgp, i) { vector_foreach_slot (pgp->paths, pp, j) { - if (pp->state == PATH_DOWN) + if (pp->state != PATH_UP && pp->state != PATH_GHOST) continue; if (!refresh_all && pp->is_checked != CHECK_PATH_CHECKED) { @@ -2186,7 +2186,7 @@ static bool update_prio(struct multipath *mpp, bool refresh_all) */ vector_foreach_slot (mpp->pg, pgp, i) { vector_foreach_slot (pgp->paths, pp, j) { - if (pp->state == PATH_DOWN) + if (pp->state != PATH_UP && pp->state != PATH_GHOST) continue; if (pp->is_checked == CHECK_PATH_CHECKED) continue; From patchwork Thu Sep 12 21:49:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802721 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0134D1C2438 for ; Thu, 12 Sep 2024 21:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177797; cv=none; b=mst8QoPSOiSkppvcx9OCvFe/JNia4quEusNqboN7+mue+1NianF+siw0tqlXo0hk3DlE/sYLLtDNzVntgjZraeHGxFbeu50u/7f3cjJHt344lV1Q5WJj9OIGTatv3HonhW3y321p6kYa30cGjIKEJ5LMzU6pqKt097zqav+6BqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177797; c=relaxed/simple; bh=dPBoCE9Y1WkTRtwROuGHR5WYobw0rp2ipdm5vOdNYHE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WxNmIU641jc1NArSP8Z/qnVfbpcJ1CcBRNxKqeiaCDnF4OJMpvpjUka19YGOlXZde9jGEZbEJVjZYBLdWJLLplELXL4dyvq+Q7+u2ptUpyxkwFSRDjkdTADRCB1V/JBjNmgAt6wImBTAnMw7yg06fggOMtZ13gmUfL3YYVzTHV8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=OqQZCL52; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OqQZCL52" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177795; h=from:from: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; bh=Z2lGrlk8MmpgF5r8gHSgrFn3/iqj504DYuv9zSd6KeU=; b=OqQZCL52jMSPtX1OmNOciuYl4PS6r0UrhtTIhaMxgjcd3LAGKW+NPmwFhOu9L7cAV4h82d 0J1bw7VobxXdnjNRBpTC5Ul1/ljLmwBntLGXZqIQQtv+CuHW14IUsantpeY5vSPpSqqlf1 FV+h6r5CuAJWX8sGnLG0i1scaXZB2II= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-28-2V1EklQhPD2z48CaD_5e_w-1; Thu, 12 Sep 2024 17:49:53 -0400 X-MC-Unique: 2V1EklQhPD2z48CaD_5e_w-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DE5DB1956088; Thu, 12 Sep 2024 21:49:52 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7E9C31956052; Thu, 12 Sep 2024 21:49:52 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnpKA783918 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:51 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnp8C783917; Thu, 12 Sep 2024 17:49:51 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 17/22] multipathd: remove pointless check Date: Thu, 12 Sep 2024 17:49:42 -0400 Message-ID: <20240912214947.783819-18-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Since we just returned if newstate wasn't PATH_UP or PATH_GHOST, it must obviously be PATH_UP or PATH_GHOST at this point in the code. We don't even wrap all the code for dealing with a path that just came up in this if-block, It's only the persistent resrvation code. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 91806e9d..18632c7d 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2545,19 +2545,19 @@ update_path_state (struct vectors * vecs, struct path * pp) return CHECK_PATH_CHECKED; } - if (newstate == PATH_UP || newstate == PATH_GHOST) { - if (pp->mpp->prflag != PRFLAG_UNSET) { - int prflag = pp->mpp->prflag; - /* - * Check Persistent Reservation. - */ - condlog(2, "%s: checking persistent " - "reservation registration", pp->dev); - mpath_pr_event_handle(pp); - if (pp->mpp->prflag == PRFLAG_SET && - prflag != PRFLAG_SET) - pr_register_active_paths(pp->mpp); - } + /* newstate == PATH_UP || newstate == PATH_GHOST */ + + if (pp->mpp->prflag != PRFLAG_UNSET) { + int prflag = pp->mpp->prflag; + /* + * Check Persistent Reservation. + */ + condlog(2, "%s: checking persistent " + "reservation registration", pp->dev); + mpath_pr_event_handle(pp); + if (pp->mpp->prflag == PRFLAG_SET && + prflag != PRFLAG_SET) + pr_register_active_paths(pp->mpp); } /* From patchwork Thu Sep 12 21:49:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802723 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B8E81C2459 for ; Thu, 12 Sep 2024 21:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177798; cv=none; b=g7NuEDodL+9rDSG6y2AI0ZgtuVjAhj5aJZ7EHpAZDyCZl3OMh92eeWCa64FY1ZlCtdWbJr/XztwZIxYcVxV8GlLADTnm+ai1SfCJLsKBnN9dsnC4t7WGqPJJLhUUa0Mg7ii7aKjLJfFte+Lbu87tEhkPBl5plGojQ5iKQyv8Q+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177798; c=relaxed/simple; bh=h3NYc3UzQyQmr2Vi6El2z8J1VZnPwk1MfO9FJlQ1yng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eUh35TbEshTxiuJ+TrVvovcvfixstutRo26VScJMNGfZhPMKD6PrOsOt7DgI66Lj/B0nLBVpbIPY07PJEUfsRZYI1QLNY5IpJ1eywzmXNFTIyU7RqW+9V628mDUldw0DENF5Ua0Gb3OfoIYXtCUsv4CA0K+oOXjhKX2wCutYDBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Xz9qaQVj; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Xz9qaQVj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177795; h=from:from: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; bh=lAB0LNz55BTC8G2muV+3xQy7AhiRXSObsBJz/xVAg9s=; b=Xz9qaQVjj5acTSOhx9LHOECWn1YTHK3tYlHmCNskj8FFFfYRNtvhf0uwrMBy6f66hBAfKU +kpnygW1evhnyExlTzKABh52wdhkk0fd2GkvtfEN7dhGMXgp918Z0bNImfoq8uXsRjkQmt PcXDIGGxNsLOlgOKDCFzH/bePAc1AE8= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-546-SGnZg2kpMe6CdwJpn4H3fA-1; Thu, 12 Sep 2024 17:49:54 -0400 X-MC-Unique: SGnZg2kpMe6CdwJpn4H3fA-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4C45F19560BD; Thu, 12 Sep 2024 21:49:53 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C2E1319560AA; Thu, 12 Sep 2024 21:49:52 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnpED783922 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:51 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnpiM783921; Thu, 12 Sep 2024 17:49:51 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 18/22] multipathd: fix deferred_failback_tick for reload removes Date: Thu, 12 Sep 2024 17:49:43 -0400 Message-ID: <20240912214947.783819-19-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com If reload_and_sync_map() removes the multipath device, deferred_failback_tick() needs to decrement the counter so that it doesn't skip the following device. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 18632c7d..5e68e470 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2098,9 +2098,12 @@ deferred_failback_tick (struct vectors *vecs) if (!mpp->failback_tick && need_switch_pathgroup(mpp, &need_reload)) { - if (need_reload) - reload_and_sync_map(mpp, vecs); - else + if (need_reload) { + if (reload_and_sync_map(mpp, vecs) == 2) { + /* multipath device removed */ + i--; + } + } else switch_pathgroup(mpp); } } From patchwork Thu Sep 12 21:49:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802730 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E62771C245D for ; Thu, 12 Sep 2024 21:49:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177800; cv=none; b=JhDEmKzuk9ol1UmE0zIyX+P8q6khKomfIic51WvThwbertJP2NIzq41LFw4bgxkQJtbWUJfek7Qsxm7BN9ZKkHEvEp+8vVzV6bXTV2DiZMgh/RVSxC/EFbpNzt5rURTzGKQf+q1dWbFLNt50C0Q3ntajkkkNolcYWTvQBouYhVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177800; c=relaxed/simple; bh=2eLNpWaXo5h2Uq+UVHA2/M46W0rFqWl9FNBoCE/SyaU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YboY28o4vgtnuHiy2bjYnp3xOPz6GMks/Wyef4UPCM40S16ROXUG89j1v9Djcspb/ZKBJG8bLw5RQ6TMDgtIpHNaJhyQVsK7n8xfqh38h5MhIywInLYj1HxwCz88/bxHKeApy6XInSGWupqcN8+Bbfsgv7pik9A75WmyGQmtWr4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=faAFtZht; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="faAFtZht" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177797; h=from:from: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; bh=Fr7UV04cweDXsSfa23fVp+PMT4jhkYva5CkHrehsnpk=; b=faAFtZhtjHrce+CrUsDzWEOMZp19gWtSPoMJad79PM+GXFxCbu9n5G32XLD5FCTwpdiqTu UT4iiCLga70GeoN03Kim5lfvfYkOo5TooQkefd0Er1J7Ej6YeeYejPtMy7w7VyhDdo4LMB vK5uM4aG4t/KfhKx2bBVg5SnHgBOPR8= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-548-ARje9lBMPAupLqbn0Ijr0w-1; Thu, 12 Sep 2024 17:49:54 -0400 X-MC-Unique: ARje9lBMPAupLqbn0Ijr0w-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 72031195604F; Thu, 12 Sep 2024 21:49:53 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1245D1955D4A; Thu, 12 Sep 2024 21:49:52 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnp17783937 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:51 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnp93783931; Thu, 12 Sep 2024 17:49:51 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 19/22] libmultipath: add libcheck_need_wait checker function Date: Thu, 12 Sep 2024 17:49:44 -0400 Message-ID: <20240912214947.783819-20-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Add a new optional checker class function, libcheck_need_wait() and a new function to call it, checker_need_wait(). This can be used to see if a path_checker is currently running. This will be used to determine if there are pending checkers that need to be waited for. Signed-off-by: Benjamin Marzinski --- libmultipath/checkers.c | 12 +++++++++++- libmultipath/checkers.h | 4 +++- libmultipath/checkers/directio.c | 10 ++++++++++ libmultipath/checkers/tur.c | 10 ++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c index f3e98352..e2eda58d 100644 --- a/libmultipath/checkers.c +++ b/libmultipath/checkers.c @@ -27,6 +27,7 @@ struct checker_class { void (*reset)(void); /* to reset the global variables */ void *(*thread)(void *); /* async thread entry point */ int (*pending)(struct checker *); /* to recheck pending paths */ + bool (*need_wait)(struct checker *); /* checker needs waiting for */ const char **msgtable; short msgtable_size; }; @@ -182,7 +183,8 @@ static struct checker_class *add_checker_class(const char *name) c->reset = (void (*)(void)) dlsym(c->handle, "libcheck_reset"); c->thread = (void *(*)(void*)) dlsym(c->handle, "libcheck_thread"); c->pending = (int (*)(struct checker *)) dlsym(c->handle, "libcheck_pending"); - /* These 4 functions can be NULL. call dlerror() to clear out any + c->need_wait = (bool (*)(struct checker *)) dlsym(c->handle, "libcheck_need_wait"); + /* These 5 functions can be NULL. call dlerror() to clear out any * error string */ dlerror(); @@ -313,6 +315,14 @@ int checker_get_state(struct checker *c) return c->path_state; } +bool checker_need_wait(struct checker *c) +{ + if (!c || !c->cls || c->path_state != PATH_PENDING || + !c->cls->need_wait) + return false; + return c->cls->need_wait(c); +} + void checker_check (struct checker * c, int path_state) { if (!c) diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h index b2342a1b..da91f499 100644 --- a/libmultipath/checkers.h +++ b/libmultipath/checkers.h @@ -2,6 +2,7 @@ #define CHECKERS_H_INCLUDED #include +#include #include "list.h" #include "defaults.h" @@ -171,6 +172,7 @@ struct checker_context { int start_checker_thread (pthread_t *thread, const pthread_attr_t *attr, struct checker_context *ctx); int checker_get_state(struct checker *c); +bool checker_need_wait(struct checker *c); void checker_check (struct checker *, int); int checker_is_sync(const struct checker *); const char *checker_name (const struct checker *); @@ -191,7 +193,7 @@ void *libcheck_thread(struct checker_context *ctx); void libcheck_reset(void); int libcheck_mp_init(struct checker *); int libcheck_pending(struct checker *c); - +bool libcheck_need_wait(struct checker *c); /* * msgid => message map. diff --git a/libmultipath/checkers/directio.c b/libmultipath/checkers/directio.c index 904e3071..4beed02e 100644 --- a/libmultipath/checkers/directio.c +++ b/libmultipath/checkers/directio.c @@ -65,6 +65,7 @@ struct directio_context { struct aio_group *aio_grp; struct async_req *req; struct timespec endtime; + bool waited_for; }; static struct aio_group * @@ -295,6 +296,7 @@ check_pending(struct directio_context *ct, struct timespec endtime) int r; struct timespec currtime, timeout; + ct->waited_for = true; while(1) { get_monotonic_time(&currtime); timespecsub(&endtime, &currtime, &timeout); @@ -346,6 +348,7 @@ check_state(int fd, struct directio_context *ct, int sync, int timeout_secs) get_monotonic_time(&ct->endtime); ct->endtime.tv_nsec += 1000 * 1000; normalize_timespec(&ct->endtime); + ct->waited_for = false; } ct->running++; if (!sync) @@ -386,6 +389,13 @@ static void set_msgid(struct checker *c, int state) } } +bool libcheck_need_wait(struct checker *c) +{ + struct directio_context *ct = (struct directio_context *)c->context; + return (ct && ct->running && ct->req->state == PATH_PENDING && + !ct->waited_for); +} + int libcheck_pending(struct checker *c) { int rc; diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c index 81db565b..41d6b9c3 100644 --- a/libmultipath/checkers/tur.c +++ b/libmultipath/checkers/tur.c @@ -59,6 +59,7 @@ struct tur_checker_context { struct checker_context ctx; unsigned int nr_timeouts; struct timespec endtime; + bool waited_for; }; int libcheck_init (struct checker * c) @@ -351,9 +352,17 @@ int check_pending(struct checker *c) ct->thread = 0; } + ct->waited_for = true; return tur_status; } +bool libcheck_need_wait(struct checker *c) +{ + struct tur_checker_context *ct = c->context; + return (ct && ct->thread && uatomic_read(&ct->running) != 0 && + !ct->waited_for); +} + int libcheck_pending(struct checker *c) { struct tur_checker_context *ct = c->context; @@ -463,6 +472,7 @@ int libcheck_check(struct checker * c) pthread_mutex_unlock(&ct->lock); ct->fd = c->fd; ct->timeout = c->timeout; + ct->waited_for = false; uatomic_add(&ct->holders, 1); uatomic_set(&ct->running, 1); tur_set_async_timeout(c); From patchwork Thu Sep 12 21:49:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802727 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F319A1C2DB2 for ; Thu, 12 Sep 2024 21:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177799; cv=none; b=svbZvfEEe/ZltBpBY2DNw9jeUixt4SmvPQxhBXKL+PxzWJm17b0933uwv+iF38dgokq6dnNrUXsAkkGBrcBqi8tMv9IbzK9HCnUuyJkQmAmci3Z414odZYvPK8MItDh4OsGGcNg2HQu5GQWTl0U4188GdVtoyUluMT8jesIuMQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177799; c=relaxed/simple; bh=5u4/KUW+laLDyJO8EzbRtEhOGuG324koA5N5mRCRZN0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qf6oNXSouju3DTurNaWYSQSnqhPeQPqN254fb+lpTeM4Cu48kBKNuOoKRlJ4ja2lV4G0y7HKICX86xFyt7SwX9juP0gad6SzWp6+0Pea0/BBDlyEyfxv+7V1Y+qzmeKl6E2W1Zwj+l6OtllZbFajC+aAVgYmIRWiSR5pn7lApLM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=F4+tmy4c; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="F4+tmy4c" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177796; h=from:from: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; bh=USiiU9JpSKW+zG6EGxO1TfKUrW0299kTdQakFJmuFw0=; b=F4+tmy4cZjEb4vJFifh6M5FhSZajQExMhC1jbSJ2ZTCIvLwHnUgvsgCkQfVdqk0sbefeqp nU73fssyNkuQGuA4ftiBCMd17mGOkWHShe8jPCYUnQ93854/YE55VmP4RPTsVSjwnSMIJi 9jS8lTxTnQmtPxJaQ5Cex1AyQweKSUw= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-317--g7JCOhlO7mP4lmxZZFMyQ-1; Thu, 12 Sep 2024 17:49:54 -0400 X-MC-Unique: -g7JCOhlO7mP4lmxZZFMyQ-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8279819560AE; Thu, 12 Sep 2024 21:49:53 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 401303001D17; Thu, 12 Sep 2024 21:49:53 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnpnI783944 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:51 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnpZK783943; Thu, 12 Sep 2024 17:49:51 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 20/22] libmultipath: don't wait in libcheck_pending Date: Thu, 12 Sep 2024 17:49:45 -0400 Message-ID: <20240912214947.783819-21-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Disable waiting in the libcheck_pending() checker class functions. Instead, they now just check if the checker has already completed. A future patch will re-add waiting outside of libcheck_pending(). Signed-off-by: Benjamin Marzinski --- libmultipath/checkers/directio.c | 41 ++++++++++++++++---------------- libmultipath/checkers/tur.c | 20 +++------------- 2 files changed, 23 insertions(+), 38 deletions(-) diff --git a/libmultipath/checkers/directio.c b/libmultipath/checkers/directio.c index 4beed02e..f37b0d39 100644 --- a/libmultipath/checkers/directio.c +++ b/libmultipath/checkers/directio.c @@ -64,7 +64,6 @@ struct directio_context { int reset_flags; struct aio_group *aio_grp; struct async_req *req; - struct timespec endtime; bool waited_for; }; @@ -291,18 +290,17 @@ get_events(struct aio_group *aio_grp, struct timespec *timeout) } static void -check_pending(struct directio_context *ct, struct timespec endtime) +check_pending(struct directio_context *ct, struct timespec timeout) { int r; - struct timespec currtime, timeout; + struct timespec endtime, currtime; ct->waited_for = true; + get_monotonic_time(&endtime); + endtime.tv_sec += timeout.tv_sec; + endtime.tv_nsec += timeout.tv_nsec; + normalize_timespec(&endtime); while(1) { - get_monotonic_time(&currtime); - timespecsub(&endtime, &currtime, &timeout); - if (timeout.tv_sec < 0) - timeout.tv_sec = timeout.tv_nsec = 0; - r = get_events(ct->aio_grp, &timeout); if (ct->req->state != PATH_PENDING) { @@ -311,6 +309,10 @@ check_pending(struct directio_context *ct, struct timespec endtime) } else if (r == 0 || (timeout.tv_sec == 0 && timeout.tv_nsec == 0)) return; + get_monotonic_time(&currtime); + timespecsub(&endtime, &currtime, &timeout); + if (timeout.tv_sec < 0) + timeout.tv_sec = timeout.tv_nsec = 0; } } @@ -320,7 +322,7 @@ check_state(int fd, struct directio_context *ct, int sync, int timeout_secs) struct stat sb; int rc; struct io_event event; - struct timespec endtime; + struct timespec timeout = { .tv_sec = timeout_secs }; if (fstat(fd, &sb) == 0) { LOG(4, "called for %x", (unsigned) sb.st_rdev); @@ -345,20 +347,13 @@ check_state(int fd, struct directio_context *ct, int sync, int timeout_secs) LOG(3, "io_submit error %i", -rc); return PATH_UNCHECKED; } - get_monotonic_time(&ct->endtime); - ct->endtime.tv_nsec += 1000 * 1000; - normalize_timespec(&ct->endtime); ct->waited_for = false; } ct->running++; if (!sync) return PATH_PENDING; - get_monotonic_time(&endtime); - endtime.tv_sec += timeout_secs; - normalize_timespec(&endtime); - - check_pending(ct, endtime); + check_pending(ct, timeout); if (ct->req->state != PATH_PENDING) return ct->req->state; @@ -401,13 +396,16 @@ int libcheck_pending(struct checker *c) int rc; struct io_event event; struct directio_context *ct = (struct directio_context *)c->context; + struct timespec no_wait = { .tv_sec = 0 }; /* The if path checker isn't running, just return the exiting value. */ - if (!ct || !ct->running) - return c->path_state; + if (!ct || !ct->running) { + rc = c->path_state; + goto out; + } if (ct->req->state == PATH_PENDING) - check_pending(ct, ct->endtime); + check_pending(ct, no_wait); else ct->running = 0; rc = ct->req->state; @@ -420,8 +418,9 @@ int libcheck_pending(struct checker *c) else LOG(4, "async io pending"); } - set_msgid(c, rc); +out: + set_msgid(c, rc); return rc; } diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c index 41d6b9c3..5d606708 100644 --- a/libmultipath/checkers/tur.c +++ b/libmultipath/checkers/tur.c @@ -58,7 +58,6 @@ struct tur_checker_context { int msgid; struct checker_context ctx; unsigned int nr_timeouts; - struct timespec endtime; bool waited_for; }; @@ -299,14 +298,6 @@ void *libcheck_thread(struct checker_context *ctx) return ((void *)0); } - -static void tur_timeout(struct timespec *tsp) -{ - get_monotonic_time(tsp); - tsp->tv_nsec += 1000 * 1000; /* 1 millisecond */ - normalize_timespec(tsp); -} - static void tur_set_async_timeout(struct checker *c) { struct tur_checker_context *ct = c->context; @@ -328,16 +319,12 @@ static int tur_check_async_timeout(struct checker *c) int check_pending(struct checker *c) { struct tur_checker_context *ct = c->context; - int r, tur_status = PATH_PENDING; + int tur_status = PATH_PENDING; pthread_mutex_lock(&ct->lock); - for (r = 0; - r == 0 && ct->state == PATH_PENDING && - ct->msgid == MSG_TUR_RUNNING; - r = pthread_cond_timedwait(&ct->active, &ct->lock, &ct->endtime)); - - if (!r) { + if (ct->state != PATH_PENDING || ct->msgid != MSG_TUR_RUNNING) + { tur_status = ct->state; c->msgid = ct->msgid; } @@ -487,7 +474,6 @@ int libcheck_check(struct checker * c) " sync mode", major(ct->devt), minor(ct->devt)); return tur_check(c->fd, c->timeout, &c->msgid); } - tur_timeout(&ct->endtime); } return tur_status; From patchwork Thu Sep 12 21:49:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802725 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5C391BE857 for ; Thu, 12 Sep 2024 21:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177798; cv=none; b=YXtr+YagVqw5MRiKdp6CrZxE/uLtk74bHrgt3bHVjzGKwzuZunqINYj5SED3ZiXiyEiMMRb7X03R6UVpnwUDOkPpAhNPevYErzrh5XazLRXApDUpHyWJ1Sz1EcPt2eJoZ5tZkOXuUY9KfvdyQDRQi+y7RmNSlyU7zmHS1zB1x8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177798; c=relaxed/simple; bh=jArEZ4bLwr1/o+sSReaJG+ycv+PTVpV0TOh2GPnzgWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s9deWbiP+KHVydbsIhRlDEihxeKocqyJIm5t7yenZlKEy/10ly7u7t3B9rNxrj6eulJJYny7rD0K2bvrP8bxG8Xf/0qfKW3DtpIv5skNKtEvYyYxr5RRSAYtqmT2kaNGjcv6eW/qOzFpB4xEPBlapGsQ9p/au+quzBeSZr/RmwY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=gprXRjjm; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gprXRjjm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177795; h=from:from: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; bh=xjdaIbqBcBF2AYepiLmnwdv/nVszpzcUlJviRtXWHDo=; b=gprXRjjmfwjGHT/YAAvGQHfXxx0vbnkAXeLzfKUvPZp4zsVPYAaEEfRTFA6GF1Wvf5D4JL BEme6ypuw4Lvrc+TiQWYng+dhOPelHPq5V5Hr7HzZ9IMQ20fgopXbRmp5RpwrwQEKXgc6m wLduchSdm11O64J1kh0hH97vNzSbWwI= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-267-1jVlPUdCOBqad0yHJyppmw-1; Thu, 12 Sep 2024 17:49:54 -0400 X-MC-Unique: 1jVlPUdCOBqad0yHJyppmw-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D256419560B2; Thu, 12 Sep 2024 21:49:53 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 521B91956052; Thu, 12 Sep 2024 21:49:53 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnpUl783948 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:51 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnptt783947; Thu, 12 Sep 2024 17:49:51 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 21/22] multipathd: wait for checkers to complete Date: Thu, 12 Sep 2024 17:49:46 -0400 Message-ID: <20240912214947.783819-22-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Multipath again waits for running checkers to complete. In pathinfo(), mutipath will just wait 1ms if the checker is running. In checkerloop(), if there are running checkers, multipathd will drop the vecs lock and wait for 5ms. The difference it wait times is because multipathd cannot drop the vecs lock in pathinfo. Signed-off-by: Benjamin Marzinski --- libmultipath/discovery.c | 9 ++++++++- libmultipath/libmultipath.version | 1 + multipathd/main.c | 12 +++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 6ccdfa0b..1d48c30a 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -2467,8 +2467,15 @@ int pathinfo(struct path *pp, struct config *conf, int mask) if (mask & DI_CHECKER) { if (path_state == PATH_UP) { int newstate = PATH_UNCHECKED; - if (start_checker(pp, conf, 0, path_state) == 0) + if (start_checker(pp, conf, 0, path_state) == 0) { + if (checker_need_wait(&pp->checker)) { + struct timespec wait = { + .tv_nsec = 1000 * 1000, + }; + nanosleep(&wait, NULL); + } newstate = get_state(pp); + } if (newstate != PATH_PENDING || pp->state == PATH_UNCHECKED || pp->state == PATH_WILD) diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version index 6439d3a7..c2e5f552 100644 --- a/libmultipath/libmultipath.version +++ b/libmultipath/libmultipath.version @@ -62,6 +62,7 @@ global: checker_enable; checker_message; checker_name; + checker_need_wait; checker_state_name; check_foreign; cleanup_bindings; diff --git a/multipathd/main.c b/multipathd/main.c index 5e68e470..5bac76ae 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2848,6 +2848,7 @@ update_uninitialized_path(struct vectors * vecs, struct path * pp) enum checker_state { CHECKER_STARTING, CHECKER_CHECKING_PATHS, + CHECKER_WAITING_FOR_PATHS, CHECKER_UPDATING_PATHS, CHECKER_FINISHED, }; @@ -2859,6 +2860,7 @@ check_paths(struct vectors *vecs, unsigned int ticks) struct timespec diff_time, start_time, end_time; struct path *pp; int i; + bool need_wait = false; get_monotonic_time(&start_time); @@ -2869,6 +2871,9 @@ check_paths(struct vectors *vecs, unsigned int ticks) pp->is_checked = check_path(pp, ticks); else pp->is_checked = check_uninitialized_path(pp, ticks); + if (pp->is_checked == CHECK_PATH_STARTED && + checker_need_wait(&pp->checker)) + need_wait = true; if (++paths_checked % 128 == 0 && (lock_has_waiters(&vecs->lock) || waiting_clients())) { get_monotonic_time(&end_time); @@ -2877,7 +2882,7 @@ check_paths(struct vectors *vecs, unsigned int ticks) return CHECKER_CHECKING_PATHS; } } - return CHECKER_UPDATING_PATHS; + return need_wait ? CHECKER_WAITING_FOR_PATHS : CHECKER_UPDATING_PATHS; } static enum checker_state @@ -2999,6 +3004,11 @@ checkerloop (void *ap) if (checker_state != CHECKER_FINISHED) { /* Yield to waiters */ struct timespec wait = { .tv_nsec = 10000, }; + if (checker_state == CHECKER_WAITING_FOR_PATHS) { + /* wait 5ms */ + wait.tv_nsec = 5 * 1000 * 1000; + checker_state = CHECKER_UPDATING_PATHS; + } nanosleep(&wait, NULL); } } From patchwork Thu Sep 12 21:49:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13802732 X-Patchwork-Delegate: bmarzins@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 225F91BE857 for ; Thu, 12 Sep 2024 21:49:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177800; cv=none; b=gH3owxP5JpEsNEPc/yBf+Qoj0XSDJnKGLDrbD6pQiMLulzZXYWdJlnu8HEQWwPW3vlf51haux8wmHpu6niU8Kbyh5kuFF8cHiWrJ36Fwq1+XRdGfJKAqaTsdt9u1S5WEJC87J2vwP/VoWNllQG4n8kZChetAAEsfxU+pAbRQbFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726177800; c=relaxed/simple; bh=3meAz/MENqsuTMqfB9aYCOaDstuXxP+5cJujI0NDkcU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sV0qm6h6ZCsr4GK+RnotU+AoP7zcF5orjzqfDaxhJcf12BmUzx7Ht9QEYNz2sB4m+42CLI0mnewaNz6zTDivKQivZcQ3Nqhfw7w6V+TcaD8kyaAyoFFv2YA4c+HJCOLhaCc0Gy3ruUSV37EwSbBuKSknuDCgXs3/naPjtX6OIy0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=eGNrWbnU; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eGNrWbnU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726177798; h=from:from: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; bh=XGPOJ/OvyWXVlRRpZyldKK3/AnGBzZpa6doUjCedEew=; b=eGNrWbnUE0zU0KCfpkmle8+BaytiznS8k4Ij8JfDBm3Q/pBZH7is0J5svuJaiN+teFoFFz ARnx+ynwwsMlAoNikgAjseyKRESSAWGuOOV8EFLH5ik3u/ewDJ0fX+UGceBWSMR6n2oj/q r6FPvYvsKPN3q+oHtLVT/A4Qev+QPSk= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-_ZOCWJSsPiiDiqFjDEC0QA-1; Thu, 12 Sep 2024 17:49:54 -0400 X-MC-Unique: _ZOCWJSsPiiDiqFjDEC0QA-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0719B1955F44; Thu, 12 Sep 2024 21:49:54 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9819D3001D16; Thu, 12 Sep 2024 21:49:53 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.1) with ESMTPS id 48CLnqgP783952 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 12 Sep 2024 17:49:52 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 48CLnqAg783951; Thu, 12 Sep 2024 17:49:52 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 22/22] multipath-tools tests: fix up directio tests Date: Thu, 12 Sep 2024 17:49:47 -0400 Message-ID: <20240912214947.783819-23-bmarzins@redhat.com> In-Reply-To: <20240912214947.783819-1-bmarzins@redhat.com> References: <20240912214947.783819-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Make the directio tests work with no waiting in the libcheck_pending() and the new libcheck_need_wait() call. Signed-off-by: Benjamin Marzinski --- tests/directio.c | 49 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/tests/directio.c b/tests/directio.c index 2e22f831..5ee482a8 100644 --- a/tests/directio.c +++ b/tests/directio.c @@ -313,23 +313,28 @@ static void test_init_reset_init(void **state) struct checker c = {.cls = NULL}; struct aio_group *aio_grp, *tmp_grp; + assert_int_equal(libcheck_need_wait(&c), false); assert_true(list_empty(&aio_grp_list)); will_return(__wrap_io_setup, 0); do_libcheck_init(&c, 4096, 0, NULL); + assert_int_equal(libcheck_need_wait(&c), false); aio_grp = get_aio_grp(&c); check_aio_grp(aio_grp, 1, 0); list_for_each_entry(tmp_grp, &aio_grp_list, node) assert_ptr_equal(aio_grp, tmp_grp); libcheck_free(&c); + assert_int_equal(libcheck_need_wait(&c), false); check_aio_grp(aio_grp, 0, 0); do_libcheck_reset(1); will_return(__wrap_io_setup, 0); do_libcheck_init(&c, 4096, 0, NULL); + assert_int_equal(libcheck_need_wait(&c), false); aio_grp = get_aio_grp(&c); check_aio_grp(aio_grp, 1, 0); list_for_each_entry(tmp_grp, &aio_grp_list, node) assert_ptr_equal(aio_grp, tmp_grp); libcheck_free(&c); + assert_int_equal(libcheck_need_wait(&c), false); check_aio_grp(aio_grp, 0, 0); do_libcheck_reset(1); } @@ -433,6 +438,7 @@ static void test_check_state_simple(void **state) do_libcheck_init(&c, 4096, 30, &req); return_io_getevents_nr(NULL, 1, &req, &res); do_check_state(&c, 1, PATH_UP); + assert_int_equal(libcheck_need_wait(&c), false); libcheck_free(&c); do_libcheck_reset(1); } @@ -465,17 +471,25 @@ static void test_check_state_async_timeout(void **state) do_libcheck_init(&c, 4096, 3, NULL); aio_grp = get_aio_grp(&c); do_check_state(&c, 0, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c), true); return_io_getevents_none(); do_libcheck_pending(&c, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c), false); do_check_state(&c, 0, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c), false); return_io_getevents_none(); do_libcheck_pending(&c, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c), false); do_check_state(&c, 0, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c), false); return_io_getevents_none(); do_libcheck_pending(&c, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c), false); do_check_state(&c, 0, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c), false); return_io_getevents_none(); do_libcheck_pending(&c, PATH_DOWN); + assert_int_equal(libcheck_need_wait(&c), false); check_aio_grp(aio_grp, 1, 0); libcheck_free(&c); do_libcheck_reset(1); @@ -496,11 +510,16 @@ static void test_free_with_pending(void **state) aio_grp = get_aio_grp(c); do_check_state(&c[0], 0, PATH_PENDING); do_check_state(&c[1], 0, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[0]), true); + assert_int_equal(libcheck_need_wait(&c[1]), true); return_io_getevents_none(); do_libcheck_pending(&c[0], PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[0]), false); + assert_int_equal(libcheck_need_wait(&c[1]), true); return_io_getevents_nr(NULL, 1, &req, &res); - return_io_getevents_none(); do_libcheck_pending(&c[1], PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[0]), false); + assert_int_equal(libcheck_need_wait(&c[1]), false); assert_true(is_checker_running(&c[0])); assert_true(is_checker_running(&c[1])); check_aio_grp(aio_grp, 2, 0); @@ -523,8 +542,10 @@ static void test_orphaned_aio_group(void **state) for (i = 0; i < AIO_GROUP_SIZE; i++) { do_libcheck_init(&c[i], 4096, 30, NULL); do_check_state(&c[i], 0, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[i]), true); return_io_getevents_none(); do_libcheck_pending(&c[i], PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[i]), false); } aio_grp = get_aio_grp(c); check_aio_grp(aio_grp, AIO_GROUP_SIZE, 0); @@ -560,15 +581,19 @@ static void test_timeout_cancel_failed(void **state) aio_grp = get_aio_grp(c); return_io_getevents_none(); do_check_state(&c[0], 1, PATH_DOWN); + assert_int_equal(libcheck_need_wait(&c[0]), false); assert_true(is_checker_running(&c[0])); check_aio_grp(aio_grp, 2, 0); return_io_getevents_none(); do_check_state(&c[0], 1, PATH_DOWN); + assert_int_equal(libcheck_need_wait(&c[0]), false); assert_true(is_checker_running(&c[0])); return_io_getevents_nr(NULL, 1, &reqs[0], &res[0]); return_io_getevents_nr(NULL, 1, &reqs[1], &res[1]); do_check_state(&c[1], 1, PATH_UP); + assert_int_equal(libcheck_need_wait(&c[1]), false); do_check_state(&c[0], 1, PATH_UP); + assert_int_equal(libcheck_need_wait(&c[0]), false); for (i = 0; i < 2; i++) { assert_false(is_checker_running(&c[i])); libcheck_free(&c[i]); @@ -590,11 +615,15 @@ static void test_async_timeout_cancel_failed(void **state) for (i = 0; i < 2; i++) do_libcheck_init(&c[i], 4096, 2, &reqs[i]); do_check_state(&c[0], 0, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[0]), true); do_check_state(&c[1], 0, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[1]), true); return_io_getevents_none(); do_libcheck_pending(&c[0], PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[0]), false); return_io_getevents_none(); do_libcheck_pending(&c[1], PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[1]), false); do_check_state(&c[0], 0, PATH_PENDING); do_check_state(&c[1], 0, PATH_PENDING); return_io_getevents_none(); @@ -605,10 +634,12 @@ static void test_async_timeout_cancel_failed(void **state) do_check_state(&c[1], 0, PATH_PENDING); return_io_getevents_none(); do_libcheck_pending(&c[0], PATH_DOWN); + assert_int_equal(libcheck_need_wait(&c[0]), false); if (!test_dev) { /* can't pick which even gets returned on real devices */ return_io_getevents_nr(NULL, 1, &reqs[1], &res[1]); do_libcheck_pending(&c[1], PATH_UP); + assert_int_equal(libcheck_need_wait(&c[1]), false); } do_check_state(&c[0], 0, PATH_PENDING); return_io_getevents_none(); @@ -641,14 +672,19 @@ static void test_orphan_checker_cleanup(void **state) do_libcheck_init(&c[i], 4096, 30, &reqs[i]); aio_grp = get_aio_grp(c); do_check_state(&c[0], 0, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[0]), true); return_io_getevents_none(); do_libcheck_pending(&c[0], PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[0]), false); check_aio_grp(aio_grp, 2, 0); libcheck_free(&c[0]); + assert_int_equal(libcheck_need_wait(&c[0]), false); check_aio_grp(aio_grp, 2, 1); do_check_state(&c[1], 0, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[1]), true); return_io_getevents_nr(NULL, 2, reqs, res); do_libcheck_pending(&c[1], PATH_UP); + assert_int_equal(libcheck_need_wait(&c[1]), false); check_aio_grp(aio_grp, 1, 0); libcheck_free(&c[1]); check_aio_grp(aio_grp, 0, 0); @@ -667,8 +703,10 @@ static void test_orphan_reset_cleanup(void **state) do_libcheck_init(&c, 4096, 30, NULL); orphan_aio_grp = get_aio_grp(&c); do_check_state(&c, 0, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c), true); return_io_getevents_none(); do_libcheck_pending(&c, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c), false); check_aio_grp(orphan_aio_grp, 1, 0); libcheck_free(&c); check_aio_grp(orphan_aio_grp, 1, 1); @@ -704,6 +742,7 @@ static void test_check_state_blksize(void **state) for (i = 0; i < 3; i++) { return_io_getevents_nr(NULL, 1, &reqs[i], &res[i]); do_check_state(&c[i], 1, chk_state[i]); + assert_int_equal(libcheck_need_wait(&c[i]), false); } for (i = 0; i < 3; i++) { assert_false(is_checker_running(&c[i])); @@ -727,18 +766,22 @@ static void test_check_state_async(void **state) do_libcheck_init(&c[i], 4096, 30, &reqs[i]); for (i = 0; i < 256; i++) { do_check_state(&c[i], 0, PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[i]), true); return_io_getevents_none(); do_libcheck_pending(&c[i], PATH_PENDING); + assert_int_equal(libcheck_need_wait(&c[i]), false); assert_true(is_checker_running(&c[i])); } do_check_state(&c[256], 0, PATH_PENDING); - return_io_getevents_nr(&full_timeout, 256, reqs, res); - return_io_getevents_nr(NULL, 1, &reqs[256], &res[256]); + assert_int_equal(libcheck_need_wait(&c[256]), true); + return_io_getevents_nr(&full_timeout, 257, reqs, res); do_libcheck_pending(&c[256], PATH_UP); + assert_int_equal(libcheck_need_wait(&c[256]), false); assert_false(is_checker_running(&c[256])); libcheck_free(&c[256]); for (i = 0; i < 256; i++) { do_check_state(&c[i], 0, PATH_UP); + assert_int_equal(libcheck_need_wait(&c[i]), false); assert_false(is_checker_running(&c[i])); libcheck_free(&c[i]); }