get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 54960,
    "url": "http://patches.dpdk.org/api/patches/54960/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1560957293-17294-7-git-send-email-ndragazis@arrikto.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1560957293-17294-7-git-send-email-ndragazis@arrikto.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1560957293-17294-7-git-send-email-ndragazis@arrikto.com",
    "date": "2019-06-19T15:14:31",
    "name": "[06/28] vhost: move vhost-user connection",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": true,
    "hash": "fd607b609a78f7ed3603b8b56120ffc39e807462",
    "submitter": {
        "id": 1339,
        "url": "http://patches.dpdk.org/api/people/1339/?format=api",
        "name": "Nikos Dragazis",
        "email": "ndragazis@arrikto.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1560957293-17294-7-git-send-email-ndragazis@arrikto.com/mbox/",
    "series": [
        {
            "id": 5082,
            "url": "http://patches.dpdk.org/api/series/5082/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=5082",
            "date": "2019-06-19T15:14:25",
            "name": "vhost: add virtio-vhost-user transport",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/5082/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/54960/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/54960/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 705251C3B3;\n\tWed, 19 Jun 2019 17:15:53 +0200 (CEST)",
            "from mx0.arrikto.com (mx0.arrikto.com [212.71.252.59])\n\tby dpdk.org (Postfix) with ESMTP id AF8E21C388\n\tfor <dev@dpdk.org>; Wed, 19 Jun 2019 17:15:38 +0200 (CEST)",
            "from troi.prod.arr (mail.arr [10.99.0.5])\n\tby mx0.arrikto.com (Postfix) with ESMTP id 80BB418200A;\n\tWed, 19 Jun 2019 18:15:38 +0300 (EEST)",
            "from localhost.localdomain (unknown [10.89.50.133])\n\tby troi.prod.arr (Postfix) with ESMTPSA id D0C29394;\n\tWed, 19 Jun 2019 18:15:37 +0300 (EEST)"
        ],
        "From": "Nikos Dragazis <ndragazis@arrikto.com>",
        "To": "dev@dpdk.org",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>,\n\tTiwei Bie <tiwei.bie@intel.com>, Zhihong Wang <zhihong.wang@intel.com>,\n\tStefan Hajnoczi <stefanha@redhat.com>, Wei Wang <wei.w.wang@intel.com>,\n\tStojaczyk Dariusz <dariusz.stojaczyk@intel.com>,\n\tVangelis Koukis <vkoukis@arrikto.com>",
        "Date": "Wed, 19 Jun 2019 18:14:31 +0300",
        "Message-Id": "<1560957293-17294-7-git-send-email-ndragazis@arrikto.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1560957293-17294-1-git-send-email-ndragazis@arrikto.com>",
        "References": "<1560957293-17294-1-git-send-email-ndragazis@arrikto.com>",
        "Subject": "[dpdk-dev] [PATCH 06/28] vhost: move vhost-user connection",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "The AF_UNIX transport can accept multiple client connections on a server\nsocket.  Each connection instantiates a separate vhost-user device,\nwhich is stored as a vhost_user_connection.  This behavior is specific\nto AF_UNIX and other transports may not support N connections per\nsocket endpoint.\n\nMove struct vhost_user_connection to trans_af_unix.c and\nconn_list/conn_mutex into struct af_unix_socket.\n\nSigned-off-by: Nikos Dragazis <ndragazis@arrikto.com>\nSigned-off-by: Stefan Hajnoczi <stefanha@redhat.com>\n---\n lib/librte_vhost/socket.c        | 54 +++---------------------------\n lib/librte_vhost/trans_af_unix.c | 72 ++++++++++++++++++++++++++++++++++++----\n lib/librte_vhost/vhost.h         | 19 ++---------\n 3 files changed, 74 insertions(+), 71 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c\nindex df6d707..976343c 100644\n--- a/lib/librte_vhost/socket.c\n+++ b/lib/librte_vhost/socket.c\n@@ -341,13 +341,6 @@ rte_vhost_driver_register(const char *path, uint64_t flags)\n \t\tvhost_user_socket_mem_free(vsocket);\n \t\tgoto out;\n \t}\n-\tTAILQ_INIT(&vsocket->conn_list);\n-\tret = pthread_mutex_init(&vsocket->conn_mutex, NULL);\n-\tif (ret) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG,\n-\t\t\t\"error: failed to init connection mutex\\n\");\n-\t\tgoto out_free;\n-\t}\n \tvsocket->dequeue_zero_copy = flags & RTE_VHOST_USER_DEQUEUE_ZERO_COPY;\n \n \t/*\n@@ -395,7 +388,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)\n \t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\"Postcopy requested but not compiled\\n\");\n \t\tret = -1;\n-\t\tgoto out_mutex;\n+\t\tgoto out_free;\n #endif\n \t}\n \n@@ -403,14 +396,14 @@ rte_vhost_driver_register(const char *path, uint64_t flags)\n \t\tvsocket->reconnect = !(flags & RTE_VHOST_USER_NO_RECONNECT);\n \t\tif (vsocket->reconnect && reconn_tid == 0) {\n \t\t\tif (vhost_user_reconnect_init() != 0)\n-\t\t\t\tgoto out_mutex;\n+\t\t\t\tgoto out_free;\n \t\t}\n \t} else {\n \t\tvsocket->is_server = true;\n \t}\n \tret = trans_ops->socket_init(vsocket, flags);\n \tif (ret < 0) {\n-\t\tgoto out_mutex;\n+\t\tgoto out_free;\n \t}\n \n \tvhost_user.vsockets[vhost_user.vsocket_cnt++] = vsocket;\n@@ -418,11 +411,6 @@ rte_vhost_driver_register(const char *path, uint64_t flags)\n \tpthread_mutex_unlock(&vhost_user.mutex);\n \treturn ret;\n \n-out_mutex:\n-\tif (pthread_mutex_destroy(&vsocket->conn_mutex)) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG,\n-\t\t\t\"error: failed to destroy connection mutex\\n\");\n-\t}\n out_free:\n \tvhost_user_socket_mem_free(vsocket);\n out:\n@@ -439,51 +427,19 @@ rte_vhost_driver_unregister(const char *path)\n {\n \tint i;\n \tint count;\n-\tstruct vhost_user_connection *conn, *next;\n \n \tif (path == NULL)\n \t\treturn -1;\n \n-again:\n \tpthread_mutex_lock(&vhost_user.mutex);\n \n \tfor (i = 0; i < vhost_user.vsocket_cnt; i++) {\n \t\tstruct vhost_user_socket *vsocket = vhost_user.vsockets[i];\n \n \t\tif (!strcmp(vsocket->path, path)) {\n-\t\t\tpthread_mutex_lock(&vsocket->conn_mutex);\n-\t\t\tfor (conn = TAILQ_FIRST(&vsocket->conn_list);\n-\t\t\t     conn != NULL;\n-\t\t\t     conn = next) {\n-\t\t\t\tnext = TAILQ_NEXT(conn, next);\n-\n-\t\t\t\t/*\n-\t\t\t\t * If r/wcb is executing, release the\n-\t\t\t\t * conn_mutex lock, and try again since\n-\t\t\t\t * the r/wcb may use the conn_mutex lock.\n-\t\t\t\t */\n-\t\t\t\tif (fdset_try_del(&vhost_user.fdset,\n-\t\t\t\t\t\t  conn->connfd) == -1) {\n-\t\t\t\t\tpthread_mutex_unlock(\n-\t\t\t\t\t\t\t&vsocket->conn_mutex);\n-\t\t\t\t\tpthread_mutex_unlock(&vhost_user.mutex);\n-\t\t\t\t\tgoto again;\n-\t\t\t\t}\n-\n-\t\t\t\tRTE_LOG(INFO, VHOST_CONFIG,\n-\t\t\t\t\t\"free connfd = %d for device '%s'\\n\",\n-\t\t\t\t\tconn->connfd, path);\n-\t\t\t\tclose(conn->connfd);\n-\t\t\t\tvhost_destroy_device(conn->vid);\n-\t\t\t\tTAILQ_REMOVE(&vsocket->conn_list, conn, next);\n-\t\t\t\tfree(conn);\n-\t\t\t}\n-\t\t\tpthread_mutex_unlock(&vsocket->conn_mutex);\n-\n \t\t\tvsocket->trans_ops->socket_cleanup(vsocket);\n-\n-\t\t\tpthread_mutex_destroy(&vsocket->conn_mutex);\n-\t\t\tvhost_user_socket_mem_free(vsocket);\n+\t\t\tfree(vsocket->path);\n+\t\t\tfree(vsocket);\n \n \t\t\tcount = --vhost_user.vsocket_cnt;\n \t\t\tvhost_user.vsockets[i] = vhost_user.vsockets[count];\ndiff --git a/lib/librte_vhost/trans_af_unix.c b/lib/librte_vhost/trans_af_unix.c\nindex 93d11f7..58fc9e2 100644\n--- a/lib/librte_vhost/trans_af_unix.c\n+++ b/lib/librte_vhost/trans_af_unix.c\n@@ -15,8 +15,20 @@\n \n #define MAX_VIRTIO_BACKLOG 128\n \n+TAILQ_HEAD(vhost_user_connection_list, vhost_user_connection);\n+\n+struct vhost_user_connection {\n+\tstruct vhost_user_socket *vsocket;\n+\tint connfd;\n+\tint vid;\n+\n+\tTAILQ_ENTRY(vhost_user_connection) next;\n+};\n+\n struct af_unix_socket {\n \tstruct vhost_user_socket socket; /* must be the first field! */\n+\tstruct vhost_user_connection_list conn_list;\n+\tpthread_mutex_t conn_mutex;\n \tint socket_fd;\n \tstruct sockaddr_un un;\n };\n@@ -131,6 +143,8 @@ send_fd_message(int sockfd, char *buf, int buflen, int *fds, int fd_num)\n static void\n vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)\n {\n+\tstruct af_unix_socket *af_vsocket =\n+\t\tcontainer_of(vsocket, struct af_unix_socket, socket);\n \tint vid;\n \tsize_t size;\n \tstruct vhost_user_connection *conn;\n@@ -188,9 +202,9 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)\n \t\tgoto err_cleanup;\n \t}\n \n-\tpthread_mutex_lock(&vsocket->conn_mutex);\n-\tTAILQ_INSERT_TAIL(&vsocket->conn_list, conn, next);\n-\tpthread_mutex_unlock(&vsocket->conn_mutex);\n+\tpthread_mutex_lock(&af_vsocket->conn_mutex);\n+\tTAILQ_INSERT_TAIL(&af_vsocket->conn_list, conn, next);\n+\tpthread_mutex_unlock(&af_vsocket->conn_mutex);\n \n \tfdset_pipe_notify(&vhost_user.fdset);\n \treturn;\n@@ -221,6 +235,8 @@ vhost_user_read_cb(int connfd, void *dat, int *remove)\n {\n \tstruct vhost_user_connection *conn = dat;\n \tstruct vhost_user_socket *vsocket = conn->vsocket;\n+\tstruct af_unix_socket *af_vsocket =\n+\t\tcontainer_of(vsocket, struct af_unix_socket, socket);\n \tint ret;\n \n \tret = vhost_user_msg_handler(conn->vid, connfd);\n@@ -238,9 +254,9 @@ vhost_user_read_cb(int connfd, void *dat, int *remove)\n \n \t\tvhost_destroy_device(conn->vid);\n \n-\t\tpthread_mutex_lock(&vsocket->conn_mutex);\n-\t\tTAILQ_REMOVE(&vsocket->conn_list, conn, next);\n-\t\tpthread_mutex_unlock(&vsocket->conn_mutex);\n+\t\tpthread_mutex_lock(&af_vsocket->conn_mutex);\n+\t\tTAILQ_REMOVE(&af_vsocket->conn_list, conn, next);\n+\t\tpthread_mutex_unlock(&af_vsocket->conn_mutex);\n \n \t\tfree(conn);\n \n@@ -512,6 +528,18 @@ static int\n af_unix_socket_init(struct vhost_user_socket *vsocket,\n \t\t    uint64_t flags __rte_unused)\n {\n+\tstruct af_unix_socket *af_vsocket =\n+\t\tcontainer_of(vsocket, struct af_unix_socket, socket);\n+\tint ret;\n+\n+\tTAILQ_INIT(&af_vsocket->conn_list);\n+\tret = pthread_mutex_init(&af_vsocket->conn_mutex, NULL);\n+\tif (ret) {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"error: failed to init connection mutex\\n\");\n+\t\treturn -1;\n+\t}\n+\n \treturn create_unix_socket(vsocket);\n }\n \n@@ -520,6 +548,7 @@ af_unix_socket_cleanup(struct vhost_user_socket *vsocket)\n {\n \tstruct af_unix_socket *af_vsocket =\n \t\tcontainer_of(vsocket, struct af_unix_socket, socket);\n+\tstruct vhost_user_connection *conn, *next;\n \n \tif (vsocket->is_server) {\n \t\tfdset_del(&vhost_user.fdset, af_vsocket->socket_fd);\n@@ -528,6 +557,37 @@ af_unix_socket_cleanup(struct vhost_user_socket *vsocket)\n \t} else if (vsocket->reconnect) {\n \t\tvhost_user_remove_reconnect(vsocket);\n \t}\n+\n+again:\n+\tpthread_mutex_lock(&af_vsocket->conn_mutex);\n+\tfor (conn = TAILQ_FIRST(&af_vsocket->conn_list);\n+\t     conn != NULL;\n+\t     conn = next) {\n+\t\tnext = TAILQ_NEXT(conn, next);\n+\n+\t\t/*\n+\t\t * If r/wcb is executing, release the\n+\t\t * conn_mutex lock, and try again since\n+\t\t * the r/wcb may use the conn_mutex lock.\n+\t\t */\n+\t\tif (fdset_try_del(&vhost_user.fdset,\n+\t\t\t\t  conn->connfd) == -1) {\n+\t\t\tpthread_mutex_unlock(\n+\t\t\t\t\t&af_vsocket->conn_mutex);\n+\t\t\tgoto again;\n+\t\t}\n+\n+\t\tRTE_LOG(INFO, VHOST_CONFIG,\n+\t\t\t\"free connfd = %d for device '%s'\\n\",\n+\t\t\tconn->connfd, vsocket->path);\n+\t\tclose(conn->connfd);\n+\t\tvhost_destroy_device(conn->vid);\n+\t\tTAILQ_REMOVE(&af_vsocket->conn_list, conn, next);\n+\t\tfree(conn);\n+\t}\n+\tpthread_mutex_unlock(&af_vsocket->conn_mutex);\n+\n+\tpthread_mutex_destroy(&af_vsocket->conn_mutex);\n }\n \n static int\ndiff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h\nindex c74753b..5c3987d 100644\n--- a/lib/librte_vhost/vhost.h\n+++ b/lib/librte_vhost/vhost.h\n@@ -404,13 +404,10 @@ struct virtio_net {\n \tstruct rte_vhost_user_extern_ops extern_ops;\n } __rte_cache_aligned;\n \n-/* The vhost_user, vhost_user_socket, vhost_user_connection, and reconnect\n- * declarations are temporary measures for moving AF_UNIX code into\n- * trans_af_unix.c.  They will be cleaned up as socket.c is untangled from\n- * trans_af_unix.c.\n+/* The vhost_user, vhost_user_socket, and reconnect declarations are temporary\n+ * measures for moving AF_UNIX code into trans_af_unix.c.  They will be cleaned\n+ * up as socket.c is untangled from trans_af_unix.c.\n  */\n-TAILQ_HEAD(vhost_user_connection_list, vhost_user_connection);\n-\n /*\n  * Every time rte_vhost_driver_register() is invoked, an associated\n  * vhost_user_socket struct will be created.\n@@ -421,8 +418,6 @@ TAILQ_HEAD(vhost_user_connection_list, vhost_user_connection);\n  * struct.\n  */\n struct vhost_user_socket {\n-\tstruct vhost_user_connection_list conn_list;\n-\tpthread_mutex_t conn_mutex;\n \tchar *path;\n \tbool is_server;\n \tbool reconnect;\n@@ -453,14 +448,6 @@ struct vhost_user_socket {\n \tstruct vhost_transport_ops const *trans_ops;\n };\n \n-struct vhost_user_connection {\n-\tstruct vhost_user_socket *vsocket;\n-\tint connfd;\n-\tint vid;\n-\n-\tTAILQ_ENTRY(vhost_user_connection) next;\n-};\n-\n #define MAX_VHOST_SOCKET 1024\n struct vhost_user {\n \tstruct vhost_user_socket *vsockets[MAX_VHOST_SOCKET];\n",
    "prefixes": [
        "06/28"
    ]
}