]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: Add .bdrv_co_pdiscard() driver callback
authorEric Blake <eblake@redhat.com>
Fri, 15 Jul 2016 23:22:58 +0000 (17:22 -0600)
committerStefan Hajnoczi <stefanha@redhat.com>
Wed, 20 Jul 2016 13:11:55 +0000 (14:11 +0100)
There's enough drivers with a sector-based callback that it will
be easier to switch one at a time.  This patch adds a byte-based
callback, and then after all drivers are swapped, we'll drop the
sector-based callback.

[checkpatch doesn't like the space after coroutine_fn in
block_int.h, but it's consistent with the rest of the file]

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1468624988-423-10-git-send-email-eblake@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/io.c
include/block/block_int.h

index 5c759fae470778b6ef1fda8757f439466ed67852..5ba0195a6953afe54d7815d83a88e28fdb56f7b3 100644 (file)
@@ -2423,7 +2423,8 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
         return 0;
     }
 
-    if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_aio_pdiscard) {
+    if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_co_pdiscard &&
+        !bs->drv->bdrv_aio_pdiscard) {
         return 0;
     }
 
@@ -2455,7 +2456,9 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
         int ret;
         int num = MIN(count, max_pdiscard);
 
-        if (bs->drv->bdrv_co_discard) {
+        if (bs->drv->bdrv_co_pdiscard) {
+            ret = bs->drv->bdrv_co_pdiscard(bs, offset, num);
+        } else if (bs->drv->bdrv_co_discard) {
             ret = bs->drv->bdrv_co_discard(bs, offset >> BDRV_SECTOR_BITS,
                                            num >> BDRV_SECTOR_BITS);
         } else {
index 9bf9aed83d1740a8a8b539e2436bfaa0e32c5afb..8f16d1652e7190da47bcedc6ef48a3f5a9a25ef7 100644 (file)
@@ -167,6 +167,8 @@ struct BlockDriver {
         int64_t offset, int count, BdrvRequestFlags flags);
     int coroutine_fn (*bdrv_co_discard)(BlockDriverState *bs,
         int64_t sector_num, int nb_sectors);
+    int coroutine_fn (*bdrv_co_pdiscard)(BlockDriverState *bs,
+        int64_t offset, int count);
     int64_t coroutine_fn (*bdrv_co_get_block_status)(BlockDriverState *bs,
         int64_t sector_num, int nb_sectors, int *pnum,
         BlockDriverState **file);