get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1307021,
    "url": "http://patchwork.ozlabs.org/api/patches/1307021/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/fddf142643a706d2ab08edf4f5390ef4ccf6af04.1591801197.git.berto@igalia.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<fddf142643a706d2ab08edf4f5390ef4ccf6af04.1591801197.git.berto@igalia.com>",
    "list_archive_url": null,
    "date": "2020-06-10T15:02:55",
    "name": "[v8,17/34] qcow2: Add cluster type parameter to qcow2_get_host_offset()",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "92d29bcae833f608825f28181c977c0709ee435e",
    "submitter": {
        "id": 65704,
        "url": "http://patchwork.ozlabs.org/api/people/65704/?format=api",
        "name": "Alberto Garcia",
        "email": "berto@igalia.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/fddf142643a706d2ab08edf4f5390ef4ccf6af04.1591801197.git.berto@igalia.com/mbox/",
    "series": [
        {
            "id": 182563,
            "url": "http://patchwork.ozlabs.org/api/series/182563/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=182563",
            "date": "2020-06-10T15:02:49",
            "name": "Add subcluster allocation to qcow2",
            "version": 8,
            "mbox": "http://patchwork.ozlabs.org/series/182563/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1307021/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1307021/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=<UNKNOWN>)",
            "ozlabs.org;\n dmarc=none (p=none dis=none) header.from=igalia.com",
            "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=igalia.com header.i=@igalia.com header.a=rsa-sha256\n header.s=20170329 header.b=ZxmEfkVZ;\n\tdkim-atps=neutral"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 49hrHM1Kfkz9sQx\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 11 Jun 2020 01:18:55 +1000 (AEST)",
            "from localhost ([::1]:38050 helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1jj2VA-0006V1-VK\n\tfor incoming@patchwork.ozlabs.org; Wed, 10 Jun 2020 11:18:52 -0400",
            "from eggs.gnu.org ([2001:470:142:3::10]:36150)\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <berto@igalia.com>)\n id 1jj2Gw-0002im-Og; Wed, 10 Jun 2020 11:04:10 -0400",
            "from fanzine.igalia.com ([178.60.130.6]:58247)\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <berto@igalia.com>)\n id 1jj2Gs-0006wb-DC; Wed, 10 Jun 2020 11:04:10 -0400",
            "from [81.0.38.199] (helo=perseus.local)\n by fanzine.igalia.com with esmtpsa\n (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim)\n id 1jj2GR-0007gx-NA; Wed, 10 Jun 2020 17:03:39 +0200",
            "from berto by perseus.local with local (Exim 4.92)\n (envelope-from <berto@igalia.com>)\n id 1jj2GC-0007NA-5T; Wed, 10 Jun 2020 17:03:24 +0200"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com;\n s=20170329;\n h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;\n bh=ctmJoE6t9F+l9JkkxXkf9Wgs/rm6W2SVqo/5HAl3/Ag=;\n b=ZxmEfkVZa/9wPm2ufNo1ntgb17jQRxErJp7/ssod4vTAS7m1ybqOddDqvPEI4O1xl2HjEJd8wGRKUbgcuUN8s+g7LlrLB0ovz248D7V5ie6oGiHMKV2etkWjSr2jj3Sk7wyUedkUcaZbmInVXAgC5kQt78Yoei50Hxoj4x9p1TMpVv2gTGPhOltgTwtk+k2QO9MITXscCGCv9K7+JozGSt4Lui09kGrBx/UBJjzdRkH3MAB5EuRISnZLSRMGL/551I7NPXD59fUszRt8DVBi/VGfgitCw0KW/xpvbspfJVrP3O2QHf5TSkQ2wYEQLjgAiJSvzRNHfP42UNz5iyQV7g==;",
        "From": "Alberto Garcia <berto@igalia.com>",
        "To": "qemu-devel@nongnu.org",
        "Subject": "[PATCH v8 17/34] qcow2: Add cluster type parameter to\n qcow2_get_host_offset()",
        "Date": "Wed, 10 Jun 2020 17:02:55 +0200",
        "Message-Id": "\n <fddf142643a706d2ab08edf4f5390ef4ccf6af04.1591801197.git.berto@igalia.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<cover.1591801197.git.berto@igalia.com>",
        "References": "<cover.1591801197.git.berto@igalia.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Received-SPF": "pass client-ip=178.60.130.6; envelope-from=berto@igalia.com;\n helo=fanzine.igalia.com",
        "X-detected-operating-system": "by eggs.gnu.org: First seen = 2020/06/10 11:03:39",
        "X-ACL-Warn": "Detected OS   = Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy]",
        "X-Spam_score_int": "-20",
        "X-Spam_score": "-2.1",
        "X-Spam_bar": "--",
        "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=_AUTOLEARN",
        "X-Spam_action": "no action",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.23",
        "Precedence": "list",
        "List-Id": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Cc": "Kevin Wolf <kwolf@redhat.com>,\n Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,\n Alberto Garcia <berto@igalia.com>, qemu-block@nongnu.org,\n Derek Su <dereksu@qnap.com>, Max Reitz <mreitz@redhat.com>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "\"Qemu-devel\"\n <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"
    },
    "content": "This function returns an integer that can be either an error code or a\ncluster type (a value from the QCow2ClusterType enum).\n\nWe are going to start using subcluster types instead of cluster types\nin some functions so it's better to use the exact data types instead\nof integers for clarity and in order to detect errors more easily.\n\nThis patch makes qcow2_get_host_offset() return 0 on success and\nputs the returned cluster type in a separate parameter. There are no\nsemantic changes.\n\nSigned-off-by: Alberto Garcia <berto@igalia.com>\nReviewed-by: Max Reitz <mreitz@redhat.com>\nReviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>\n---\n block/qcow2.h         |  3 ++-\n block/qcow2-cluster.c | 11 +++++++----\n block/qcow2.c         | 37 ++++++++++++++++++++++---------------\n 3 files changed, 31 insertions(+), 20 deletions(-)",
    "diff": "diff --git a/block/qcow2.h b/block/qcow2.h\nindex ea647c8bb5..74f65793bd 100644\n--- a/block/qcow2.h\n+++ b/block/qcow2.h\n@@ -893,7 +893,8 @@ int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t sector_num,\n                           uint8_t *buf, int nb_sectors, bool enc, Error **errp);\n \n int qcow2_get_host_offset(BlockDriverState *bs, uint64_t offset,\n-                          unsigned int *bytes, uint64_t *host_offset);\n+                          unsigned int *bytes, uint64_t *host_offset,\n+                          QCow2ClusterType *cluster_type);\n int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset,\n                                unsigned int *bytes, uint64_t *host_offset,\n                                QCowL2Meta **m);\ndiff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c\nindex 32dc6e75e3..1e5681b0c6 100644\n--- a/block/qcow2-cluster.c\n+++ b/block/qcow2-cluster.c\n@@ -565,13 +565,14 @@ static int coroutine_fn do_perform_cow_write(BlockDriverState *bs,\n  *\n  * On exit, *bytes is the number of bytes starting at offset that have the same\n  * cluster type and (if applicable) are stored contiguously in the image file.\n+ * The cluster type is stored in *cluster_type.\n  * Compressed clusters are always returned one by one.\n  *\n- * Returns the cluster type (QCOW2_CLUSTER_*) on success, -errno in error\n- * cases.\n+ * Returns 0 on success, -errno in error cases.\n  */\n int qcow2_get_host_offset(BlockDriverState *bs, uint64_t offset,\n-                          unsigned int *bytes, uint64_t *host_offset)\n+                          unsigned int *bytes, uint64_t *host_offset,\n+                          QCow2ClusterType *cluster_type)\n {\n     BDRVQcow2State *s = bs->opaque;\n     unsigned int l2_index;\n@@ -712,7 +713,9 @@ out:\n     assert(bytes_available - offset_in_cluster <= UINT_MAX);\n     *bytes = bytes_available - offset_in_cluster;\n \n-    return type;\n+    *cluster_type = type;\n+\n+    return 0;\n \n fail:\n     qcow2_cache_put(s->l2_table_cache, (void **)&l2_slice);\ndiff --git a/block/qcow2.c b/block/qcow2.c\nindex 7df55a88a8..89e17bdaba 100644\n--- a/block/qcow2.c\n+++ b/block/qcow2.c\n@@ -2033,6 +2033,7 @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs,\n     BDRVQcow2State *s = bs->opaque;\n     uint64_t host_offset;\n     unsigned int bytes;\n+    QCow2ClusterType type;\n     int ret, status = 0;\n \n     qemu_co_mutex_lock(&s->lock);\n@@ -2044,7 +2045,7 @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs,\n     }\n \n     bytes = MIN(INT_MAX, count);\n-    ret = qcow2_get_host_offset(bs, offset, &bytes, &host_offset);\n+    ret = qcow2_get_host_offset(bs, offset, &bytes, &host_offset, &type);\n     qemu_co_mutex_unlock(&s->lock);\n     if (ret < 0) {\n         return ret;\n@@ -2052,15 +2053,15 @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs,\n \n     *pnum = bytes;\n \n-    if ((ret == QCOW2_CLUSTER_NORMAL || ret == QCOW2_CLUSTER_ZERO_ALLOC) &&\n+    if ((type == QCOW2_CLUSTER_NORMAL || type == QCOW2_CLUSTER_ZERO_ALLOC) &&\n         !s->crypto) {\n         *map = host_offset;\n         *file = s->data_file->bs;\n         status |= BDRV_BLOCK_OFFSET_VALID;\n     }\n-    if (ret == QCOW2_CLUSTER_ZERO_PLAIN || ret == QCOW2_CLUSTER_ZERO_ALLOC) {\n+    if (type == QCOW2_CLUSTER_ZERO_PLAIN || type == QCOW2_CLUSTER_ZERO_ALLOC) {\n         status |= BDRV_BLOCK_ZERO;\n-    } else if (ret != QCOW2_CLUSTER_UNALLOCATED) {\n+    } else if (type != QCOW2_CLUSTER_UNALLOCATED) {\n         status |= BDRV_BLOCK_DATA;\n     }\n     if (s->metadata_preallocation && (status & BDRV_BLOCK_DATA) &&\n@@ -2269,6 +2270,7 @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs,\n     int ret = 0;\n     unsigned int cur_bytes; /* number of bytes in current iteration */\n     uint64_t host_offset = 0;\n+    QCow2ClusterType type;\n     AioTaskPool *aio = NULL;\n \n     while (bytes != 0 && aio_task_pool_status(aio) == 0) {\n@@ -2280,22 +2282,23 @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs,\n         }\n \n         qemu_co_mutex_lock(&s->lock);\n-        ret = qcow2_get_host_offset(bs, offset, &cur_bytes, &host_offset);\n+        ret = qcow2_get_host_offset(bs, offset, &cur_bytes,\n+                                    &host_offset, &type);\n         qemu_co_mutex_unlock(&s->lock);\n         if (ret < 0) {\n             goto out;\n         }\n \n-        if (ret == QCOW2_CLUSTER_ZERO_PLAIN ||\n-            ret == QCOW2_CLUSTER_ZERO_ALLOC ||\n-            (ret == QCOW2_CLUSTER_UNALLOCATED && !bs->backing))\n+        if (type == QCOW2_CLUSTER_ZERO_PLAIN ||\n+            type == QCOW2_CLUSTER_ZERO_ALLOC ||\n+            (type == QCOW2_CLUSTER_UNALLOCATED && !bs->backing))\n         {\n             qemu_iovec_memset(qiov, qiov_offset, 0, cur_bytes);\n         } else {\n             if (!aio && cur_bytes != bytes) {\n                 aio = aio_task_pool_new(QCOW2_MAX_WORKERS);\n             }\n-            ret = qcow2_add_task(bs, aio, qcow2_co_preadv_task_entry, ret,\n+            ret = qcow2_add_task(bs, aio, qcow2_co_preadv_task_entry, type,\n                                  host_offset, offset, cur_bytes,\n                                  qiov, qiov_offset, NULL);\n             if (ret < 0) {\n@@ -3841,6 +3844,7 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs,\n     if (head || tail) {\n         uint64_t off;\n         unsigned int nr;\n+        QCow2ClusterType type;\n \n         assert(head + bytes <= s->cluster_size);\n \n@@ -3856,10 +3860,11 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs,\n         offset = QEMU_ALIGN_DOWN(offset, s->cluster_size);\n         bytes = s->cluster_size;\n         nr = s->cluster_size;\n-        ret = qcow2_get_host_offset(bs, offset, &nr, &off);\n-        if (ret != QCOW2_CLUSTER_UNALLOCATED &&\n-            ret != QCOW2_CLUSTER_ZERO_PLAIN &&\n-            ret != QCOW2_CLUSTER_ZERO_ALLOC) {\n+        ret = qcow2_get_host_offset(bs, offset, &nr, &off, &type);\n+        if (ret < 0 ||\n+            (type != QCOW2_CLUSTER_UNALLOCATED &&\n+             type != QCOW2_CLUSTER_ZERO_PLAIN &&\n+             type != QCOW2_CLUSTER_ZERO_ALLOC)) {\n             qemu_co_mutex_unlock(&s->lock);\n             return -ENOTSUP;\n         }\n@@ -3923,16 +3928,18 @@ qcow2_co_copy_range_from(BlockDriverState *bs,\n \n     while (bytes != 0) {\n         uint64_t copy_offset = 0;\n+        QCow2ClusterType type;\n         /* prepare next request */\n         cur_bytes = MIN(bytes, INT_MAX);\n         cur_write_flags = write_flags;\n \n-        ret = qcow2_get_host_offset(bs, src_offset, &cur_bytes, &copy_offset);\n+        ret = qcow2_get_host_offset(bs, src_offset, &cur_bytes,\n+                                    &copy_offset, &type);\n         if (ret < 0) {\n             goto out;\n         }\n \n-        switch (ret) {\n+        switch (type) {\n         case QCOW2_CLUSTER_UNALLOCATED:\n             if (bs->backing && bs->backing->bs) {\n                 int64_t backing_length = bdrv_getlength(bs->backing->bs);\n",
    "prefixes": [
        "v8",
        "17/34"
    ]
}