qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, jsnow@redhat.com, famz@redhat.com,
	qemu-block@nongnu.org, vsementsov@virtuozzo.com,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH v5 20/20] block: Drop unused .bdrv_co_get_block_status()
Date: Thu, 30 Nov 2017 19:42:42 -0600	[thread overview]
Message-ID: <20171201014242.16877-21-eblake@redhat.com> (raw)
In-Reply-To: <20171201014242.16877-1-eblake@redhat.com>

We are gradually moving away from sector-based interfaces, towards
byte-based.  Now that all drivers have been updated to provide the
byte-based .bdrv_co_block_status(), we can delete the sector-based
interface.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

---
v5: rebase to master
v4: rebase to interface tweak
v3: no change
v2: rebase to earlier changes
---
 include/block/block_int.h |  3 ---
 block/io.c                | 34 +---------------------------------
 2 files changed, 1 insertion(+), 36 deletions(-)

diff --git a/include/block/block_int.h b/include/block/block_int.h
index 980333c671..df9b62934d 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -215,9 +215,6 @@ struct BlockDriver {
      * in turn, the driver must return an error or set pnum to an
      * aligned non-zero value.
      */
-    int64_t coroutine_fn (*bdrv_co_get_block_status)(BlockDriverState *bs,
-        int64_t sector_num, int nb_sectors, int *pnum,
-        BlockDriverState **file);
     int coroutine_fn (*bdrv_co_block_status)(BlockDriverState *bs,
         bool want_zero, int64_t offset, int64_t bytes, int64_t *pnum,
         int64_t *map, BlockDriverState **file);
diff --git a/block/io.c b/block/io.c
index 49d299b7e3..9e59dfb550 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1893,7 +1893,7 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,

     /* Must be non-NULL or bdrv_getlength() would have failed */
     assert(bs->drv);
-    if (!bs->drv->bdrv_co_get_block_status && !bs->drv->bdrv_co_block_status) {
+    if (!bs->drv->bdrv_co_block_status) {
         *pnum = bytes;
         ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED;
         if (offset + bytes == total_size) {
@@ -1911,40 +1911,9 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,

     /* Round out to request_alignment boundaries */
     align = bs->bl.request_alignment;
-    if (bs->drv->bdrv_co_get_block_status && align < BDRV_SECTOR_SIZE) {
-        align = BDRV_SECTOR_SIZE;
-    }
     aligned_offset = QEMU_ALIGN_DOWN(offset, align);
     aligned_bytes = ROUND_UP(offset + bytes, align) - aligned_offset;

-    if (bs->drv->bdrv_co_get_block_status) {
-        int count; /* sectors */
-        int64_t longret;
-
-        assert(QEMU_IS_ALIGNED(aligned_offset | aligned_bytes,
-                               BDRV_SECTOR_SIZE));
-        /*
-         * The contract allows us to return pnum smaller than bytes, even
-         * if the next query would see the same status; we truncate the
-         * request to avoid overflowing the driver's 32-bit interface.
-         */
-        longret = bs->drv->bdrv_co_get_block_status(
-            bs, aligned_offset >> BDRV_SECTOR_BITS,
-            MIN(INT_MAX, aligned_bytes) >> BDRV_SECTOR_BITS, &count,
-            &local_file);
-        if (longret < 0) {
-            assert(INT_MIN <= longret);
-            ret = longret;
-            goto out;
-        }
-        if (longret & BDRV_BLOCK_OFFSET_VALID) {
-            local_map = longret & BDRV_BLOCK_OFFSET_MASK;
-        }
-        ret = longret & ~BDRV_BLOCK_OFFSET_MASK;
-        *pnum = count * BDRV_SECTOR_SIZE;
-        goto refine;
-    }
-
     ret = bs->drv->bdrv_co_block_status(bs, want_zero, aligned_offset,
                                         aligned_bytes, pnum, &local_map,
                                         &local_file);
@@ -1963,7 +1932,6 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,
         *pnum = total_size - aligned_offset;
     }

-refine:
     /*
      * The driver's result must be a multiple of request_alignment.
      * Clamp pnum and adjust map to original request.
-- 
2.14.3

      parent reply	other threads:[~2017-12-01 15:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01  1:42 [Qemu-devel] [PATCH v5 00/20] add byte-based block_status driver callbacks Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 01/20] block: Add .bdrv_co_block_status() callback Eric Blake
2017-12-01 14:40   ` Kevin Wolf
2017-12-01 15:03     ` Eric Blake
2017-12-01 15:24       ` Kevin Wolf
2017-12-06 15:20         ` Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 02/20] block: Switch passthrough drivers to .bdrv_co_block_status() Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 03/20] file-posix: Switch " Eric Blake
2017-12-01 16:00   ` Kevin Wolf
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 04/20] gluster: " Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 05/20] iscsi: Switch cluster_sectors to byte-based Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 06/20] iscsi: Switch iscsi_allocmap_update() " Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 07/20] iscsi: Switch to .bdrv_co_block_status() Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 08/20] null: " Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 09/20] parallels: " Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 10/20] qcow: " Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 11/20] qcow2: " Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 12/20] qed: " Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 13/20] raw: " Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 14/20] sheepdog: " Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 15/20] vdi: Avoid bitrot of debugging code Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 16/20] vdi: Switch to .bdrv_co_block_status() Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 17/20] vmdk: " Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 18/20] vpc: " Eric Blake
2017-12-01  1:42 ` [Qemu-devel] [PATCH v5 19/20] vvfat: " Eric Blake
2017-12-01  1:42 ` Eric Blake [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171201014242.16877-21-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=famz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).