From patchwork Fri Jun 19 11:10:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1312803 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49pGLW73yFz9sNR for ; Fri, 19 Jun 2020 21:10:27 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id A788222C1A; Fri, 19 Jun 2020 11:10:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2T1dWwu-IVzK; Fri, 19 Jun 2020 11:10:21 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id F03F522091; Fri, 19 Jun 2020 11:10:20 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D8011C0865; Fri, 19 Jun 2020 11:10:20 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5AEC8C016E for ; Fri, 19 Jun 2020 11:10:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 4872388C67 for ; Fri, 19 Jun 2020 11:10:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0BoryDNr4rSL for ; Fri, 19 Jun 2020 11:10:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by whitealder.osuosl.org (Postfix) with ESMTPS id 8648288E84 for ; Fri, 19 Jun 2020 11:10:17 +0000 (UTC) X-Originating-IP: 115.99.208.123 Received: from nusiddiq.home.org.com (unknown [115.99.208.123]) (Authenticated sender: numans@ovn.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id EAEBC20003; Fri, 19 Jun 2020 11:10:12 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Fri, 19 Jun 2020 16:40:08 +0530 Message-Id: <20200619111008.2355778-1-numans@ovn.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200619110950.2355684-1-numans@ovn.org> References: <20200619110950.2355684-1-numans@ovn.org> MIME-Version: 1.0 Cc: Han Zhou Subject: [ovs-dev] [PATCH ovn v13 1/7] I-P engine: Provide the option for an engine to clear tracked engine data in every run. 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" From: Numan Siddique A new function is added in the engine node called - clear_tracked_data() to clear any engine data which was tracked during the engine run. This tracked data has to be part of the engine 'data'. engine_init_run() calls clear_tracked_data() and each engine node interested in tracking the data needs to implement the en_clear_tracked_data() function. With this patch, an engine node can store any changes done to the engine data separately in the engine change handlers. The parent of this engine node can use this tracked data for incrementally processing the changes. Upcoming patches in the series will make use of this. Acked-by: Dumitru Ceara Acked-by: Han Zhou Signed-off-by: Numan Siddique --- lib/inc-proc-eng.c | 8 ++++++++ lib/inc-proc-eng.h | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/inc-proc-eng.c b/lib/inc-proc-eng.c index 9b1479a1c..8b56cbaec 100644 --- a/lib/inc-proc-eng.c +++ b/lib/inc-proc-eng.c @@ -121,6 +121,10 @@ void engine_cleanup(void) { for (size_t i = 0; i < engine_n_nodes; i++) { + if (engine_nodes[i]->clear_tracked_data) { + engine_nodes[i]->clear_tracked_data(engine_nodes[i]->data); + } + if (engine_nodes[i]->cleanup) { engine_nodes[i]->cleanup(engine_nodes[i]->data); } @@ -260,6 +264,10 @@ engine_init_run(void) VLOG_DBG("Initializing new run"); for (size_t i = 0; i < engine_n_nodes; i++) { engine_set_node_state(engine_nodes[i], EN_STALE); + + if (engine_nodes[i]->clear_tracked_data) { + engine_nodes[i]->clear_tracked_data(engine_nodes[i]->data); + } } } diff --git a/lib/inc-proc-eng.h b/lib/inc-proc-eng.h index 8606a360b..e25bcb29c 100644 --- a/lib/inc-proc-eng.h +++ b/lib/inc-proc-eng.h @@ -149,6 +149,10 @@ struct engine_node { * doesn't store pointers to DB records it's still safe to use). */ bool (*is_valid)(struct engine_node *); + + /* Method to clear up tracked data maintained by the engine node in the + * engine 'data'. It may be NULL. */ + void (*clear_tracked_data)(void *tracked_data); }; /* Initialize the data for the engine nodes. It calls each node's @@ -282,6 +286,7 @@ void engine_ovsdb_node_add_index(struct engine_node *, const char *name, .run = en_##NAME##_run, \ .cleanup = en_##NAME##_cleanup, \ .is_valid = en_##NAME##_is_valid, \ + .clear_tracked_data = NULL, \ }; #define ENGINE_NODE_CUSTOM_DATA(NAME, NAME_STR) \ @@ -291,6 +296,10 @@ void engine_ovsdb_node_add_index(struct engine_node *, const char *name, static bool (*en_##NAME##_is_valid)(struct engine_node *node) = NULL; \ ENGINE_NODE_DEF(NAME, NAME_STR) +#define ENGINE_NODE_WITH_CLEAR_TRACK_DATA(NAME, NAME_STR) \ + ENGINE_NODE(NAME, NAME_STR) \ + en_##NAME.clear_tracked_data = en_##NAME##_clear_tracked_data; + /* Macro to define member functions of an engine node which represents * a table of OVSDB */ #define ENGINE_FUNC_OVSDB(DB_NAME, TBL_NAME) \