get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/815885/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 815885,
    "url": "http://patchwork.ozlabs.org/api/patches/815885/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/20170919220125.32535-19-blp@ovn.org/",
    "project": {
        "id": 47,
        "url": "http://patchwork.ozlabs.org/api/projects/47/?format=api",
        "name": "Open vSwitch",
        "link_name": "openvswitch",
        "list_id": "ovs-dev.openvswitch.org",
        "list_email": "ovs-dev@openvswitch.org",
        "web_url": "http://openvswitch.org/",
        "scm_url": "git@github.com:openvswitch/ovs.git",
        "webscm_url": "https://github.com/openvswitch/ovs",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20170919220125.32535-19-blp@ovn.org>",
    "list_archive_url": null,
    "date": "2017-09-19T22:00:51",
    "name": "[ovs-dev,RFC,18/52] ovsdb-server: Distinguish logs from other replicas.",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": false,
    "hash": "a651929ee9b74fa85d664693d2931ffc58c67d19",
    "submitter": {
        "id": 67603,
        "url": "http://patchwork.ozlabs.org/api/people/67603/?format=api",
        "name": "Ben Pfaff",
        "email": "blp@ovn.org"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/20170919220125.32535-19-blp@ovn.org/mbox/",
    "series": [
        {
            "id": 3975,
            "url": "http://patchwork.ozlabs.org/api/series/3975/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=3975",
            "date": "2017-09-19T22:00:34",
            "name": "clustering implementation",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/3975/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/815885/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/815885/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<ovs-dev-bounces@openvswitch.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "dev@openvswitch.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "ovs-dev@mail.linuxfoundation.org"
        ],
        "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=openvswitch.org\n\t(client-ip=140.211.169.12; helo=mail.linuxfoundation.org;\n\tenvelope-from=ovs-dev-bounces@openvswitch.org;\n\treceiver=<UNKNOWN>)",
        "Received": [
            "from mail.linuxfoundation.org (mail.linuxfoundation.org\n\t[140.211.169.12])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxcbg3rR2z9sPr\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 08:14:07 +1000 (AEST)",
            "from mail.linux-foundation.org (localhost [127.0.0.1])\n\tby mail.linuxfoundation.org (Postfix) with ESMTP id 2BB49CCC;\n\tTue, 19 Sep 2017 22:02:07 +0000 (UTC)",
            "from smtp2.linuxfoundation.org (smtp2.linux-foundation.org\n\t[172.17.192.36])\n\tby mail.linuxfoundation.org (Postfix) with ESMTPS id 7D4A8CB5\n\tfor <dev@openvswitch.org>; Tue, 19 Sep 2017 22:02:03 +0000 (UTC)",
            "from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net\n\t[217.70.183.196])\n\tby smtp2.linuxfoundation.org (Postfix) with ESMTPS id AA6141DCE2\n\tfor <dev@openvswitch.org>; Tue, 19 Sep 2017 22:02:02 +0000 (UTC)",
            "from sigabrt.benpfaff.org (unknown [208.91.2.3])\n\t(Authenticated sender: blp@ovn.org)\n\tby relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 382D5172094;\n\tWed, 20 Sep 2017 00:01:59 +0200 (CEST)"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "X-Originating-IP": "208.91.2.3",
        "From": "Ben Pfaff <blp@ovn.org>",
        "To": "dev@openvswitch.org",
        "Date": "Tue, 19 Sep 2017 15:00:51 -0700",
        "Message-Id": "<20170919220125.32535-19-blp@ovn.org>",
        "X-Mailer": "git-send-email 2.10.2",
        "In-Reply-To": "<20170919220125.32535-1-blp@ovn.org>",
        "References": "<20170919220125.32535-1-blp@ovn.org>",
        "X-Spam-Status": "No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW\n\tautolearn=ham version=3.3.1",
        "X-Spam-Checker-Version": "SpamAssassin 3.3.1 (2010-03-16) on\n\tsmtp2.linux-foundation.org",
        "Cc": "Ben Pfaff <blp@ovn.org>",
        "Subject": "[ovs-dev] [PATCH RFC 18/52] ovsdb-server: Distinguish logs from\n\tother replicas.",
        "X-BeenThere": "ovs-dev@openvswitch.org",
        "X-Mailman-Version": "2.1.12",
        "Precedence": "list",
        "List-Id": "<ovs-dev.openvswitch.org>",
        "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>",
        "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>",
        "List-Post": "<mailto:ovs-dev@openvswitch.org>",
        "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>",
        "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Sender": "ovs-dev-bounces@openvswitch.org",
        "Errors-To": "ovs-dev-bounces@openvswitch.org"
    },
    "content": "Until now, ovsdb-server has internally chained a list of replicas from\neach database.  Whenever a transaction commits, it is passed to each\nof the replicas.  The first replica, which until now is always the disk\nfile that stores the database, is special because it is the only replica\nthat can report an error and thereby abort the transaction.  This commit\nbreaks that first replica out as a separate kind of entity that is not\non the list of replicas.  In later commits when we start adding support\nfor clustering, there will only be more and more special cases for the\n\"first replica\", so it makes sense to distinguish it this way.\n\nSigned-off-by: Ben Pfaff <blp@ovn.org>\n---\n ovsdb/file.c        | 33 ++++++---------------------------\n ovsdb/file.h        |  7 ++++++-\n ovsdb/monitor.c     |  4 +---\n ovsdb/ovsdb.c       |  7 +++++++\n ovsdb/ovsdb.h       |  5 +++--\n ovsdb/transaction.c | 14 +++++++-------\n 6 files changed, 30 insertions(+), 40 deletions(-)",
    "diff": "diff --git a/ovsdb/file.c b/ovsdb/file.c\nindex 1668220bc9a2..6b2adad2759c 100644\n--- a/ovsdb/file.c\n+++ b/ovsdb/file.c\n@@ -1,4 +1,4 @@\n-/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2016 Nicira, Inc.\n+/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2016, 2017 Nicira, Inc.\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\");\n  * you may not use this file except in compliance with the License.\n@@ -253,6 +253,7 @@ ovsdb_file_open__(const char *file_name,\n         if (filep) {\n             *filep = file;\n         }\n+        db->file = file;\n     } else {\n         ovsdb_log_close(log);\n     }\n@@ -503,10 +504,7 @@ ovsdb_file_read_schema(const char *file_name, struct ovsdb_schema **schemap)\n     return ovsdb_file_open_log(file_name, OVSDB_LOG_READ_ONLY, NULL, schemap);\n }\n \f\n-/* Replica implementation. */\n-\n struct ovsdb_file {\n-    struct ovsdb_replica replica;\n     struct ovsdb *db;\n     struct ovsdb_log *log;\n     char *file_name;\n@@ -516,8 +514,6 @@ struct ovsdb_file {\n     off_t snapshot_size;\n };\n \n-static const struct ovsdb_replica_class ovsdb_file_class;\n-\n static struct ovsdb_error *\n ovsdb_file_create(struct ovsdb *db, struct ovsdb_log *log,\n                   const char *file_name,\n@@ -540,7 +536,6 @@ ovsdb_file_create(struct ovsdb *db, struct ovsdb_log *log,\n     }\n \n     file = xmalloc(sizeof *file);\n-    ovsdb_replica_init(&file->replica, &ovsdb_file_class);\n     file->db = db;\n     file->log = log;\n     file->file_name = abs_name;\n@@ -548,19 +543,11 @@ ovsdb_file_create(struct ovsdb *db, struct ovsdb_log *log,\n     file->next_compact = file->last_compact + COMPACT_MIN_MSEC;\n     file->snapshot_size = snapshot_size;\n     file->n_transactions = n_transactions;\n-    ovsdb_add_replica(db, &file->replica);\n \n     *filep = file;\n     return NULL;\n }\n \n-static struct ovsdb_file *\n-ovsdb_file_cast(struct ovsdb_replica *replica)\n-{\n-    ovs_assert(replica->class == &ovsdb_file_class);\n-    return CONTAINER_OF(replica, struct ovsdb_file, replica);\n-}\n-\n static bool\n ovsdb_file_change_cb(const struct ovsdb_row *old,\n                      const struct ovsdb_row *new,\n@@ -572,11 +559,10 @@ ovsdb_file_change_cb(const struct ovsdb_row *old,\n     return true;\n }\n \n-static struct ovsdb_error *\n-ovsdb_file_commit(struct ovsdb_replica *replica,\n+struct ovsdb_error *\n+ovsdb_file_commit(struct ovsdb_file *file,\n                   const struct ovsdb_txn *txn, bool durable)\n {\n-    struct ovsdb_file *file = ovsdb_file_cast(replica);\n     struct ovsdb_file_txn ftxn;\n     struct ovsdb_error *error;\n \n@@ -759,20 +745,13 @@ exit:\n     return error;\n }\n \n-static void\n-ovsdb_file_destroy(struct ovsdb_replica *replica)\n+void\n+ovsdb_file_destroy(struct ovsdb_file *file)\n {\n-    struct ovsdb_file *file = ovsdb_file_cast(replica);\n-\n     ovsdb_log_close(file->log);\n     free(file->file_name);\n     free(file);\n }\n-\n-static const struct ovsdb_replica_class ovsdb_file_class = {\n-    ovsdb_file_commit,\n-    ovsdb_file_destroy\n-};\n \f\n static void\n ovsdb_file_txn_init(struct ovsdb_file_txn *ftxn)\ndiff --git a/ovsdb/file.h b/ovsdb/file.h\nindex ee67b127dd25..d4b8c2015815 100644\n--- a/ovsdb/file.h\n+++ b/ovsdb/file.h\n@@ -1,4 +1,4 @@\n-/* Copyright (c) 2009, 2010, 2011 Nicira, Inc.\n+/* Copyright (c) 2009, 2010, 2011, 2016, 2017 Nicira, Inc.\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\");\n  * you may not use this file except in compliance with the License.\n@@ -23,6 +23,7 @@\n struct ovsdb;\n struct ovsdb_file;\n struct ovsdb_schema;\n+struct ovsdb_txn;\n \n struct ovsdb_error *ovsdb_file_open(const char *file_name, bool read_only,\n                                     struct ovsdb **, struct ovsdb_file **)\n@@ -44,4 +45,8 @@ struct ovsdb_error *ovsdb_file_read_schema(const char *file_name,\n                                            struct ovsdb_schema **)\n     OVS_WARN_UNUSED_RESULT;\n \n+struct ovsdb_error *ovsdb_file_commit(struct ovsdb_file *,\n+                                      const struct ovsdb_txn *, bool durable);\n+void ovsdb_file_destroy(struct ovsdb_file *);\n+\n #endif /* ovsdb/file.h */\ndiff --git a/ovsdb/monitor.c b/ovsdb/monitor.c\nindex c0f9c557ab67..b2ecd109ed60 100644\n--- a/ovsdb/monitor.c\n+++ b/ovsdb/monitor.c\n@@ -1573,7 +1573,7 @@ ovsdb_monitor_destroy(struct ovsdb_monitor *dbmon)\n     free(dbmon);\n }\n \n-static struct ovsdb_error *\n+static void\n ovsdb_monitor_commit(struct ovsdb_replica *replica,\n                      const struct ovsdb_txn *txn,\n                      bool durable OVS_UNUSED)\n@@ -1601,8 +1601,6 @@ ovsdb_monitor_commit(struct ovsdb_replica *replica,\n         ovsdb_monitor_json_cache_flush(m);\n         break;\n     }\n-\n-    return NULL;\n }\n \n static void\ndiff --git a/ovsdb/ovsdb.c b/ovsdb/ovsdb.c\nindex d8f441ad0728..213d0d4823e1 100644\n--- a/ovsdb/ovsdb.c\n+++ b/ovsdb/ovsdb.c\n@@ -18,6 +18,7 @@\n #include \"ovsdb.h\"\n \n #include \"column.h\"\n+#include \"file.h\"\n #include \"openvswitch/json.h\"\n #include \"ovsdb-error.h\"\n #include \"ovsdb-parser.h\"\n@@ -328,6 +329,7 @@ ovsdb_create(struct ovsdb_schema *schema)\n \n     db = xmalloc(sizeof *db);\n     db->schema = schema;\n+    db->file = NULL;\n     ovs_list_init(&db->replicas);\n     ovs_list_init(&db->triggers);\n     db->run_triggers = false;\n@@ -363,6 +365,11 @@ ovsdb_destroy(struct ovsdb *db)\n     if (db) {\n         struct shash_node *node;\n \n+        /* Close the log. */\n+        if (db->file) {\n+            ovsdb_file_destroy(db->file);\n+        }\n+\n         /* Remove all the replicas. */\n         while (!ovs_list_is_empty(&db->replicas)) {\n             struct ovsdb_replica *r\ndiff --git a/ovsdb/ovsdb.h b/ovsdb/ovsdb.h\nindex 89bbfa2512fa..06cd3a72e49e 100644\n--- a/ovsdb/ovsdb.h\n+++ b/ovsdb/ovsdb.h\n@@ -56,6 +56,7 @@ bool ovsdb_schema_equal(const struct ovsdb_schema *,\n /* Database. */\n struct ovsdb {\n     struct ovsdb_schema *schema;\n+    struct ovsdb_file *file;    /* If nonnull, log for transactions. */\n     struct ovs_list replicas;   /* Contains \"struct ovsdb_replica\"s. */\n     struct shash tables;        /* Contains \"struct ovsdb_table *\"s. */\n \n@@ -87,8 +88,8 @@ struct ovsdb_replica {\n };\n \n struct ovsdb_replica_class {\n-    struct ovsdb_error *(*commit)(struct ovsdb_replica *,\n-                                  const struct ovsdb_txn *, bool durable);\n+    void (*commit)(struct ovsdb_replica *,\n+                   const struct ovsdb_txn *, bool durable);\n     void (*destroy)(struct ovsdb_replica *);\n };\n \ndiff --git a/ovsdb/transaction.c b/ovsdb/transaction.c\nindex 2e315804a19e..55d562c95fcb 100644\n--- a/ovsdb/transaction.c\n+++ b/ovsdb/transaction.c\n@@ -1,4 +1,4 @@\n-/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.\n+/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2017 Nicira, Inc.\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\");\n  * you may not use this file except in compliance with the License.\n@@ -19,6 +19,7 @@\n \n #include \"bitmap.h\"\n #include \"openvswitch/dynamic-string.h\"\n+#include \"file.h\"\n #include \"hash.h\"\n #include \"openvswitch/hmap.h\"\n #include \"openvswitch/json.h\"\n@@ -864,17 +865,16 @@ ovsdb_txn_commit_(struct ovsdb_txn *txn, bool durable)\n     }\n \n     /* Send the commit to each replica. */\n-    LIST_FOR_EACH (replica, node, &txn->db->replicas) {\n-        error = (replica->class->commit)(replica, txn, durable);\n+    if (txn->db->file) {\n+        error = ovsdb_file_commit(txn->db->file, txn, durable);\n         if (error) {\n-            /* We don't support two-phase commit so only the first replica is\n-             * allowed to report an error. */\n-            ovs_assert(&replica->node == txn->db->replicas.next);\n-\n             ovsdb_txn_abort(txn);\n             return error;\n         }\n     }\n+    LIST_FOR_EACH (replica, node, &txn->db->replicas) {\n+        replica->class->commit(replica, txn, durable);\n+    }\n \n     /* Finalize commit. */\n     txn->db->run_triggers = true;\n",
    "prefixes": [
        "ovs-dev",
        "RFC",
        "18/52"
    ]
}