From patchwork Tue Oct 15 03:28: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: 13835694 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 144C3170A29 for ; Tue, 15 Oct 2024 03:28:41 +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=1728962923; cv=none; b=EWkY7mEc5WydCwk/jJec6hhIAXUvZ/HHWm4MtGtajpEckb1xc4PfR1XFIVD5+yXOudLXeOdldfAmACOeUG7thKPTbQIyT+gNEHSv/tM9zO5ZI+Bd9xe0mCGkFhoyo9auGqkeRl4WfB80DOXsXmTpRzWPXVpOXl9Ko2qs8yt9fgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728962923; c=relaxed/simple; bh=jBpQ6zE+7D2Me1PRYsOFpxR6pHrr0D5aXd5/aBz1ivk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eCJTIfBnw0DFDfsj0F2HA2vQvng99KdlmUReXD+Jv31+tgkdrkAzTLkJ7k4vlsNn5T8dPz2kj5ztcrHJumUixo4q5ssDREo3k9UZxaspqjpbHiQd9MWvm6KGIGxj00SCS8eNjlJVRJK/XZNW3/QTnuW21h9kqXC5T8guKp+60fw= 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=SyxBz+zp; 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="SyxBz+zp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728962921; 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=SyxBz+zp44pT6m4Pvg+Wi/sdn17kNwMg5o5nZ3I7BqFx9+cE89MCzxZCMn0A6yQm3vn3af H94bbjPmhDdBCeFSN3VKbA9/8HWQT8ofgbOiqARfOVsjJlJ4lYbRy74d4Q6gaYbksxDYbC o96onEXWI6Q13ip53HhI0aFy+zvwqY8= 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-532-fkiCE6kzPOSOStDddo635Q-1; Mon, 14 Oct 2024 23:28:39 -0400 X-MC-Unique: fkiCE6kzPOSOStDddo635Q-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9A01519560BA; Tue, 15 Oct 2024 03:28:38 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C21B300019D; Tue, 15 Oct 2024 03:28:38 +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 49F3Sbld2693319 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 14 Oct 2024 23:28:37 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.2/8.17.2/Submit) id 49F3Sbxs2693318; Mon, 14 Oct 2024 23:28:37 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v5 10/23] multipathd: split check_path into two functions Date: Mon, 14 Oct 2024 23:28:22 -0400 Message-ID: <20241015032835.2693247-11-bmarzins@redhat.com> In-Reply-To: <20241015032835.2693247-1-bmarzins@redhat.com> References: <20241015032835.2693247-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 Reviewed-by: Martin Wilck --- 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)