Skip to contentSkip to conversation

Remove unsupported / empty .bdrv_make_empty functions

PATCH In review Jeff Cody 4 participants 7 messages Jan 27, 2014 – Jan 28, 2014 Block layer

lore
Share & tools
lore

Jeff Cody

author
#0 lore raw

cover Remove unsupported / empty .bdrv_make_empty functions

QED and QCOW2 both have .bdrv_make_empty stubs that do nothing. In the case of QED, it returns an error (-ENOTSUP), which causes problems with bdrv_commit().

This removes those stubs.

Jeff Cody (2):
block: remove QED .bdrv_make_empty implementation
block: remove qcow2 .bdrv_make_empty implementation

 block/qcow2.c | 21 ---------------------
 block/qed.c   |  6 ------
 2 files changed, 27 deletions(-)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/2 block: remove QED .bdrv_make_empty implementation

The QED .bdrv_make_empty() implementation does nothing but return -ENOTSUP, which causes problems in bdrv_commit(). Since the function stub exists for QED, it is called, which then always returns an error.

The proper way to not support an optional driver function stub is to just not implement it, so let's remove the stub.

---
 block/qed.c | 6 ------
 1 file changed, 6 deletions(-)
block/qed.c +0 -6
index 694e6e2..b9ca7ac 100644
@@ -731,11 +731,6 @@ static int64_t coroutine_fn bdrv_qed_co_get_block_status(BlockDriverState *bs,
     return cb.status;
 }
 
