From patchwork Wed Oct 9 01:15:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827343 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 8E6BB1CD2B for ; Wed, 9 Oct 2024 01:15:31 +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=1728436534; cv=none; b=NIGKD9lkvsCbD7Fyl0N8jGAPjirFYglXZBhRM2DGQWwOGS5AK25TMG88KbkolqRCeSUfEyS12BvI1DWl3P/yEhGCz5tMWOGSLmRehk2eFxVkiZNN32az2lffWVRxGj50J2nXCF4AdLC1/BZIL9lkxM3P6nSZBYBcr2eKA0x9zps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436534; c=relaxed/simple; bh=K1uD84RpdQMm62QBvQQrkNvq4iYFIL7AhA9ICg0G2PE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E45HoULXTCOOWUfqNTGG4iua9JVZCw7H1eqJVMaalT36k/cn/QLf/LnYn9qgwivzKMq4Lnp8as7bllGkbG+FG9Q0OOL12dNh+sC8in9XEl4FW4a4iXiIwfj0RI82hMHJhbHKcy9ZSOpUVxqvEa6hF5kVUdZJDYAChmmwRu8Ma+I= 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=JhCivla+; 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="JhCivla+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436530; 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=fDbPEXd1L46Bz924xjYAv09ESeJm5szPAAZ96dLVYtA=; b=JhCivla+6vWhX9TIPXCM+c/TJxdw1whgO8+DCBsl81ZAeNqez4sRq4flLsvoTT3eyMsJSP KTKpGPVVSaicKgmm1o1a5mbodLYVn84t1pUmpHlES8L7RBlxT0noRwyhfZ0/3JQB67vHk8 nRnn4xStPvjwJxtR9j6FHnQV4ruhtzE= 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-452-Wozb2FTnNt6O6yWqegYdLw-1; Tue, 08 Oct 2024 21:15:27 -0400 X-MC-Unique: Wozb2FTnNt6O6yWqegYdLw-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 3DEA41955D4D; Wed, 9 Oct 2024 01:15:26 +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 B205419560A3; Wed, 9 Oct 2024 01:15:25 +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 4991FOL92381610 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:24 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FOCF2381609; Tue, 8 Oct 2024 21:15:24 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 01/22] libmultipath: store checker_check() result in checker struct Date: Tue, 8 Oct 2024 21:15:02 -0400 Message-ID: <20241009011523.2381575-2-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 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. Reviewed-by: Martin Wilck 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 Wed Oct 9 01:15:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827337 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 8E7BF1D6AA for ; Wed, 9 Oct 2024 01:15:31 +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=1728436533; cv=none; b=l6NRW3kFTXUOGLpYjpCvvtyDju6qh7dn+DHDU+ErzDAZbLM/5t11+tyFdIV7FGHVxUPI2IQf6sxNT0ZpsCVyNsOGG8QaGtI+a7FB0jtCVB1mjxJarGA5yb9p8UK9uD4OxcwQ0KcPvvXKj5IeI5f5gtQMJwxChjL4TkgIQeJk6zc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436533; c=relaxed/simple; bh=/gwPJEkUJRxZWnG/yNxxk0/KQxOhLA+xhqgoyL3Bg6c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pq9/hkTtfwfN+Atk1DkR1g2pwEMgy4GDMhGixrzYNOp8m5NkhB1SxqiHGlML0fUyKtHIgApN3MamfWJiJ36Ia8lUJYkjjntLc58a0JXMNA9f/B25WDu5bwhyIZ/rOUCPPzb0n3QtYmjUUryWPeNhLGvyuO/2/r4JriO1KBjhRZQ= 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=Or1s3CkJ; 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="Or1s3CkJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436530; 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=SG/QEWVYn2IyaP1Pf7//bD8wY3Ah2v2mDwF8hGeVz+E=; b=Or1s3CkJV7R8B8b7e34NHGmsUeZYzqwlQeHOS8rVawkj/8FU03DCgUCq3YsfVF388DMaYQ V75s9ykogYtmMMDExevPF2iTfkfg+rsoiT7WjI8vr4E9kXLjh3VUwCvCNAst0j/83sZhM6 5iUkh212BGeVs6h2ryKz4q5XhnBdQq4= 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-460-AqSNoSxtOcmJ9G_lVeTGMg-1; Tue, 08 Oct 2024 21:15:27 -0400 X-MC-Unique: AqSNoSxtOcmJ9G_lVeTGMg-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 57F391955F65; Wed, 9 Oct 2024 01:15:26 +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 A885919560AA; Wed, 9 Oct 2024 01:15:25 +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 4991FOQi2381616 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:24 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FOcV2381615; Tue, 8 Oct 2024 21:15:24 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 02/22] libmultipath: add missing checker function prototypes Date: Tue, 8 Oct 2024 21:15:03 -0400 Message-ID: <20241009011523.2381575-3-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 Reviewed-by: Martin Wilck 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 Wed Oct 9 01:15:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827332 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 D312E18EBF for ; Wed, 9 Oct 2024 01:15:29 +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=1728436531; cv=none; b=DNl761MuaH92MdXjUZhLwyDgjsOCdKh7ajE8vWXRKH2dV2Oee+519pgsZyI2HUKqkOFxkwCDoGRXZOp154ku7J21zNqrNjioROFQommn+EpZQoThqIN8oXpPmqF7iLREVGcVJXlroaiT7lTrISIW8l8rjekfBpLxOthW3oY6wbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436531; c=relaxed/simple; bh=XYrA09mkFsb2Fo7BUR6/8WmKh2VrTUllBGTwXh6awXk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QTjruWLJGyZMmKvPeOSZ9hLx8btkbuT8wiWjAXSHXFYGG+E24WgTvJ4pEIW0GYFZeZEA45BJ3cpJEp8yqqN8zmzv9NTiLNij4Lziddi6RHxtOfLQKDIGTi/JqTyAgdMI77NlthbtMwzlo48486ZUBMNl6HDZ9OA0Koz7f2zv7wE= 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=H84EfZhI; 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="H84EfZhI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436528; 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=7HWCQyiqKQb3VwL7z1bSCn9lfcUcYkeaxu5HGByVueA=; b=H84EfZhI3/5lFD3Bpp9TflcM/I3PFwU19ILPOMhEqKhwu8OHQ/Tpx6NhIx7cPke66E23pZ hNvvHFO5rYEK263R6zUC3e9aebyJEI5ITOpMJphsAePRP6EXbG4w/UK7ts24tdBRJMZ0l0 7YJ8EpR7xdWQ2Hb7zNoZqONFLzqRlog= 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-557-jVgNU10HNvSu3lD8mqtg6Q-1; Tue, 08 Oct 2024 21:15:27 -0400 X-MC-Unique: jVgNU10HNvSu3lD8mqtg6Q-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 545F61956048; Wed, 9 Oct 2024 01:15:26 +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 EEEFE19560AD; Wed, 9 Oct 2024 01:15:25 +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 4991FO0X2381620 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:24 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FOXU2381619; Tue, 8 Oct 2024 21:15:24 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 03/22] libmultipath: split out the code to wait for pending checkers Date: Tue, 8 Oct 2024 21:15:04 -0400 Message-ID: <20241009011523.2381575-4-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 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. Reviewed-by: Martin Wilck 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 Wed Oct 9 01:15:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827349 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 8E7031CD2C for ; Wed, 9 Oct 2024 01:15:31 +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=1728436535; cv=none; b=AgJXP/EQfO9L6Itr2eS61ATJhg5Oy3Yg8GIaLpDHaL9oWrs1DDwYmeZCVBdR6fLgsUeCDLAt7mR20xHlS3HROp59vnHvVqDZvq3N/t+q7/DMfVnW6LIxDWeZ+rNaApO+KQuUgsO3ah4JescWgbZr1/LzjeQBMxz14JoL+B1AFeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436535; c=relaxed/simple; bh=9gf0xS5uvMboH734GTPPdJpFwAl6aDwk3bX/llWFMFI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eobB1dejeGZI3l80SROoZBZjaAJEphOQ0mQ7H/52eltUWvySlIrNJzDtPNgKd1BfBZHrhm+H9ZOivZj0s/f8tE4LAwXg7Kjw9RmDdMGXyrHqUKCpREbfJFxQtM5hB3cB7kNHaJ6NP1q2v6Ml9rEOxveHtvzGWrkgwxnTT3QU+HQ= 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=MaCjxWP3; 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="MaCjxWP3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436530; 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=6pAoNay9S+X0hEUCnIb37okRQ6By4AndDEubmxEliNU=; b=MaCjxWP3AmLJ8MFOAoz4JGxRX5/3UAN8nMD+/JS9abQHvvH/cuyOAk0aCoFEANcYjOvCaF oDg1wkdBcvWLV1bR0KAqAQsb088Fkvn03H3EAKQEsvEY+FzhZkQ1jy0hA1kCdzohtJT22K zX7KBWgx0By4PKLGowoXmjfU0bcyErA= 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-490-XbmLBmQbPvyXPA3AKDetHQ-1; Tue, 08 Oct 2024 21:15:27 -0400 X-MC-Unique: XbmLBmQbPvyXPA3AKDetHQ-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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 46B361955EA8; Wed, 9 Oct 2024 01:15:26 +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 03B5E1956086; Wed, 9 Oct 2024 01:15:25 +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 4991FOga2381624 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:24 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FOJ52381623; Tue, 8 Oct 2024 21:15:24 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 04/22] libmultipath: remove pending wait code from libcheck_check calls Date: Tue, 8 Oct 2024 21:15:05 -0400 Message-ID: <20241009011523.2381575-5-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 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. Reviewed-by: Martin Wilck 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 Wed Oct 9 01:15:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827342 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 C8761210FB for ; Wed, 9 Oct 2024 01:15:31 +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=1728436534; cv=none; b=aHWKZxenOsAjRiWrQ8ln1bgiBscq3IkzhL7BlExnCXojCk+dVQcPunB3MKddjqjlmTkTQDAp66n2knZosr1E84pchEGmtIqyaKDdo2/anCVDrWmgokrEbTX5vpKYHyjaUMtfcH31WfwUtsPBRJ07eyChtJn8AlNVlo1SGW9igY0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436534; c=relaxed/simple; bh=ag4LoPZGTQKSadSxgqREFDqvcz5GzuEwdtaJacB+dKk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gGxxAjwTBeZefakoAh+2vO9lHLt0t4EqGdFck73X5SDDRIZSpsSWItku4RrQEonIhQCCL9kF1hs7uib37UusyqeTuBs0LWyDA2zc/enZwBrtz92JlcpEeK9xNYtPmLoUq7JT58L8cQ7BcAhf4KN9XpHi3XzxMZiA1N//c8/UR94= 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=HTLzixKH; 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="HTLzixKH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436530; 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=b3MeuiXHpoDkGrIha11WWIwSL5siHJTfu9lyMXGZ7iA=; b=HTLzixKH7v730B9fnJEeCL0aPG13RbN/g+tkg+ebAQS2b9kuiLiJAyJMADgmRdnHG8c9UY U1lztlMJPDfmm+8Au+BuwzuWXGPicLcU9R+sDexib547bCUeQreRkuWEJiFwO4UFh0EAdo UEpNltF/k/XFUmL76Dd9LQzmiQKuwzY= 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-561-3b7y_gtpN0eBAxDQ7zuuuw-1; Tue, 08 Oct 2024 21:15:27 -0400 X-MC-Unique: 3b7y_gtpN0eBAxDQ7zuuuw-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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7C05F19560BD; Wed, 9 Oct 2024 01:15:26 +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 35F5E19560A7; Wed, 9 Oct 2024 01:15:26 +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 4991FO8Y2381628 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:24 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FO882381627; Tue, 8 Oct 2024 21:15:24 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 05/22] multipath-tools tests: fix up directio tests Date: Tue, 8 Oct 2024 21:15:06 -0400 Message-ID: <20241009011523.2381575-6-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 Make the directio tests work with libcheck_pending() being separate from libcheck_check Reviewed-by: Martin Wilck 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 Wed Oct 9 01:15:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827338 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 C86E7208D0 for ; Wed, 9 Oct 2024 01:15:31 +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=1728436534; cv=none; b=ic5RBW6uoJmOFO05sQNtSlAt5yaw0IwhxVLST6WzSjV7Ay0cAQnhnU6jOiObaYooyYQvo2PVSctwLVR8Quue+d9Tpuq1iJk/8r14qnGbmoTtBLhLdf2KQD9x6+N9xMEYQFSbZSwPkwR3zWCr2/Avge3Mp1YWz5IWmW5/g4MaBhs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436534; c=relaxed/simple; bh=DZTb0BWSmeyBfjiIkjFphYb8nQXGB1t8tf042fhVx2c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kJEju2YY+N0Uua5DflalJy4WAXxns5FxfTjhzRl7TH2od9+8Iy9AS8i6ukm1v0/0+PmFKr14cYY+m05X/KmYiAhw87s662R6CnpeyfW+Z68C/wstaWkTcFlwZHY/8YgjxZGk1lnjI6NWVEtRCWRskdeIoRHVZZUBeF3SHUeNZWw= 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=BkgDyTaC; 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="BkgDyTaC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436530; 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=CxVWR9mGuSCvNQeAMZWWeiixsel1OjZZaSBgvQsHKWs=; b=BkgDyTaCQugsi7LO1A8D6Hp8wSzyDyYhi43ei7PiuhQb0y0O0Xb7IRbV3Zv8UT0bbMKye4 gO4U4wFn46b8hHTUQtyQG/7F4KRMKIPoA4XFNY2ZD/Q2nTIA9ZP41AWUUre0bCzwK3/FMV LV1C8YeCqlE+nsRUrrqbyZ2pvOmGn1A= 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-561-cjPdQYlVMUitIbM7rywbbw-1; Tue, 08 Oct 2024 21:15:27 -0400 X-MC-Unique: cjPdQYlVMUitIbM7rywbbw-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 9ACCC1956057; Wed, 9 Oct 2024 01:15:26 +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 4A4FA1956088; Wed, 9 Oct 2024 01:15:26 +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 4991FOIu2381632 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:24 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FOdO2381631; Tue, 8 Oct 2024 21:15:24 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 06/22] libmultipath: split get_state into two functions Date: Tue, 8 Oct 2024 21:15:07 -0400 Message-ID: <20241009011523.2381575-7-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 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. Reviewed-by: Martin Wilck 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 Wed Oct 9 01:15:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827354 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 3DC011CD2C for ; Wed, 9 Oct 2024 01:15:39 +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=1728436541; cv=none; b=TzVlhXMIG3ewTTtftibwyAAuHY8gok+pw11swUh5o64DDxhMWHk+72B520zfZ/x54QZbIA2JPGf/8S+Y/1I52PztP3Nx7um84A0cnxRpDBW7NMHVfJwo3D2GpmY9emrnfWCK/J0Id9UOLTWLAJwfjXEScaIeVYBFgtd3t3gK7iM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436541; c=relaxed/simple; bh=ev9hbR9J8QxR3vyZrwK3UV9bUOZUj0BJOpliD5gDO5s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VvWzxxpRiig3yKBol0qjrD4uOtfX5IxuDMq7Uv+rAl2wrzJN5cmARTWaLeH9fzbWBqhypvpkEJYcMuA/S5UxPj2WL6PLHp7Bm/tiZ8+10MdAZNfahQV41zJC9sDpbTFlO9iW1eSU4wTvSxq+XaJZEybcBw0XfHL3lJ5CAKYDjpU= 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=LVBzZIoI; 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="LVBzZIoI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436539; 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=mWIDSC0L+QVlymRHw3Vd+wWnbhNrMXo3bWFIYFiW1CA=; b=LVBzZIoIE9PcFF7TvcN/es+oqMd5udLk0kQq0jOy68gPGqnNEulkzIl/NOMWcLOLiAsIb8 vEYaC6LQwYjrpWPy7b/PiyvIdH8ACGSM5uGet1nDZJOQNJbDz/iXVAuDVmEL2i62t8TuMz mBdRU7eaW/aylykveh+XYKWN6wgzFm4= 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-512-sp-zqBpNPqSVaUNfgXZwVg-1; Tue, 08 Oct 2024 21:15:28 -0400 X-MC-Unique: sp-zqBpNPqSVaUNfgXZwVg-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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E42761955EE8; Wed, 9 Oct 2024 01:15:26 +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 8A00C1956052; Wed, 9 Oct 2024 01:15:26 +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 4991FP7T2381636 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:25 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FP2G2381635; Tue, 8 Oct 2024 21:15:25 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 07/22] libmultipath: change path_offline to path_sysfs_state Date: Tue, 8 Oct 2024 21:15:08 -0400 Message-ID: <20241009011523.2381575-8-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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. Reviewed-by: Martin Wilck 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 Wed Oct 9 01:15:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827340 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 8A54F28399 for ; Wed, 9 Oct 2024 01:15:32 +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=1728436534; cv=none; b=t5leUBe9eywzx5J3hb2BPVRVgjZuyHjegRn3jnnH0zfmmlElv5xTDFhOPAFNxxOJwIZ9y4lMN5FXYc2D5c7w757pKUo9l+RoJ2c3uKK2swQiyYcCHBKDLTKF28zDlYDCbP3gUzTd+YqCT8y2+VKhV+lZytBPRGI/biynxg9DsrM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436534; c=relaxed/simple; bh=M9eNzj/l2YhC0Ow+8Y85N5SSEpFfJWxEJcScAAC0SPQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kf4vKkNlPAhff2pTC94i8t0y6n5CcdKj4GRcO1HGmbwxH9EqlT+jxU0QdoykfdwU1KWLhxUzc7RFnG2y9XQtiCxjqosl/4O8hNst1heVB6jcMiGVilJflfRE0/8M4nsgWYxvOIjQMIuWHNZHw4h55+1Lk5NiRy2LL7Dd53hHC4w= 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=gxcRj2i2; 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="gxcRj2i2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436531; 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=/xSNWjnq4MvF1/6rUIiggT/NFv8MV1T6dyoFZEajvUg=; b=gxcRj2i26CEoNnJZC/DmvNyhY5f6ZwbLfvqvCCJfwiyX0SINj66UOiNScAvksydH3GlMVy NOc/mbxVNnjQdhNKWJqT476QcaPN+MEd65fQfsJydDii0qCU0djQO8pN34L/U4m2zthFVT nWDXHjMZu/ga7U9qVJQRjoeh8Oc446E= 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-542-FOlGk13IMTCS402ukj4PqA-1; Tue, 08 Oct 2024 21:15:28 -0400 X-MC-Unique: FOlGk13IMTCS402ukj4PqA-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 0A8941955F79; Wed, 9 Oct 2024 01:15:27 +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 9FA2919560A2; Wed, 9 Oct 2024 01:15:26 +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 4991FPQC2381640 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:25 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FPLa2381639; Tue, 8 Oct 2024 21:15:25 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 08/22] multipathd: split check_path_state into two functions Date: Tue, 8 Oct 2024 21:15:09 -0400 Message-ID: <20241009011523.2381575-9-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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(). Reviewed-by: Martin Wilck 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 Wed Oct 9 01:15:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827339 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 716FC2837B for ; Wed, 9 Oct 2024 01:15:32 +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=1728436534; cv=none; b=mW7n0/2G9QuhFYdOULdl32pzc3MC+P2NwgGhNAX61rGTZFE7PH1lKFd9aP0biNoGUKxYASps0pCpfiGPyEPDw2gkm0LqBBeL9ok5y00M3C57p3Vvsf9mNKn8Esy5GKQ+QQx4HzQ4HYJ2BqW8P0lchj4Fblo+bQwu2YDGxBm+QNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436534; c=relaxed/simple; bh=9T8Hn2v/DAA05EWxuLl/0vPGncBmmOjV0Qau/nh5324=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iUdRNU5XmmaBHbADgptiPZZH9ho6P9HtJWLpnaxwiGmVRu1BQiPDMuzXC1afALvQIlsSRZ8VYIpiL+EPkfb+pQhJCCNIu2JhMfWvt0nNLfDi3jmDNFa7Ao9hnKcW2in//4yC9YdajQGvEfXxBRgwWdgUxgfFqqguPcBVuY720kw= 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=dqLW4Jia; 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="dqLW4Jia" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436531; 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=aSJMRVFe0C+Fen574tMyVMu/sjlFYHEciXXA4GnGkuw=; b=dqLW4JiaflGc7ct3z8jJHARkulA5vfgioJ/DaM+6rK58XyUZ6FSfLcZcc3PKePDhuOaXP4 RpCj/p3kRdH60NSwfdla2pcX1wHxcua++iqa8O+G5QfGoll2YX1yQvQbb4w0uu3FWBVmob +qQwevIrT2giu55KxpM00BoATqmw43E= 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-465-yXeuaBOSMhWe5p1IQwDNag-1; Tue, 08 Oct 2024 21:15:27 -0400 X-MC-Unique: yXeuaBOSMhWe5p1IQwDNag-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 F2D0E1955D50; Wed, 9 Oct 2024 01:15:26 +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 A04E21956089; Wed, 9 Oct 2024 01:15:26 +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 4991FPij2381644 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:25 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FPUT2381643; Tue, 8 Oct 2024 21:15:25 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v4 09/22] multipathd: rename do_check_path to update_path_state Date: Tue, 8 Oct 2024 21:15:10 -0400 Message-ID: <20241009011523.2381575-10-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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..488aa225 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_state() removed or orphaned the path. */ if (r == CHECK_PATH_REMOVED || !pp->mpp) return r; From patchwork Wed Oct 9 01:15:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827353 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 7355328382 for ; Wed, 9 Oct 2024 01:15:32 +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=1728436536; cv=none; b=nVfNZq8jWwvGKdZX2vyzQAl2AMP4UgnZmjv1/eadZ+TClfIo2hRGHqtVye+ZPlaHbfTOpqTmDbychAoVvNEVwLDm4z4kxhgcgriIE761Kx7K4i89QDbPWQMBdsvmu/WpKPwHDLsFlKSgX2nUwTaqf2ESFhpNCT+WuO3b3lAXleI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436536; c=relaxed/simple; bh=jBpQ6zE+7D2Me1PRYsOFpxR6pHrr0D5aXd5/aBz1ivk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OadaMwCZK8LMgDxS+gptdYLINK2uS6kXsGMJeJptvMSXo3nQV8qPnNVFEB0ibpHLm+5foDP9MF7FWrS6QLkxGLEIlToVY1Ab+SvP/MXdWvAdeuLh10LJE+gyiQ2h8ipdJtHVsLxMRPlwPStHajYfhvQfUhPbFZdL88+x012FRNI= 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=QuyiI7O5; 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="QuyiI7O5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436531; 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=3mXkKGvLzCDO7253OcHK4EFZvaEdEDLktaTSNH4bi+w=; b=QuyiI7O5/B3VwVcSerdUuYyYgy3Vw0+ZSUfwL6gfpFB3kKwXeryZIMiYlq3XMV1OUu/OaZ 8jcJpe6okERyiMYtCByTPpdf5xuRIE5rG/5ewwYEljwqqjb4qsedVNQFScaCjffaThyBww x9BQrIov3wq6MrO4mlJp6a8d9+ZRk1I= 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-575-PF8pQg1POb-mESLTqfN2kw-1; Tue, 08 Oct 2024 21:15:28 -0400 X-MC-Unique: PF8pQg1POb-mESLTqfN2kw-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 6FEDF1955F42; Wed, 9 Oct 2024 01:15:27 +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 06F1319560A7; Wed, 9 Oct 2024 01:15:26 +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 4991FPjr2381648 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:25 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FPXK2381647; Tue, 8 Oct 2024 21:15:25 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v4 10/22] multipathd: split check_path into two functions Date: Tue, 8 Oct 2024 21:15:11 -0400 Message-ID: <20241009011523.2381575-11-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 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 | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 488aa225..ac54ace4 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,14 +2630,8 @@ 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; - struct config *conf; - time_t next_idx, goal_idx; - if (pp->initialized == INIT_REMOVED) return CHECK_PATH_SKIPPED; @@ -2645,18 +2640,27 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks, if (pp->tick) 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); - if (pp->checkint == CHECKINT_UNDEF) { + struct config *conf; + condlog(0, "%s: BUG: checkint is not set", pp->dev); - pp->checkint = checkint; + conf = get_multipath_config(); + pp->checkint = conf->checkint; + put_multipath_config(conf); } 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 +2689,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 +2826,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 Wed Oct 9 01:15:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827334 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 529CB1CABA for ; Wed, 9 Oct 2024 01:15:31 +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=1728436533; cv=none; b=chlMZvEdMk3rIKts9G5H7HtYNggr7dbfmN0d+kLUlUW/fQfSwW3sIC5Sc7zUsuFNPt1HesEU4vaD3Cx/jGub2n6oBqbVMybt6Yubr5ZK5ScFxk0+RkIek1Z0kvklmrWnqxSx23mkoUiE0gBEWykuYfq9h3nG/5b3R92TeaI38AA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436533; c=relaxed/simple; bh=99K6VTJJFJxLyjokNBy4ckNi1r7YQLB+jPluDJU/KQA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oPZoT6VEf3IXrQDbp4VzU7mKyP5EEkYp7BtyY/9073qLrVv43baDZTYPTIaTOUEsoam6N7hgBiFmQaO3nsGrkUk3YE2I2UaALd/5kTjb89EnpPUIs7saCvPpsif3P/wwGZNLsBSGA+ol8g3f6pPtifHMpzOypxrxE8aBNjlh2bQ= 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=SAvUN9Vl; 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="SAvUN9Vl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436530; 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=ppC/N7vQ2ltmCpoFIF5mEowm4dAipA83IZBEj/LI+qM=; b=SAvUN9VljgSR79BrcyFJFkOziD1OxWlml3ncE5WL+LfmAa9PrPuHaSYFtyG6BEh5eZAFG6 nawwmQsZgtX5h9AAlfhvdypxea6XiEqzbOCJBKqWrfIlrp5v8FSJUnH2FAfMaYdETYnv5l YBV5xTz1d6A9etXZg48lplF+/eq2mcw= 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-504-0muSLfKSOFmFbYSk8HVQ1A-1; Tue, 08 Oct 2024 21:15:28 -0400 X-MC-Unique: 0muSLfKSOFmFbYSk8HVQ1A-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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7A99C19560AA; Wed, 9 Oct 2024 01:15:27 +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 2E2A419560A3; Wed, 9 Oct 2024 01:15:27 +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 4991FPfZ2381652 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:25 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FP5M2381651; Tue, 8 Oct 2024 21:15:25 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v4 11/22] multipathd: split handle_uninitialized_path into two functions Date: Tue, 8 Oct 2024 21:15:12 -0400 Message-ID: <20241009011523.2381575-12-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 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 | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index ac54ace4..89f02a3a 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2715,13 +2715,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) @@ -2735,6 +2732,7 @@ handle_uninitialized_path(struct vectors * vecs, struct path * pp, 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) { @@ -2769,6 +2767,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) && @@ -2859,7 +2866,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 Wed Oct 9 01:15:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827333 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 D0157C8E0 for ; Wed, 9 Oct 2024 01:15:30 +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=1728436532; cv=none; b=U/T5mMf4qQT/GkuDvGjClaMpryA3zR7vD9NQiU1IMp6JLbUorD2qHCkmM04m9LwBZsgTmr3/XCmL3XcH5vs5p+kcNbVI4eFvesiYweJOCkrJ+AYeAe7IU8aJIa/rKxqxI/QG03wxLvFUVHQxoeJRWl6PByIny19X8N4HH6GnxH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436532; c=relaxed/simple; bh=wWPnR+o3byB0vhX6nlRIAyV5Xl/EVbcg+NTourlorjE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=djT9vtaGuEvpjVndGr+MblMcC2d1mVeTiE+DQRipWmwDB3jaVrbkgy3CcX1aw+4q1VNlprik13g2GCI/IwT5oSF2vU5pXJ91j7p/QNyCWS71/9bJU01KCe7NbVAT35+zhbEjQHaZ75a8L+nAKDlfNxxtsDl+EcMwdMJiDkuBWs4= 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=Cr2e8P7I; 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="Cr2e8P7I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436529; 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=3ocU7+I2+d1xMXa/ZMQZXn9qyzm2+esou0DE/soHhxk=; b=Cr2e8P7Ihzx4e3bcTf5SdzaRZ8C8ymM58R+EvRUc5oKC3XVWj5r7Gg1VxO/8R6CCRRswIW r3GhBKRYYSiRwaDOFItwt54W/ay3ub5oaEWueFdCfMhYiGEPPVemRx7Qg31mBsDF/1hsBT KbIN2V2M+6aEpJuLkSQ5nlXsvk8V+NA= 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-428-1pqvz1gKPlakKdVUEJxzlg-1; Tue, 08 Oct 2024 21:15:28 -0400 X-MC-Unique: 1pqvz1gKPlakKdVUEJxzlg-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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7D2281955D53; Wed, 9 Oct 2024 01:15:27 +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 3ACB419560AD; Wed, 9 Oct 2024 01:15:27 +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 4991FPBo2381656 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:25 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FP3p2381655; Tue, 8 Oct 2024 21:15:25 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v4 12/22] multipathd: split check_paths into two functions Date: Tue, 8 Oct 2024 21:15:13 -0400 Message-ID: <20241009011523.2381575-13-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 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 | 104 +++++++++++++++++++---------------------- 2 files changed, 56 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 89f02a3a..ca84331d 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) { @@ -2776,6 +2769,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) && @@ -2805,80 +2802,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; @@ -2946,10 +2932,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 Wed Oct 9 01:15:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827350 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 3155939AEB for ; Wed, 9 Oct 2024 01:15:34 +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=1728436535; cv=none; b=FMwPfC86XnKPixD3d8cp9h2TAUe7i0FD0R0gjdUGWvvoNMUB4VlZDQfRl8j2sTroCRcGoKJlfsqdsp2BgD8id8uG1z0WoVD+ozCzA+o5ZPSjSn3n7XRDZSL3569nx6hQUozNqiz8Ju0DCx3lvT0JhdFH7mHt8GHTRBFsuw6P334= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436535; c=relaxed/simple; bh=QwWLCaoqkEO7MdxjSSX1AlBvBOqamwc2C9mCQH8UZjg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rwaruBnzaELnYq0a9GTH48Erp5e+rEKuyUsCrHfkoeFanLkoRLc4ZMJA9hp5pcAPx4sR6q1Tb4o8EGfYf8tAKXNFrYXfqJLb6n80UMrrStv57o64JsB1RV3MpGc8XkPin17RIo+PWsO3ei7SWrMjejXAaW1lVxix+fb74Ems/DE= 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=Xcgp4Hz4; 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="Xcgp4Hz4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436533; 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=uMHUFgDHX/rlgtd8bQh97l/dzcQRe0tvCTscS6K1NIQ=; b=Xcgp4Hz4tGucjUJs4rZPplL9zlHcU18AdY3NVFhLCHS1opm8LXVRKEabYEz/GatoRXDeSz ZBot0yjZOsMgC5CfBxNL9aZoBQW8vEtCsnmLQjVZxJEVdR9Kd4Ya9ebWY7iyqG2zrDUanP FfsX6q7iDCUcUlags2KuunTt0DIqZVE= 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-191-ZPBpwI__NmGv1W30aIIruw-1; Tue, 08 Oct 2024 21:15:30 -0400 X-MC-Unique: ZPBpwI__NmGv1W30aIIruw-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 C596319560A3; Wed, 9 Oct 2024 01:15:27 +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 79C7C1956088; Wed, 9 Oct 2024 01:15:27 +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 4991FPWk2381660 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:26 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FPbE2381659; Tue, 8 Oct 2024 21:15:25 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 13/22] multipathd: fix "fail path" and "reinstate path" commands Date: Tue, 8 Oct 2024 21:15:14 -0400 Message-ID: <20241009011523.2381575-14-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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. Reviewed-by: Martin Wilck 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 Wed Oct 9 01:15:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827341 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 8E7451D69E for ; Wed, 9 Oct 2024 01:15:31 +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=1728436534; cv=none; b=ZDNAQ/4LhLBrg3W8gCr9zcYV434Geg7a2LEhdcir99N+E2rnOzWN05yxf/gMgHyva2kptrI8jk86Mt/deLFFdtg1tW+6APY2RdbxmrhcXXGmtXh2UfhaNIhgUckqotSrMC1eoA+h0u4SxrrWuStEomr7hIPklRkdgrqw9sEhxaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436534; c=relaxed/simple; bh=e6OzqhsAonj4bA/TeGJUiRtgmpbsZ7PzyPONeAorJIE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A2fSRL2e5JAfnWeUXprsS6Rk06bU8dQSgb9/OdbN+kLl0VJbPkEFoqb8GEgRVJw5qaIoVNP3d9oPYo7/vYY9nciHHB4LWXxwqs5O2YA1RgGElWc3Io3kqpeYhsjcXEt2guBv04F4a9+jUNtODvwjbcxbYhPz5GmlmynKIhAsmiY= 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=YXeELukt; 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="YXeELukt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436530; 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=Q0amrwaMhpzwHVsclVNYT1+bKgK5IvtHmiQkFNtvjBE=; b=YXeELuktuv9MNHqMEE5tqM7qA499NqZhQ62oBf+a0jP5H9rCCm+Ya6+oxMMehCrE1whvCE Q8CXjZc8mdz3kUY8Et75fC2HMX/Kv5YE+EeY3jwMpoPW+hx7r+QJM/g/n9RKuYzOm2XX4X eJBFquPysln6yrQ2ypmf+2gOjaFt0sU= 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-468-XxDCrwLNOnm2llaWwGa0pw-1; Tue, 08 Oct 2024 21:15:28 -0400 X-MC-Unique: XxDCrwLNOnm2llaWwGa0pw-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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CAB3F1955F40; Wed, 9 Oct 2024 01:15:27 +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 8774719560A3; Wed, 9 Oct 2024 01:15:27 +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 4991FQKv2381664 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:26 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FQGL2381663; Tue, 8 Oct 2024 21:15:26 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v4 14/22] multipathd: update priority once after updating all paths Date: Tue, 8 Oct 2024 21:15:15 -0400 Message-ID: <20241009011523.2381575-15-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 | 174 +++++++++++++++++++++++++++-------------- 2 files changed, 123 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 ca84331d..f48dbe25 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,58 @@ 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; + /* + * refresh_all will be set if the mpp has any path + * for whom pp->marginal switched values or for whom + * pp->is_checked == CHECK_PATH_NEW_UP + */ + 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 +2428,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 +2495,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 +2503,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 +2570,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 +2622,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 @@ -2856,7 +2900,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 && @@ -2929,8 +2973,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; @@ -2940,6 +2986,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 Wed Oct 9 01:15:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827344 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 8E86A1E49F for ; Wed, 9 Oct 2024 01:15:31 +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=1728436535; cv=none; b=X+klzl2T+hfvUFkfqrw0I7mxU0YoWawRdGwFjaGJW5+54YMO03TaVlO7g79wAYuD7sOba5Y9Wl0WLCih/J9T8QWOaTC7jFD7q2ixW1nqYz1+kJFWVK3KMp2l1QQhmbbE0FyLI6y8d3rUicVVGtzgWwCrjk2y6ear7vzEbE/yDtw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436535; c=relaxed/simple; bh=TVueBc3knMc5YbTSIAYV3r+I9/3bai/9AUTG9nnnTEo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XqHDVtrWgXr7VOxXKkzggm0uAvIK2eoWg85Lll7tEuJsAWjRQWLzKRbn4+xYMKTzwcCfPMC58mCMAMVV3WcVxHYBTumICorPVRlaxBGU7bY9VOKDCiIXAwPYg+h+VI6YEPjOSbwncJMlE2GAuGNsFL8nnKnQ89RvGjYVj8tKk7s= 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=TDvYMwfc; 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="TDvYMwfc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436530; 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=GRzj54dB3uT+CxggsXo/PP5NtZgRtoGn5Aag07Cnl9A=; b=TDvYMwfcNTpQZl0sfnguytIbvW+RQYDzP3uGZ2XkokDE7uCHLZ5IXQ2/xGcJNwPHu+lZgr HQyfcf0YWBQFHiMtU3NCcKD5X3etjCUWANa/s00sqUtofVYB7u+fjPsYxSRpexLM6yTaoQ p4wUUXH5Sb2TxmSfRKt/jLmDROSbjfY= 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-470-dok3otZwN-GjiUhE8MXSHA-1; Tue, 08 Oct 2024 21:15:29 -0400 X-MC-Unique: dok3otZwN-GjiUhE8MXSHA-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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E817819560B8; Wed, 9 Oct 2024 01:15:27 +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 88B7F1956052; Wed, 9 Oct 2024 01:15:27 +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 4991FQu62381668 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:26 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FQ7C2381667; Tue, 8 Oct 2024 21:15:26 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 15/22] multipathd: simplify checking for followover_should_failback Date: Tue, 8 Oct 2024 21:15:16 -0400 Message-ID: <20241009011523.2381575-16-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 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. Reviewed-by: Martin Wilck 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 f48dbe25..ea4adac8 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 Wed Oct 9 01:15:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827336 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 8E8DC1F947 for ; Wed, 9 Oct 2024 01:15:31 +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=1728436533; cv=none; b=ftsX6xQ++L4xTQgaA78/F11UrWQq+l9ICNUKKX8sgs2nbYyr+Lc27GIG8fyElh/p/8U4JXD3pVPWN66hiU86O2p9M1z81miJp8q0Ax7XR5qf6p4IzQUZZ2+meHkDgL+YbnUnucLZZcdZ6T44Ig6Snh6l/rk+78MyeNCtFmTbwbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436533; c=relaxed/simple; bh=Ama3sgic4Q55+LMItVyZvetCA/GkdYvfV2UOI8OnrTo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LxXg2eKJSmvKkSmwui82iMikyRxUSoD04WTwTx7mlTM5CLdolpwnL4mmb3cGBAlwZHB7oR3fOFtyRX2xdrQUU/6hXvMZlSqZYbbN3PjqCAL7VbIhEyTc7AjuNPfURm1v0drygtob/NTK8sCmZeoAZPWvpGChiWqpO4zXXGEhF4o= 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=fh37IySO; 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="fh37IySO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436530; 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=Md4emmpgtWKs6xlxe1zNgmqs5la/lqParoon+C+2nh0=; b=fh37IySOcbLm4gYkL/FLZJX955V1Ac9u2IKoqQQRByJYVc/vsg6wI/61AINtcFTfb1d0bO Ugf2rNDHcLj0uElUzLvAqU6eTc//dUEwOCaVYFdNvlfTekvZVAio2dB4syqoCCnb6z14KC cjj5bxjjgugIfXJFmD8UY+RpyM4jX0Q= 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-207-sabcGwbOPtGAm2sU9nvLHA-1; Tue, 08 Oct 2024 21:15:29 -0400 X-MC-Unique: sabcGwbOPtGAm2sU9nvLHA-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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 247731955F2B; Wed, 9 Oct 2024 01:15:28 +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 CC3E71956056; Wed, 9 Oct 2024 01:15:27 +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 4991FQCr2381672 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:26 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FQZF2381671; Tue, 8 Oct 2024 21:15:26 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 16/22] multipathd: only refresh prios on PATH_UP and PATH_GHOST Date: Tue, 8 Oct 2024 21:15:17 -0400 Message-ID: <20241009011523.2381575-17-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 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. Reviewed-by: Martin Wilck 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 ea4adac8..d479d0c0 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; /* * refresh_all will be set if the mpp has any path @@ -2191,7 +2191,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 Wed Oct 9 01:15:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827347 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 A37772D7BF for ; Wed, 9 Oct 2024 01:15:33 +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=1728436535; cv=none; b=TQnrr/xl2fEzQdZPzMmazhpX6PS7UUGsb+wGX3Gev12qxQbDkfwpOpSOTMu2rU9vejOp48NnduDOTQ3s8GHukoI1eSiBVrsuLNu/tOkIBQMLbThCYHF3KcT596gcyvjEXnvTeg6u8NSZAYo/jNXvdbU+U9TlK5pxR4YbXFdXFQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436535; c=relaxed/simple; bh=fogHgKkf06/XAZau6gZhQRwgh5+C538jFtU/BkSksRQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PleahiEYzmgmgBzWkomNN+Z/JOd7Ed3UMggagkIwMl5Qk9lARNb1ZUre4pZiYEHqa1hQlb/Wq/UPGdCJo1qsStA7nFN0EQzN4WTbleY5QwGjzhn5kIY1y+se0tKaPtQeGag2oFXBDrIY4VMlLkwyPdHPIaChAhrt1idS+I2tWAM= 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=KdCNCvwN; 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="KdCNCvwN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436532; 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=0u3XKLQL68D5VjpSMku/sQH35STdRSYAt+YMguSAzLM=; b=KdCNCvwN9PPBHa4tJkg6/iD5RvYkuxcGr577IEPzh6Zj7pBKfBfbBdTK4dBPcz5eba77Je oTAd4SzWqKvm4Uqp6U80u/abZDlU5sedAEdub5gXJcc907GHrWSPdrowGm/O1hUZBA6Yhg GRk617irK63cTbNPYIM1Usq0J4+EUkI= 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-267-NxG4E3MxN9C0YR4GXnxrTw-1; Tue, 08 Oct 2024 21:15:29 -0400 X-MC-Unique: NxG4E3MxN9C0YR4GXnxrTw-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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 542DA1955EA8; Wed, 9 Oct 2024 01:15:28 +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 DD3C519560AA; Wed, 9 Oct 2024 01:15:27 +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 4991FQhQ2381676 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:26 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FQ572381675; Tue, 8 Oct 2024 21:15:26 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 17/22] multipathd: remove pointless check Date: Tue, 8 Oct 2024 21:15:18 -0400 Message-ID: <20241009011523.2381575-18-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 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. Reviewed-by: Martin Wilck 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 d479d0c0..ec172021 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2550,19 +2550,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 Wed Oct 9 01:15:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827348 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 A9B31364AE for ; Wed, 9 Oct 2024 01:15:33 +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=1728436535; cv=none; b=VUMlOWBJR4p93FAmX31XAH4PbS2++Ua3E2EJBa1YqT4cU4r2UUPy7DuN+6TktmSl0O+ZatDQNGQLKSFL+BMFozm9PG7witkeOHwK7OmBOtP0nCpCcZGTtTtHIcVvI4qNJNY88gDhrx2FezDcQOUiFV7pDsGRPh0A9Pr0wwVU/tc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436535; c=relaxed/simple; bh=zaNexoUneOEQPf+9ysIfEbZaWN6PLoQIcIse4OA0nXs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z0fOpffyQ7tWrx2gjpjt6MIgmlmdiZu1YckdbgPc0AJXzdp+tGEhWMV/ymdV1DuZg+zF+mEFejvx0tH2B24i9G/nq6yfmchlBqgJrC2nHpaTXuX/9wAcwjfnSBGXn43A3FgBP9fWGzzZOxtVU0Yzu0ah3azjEfC0E8UxjtQyFf0= 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=C7JplKWk; 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="C7JplKWk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436532; 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=kR0kv7vtx28nx1HwYUaVB0jOK/P9d+OGolWX1vzDtWg=; b=C7JplKWkDPBYHAVOE4BdwKwWP7o99qt36WhDkQmkGqe/AO5fO4A7JkNUiIIdLSDz37Wb4H sQDbHc11DH7KKQf4rJtCOwQAOWrp66/vwzsdT1CZncqUijNdb9GTYMfgGUpuX3aR4P7995 OEhSHLo/zeBafN86d4xE+JRRGzbR+6I= 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-84-jEgZAmSWPKaC2ed01ArGMw-1; Tue, 08 Oct 2024 21:15:29 -0400 X-MC-Unique: jEgZAmSWPKaC2ed01ArGMw-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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6B6B319560BD; Wed, 9 Oct 2024 01:15:28 +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 272EF19560A3; Wed, 9 Oct 2024 01:15:28 +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 4991FQWa2381680 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:26 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FQNf2381679; Tue, 8 Oct 2024 21:15:26 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 18/22] multipathd: fix deferred_failback_tick for reload removes Date: Tue, 8 Oct 2024 21:15:19 -0400 Message-ID: <20241009011523.2381575-19-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 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. Reviewed-by: Martin Wilck 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 ec172021..846be5a9 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 Wed Oct 9 01:15:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827351 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 F422F383B1 for ; Wed, 9 Oct 2024 01:15:33 +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=1728436535; cv=none; b=oSWEU5YyucdAT7XDbjC1kzXJ9w9dkgHL7NlOhEMMAZqc8iJbkHJ/IfKSvLaHcwnrUc7b/OppMMWNcSfAaVqsrlGaBeMvbShuKxu8xCNe9GEdSOgYoe/792gM7a/ebPux3drxN9W1us/TMhvkYhhLNUql5G5fRHqdaweb45C30zo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436535; 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=W76G1OFiEu8dfooC/i+R2QwtxXxRwTqV5m8+yCUTMS9L3tMxcZsEfcWWwy0/Zsx2NferWNowMpEy63kxAFnnYJ+jg9OI0EUFdO51lzrrJgZrZTwTrPM3ZSBI2TwAg6AoheVJ0FA4TXNJb3GyDcpvBe0SznI3yfonSVeijn2vJNs= 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=gNiyplIH; 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="gNiyplIH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436532; 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=gNiyplIH2oLMhVJ/wAE8qbzNyHgEDk6AwhdV8GLTtcGd1Np2Wl2njCLpsw9ff17S5rCD4r wvMPAzv8NJB71/eqzlF+1Hf3Kg+GfJkeuEjozgwjjyaNwKft9UY5fGTCu6Fmm9oMH6pmBc BzUUza/VMBuZOUbTxkkT4tXF/KS+scg= 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-474-_TeDN53cM2iCarLYkqWMUw-1; Tue, 08 Oct 2024 21:15:29 -0400 X-MC-Unique: _TeDN53cM2iCarLYkqWMUw-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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8DBF219560AD; Wed, 9 Oct 2024 01:15:28 +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 4BBBF19560AD; Wed, 9 Oct 2024 01:15:28 +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 4991FQid2381684 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:26 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FQqi2381683; Tue, 8 Oct 2024 21:15:26 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v4 19/22] libmultipath: add libcheck_need_wait checker function Date: Tue, 8 Oct 2024 21:15:20 -0400 Message-ID: <20241009011523.2381575-20-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 Wed Oct 9 01:15:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827346 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 A37262D613 for ; Wed, 9 Oct 2024 01:15:33 +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=1728436535; cv=none; b=B+axJuY/UM3vvm35WhU7z82b9pl9TFm86XGczJn2ZvaaGavA1EEbiIFYuXxPplhhLCaKSaFKTmc4CG2IMm5n1T8bUr4CKqPbHEV4hffHdaNSGWqGO4YpHr8FHQSPNYqgLv8QU582rCG4YwvIR+IQO4LiwVXdJVOQyMtk/gtFr14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436535; c=relaxed/simple; bh=ri5SHcICAqKyMBnjaGQIRsNOYBAJ05yi2UXBJ9wk/Z4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=vDVEIFOZIlwSKMF9lwhmoU3k7i4W/2tAXKpnOKOcDin7TeHzTNTqVdcXTM/1EKyqX389k2CBevw7qPvwK/1fqeNA0NFTV1WAzGkjce5KRxRl7+Psp4WVX5ZqCzY0dPxM37gHcZEn0/a32g3oQKtDimGef/jZ60MON8SWTYlpbqc= 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=OryPP72M; 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="OryPP72M" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436532; 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=IUBl+QIZ0soU48AnRx9GQ7IWfuULCU8E6mFFdnJuTX8=; b=OryPP72MbFrp8AgrQnpKxwpeIsYt+XRf/ia8bFgFt5w2sUmdgXJVvXUNo/LNNcPqHn3kDd nDJMguE1ivqc55tBX98X96WBRez/0y5VyBWt51j1zQo5L7QRqH75ybqVY0xb50y27mZPPN YnoT91DGk9sNUbstOaDKWhB9l371VBE= 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-127-21e6Ai1iPsKzAkG51a0DJQ-1; Tue, 08 Oct 2024 21:15:29 -0400 X-MC-Unique: 21e6Ai1iPsKzAkG51a0DJQ-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 B375919560B0; Wed, 9 Oct 2024 01:15:28 +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 70D831956089; Wed, 9 Oct 2024 01:15:28 +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 4991FRVG2381688 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:27 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FRp82381687; Tue, 8 Oct 2024 21:15:27 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 20/22] libmultipath: don't wait in libcheck_pending Date: Tue, 8 Oct 2024 21:15:21 -0400 Message-ID: <20241009011523.2381575-21-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 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(). Reviewed-by: Martin Wilck 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 Wed Oct 9 01:15:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827345 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 9A4542C697 for ; Wed, 9 Oct 2024 01:15:33 +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=1728436535; cv=none; b=Qdh7LQFt0CAv6aXTtNYVPdTIwSAiqxk8gf4HV2jJmPow/uZUk1g89IqeMG3cCnG/t7wU1jDGKCQU7wHzMI3dHqucX+uQZUPLuMmjokZlQIM5B5cAC4TTTyazl8TCTDtdMUMWoK4GLd6vxpKJ6nx3VLhPKHz/VuB8Zgfqq2qmQvY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436535; c=relaxed/simple; bh=wQ1nePph6dUXU7bvFvowIYwNCYq8PFKyHFWr8UlTcHI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GTPQx3n7RdOedvwWpR3GSqIQL1J1VIS8NcfDn/Ycd4l7QaN1myAphbkGiuuR+gyzkMxsTZAfcqFsv+3g/t4Pnt5eJXpB6mRQFPN4Wazkidn43ba1MwJDowY3b/W68knzdl0k2tn25Fnqadqo3fFlmusAbQwMho1+wfPC0SNaQnk= 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=P+c0VpLn; 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="P+c0VpLn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436532; 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=i/IF6FkL0st3WJlofb0F9sBmzyu28qPBTHH4HvimkHs=; b=P+c0VpLn59LZ19N03OeG7LJiQ7P5k/b3/8PUMkzo7ix9jLWLfMcswKu90mTd/d0JO35Luf 6RqnCorWpBYWURhuGU7NmHY9kl8L0OHJWBzhup5u4+RjT1HdCToT+htOJ9U4PFfyAw3HoE 4UBemxZmZl18ECyUH/fRGJXiuuid/q4= 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-127-aHL2cbuhMHuoT4NOZJxuag-1; Tue, 08 Oct 2024 21:15:29 -0400 X-MC-Unique: aHL2cbuhMHuoT4NOZJxuag-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 BA7DF195609F; Wed, 9 Oct 2024 01:15:28 +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 777BD1956088; Wed, 9 Oct 2024 01:15:28 +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 4991FRP12381692 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:27 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FRJY2381691; Tue, 8 Oct 2024 21:15:27 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 21/22] multipathd: wait for checkers to complete Date: Tue, 8 Oct 2024 21:15:22 -0400 Message-ID: <20241009011523.2381575-22-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 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. Reviewed-by: Martin Wilck 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 846be5a9..e92f3ebd 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2850,6 +2850,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, }; @@ -2861,6 +2862,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); @@ -2871,6 +2873,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); @@ -2879,7 +2884,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 @@ -3001,6 +3006,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 Wed Oct 9 01:15:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13827352 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 315A939FD9 for ; Wed, 9 Oct 2024 01:15:34 +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=1728436536; cv=none; b=rBucLUFqFzxKsorwAEJ1MxvcclNRVaDHGq4aiuwr4WlEV1DQAdIW1mymcYwGpGWLVrS/NbR9F/xOPotR8dn/Z6+syEKphbZ6ARRyf4HfurXzSxzoYbrxvtfYQJt/I5DggsQxaqvZdCacqCg+z+PppSPNn5dcwZsDqXC5q6v+X/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436536; c=relaxed/simple; bh=BzJngYBcYcGRH3T9avRonYEJrI9SngwMl5W5X84CrKU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UoXcEn2JKkBbJrPpt4KF5T0Cn3MUrT+KY1YldQYJ2Yuwmppa3AoiSX61B74AxD5qN3QViBMG3Xwq1Z4tLv37bEE7G7Vi7Tah0OjZrJ0qZJJhMsDxSXz/KG1e4U9Wxojf5oJM3GmExz2wxBSY9JmzZLMBagMYXIR4aVPTPubF7kE= 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=OB45vMSu; 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="OB45vMSu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728436533; 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=rQDEPPXMo3/Bb2SHhlH4+sI+igtzxVWyAt9dqVb547s=; b=OB45vMSuJvu9v6jOuq5TSY5n2F9dwDH/eYDhUjGe9woJwi6vkPP2qwBnWCmXMX9RsrSrWB PKn384jAnp+YCIoTCOBjNe+zFd9vFfzXZs3OUqTtzSB/PQGjX8wSeFaOvZ8n1meesbYlgK RXv9Qr9uGWaVRf0mliCBLsVroOKRgPc= 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-137-No6PzEhGPBCttxT_RhI9pA-1; Tue, 08 Oct 2024 21:15:30 -0400 X-MC-Unique: No6PzEhGPBCttxT_RhI9pA-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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0CBA319560AF; Wed, 9 Oct 2024 01:15:29 +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 BD7EC19560AA; Wed, 9 Oct 2024 01:15:28 +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 4991FRAp2381696 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 8 Oct 2024 21:15:27 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 4991FRQD2381695; Tue, 8 Oct 2024 21:15:27 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck , Martin Wilck Subject: [PATCH v4 22/22] multipath-tools tests: fix up directio tests Date: Tue, 8 Oct 2024 21:15:23 -0400 Message-ID: <20241009011523.2381575-23-bmarzins@redhat.com> In-Reply-To: <20241009011523.2381575-1-bmarzins@redhat.com> References: <20241009011523.2381575-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 Make the directio tests work with no waiting in the libcheck_pending() and the new libcheck_need_wait() call. Reviewed-by: Martin Wilck 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]); }