From patchwork Tue Sep 29 18:34:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Gray X-Patchwork-Id: 1373561 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.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: 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=b7FQIIOQ; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C17ND72Gsz9sRR for ; Wed, 30 Sep 2020 04:34:51 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A6B4C871AA; Tue, 29 Sep 2020 18:34:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id by-EZRO2ggup; Tue, 29 Sep 2020 18:34:46 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id A6ACE87180; Tue, 29 Sep 2020 18:34:46 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7E7D4C0889; Tue, 29 Sep 2020 18:34:46 +0000 (UTC) X-Original-To: ovs-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 D7B73C0051 for ; Tue, 29 Sep 2020 18:34:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D288185D5F for ; Tue, 29 Sep 2020 18:34:44 +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 gpG5sdsisEk9 for ; Tue, 29 Sep 2020 18:34:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by whitealder.osuosl.org (Postfix) with ESMTPS id 2F50785B7C for ; Tue, 29 Sep 2020 18:34:43 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601404481; 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=lcl+K2PHVp10JGU9KOi0gYDGQlHOfCz1YcRZQ4uOmyw=; b=b7FQIIOQOmrrzX82Drjo07gUmh27BvHQ9uXJGMOYHIOsEyilqrlZRR7JuI8RXZ2/fMeI3E eLmJ4JUBFlA112vrryJGw0gwmA9I/UPmNKjt5iINh3D5yXo1O2aSLZZiVapy9AWFTqqtU5 69tQL4I03k5zN8XJrV5cWzI0wsguXlc= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-68-rfdREuwOMjuJ1gjJH2TBjQ-1; Tue, 29 Sep 2020 14:34:40 -0400 X-MC-Unique: rfdREuwOMjuJ1gjJH2TBjQ-1 Received: by mail-qv1-f72.google.com with SMTP id dj20so3052700qvb.23 for ; Tue, 29 Sep 2020 11:34:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lcl+K2PHVp10JGU9KOi0gYDGQlHOfCz1YcRZQ4uOmyw=; b=rEc6qt4OwVdjRkke8sjkpp42H9uYXuORBeH03/5FKcXJ3fRJbk1VO643QeeesX+AdY UYwILIMgX0un/NJAGTSZflzbGw+ECNEo4tjM6SP24tcWDABpUFgZiOl5uHD1r2/aJhwi YtFl59Y8b5tjMgD9+5eC4AwtRnM+1GIxNwqeYwjzYRUmzhyitstNHNUw+fa+1+0AmRwS rklCLKe3fWX3siuHJhC20Wb+RB45EvXbPcQUmOIWmdZa502mLFjzOXgQql+KrLXx6RcH mbMyB47AuVdp7nzJpFQw+iCMh1qXV8W9fZQa1mj3/X63X7KOGbPCR9pJrvN0ZgIIfIK/ JijQ== X-Gm-Message-State: AOAM530bqGvHSOP1AtHazaqdAMAy/hRcVdGnt/3iP4SPQ+rzmVgl5TxL /64jHtfM3+kmjPWZ0OSsPovWSn/P6IqHVgPjA7YH2MJyiuRG7/TpJp1AzOOVvtkY5p7Z9+HhtyF SBzfMv4Qcf2vF5s0UsA== X-Received: by 2002:a0c:fd42:: with SMTP id j2mr5849731qvs.37.1601404479618; Tue, 29 Sep 2020 11:34:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDzOd9jAflVski7bioZnf+dPMoqKyREZqvbthQ+x7UAFaT8jC6fXl+eqcOIUuhsQ3ebPAMNw== X-Received: by 2002:a0c:fd42:: with SMTP id j2mr5849701qvs.37.1601404479208; Tue, 29 Sep 2020 11:34:39 -0700 (PDT) Received: from wsfd-netdev77.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id x3sm6641850qta.53.2020.09.29.11.34.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 11:34:38 -0700 (PDT) From: Mark Gray To: ovs-dev@openvswitch.org Date: Tue, 29 Sep 2020 14:34:33 -0400 Message-Id: <20200929183433.925570-1-mark.d.gray@redhat.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mark.d.gray@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH] ovsdb-idl: Fix *_is_new() IDL functions 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" Currently all functions of the type *_is_new() always return 'false'. This patch resolves this issue by using the 'OVSDB_IDL_CHANGE_INSERT' 'change_seqno' instead of the 'OVSDB_IDL_CHANGE_MODIFY' 'change_seqno' to determine if a row is new and by resetting the 'OVSDB_IDL_CHANGE_INSERT' 'change_seqno' on clear. Further to this, the code is also updated to match this behaviour: When a row is inserted, the 'OVSDB_IDL_CHANGE_INSERT' 'change_seqno' is updated to match the new database change_seqno. The 'OVSDB_IDL_CHANGE_MODIFY' 'change_seqno' is not set for inserted rows (only for updated rows). At the end of a run, ovsdb_idl_db_track_clear() should be called to clear all tracking information, this includes resetting all row 'change_seqno' to zero. This will ensure that subsequent runs will not see a previously 'new' row. add_tracked_change_for_references() is updated to only track rows that reference the current row. Signed-off-by: Mark Gray Suggested-by: Dumitru Ceara Reported-at: https://bugzilla.redhat.com/1883562 --- lib/ovsdb-idl.c | 39 +++++++++++++++++++++++++++------------ ovsdb/ovsdb-idlc.in | 2 +- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index d8f221ca6..3cfd73871 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -1959,6 +1959,11 @@ ovsdb_idl_db_track_clear(struct ovsdb_idl_db *db) free(row->updated); row->updated = NULL; } + + row->change_seqno[OVSDB_IDL_CHANGE_INSERT] = + row->change_seqno[OVSDB_IDL_CHANGE_MODIFY] = + row->change_seqno[OVSDB_IDL_CHANGE_DELETE] = 0; + ovs_list_remove(&row->track_node); ovs_list_init(&row->track_node); if (ovsdb_idl_row_is_orphan(row) && row->tracked_old_datum) { @@ -2684,24 +2689,27 @@ ovsdb_idl_process_update2(struct ovsdb_idl_table *table, return OVSDB_IDL_UPDATE_DB_CHANGED; } -/* Recursively add rows to tracked change lists for current row - * and the rows that reference this row. */ +/* Recursively add rows to tracked change lists for all rows that reference + 'row'. */ static void add_tracked_change_for_references(struct ovsdb_idl_row *row) { - if (ovs_list_is_empty(&row->track_node) && - ovsdb_idl_track_is_set(row->table)) { - ovs_list_push_back(&row->table->track_list, - &row->track_node); - row->change_seqno[OVSDB_IDL_CHANGE_MODIFY] - = row->table->change_seqno[OVSDB_IDL_CHANGE_MODIFY] - = row->table->db->change_seqno + 1; - const struct ovsdb_idl_arc *arc; LIST_FOR_EACH (arc, dst_node, &row->dst_arcs) { - add_tracked_change_for_references(arc->src); + struct ovsdb_idl_row *ref = arc->src; + + if (ovs_list_is_empty(&ref->track_node) && + ovsdb_idl_track_is_set(ref->table)) { + ovs_list_push_back(&ref->table->track_list, + &ref->track_node); + + ref->change_seqno[OVSDB_IDL_CHANGE_MODIFY] + = ref->table->change_seqno[OVSDB_IDL_CHANGE_MODIFY] + = ref->table->db->change_seqno + 1; + + add_tracked_change_for_references(ref); + } } - } } @@ -2767,7 +2775,14 @@ ovsdb_idl_row_change__(struct ovsdb_idl_row *row, const struct json *row_json, row->change_seqno[change] = row->table->change_seqno[change] = row->table->db->change_seqno + 1; + if (table->modes[column_idx] & OVSDB_IDL_TRACK) { + if (ovs_list_is_empty(&row->track_node) && + ovsdb_idl_track_is_set(row->table)) { + ovs_list_push_back(&row->table->track_list, + &row->track_node); + } + add_tracked_change_for_references(row); if (!row->updated) { row->updated = bitmap_allocate(class->n_columns); diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index 698fe25f3..89c3eb682 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -282,7 +282,7 @@ const struct %(s)s *%(s)s_table_track_get_first(const struct %(s)s_table *); /* Returns true if 'row' was inserted since the last change tracking reset. */ static inline bool %(s)s_is_new(const struct %(s)s *row) { - return %(s)s_row_get_seqno(row, OVSDB_IDL_CHANGE_MODIFY) == 0; + return %(s)s_row_get_seqno(row, OVSDB_IDL_CHANGE_INSERT) > 0; } /* Returns true if 'row' was deleted since the last change tracking reset. */