-static int bdrv_qed_make_empty(BlockDriverState *bs)
-{
-    return -ENOTSUP;
-}
-
 static BDRVQEDState *acb_to_s(QEDAIOCB *acb)
 {
     return acb->common.bs->opaque;
@@ -1617,7 +1612,6 @@ static BlockDriver bdrv_qed = {
     .bdrv_create              = bdrv_qed_create,
     .bdrv_has_zero_init       = bdrv_has_zero_init_1,
     .bdrv_co_get_block_status = bdrv_qed_co_get_block_status,
-    .bdrv_make_empty          = bdrv_qed_make_empty,
     .bdrv_aio_readv           = bdrv_qed_aio_readv,
     .bdrv_aio_writev          = bdrv_qed_aio_writev,
     .bdrv_co_write_zeroes     = bdrv_qed_co_write_zeroes,
Signature · 1 line
1.8.3.1
Reviewed-by Benoit Canet on v1 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] block: remove QED .bdrv_make_empty implementation

Quoted 40 lines · Jeff Cody

The QED .bdrv_make_empty() implementation does nothing but return -ENOTSUP, which causes problems in bdrv_commit(). Since the function stub exists for QED, it is called, which then always returns an error.

The proper way to not support an optional driver function stub is to just not implement it, so let's remove the stub.

---
 block/qed.c | 6 ------
 1 file changed, 6 deletions(-)
block/qed.c +0 -6
index 694e6e2..b9ca7ac 100644
@@ -731,11 +731,6 @@ static int64_t coroutine_fn bdrv_qed_co_get_block_status(BlockDriverState *bs,
     return cb.status;
 }
 
-static int bdrv_qed_make_empty(BlockDriverState *bs)
-{
-    return -ENOTSUP;
-}
-
 static BDRVQEDState *acb_to_s(QEDAIOCB *acb)
 {
     return acb->common.bs->opaque;
@@ -1617,7 +1612,6 @@ static BlockDriver bdrv_qed = {
     .bdrv_create              = bdrv_qed_create,
     .bdrv_has_zero_init       = bdrv_has_zero_init_1,
     .bdrv_co_get_block_status = bdrv_qed_co_get_block_status,
-    .bdrv_make_empty          = bdrv_qed_make_empty,
     .bdrv_aio_readv           = bdrv_qed_aio_readv,
     .bdrv_aio_writev          = bdrv_qed_aio_writev,
     .bdrv_co_write_zeroes     = bdrv_qed_co_write_zeroes,
Signature · 1 line
1.8.3.1
author
#3 lore raw

PATCH 2/2 block: remove qcow2 .bdrv_make_empty implementation

In reply to Jeff Cody

The QCOW2 .bdrv_make_empty implementation always returns 0 for success, but does not actually do anything.

The proper way to not support an optional driver function stub is to just not implement it, so let's remove the stub.

---
 block/qcow2.c | 21 ---------------------
 1 file changed, 21 deletions(-)
block/qcow2.c +0 -21
index 2da62b8..99a1ad1 100644
@@ -1689,26 +1689,6 @@ static int qcow2_create(const char *filename, QEMUOptionParameter *options,
     return ret;
 }
 
-static int qcow2_make_empty(BlockDriverState *bs)
-{
-#if 0
-    /* XXX: not correct */
-    BDRVQcowState *s = bs->opaque;
-    uint32_t l1_length = s->l1_size * sizeof(uint64_t);
-    int ret;
-
-    memset(s->l1_table, 0, l1_length);
-    if (bdrv_pwrite(bs->file, s->l1_table_offset, s->l1_table, l1_length) < 0)
-        return -1;
-    ret = bdrv_truncate(bs->file, s->l1_table_offset + l1_length);
-    if (ret < 0)
-        return ret;
-
-    l2_cache_reset(bs);
-#endif
-    return 0;
-}
-
 static coroutine_fn int qcow2_co_write_zeroes(BlockDriverState *bs,
     int64_t sector_num, int nb_sectors, BdrvRequestFlags flags)
 {
@@ -2252,7 +2232,6 @@ static BlockDriver bdrv_qcow2 = {
     .bdrv_has_zero_init = bdrv_has_zero_init_1,
     .bdrv_co_get_block_status = qcow2_co_get_block_status,
     .bdrv_set_key       = qcow2_set_key,
-    .bdrv_make_empty    = qcow2_make_empty,
 
     .bdrv_co_readv          = qcow2_co_readv,
     .bdrv_co_writev         = qcow2_co_writev,
Signature · 1 line
1.8.3.1
Reviewed-by Benoit Canet on v1 2/2
#4 lore raw

Re: [Qemu-devel] [PATCH 2/2] block: remove qcow2 .bdrv_make_empty implementation

Quoted 54 lines · Jeff Cody

The QCOW2 .bdrv_make_empty implementation always returns 0 for success, but does not actually do anything.

The proper way to not support an optional driver function stub is to just not implement it, so let's remove the stub.

---
 block/qcow2.c | 21 ---------------------
 1 file changed, 21 deletions(-)
block/qcow2.c +0 -21
index 2da62b8..99a1ad1 100644
@@ -1689,26 +1689,6 @@ static int qcow2_create(const char *filename, QEMUOptionParameter *options,
     return ret;
 }
 
-static int qcow2_make_empty(BlockDriverState *bs)
-{
-#if 0
-    /* XXX: not correct */
-    BDRVQcowState *s = bs->opaque;
-    uint32_t l1_length = s->l1_size * sizeof(uint64_t);
-    int ret;
-
-    memset(s->l1_table, 0, l1_length);
-    if (bdrv_pwrite(bs->file, s->l1_table_offset, s->l1_table, l1_length) < 0)
-        return -1;
-    ret = bdrv_truncate(bs->file, s->l1_table_offset + l1_length);
-    if (ret < 0)
-        return ret;
-
-    l2_cache_reset(bs);
-#endif
-    return 0;
-}
-
 static coroutine_fn int qcow2_co_write_zeroes(BlockDriverState *bs,
     int64_t sector_num, int nb_sectors, BdrvRequestFlags flags)
 {
@@ -2252,7 +2232,6 @@ static BlockDriver bdrv_qcow2 = {
     .bdrv_has_zero_init = bdrv_has_zero_init_1,
     .bdrv_co_get_block_status = qcow2_co_get_block_status,
     .bdrv_set_key       = qcow2_set_key,
-    .bdrv_make_empty    = qcow2_make_empty,
 
     .bdrv_co_readv          = qcow2_co_readv,
     .bdrv_co_writev         = qcow2_co_writev,
Signature · 1 line
1.8.3.1
Reviewed-by on the v1 series
#5 lore raw
In reply to Jeff Cody
Quoted 6 lines · Jeff Cody

QED and QCOW2 both have .bdrv_make_empty stubs that do nothing. In the case of QED, it returns an error (-ENOTSUP), which causes problems with bdrv_commit().

This removes those stubs.

Quoted 7 lines

Jeff Cody (2):
block: remove QED .bdrv_make_empty implementation
block: remove qcow2 .bdrv_make_empty implementation

 block/qcow2.c | 21 ---------------------
 block/qed.c   |  6 ------
 2 files changed, 27 deletions(-)

Always fun when you can fix bugs by pure deletion :)

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Reviewed-by on the v1 series
#6 lore raw
In reply to Jeff Cody

Am 27.01.2014 um 22:09 hat Jeff Cody geschrieben:

Quoted 9 lines

QED and QCOW2 both have .bdrv_make_empty stubs that do nothing. In the case of QED, it returns an error (-ENOTSUP), which causes problems with bdrv_commit().

This removes those stubs.

Jeff Cody (2):
block: remove QED .bdrv_make_empty implementation
block: remove qcow2 .bdrv_make_empty implementation