diff mbox

[17/17] block: Kill .bdrv_co_discard()

Message ID 1466610674-23157-18-git-send-email-eblake@redhat.com
State New
Headers show

Commit Message

Eric Blake June 22, 2016, 3:51 p.m. UTC
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>
---
 include/block/block_int.h | 2 --
 block/io.c                | 9 ++-------
 2 files changed, 2 insertions(+), 9 deletions(-)

Comments

Stefan Hajnoczi July 14, 2016, 12:16 p.m. UTC | #1
On Wed, Jun 22, 2016 at 09:51:14AM -0600, Eric Blake wrote:
> 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>
> ---
>  include/block/block_int.h | 2 --
>  block/io.c                | 9 ++-------
>  2 files changed, 2 insertions(+), 9 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox

Patch

diff --git a/include/block/block_int.h b/include/block/block_int.h
index 61e5b5a..651262d 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -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,
diff --git a/block/io.c b/block/io.c
index 9d1f36d..0b03944 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2394,14 +2394,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) {
@@ -2429,9 +2427,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 = {