block: Kill .bdrv_co_discard()
authorEric Blake <eblake@redhat.com>
Fri, 15 Jul 2016 23:23:06 +0000 (17:23 -0600)
committerStefan Hajnoczi <stefanha@redhat.com>
Wed, 20 Jul 2016 13:24:25 +0000 (14:24 +0100)
Now that all drivers have a byte-based .bdrv_co_pdiscard(), we
no longer need to worry about the sector-based version.  We can
also relax our minimum alignment to 1 for drivers that support it.

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

index 5ba0195a6953afe54d7815d83a88e28fdb56f7b3..7323f0fb7b63bb967f89488fb08965a8fe5cb61f 100644 (file)
@@ -2423,14 +2423,12 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
         return 0;
     }
 
-    if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_co_pdiscard &&
-        !bs->drv->bdrv_aio_pdiscard) {
+    if (!bs->drv->bdrv_co_pdiscard && !bs->drv->bdrv_aio_pdiscard) {
         return 0;
     }
 
     /* Discard is advisory, so ignore any unaligned head or tail */
-    align = MAX(BDRV_SECTOR_SIZE,
-                MAX(bs->bl.pdiscard_alignment, bs->bl.request_alignment));
+    align = MAX(bs->bl.pdiscard_alignment, bs->bl.request_alignment);
     assert(is_power_of_2(align));
     head = MIN(count, -offset & (align - 1));
     if (head) {
@@ -2458,9 +2456,6 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
 
         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 {
             BlockAIOCB *acb;
             CoroutineIOCompletion co = {
index 8f16d1652e7190da47bcedc6ef48a3f5a9a25ef7..a069f97b375e57b82f7c2fae125b997269c8026e 100644 (file)
@@ -165,8 +165,6 @@ struct BlockDriver {
      */
     int coroutine_fn (*bdrv_co_pwrite_zeroes)(BlockDriverState *bs,
         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,