[05/10] block: remove BlockDriver.bdrv_write_compressed
diff mbox

Message ID 1463229957-14253-6-git-send-email-den@openvz.org
State New
Headers show

Commit Message

Denis V. Lunev May 14, 2016, 12:45 p.m. UTC
From: Pavel Butsykin <pbutsykin@virtuozzo.com>

There are no block drivers left that implement the old
.bdrv_write_compressed interface, so it can be removed now.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Jeff Cody <jcody@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
CC: Eric Blake <eblake@redhat.com>
CC: John Snow <jsnow@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
---
 block/io.c                | 14 --------------
 include/block/block_int.h |  3 ---
 qemu-img.c                |  2 +-
 3 files changed, 1 insertion(+), 18 deletions(-)

Comments

Eric Blake May 16, 2016, 4:57 p.m. UTC | #1
On 05/14/2016 06:45 AM, Denis V. Lunev wrote:
> From: Pavel Butsykin <pbutsykin@virtuozzo.com>
> 
> There are no block drivers left that implement the old
> .bdrv_write_compressed interface, so it can be removed now.
> 
> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Jeff Cody <jcody@redhat.com>
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Eric Blake <eblake@redhat.com>
> CC: John Snow <jsnow@redhat.com>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> CC: Kevin Wolf <kwolf@redhat.com>
> ---

> +++ b/block/io.c
> @@ -1876,7 +1876,6 @@ static void bdrv_write_compressed_co_entry(void *opaque)
>  int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
>                            const uint8_t *buf, int nb_sectors)
>  {
> -    BlockDriver *drv = bs->drv;
>      BdrvWriteCompressedCo data = {
>          .bs         = bs,
>          .sector_num = sector_num,
> @@ -1885,19 +1884,6 @@ int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
>          .ret        = -EINPROGRESS,
>      };
>  
> -    if (!drv) {
> -        return -ENOMEDIUM;
> -    }

Why are you deleting this check?
Pavel Butsykin May 17, 2016, 12:22 p.m. UTC | #2
On 16.05.2016 19:57, Eric Blake wrote:
> On 05/14/2016 06:45 AM, Denis V. Lunev wrote:
>> From: Pavel Butsykin <pbutsykin@virtuozzo.com>
>>
>> There are no block drivers left that implement the old
>> .bdrv_write_compressed interface, so it can be removed now.
>>
>> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
>> Signed-off-by: Denis V. Lunev <den@openvz.org>
>> CC: Jeff Cody <jcody@redhat.com>
>> CC: Markus Armbruster <armbru@redhat.com>
>> CC: Eric Blake <eblake@redhat.com>
>> CC: John Snow <jsnow@redhat.com>
>> CC: Stefan Hajnoczi <stefanha@redhat.com>
>> CC: Kevin Wolf <kwolf@redhat.com>
>> ---
>
>> +++ b/block/io.c
>> @@ -1876,7 +1876,6 @@ static void bdrv_write_compressed_co_entry(void *opaque)
>>   int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
>>                             const uint8_t *buf, int nb_sectors)
>>   {
>> -    BlockDriver *drv = bs->drv;
>>       BdrvWriteCompressedCo data = {
>>           .bs         = bs,
>>           .sector_num = sector_num,
>> @@ -1885,19 +1884,6 @@ int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
>>           .ret        = -EINPROGRESS,
>>       };
>>
>> -    if (!drv) {
>> -        return -ENOMEDIUM;
>> -    }
>
> Why are you deleting this check?
>

Because this check is duplicated in bdrv_co_write_compressed(), but
in this place it was necessary for drv->bdrv_write_compressed.

Patch
diff mbox

diff --git a/block/io.c b/block/io.c
index 88af10c..ae87e72 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1876,7 +1876,6 @@  static void bdrv_write_compressed_co_entry(void *opaque)
 int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
                           const uint8_t *buf, int nb_sectors)
 {
-    BlockDriver *drv = bs->drv;
     BdrvWriteCompressedCo data = {
         .bs         = bs,
         .sector_num = sector_num,
@@ -1885,19 +1884,6 @@  int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
         .ret        = -EINPROGRESS,
     };
 
-    if (!drv) {
-        return -ENOMEDIUM;
-    }
-
-    if (drv->bdrv_write_compressed) {
-        int ret = bdrv_check_request(bs, sector_num, nb_sectors);
-        if (ret < 0) {
-            return ret;
-        }
-        assert(QLIST_EMPTY(&bs->dirty_bitmaps));
-        return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);
-    }
-
     if (qemu_in_coroutine()) {
         /* Fast-path if already in coroutine context */
         bdrv_write_compressed_co_entry(&data);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 3c93ddb..cae838c 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -205,9 +205,6 @@  struct BlockDriver {
     bool has_variable_length;
     int64_t (*bdrv_get_allocated_file_size)(BlockDriverState *bs);
 
-    int (*bdrv_write_compressed)(BlockDriverState *bs, int64_t sector_num,
-                                 const uint8_t *buf, int nb_sectors);
-
     int (*bdrv_co_write_compressed)(BlockDriverState *bs, int64_t sector_num,
                                     int nb_sectors, QEMUIOVector *qiov);
 
diff --git a/qemu-img.c b/qemu-img.c
index 0d38eac..fd892e8 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2022,7 +2022,7 @@  static int img_convert(int argc, char **argv)
         const char *preallocation =
             qemu_opt_get(opts, BLOCK_OPT_PREALLOC);
 
-        if (!drv->bdrv_write_compressed && !drv->bdrv_co_write_compressed) {
+        if (!drv->bdrv_co_write_compressed) {
             error_report("Compression not supported for this file format");
             ret = -1;
             goto out;