From patchwork Mon Feb 26 13:55:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Heib X-Patchwork-Id: 1904376 X-Patchwork-Delegate: nusiddiq@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bN66/Tr8; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tk2F85ZB3z23cb for ; Tue, 27 Feb 2024 00:55:24 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0C69740602; Mon, 26 Feb 2024 13:55:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YE2EHOxEik2e; Mon, 26 Feb 2024 13:55:20 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8EF4C40907 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bN66/Tr8 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 8EF4C40907; Mon, 26 Feb 2024 13:55:20 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5FBCBC0077; Mon, 26 Feb 2024 13:55:20 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id A686EC0037 for ; Mon, 26 Feb 2024 13:55:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 8F41640907 for ; Mon, 26 Feb 2024 13:55:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xcxc0fA91nAI for ; Mon, 26 Feb 2024 13:55:18 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=mheib@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 39E4F40602 Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 39E4F40602 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 39E4F40602 for ; Mon, 26 Feb 2024 13:55:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708955716; 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; bh=lgNVXa/I6oFWfjP4EYfAoNptilfZ/cBIv/6ft4zQyzg=; b=bN66/Tr8D+N3eUrls9ajT0QZ5ijhOvSwAPyTPFxcoN2dGVqQu0w4vHFZ6nLzNqWu6du9kX 3OZR86CQhaH1PRdHgX5N9tlWw0wWbjpleAlzU2z43p6kHDzX4H9MhoaeScgsprzE4K8fMn lQ9aP5y8cAUhY3zAdcVQsTKD+JINYvM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-91-pU-UMmpBP1Sjiw77En5McA-1; Mon, 26 Feb 2024 08:55:15 -0500 X-MC-Unique: pU-UMmpBP1Sjiw77En5McA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id BF18D86F12B for ; Mon, 26 Feb 2024 13:55:14 +0000 (UTC) Received: from mheiblap.localdomain.com (unknown [10.47.238.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE6131C14B04; Mon, 26 Feb 2024 13:55:13 +0000 (UTC) From: Mohammad Heib To: dev@openvswitch.org Date: Mon, 26 Feb 2024 15:55:05 +0200 Message-Id: <20240226135505.628518-1-mheib@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v2] ovn-controller: Stop dropping bind_vport requests immediately after handling. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" ovn-controller immediately removes the vport_bindings requests that were generated by VIFs after handling them locally, this approach is intended to avoid binding the vport to one VIF only and allocate the vport between the different VIFs that exist in the vport:virtual-parents. Although the behavior mentioned above is correct, in some cases when the SB Database is busy the transaction that binds this vport to the desired VIF/chassis can fail and the controller will not re-try to bind the vport again because we deleted the bind_vport request in the previous loop/TXN. This patch aims to change the above behavior by storing the bind_vport requests for a bit longer time and this is done by the following: 1. mark each new bind_vport request as new. 2. loop0: ovn-controller will try to handle this bind_vport request for the first time as usual (no change). 3. loop0: ovn-controller will try to delete the already handled bind_vport request as usual but first, it will check if this request is marked as new and if so the controller will mark this request as an old request and keep it, otherwise remove it. 4. loop1: ovn-controller will try to commit the same change again for the old request, if the previous commit in loop0 succeeded the change will not have any effect on SB, otherwise we will try to commit the same vport_bind request again. 5. loop1: delete the old bind_vport request. Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1954659 Signed-off-by: Mohammad Heib Acked-by: Ales Musil --- V2: Address comments from Ales in v1. --- controller/pinctrl.c | 50 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index 98b29de9f..e2f86f299 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -6529,11 +6529,46 @@ struct put_vport_binding { uint32_t vport_key; uint32_t vport_parent_key; + + /* This vport record Only relevant if "new_record" is true. */ + bool new_record; }; /* Contains "struct put_vport_binding"s. */ static struct hmap put_vport_bindings; +/* + * Validate if the vport_binding record that was added + * by the pinctrl thread is still relevant and needs + * to be updated in the SBDB or not. + * + * vport_binding record is only relevant and needs to be updated in SB if: + * 2. The put_vport_binding:new_record is true: + * The new_record will be set to "true" when this vport record is created + * by function "pinctrl_handle_bind_vport". + * + * After the first attempt to bind this vport to the chassis and + * virtual_parent by function "run_put_vport_bindings" we will set the + * value of vpb:new_record to "false" and keep it in "put_vport_bindings" + * + * After the second attempt of binding the vpb it will be removed by + * this function. + * + * The above guarantees that we will try to bind the vport twice in + * a certain amount of time. + * +*/ +static bool +is_vport_binding_relevant(struct put_vport_binding *vpb) +{ + + if (vpb->new_record) { + vpb->new_record = false; + return true; + } + return false; +} + static void init_put_vport_bindings(void) { @@ -6541,18 +6576,21 @@ init_put_vport_bindings(void) } static void -flush_put_vport_bindings(void) +flush_put_vport_bindings(bool force_flush) { struct put_vport_binding *vport_b; - HMAP_FOR_EACH_POP (vport_b, hmap_node, &put_vport_bindings) { - free(vport_b); + HMAP_FOR_EACH_SAFE (vport_b, hmap_node, &put_vport_bindings) { + if (!is_vport_binding_relevant(vport_b) || force_flush) { + hmap_remove(&put_vport_bindings, &vport_b->hmap_node); + free(vport_b); + } } } static void destroy_put_vport_bindings(void) { - flush_put_vport_bindings(); + flush_put_vport_bindings(true); hmap_destroy(&put_vport_bindings); } @@ -6630,7 +6668,7 @@ run_put_vport_bindings(struct ovsdb_idl_txn *ovnsb_idl_txn, sbrec_port_binding_by_key, chassis, vpb); } - flush_put_vport_bindings(); + flush_put_vport_bindings(false); } /* Called with in the pinctrl_handler thread context. */ @@ -6668,7 +6706,7 @@ pinctrl_handle_bind_vport( vpb->dp_key = dp_key; vpb->vport_key = vport_key; vpb->vport_parent_key = vport_parent_key; - + vpb->new_record = true; notify_pinctrl_main(); }