get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 813515,
    "url": "http://patchwork.ozlabs.org/api/patches/813515/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170913160333.23622-9-eblake@redhat.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": "<20170913160333.23622-9-eblake@redhat.com>",
    "list_archive_url": null,
    "date": "2017-09-13T16:03:18",
    "name": "[v4,08/23] block: Switch bdrv_co_get_block_status() to byte-based",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "12bd5518942edcd69816d2d0bfea262c217d43c0",
    "submitter": {
        "id": 6591,
        "url": "http://patchwork.ozlabs.org/api/people/6591/?format=api",
        "name": "Eric Blake",
        "email": "eblake@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170913160333.23622-9-eblake@redhat.com/mbox/",
    "series": [
        {
            "id": 2944,
            "url": "http://patchwork.ozlabs.org/api/series/2944/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2944",
            "date": "2017-09-13T16:03:10",
            "name": "make bdrv_get_block_status byte-based",
            "version": 4,
            "mbox": "http://patchwork.ozlabs.org/series/2944/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/813515/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/813515/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\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=208.118.235.17; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)",
            "ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com",
            "ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@redhat.com"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [208.118.235.17])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xsmtc28tXz9sPk\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 02:13:44 +1000 (AEST)",
            "from localhost ([::1]:43397 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dsAII-0003fI-6U\n\tfor incoming@patchwork.ozlabs.org; Wed, 13 Sep 2017 12:13:42 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:45826)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dsA9P-0001eZ-Qn\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 12:04:33 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dsA9L-0006Ax-Dj\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 12:04:31 -0400",
            "from mx1.redhat.com ([209.132.183.28]:56734)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>)\n\tid 1dsA9D-00064g-8M; Wed, 13 Sep 2017 12:04:19 -0400",
            "from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 315ECC04B944;\n\tWed, 13 Sep 2017 16:04:18 +0000 (UTC)",
            "from red.redhat.com (ovpn-120-201.rdu2.redhat.com [10.10.120.201])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 8B18B64433;\n\tWed, 13 Sep 2017 16:04:11 +0000 (UTC)"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 315ECC04B944",
        "From": "Eric Blake <eblake@redhat.com>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Wed, 13 Sep 2017 11:03:18 -0500",
        "Message-Id": "<20170913160333.23622-9-eblake@redhat.com>",
        "In-Reply-To": "<20170913160333.23622-1-eblake@redhat.com>",
        "References": "<20170913160333.23622-1-eblake@redhat.com>",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.11",
        "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tWed, 13 Sep 2017 16:04:18 +0000 (UTC)",
        "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]",
        "X-Received-From": "209.132.183.28",
        "Subject": "[Qemu-devel] [PATCH v4 08/23] block: Switch\n\tbdrv_co_get_block_status() to byte-based",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.21",
        "Precedence": "list",
        "List-Id": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<http://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\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Cc": "kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org,\n\tMax Reitz <mreitz@redhat.com>,\n\tStefan Hajnoczi <stefanha@redhat.com>, jsnow@redhat.com",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"
    },
    "content": "We are gradually converting to byte-based interfaces, as they are\neasier to reason about than sector-based.  Convert another internal\nfunction (no semantic change); and as with its public counterpart,\nrename to bdrv_co_block_status() to make the compiler enforce that\nwe catch all uses.  For now, we assert that callers still pass\naligned data, but ultimately, this will be the function where we\nhand off to a byte-based driver callback, and will eventually need\nto add logic to ensure we round calls according to the driver's\nrequest_alignment then touch up the result handed back to the\ncaller, to start permitting a caller to pass unaligned offsets.\n\nNote that we are now prepared to accepts 'bytes' larger than INT_MAX;\nthis is okay as long as we clamp things internally before violating\nany 32-bit limits, and makes no difference to how a client will\nuse the information (clients looping over the entire file must\nalready be prepared for consecutive calls to return the same status,\nas drivers are already free to return shorter-than-maximal status\ndue to any other convenient split points, such as when the L2 table\ncrosses cluster boundaries in qcow2).\n\nSigned-off-by: Eric Blake <eblake@redhat.com>\n\n---\nv4: no change\nv3: rebase to allocation/mapping sense change, clamp bytes to 32-bits\nwhen needed, drop R-b\nv2: rebase to earlier changes\n---\n block/io.c | 91 +++++++++++++++++++++++++++++++++++++-------------------------\n 1 file changed, 54 insertions(+), 37 deletions(-)",
    "diff": "diff --git a/block/io.c b/block/io.c\nindex 1ed46bcece..da85c903dd 100644\n--- a/block/io.c\n+++ b/block/io.c\n@@ -1748,42 +1748,43 @@ int64_t coroutine_fn bdrv_co_get_block_status_from_backing(BlockDriverState *bs,\n  * possible; otherwise, the result may omit that bit particularly if\n  * it allows for a larger value in 'pnum'.\n  *\n- * If 'sector_num' is beyond the end of the disk image the return value is\n+ * If 'offset' is beyond the end of the disk image the return value is\n  * BDRV_BLOCK_EOF and 'pnum' is set to 0.\n  *\n- * 'pnum' is set to the number of sectors (including and immediately following\n- * the specified sector) that are known to be in the same\n- * allocated/unallocated state.\n+ * 'pnum' is set to the number of bytes (including and immediately following\n+ * the specified offset) that are known to be in the same\n+ * allocated/unallocated state.  It may be NULL.\n  *\n- * 'nb_sectors' is the max value 'pnum' should be set to.  If nb_sectors goes\n+ * 'bytes' is the max value 'pnum' should be set to.  If bytes goes\n  * beyond the end of the disk image it will be clamped; if 'pnum' is set to\n  * the end of the image, then the returned value will include BDRV_BLOCK_EOF.\n  *\n  * If returned value is positive, BDRV_BLOCK_OFFSET_VALID bit is set, and\n- * 'file' is non-NULL, then '*file' points to the BDS which the sector range\n- * is allocated in.\n+ * 'file' is non-NULL, then '*file' points to the BDS which owns the\n+ * allocated sector that contains offset.\n  */\n-static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,\n-                                                     bool mapping,\n-                                                     int64_t sector_num,\n-                                                     int nb_sectors, int *pnum,\n-                                                     BlockDriverState **file)\n+static int64_t coroutine_fn bdrv_co_block_status(BlockDriverState *bs,\n+                                                 bool mapping,\n+                                                 int64_t offset, int64_t bytes,\n+                                                 int64_t *pnum,\n+                                                 BlockDriverState **file)\n {\n-    int64_t total_sectors;\n-    int64_t n;\n+    int64_t total_size;\n+    int64_t n; /* bytes */\n     int64_t ret, ret2;\n     BlockDriverState *local_file = NULL;\n+    int count; /* sectors */\n\n     assert(pnum);\n-    total_sectors = bdrv_nb_sectors(bs);\n-    if (total_sectors < 0) {\n+    total_size = bdrv_getlength(bs);\n+    if (total_size < 0) {\n         if (file) {\n             *file = NULL;\n         }\n-        return total_sectors;\n+        return total_size;\n     }\n\n-    if (sector_num >= total_sectors) {\n+    if (offset >= total_size) {\n         *pnum = 0;\n         if (file) {\n             *file = NULL;\n@@ -1791,19 +1792,19 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,\n         return BDRV_BLOCK_EOF;\n     }\n\n-    n = total_sectors - sector_num;\n-    if (n < nb_sectors) {\n-        nb_sectors = n;\n+    n = total_size - offset;\n+    if (n < bytes) {\n+        bytes = n;\n     }\n\n     if (!bs->drv->bdrv_co_get_block_status) {\n-        *pnum = nb_sectors;\n+        *pnum = bytes;\n         ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED;\n-        if (sector_num + nb_sectors == total_sectors) {\n+        if (offset + bytes == total_size) {\n             ret |= BDRV_BLOCK_EOF;\n         }\n         if (bs->drv->protocol_name) {\n-            ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE);\n+            ret |= BDRV_BLOCK_OFFSET_VALID | (offset & BDRV_BLOCK_OFFSET_MASK);\n             if (file) {\n                 *file = bs;\n             }\n@@ -1814,18 +1815,28 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,\n     }\n\n     bdrv_inc_in_flight(bs);\n-    ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum,\n+    /*\n+     * TODO: Rather than require aligned offsets, we could instead\n+     * round to the driver's request_alignment here, then touch up\n+     * count afterwards back to the caller's expectations.\n+     */\n+    assert(QEMU_IS_ALIGNED(offset | bytes, BDRV_SECTOR_SIZE));\n+    bytes = MIN(bytes, BDRV_REQUEST_MAX_BYTES);\n+    ret = bs->drv->bdrv_co_get_block_status(bs, offset >> BDRV_SECTOR_BITS,\n+                                            bytes >> BDRV_SECTOR_BITS, &count,\n                                             &local_file);\n     if (ret < 0) {\n         *pnum = 0;\n         goto out;\n     }\n+    *pnum = count * BDRV_SECTOR_SIZE;\n\n     if (ret & BDRV_BLOCK_RAW) {\n         assert(ret & BDRV_BLOCK_OFFSET_VALID && local_file);\n-        ret = bdrv_co_get_block_status(local_file, mapping,\n-                                       ret >> BDRV_SECTOR_BITS,\n-                                       *pnum, pnum, &local_file);\n+        ret = bdrv_co_block_status(local_file, mapping,\n+                                   ret & BDRV_BLOCK_OFFSET_MASK,\n+                                   *pnum, pnum, &local_file);\n+        assert(QEMU_IS_ALIGNED(*pnum, BDRV_SECTOR_SIZE));\n         goto out;\n     }\n\n@@ -1836,8 +1847,8 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,\n             ret |= BDRV_BLOCK_ZERO;\n         } else if (bs->backing) {\n             BlockDriverState *bs2 = bs->backing->bs;\n-            int64_t nb_sectors2 = bdrv_nb_sectors(bs2);\n-            if (nb_sectors2 >= 0 && sector_num >= nb_sectors2) {\n+            int64_t size2 = bdrv_getlength(bs2);\n+            if (size2 >= 0 && offset >= size2) {\n                 ret |= BDRV_BLOCK_ZERO;\n             }\n         }\n@@ -1846,11 +1857,11 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,\n     if (mapping && local_file && local_file != bs &&\n         (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) &&\n         (ret & BDRV_BLOCK_OFFSET_VALID)) {\n-        int file_pnum;\n+        int64_t file_pnum;\n\n-        ret2 = bdrv_co_get_block_status(local_file, mapping,\n-                                        ret >> BDRV_SECTOR_BITS,\n-                                        *pnum, &file_pnum, NULL);\n+        ret2 = bdrv_co_block_status(local_file, mapping,\n+                                    ret & BDRV_BLOCK_OFFSET_MASK,\n+                                    *pnum, &file_pnum, NULL);\n         if (ret2 >= 0) {\n             /* Ignore errors.  This is just providing extra information, it\n              * is useful but not necessary.\n@@ -1876,7 +1887,7 @@ out:\n         *file = local_file;\n     }\n     bdrv_dec_in_flight(bs);\n-    if (ret >= 0 && sector_num + *pnum == total_sectors) {\n+    if (ret >= 0 && offset + *pnum == total_size) {\n         ret |= BDRV_BLOCK_EOF;\n     }\n     return ret;\n@@ -1896,11 +1907,17 @@ static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs,\n\n     assert(bs != base);\n     for (p = bs; p != base; p = backing_bs(p)) {\n-        ret = bdrv_co_get_block_status(p, mapping, sector_num, nb_sectors,\n-                                       pnum, file);\n+        int64_t count;\n+\n+        ret = bdrv_co_block_status(p, mapping,\n+                                   sector_num * BDRV_SECTOR_SIZE,\n+                                   nb_sectors * BDRV_SECTOR_SIZE, &count,\n+                                   file);\n         if (ret < 0) {\n             break;\n         }\n+        assert(QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE));\n+        *pnum = count >> BDRV_SECTOR_BITS;\n         if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) {\n             /*\n              * Reading beyond the end of the file continues to read\n",
    "prefixes": [
        "v4",
        "08/23"
    ]
}