|
|
0a122b |
From c8cc35838d42aa286242772d97e3a9be7bb786ba Mon Sep 17 00:00:00 2001
|
|
|
0a122b |
Message-Id: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
|
|
|
0a122b |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
Date: Mon, 9 Dec 2013 14:08:49 +0100
|
|
|
0a122b |
Subject: [PATCH 01/50] block: change default of .has_zero_init to 0
|
|
|
0a122b |
|
|
|
0a122b |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
Message-id: <1386598178-11845-4-git-send-email-pbonzini@redhat.com>
|
|
|
0a122b |
Patchwork-id: 56040
|
|
|
0a122b |
O-Subject: [RHEL 7.0 qemu-kvm PATCH 03/52] block: change default of .has_zero_init to 0
|
|
|
0a122b |
Bugzilla: 1007815
|
|
|
0a122b |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
From: Peter Lieven <pl@kamp.de>
|
|
|
0a122b |
|
|
|
0a122b |
.has_zero_init defaults to 1 for all formats and protocols.
|
|
|
0a122b |
|
|
|
0a122b |
this is a dangerous default since this means that all
|
|
|
0a122b |
new added drivers need to manually overwrite it to 0 if
|
|
|
0a122b |
they do not ensure that a device is zero initialized
|
|
|
0a122b |
after bdrv_create().
|
|
|
0a122b |
|
|
|
0a122b |
if a driver needs to explicitly set this value to
|
|
|
0a122b |
1 its easier to verify the correctness in the review process.
|
|
|
0a122b |
|
|
|
0a122b |
during review of the existing drivers it turned out
|
|
|
0a122b |
that ssh and gluster had a wrong default of 1.
|
|
|
0a122b |
both protocols support host_devices as backend
|
|
|
0a122b |
which are not by default zero initialized. this
|
|
|
0a122b |
wrong assumption will lead to possible corruption
|
|
|
0a122b |
if qemu-img convert is used to write to such a backend.
|
|
|
0a122b |
|
|
|
0a122b |
vpc and vmdk also defaulted to 1 altough they support
|
|
|
0a122b |
fixed respectively flat extends. this has to be addresses
|
|
|
0a122b |
in separate patches. both formats as well as the mentioned
|
|
|
0a122b |
ssh and gluster are turned to the default of 0 with this
|
|
|
0a122b |
patch for safety.
|
|
|
0a122b |
|
|
|
0a122b |
a similar problem with the wrong default existed for
|
|
|
0a122b |
iscsi most likely because the driver developer did
|
|
|
0a122b |
oversee the default value of 1.
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Peter Lieven <pl@kamp.de>
|
|
|
0a122b |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
0a122b |
(cherry picked from commit 3ac216270a62418519c08e88c17005a8f1539cf2)
|
|
|
0a122b |
|
|
|
0a122b |
Conflicts: [due to get_block_status going in RHEL7 before this patch]
|
|
|
0a122b |
block/qcow2.c
|
|
|
0a122b |
block/qed.c
|
|
|
0a122b |
block/raw-posix.c
|
|
|
0a122b |
block/vdi.c
|
|
|
0a122b |
---
|
|
|
0a122b |
block.c | 8 +++++++-
|
|
|
0a122b |
block/cow.c | 1 +
|
|
|
0a122b |
block/qcow.c | 1 +
|
|
|
0a122b |
block/qcow2.c | 1 +
|
|
|
0a122b |
block/qed.c | 1 +
|
|
|
0a122b |
block/raw-posix.c | 10 +---------
|
|
|
0a122b |
block/raw-win32.c | 7 +------
|
|
|
0a122b |
block/rbd.c | 1 +
|
|
|
0a122b |
block/sheepdog.c | 1 +
|
|
|
0a122b |
block/vdi.c | 1 +
|
|
|
0a122b |
include/block/block.h | 1 +
|
|
|
0a122b |
11 files changed, 17 insertions(+), 16 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Michal Novotny <minovotn@redhat.com>
|
|
|
0a122b |
---
|
|
|
0a122b |
block.c | 8 +++++++-
|
|
|
0a122b |
block/cow.c | 1 +
|
|
|
0a122b |
block/qcow.c | 1 +
|
|
|
0a122b |
block/qcow2.c | 1 +
|
|
|
0a122b |
block/qed.c | 1 +
|
|
|
0a122b |
block/raw-posix.c | 10 +---------
|
|
|
0a122b |
block/raw-win32.c | 7 +------
|
|
|
0a122b |
block/rbd.c | 1 +
|
|
|
0a122b |
block/sheepdog.c | 1 +
|
|
|
0a122b |
block/vdi.c | 1 +
|
|
|
0a122b |
include/block/block.h | 1 +
|
|
|
0a122b |
11 files changed, 17 insertions(+), 16 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/block.c b/block.c
|
|
|
0a122b |
index 8ef07bb..02994ec 100644
|
|
|
0a122b |
--- a/block.c
|
|
|
0a122b |
+++ b/block.c
|
|
|
0a122b |
@@ -3098,6 +3098,11 @@ int bdrv_flush_all(void)
|
|
|
0a122b |
return result;
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
+int bdrv_has_zero_init_1(BlockDriverState *bs)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ return 1;
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
int bdrv_has_zero_init(BlockDriverState *bs)
|
|
|
0a122b |
{
|
|
|
0a122b |
assert(bs->drv);
|
|
|
0a122b |
@@ -3111,7 +3116,8 @@ int bdrv_has_zero_init(BlockDriverState *bs)
|
|
|
0a122b |
return bs->drv->bdrv_has_zero_init(bs);
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
- return 1;
|
|
|
0a122b |
+ /* safe default */
|
|
|
0a122b |
+ return 0;
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
typedef struct BdrvCoGetBlockStatusData {
|
|
|
0a122b |
diff --git a/block/cow.c b/block/cow.c
|
|
|
0a122b |
index cd78129..cb9a3b0 100644
|
|
|
0a122b |
--- a/block/cow.c
|
|
|
0a122b |
+++ b/block/cow.c
|
|
|
0a122b |
@@ -386,6 +386,7 @@ static BlockDriver bdrv_cow = {
|
|
|
0a122b |
.bdrv_open = cow_open,
|
|
|
0a122b |
.bdrv_close = cow_close,
|
|
|
0a122b |
.bdrv_create = cow_create,
|
|
|
0a122b |
+ .bdrv_has_zero_init = bdrv_has_zero_init_1,
|
|
|
0a122b |
|
|
|
0a122b |
.bdrv_read = cow_co_read,
|
|
|
0a122b |
.bdrv_write = cow_co_write,
|
|
|
0a122b |
diff --git a/block/qcow.c b/block/qcow.c
|
|
|
0a122b |
index 6d029cc..6bc2358 100644
|
|
|
0a122b |
--- a/block/qcow.c
|
|
|
0a122b |
+++ b/block/qcow.c
|
|
|
0a122b |
@@ -906,6 +906,7 @@ static BlockDriver bdrv_qcow = {
|
|
|
0a122b |
.bdrv_close = qcow_close,
|
|
|
0a122b |
.bdrv_reopen_prepare = qcow_reopen_prepare,
|
|
|
0a122b |
.bdrv_create = qcow_create,
|
|
|
0a122b |
+ .bdrv_has_zero_init = bdrv_has_zero_init_1,
|
|
|
0a122b |
|
|
|
0a122b |
.bdrv_co_readv = qcow_co_readv,
|
|
|
0a122b |
.bdrv_co_writev = qcow_co_writev,
|
|
|
0a122b |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
0a122b |
index 850d1c2..8de8892 100644
|
|
|
0a122b |
--- a/block/qcow2.c
|
|
|
0a122b |
+++ b/block/qcow2.c
|
|
|
0a122b |
@@ -2034,6 +2034,7 @@ static BlockDriver bdrv_qcow2 = {
|
|
|
0a122b |
.bdrv_close = qcow2_close,
|
|
|
0a122b |
.bdrv_reopen_prepare = qcow2_reopen_prepare,
|
|
|
0a122b |
.bdrv_create = qcow2_create,
|
|
|
0a122b |
+ .bdrv_has_zero_init = bdrv_has_zero_init_1,
|
|
|
0a122b |
.bdrv_co_get_block_status = qcow2_co_get_block_status,
|
|
|
0a122b |
.bdrv_set_key = qcow2_set_key,
|
|
|
0a122b |
.bdrv_make_empty = qcow2_make_empty,
|
|
|
0a122b |
diff --git a/block/qed.c b/block/qed.c
|
|
|
0a122b |
index 7b13bb5..084dc0a 100644
|
|
|
0a122b |
--- a/block/qed.c
|
|
|
0a122b |
+++ b/block/qed.c
|
|
|
0a122b |
@@ -1603,6 +1603,7 @@ static BlockDriver bdrv_qed = {
|
|
|
0a122b |
.bdrv_close = bdrv_qed_close,
|
|
|
0a122b |
.bdrv_reopen_prepare = bdrv_qed_reopen_prepare,
|
|
|
0a122b |
.bdrv_create = bdrv_qed_create,
|
|
|
0a122b |
+ .bdrv_has_zero_init = bdrv_has_zero_init_1,
|
|
|
0a122b |
.bdrv_co_get_block_status = bdrv_qed_co_get_block_status,
|
|
|
0a122b |
.bdrv_make_empty = bdrv_qed_make_empty,
|
|
|
0a122b |
.bdrv_aio_readv = bdrv_qed_aio_readv,
|
|
|
0a122b |
diff --git a/block/raw-posix.c b/block/raw-posix.c
|
|
|
0a122b |
index eae1b40..c2b3dfd 100644
|
|
|
0a122b |
--- a/block/raw-posix.c
|
|
|
0a122b |
+++ b/block/raw-posix.c
|
|
|
0a122b |
@@ -1220,6 +1220,7 @@ static BlockDriver bdrv_file = {
|
|
|
0a122b |
.bdrv_reopen_abort = raw_reopen_abort,
|
|
|
0a122b |
.bdrv_close = raw_close,
|
|
|
0a122b |
.bdrv_create = raw_create,
|
|
|
0a122b |
+ .bdrv_has_zero_init = bdrv_has_zero_init_1,
|
|
|
0a122b |
.bdrv_co_get_block_status = raw_co_get_block_status,
|
|
|
0a122b |
|
|
|
0a122b |
.bdrv_aio_readv = raw_aio_readv,
|
|
|
0a122b |
@@ -1563,11 +1564,6 @@ static int hdev_create(const char *filename, QEMUOptionParameter *options,
|
|
|
0a122b |
return ret;
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
-static int hdev_has_zero_init(BlockDriverState *bs)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- return 0;
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
static BlockDriver bdrv_host_device = {
|
|
|
0a122b |
.format_name = "host_device",
|
|
|
0a122b |
.protocol_name = "host_device",
|
|
|
0a122b |
@@ -1580,7 +1576,6 @@ static BlockDriver bdrv_host_device = {
|
|
|
0a122b |
.bdrv_reopen_abort = raw_reopen_abort,
|
|
|
0a122b |
.bdrv_create = hdev_create,
|
|
|
0a122b |
.create_options = raw_create_options,
|
|
|
0a122b |
- .bdrv_has_zero_init = hdev_has_zero_init,
|
|
|
0a122b |
|
|
|
0a122b |
.bdrv_aio_readv = raw_aio_readv,
|
|
|
0a122b |
.bdrv_aio_writev = raw_aio_writev,
|
|
|
0a122b |
@@ -1711,7 +1706,6 @@ static BlockDriver bdrv_host_floppy = {
|
|
|
0a122b |
.bdrv_reopen_abort = raw_reopen_abort,
|
|
|
0a122b |
.bdrv_create = hdev_create,
|
|
|
0a122b |
.create_options = raw_create_options,
|
|
|
0a122b |
- .bdrv_has_zero_init = hdev_has_zero_init,
|
|
|
0a122b |
|
|
|
0a122b |
.bdrv_aio_readv = raw_aio_readv,
|
|
|
0a122b |
.bdrv_aio_writev = raw_aio_writev,
|
|
|
0a122b |
@@ -1821,7 +1815,6 @@ static BlockDriver bdrv_host_cdrom = {
|
|
|
0a122b |
.bdrv_reopen_abort = raw_reopen_abort,
|
|
|
0a122b |
.bdrv_create = hdev_create,
|
|
|
0a122b |
.create_options = raw_create_options,
|
|
|
0a122b |
- .bdrv_has_zero_init = hdev_has_zero_init,
|
|
|
0a122b |
|
|
|
0a122b |
.bdrv_aio_readv = raw_aio_readv,
|
|
|
0a122b |
.bdrv_aio_writev = raw_aio_writev,
|
|
|
0a122b |
@@ -1949,7 +1942,6 @@ static BlockDriver bdrv_host_cdrom = {
|
|
|
0a122b |
.bdrv_reopen_abort = raw_reopen_abort,
|
|
|
0a122b |
.bdrv_create = hdev_create,
|
|
|
0a122b |
.create_options = raw_create_options,
|
|
|
0a122b |
- .bdrv_has_zero_init = hdev_has_zero_init,
|
|
|
0a122b |
|
|
|
0a122b |
.bdrv_aio_readv = raw_aio_readv,
|
|
|
0a122b |
.bdrv_aio_writev = raw_aio_writev,
|
|
|
0a122b |
diff --git a/block/raw-win32.c b/block/raw-win32.c
|
|
|
0a122b |
index 584790f..6ac3797 100644
|
|
|
0a122b |
--- a/block/raw-win32.c
|
|
|
0a122b |
+++ b/block/raw-win32.c
|
|
|
0a122b |
@@ -465,6 +465,7 @@ static BlockDriver bdrv_file = {
|
|
|
0a122b |
.bdrv_file_open = raw_open,
|
|
|
0a122b |
.bdrv_close = raw_close,
|
|
|
0a122b |
.bdrv_create = raw_create,
|
|
|
0a122b |
+ .bdrv_has_zero_init = bdrv_has_zero_init_1,
|
|
|
0a122b |
|
|
|
0a122b |
.bdrv_aio_readv = raw_aio_readv,
|
|
|
0a122b |
.bdrv_aio_writev = raw_aio_writev,
|
|
|
0a122b |
@@ -600,11 +601,6 @@ done:
|
|
|
0a122b |
return ret;
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
-static int hdev_has_zero_init(BlockDriverState *bs)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- return 0;
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
static BlockDriver bdrv_host_device = {
|
|
|
0a122b |
.format_name = "host_device",
|
|
|
0a122b |
.protocol_name = "host_device",
|
|
|
0a122b |
@@ -612,7 +608,6 @@ static BlockDriver bdrv_host_device = {
|
|
|
0a122b |
.bdrv_probe_device = hdev_probe_device,
|
|
|
0a122b |
.bdrv_file_open = hdev_open,
|
|
|
0a122b |
.bdrv_close = raw_close,
|
|
|
0a122b |
- .bdrv_has_zero_init = hdev_has_zero_init,
|
|
|
0a122b |
|
|
|
0a122b |
.bdrv_aio_readv = raw_aio_readv,
|
|
|
0a122b |
.bdrv_aio_writev = raw_aio_writev,
|
|
|
0a122b |
diff --git a/block/rbd.c b/block/rbd.c
|
|
|
0a122b |
index 169d3cf..b870401 100644
|
|
|
0a122b |
--- a/block/rbd.c
|
|
|
0a122b |
+++ b/block/rbd.c
|
|
|
0a122b |
@@ -974,6 +974,7 @@ static BlockDriver bdrv_rbd = {
|
|
|
0a122b |
.bdrv_file_open = qemu_rbd_open,
|
|
|
0a122b |
.bdrv_close = qemu_rbd_close,
|
|
|
0a122b |
.bdrv_create = qemu_rbd_create,
|
|
|
0a122b |
+ .bdrv_has_zero_init = bdrv_has_zero_init_1,
|
|
|
0a122b |
.bdrv_get_info = qemu_rbd_getinfo,
|
|
|
0a122b |
.create_options = qemu_rbd_create_options,
|
|
|
0a122b |
.bdrv_getlength = qemu_rbd_getlength,
|
|
|
0a122b |
diff --git a/block/sheepdog.c b/block/sheepdog.c
|
|
|
0a122b |
index e7c4448..09203ad 100644
|
|
|
0a122b |
--- a/block/sheepdog.c
|
|
|
0a122b |
+++ b/block/sheepdog.c
|
|
|
0a122b |
@@ -2411,6 +2411,7 @@ static BlockDriver bdrv_sheepdog_unix = {
|
|
|
0a122b |
.bdrv_file_open = sd_open,
|
|
|
0a122b |
.bdrv_close = sd_close,
|
|
|
0a122b |
.bdrv_create = sd_create,
|
|
|
0a122b |
+ .bdrv_has_zero_init = bdrv_has_zero_init_1,
|
|
|
0a122b |
.bdrv_getlength = sd_getlength,
|
|
|
0a122b |
.bdrv_truncate = sd_truncate,
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/block/vdi.c b/block/vdi.c
|
|
|
0a122b |
index 84860fe..dcbc27c 100644
|
|
|
0a122b |
--- a/block/vdi.c
|
|
|
0a122b |
+++ b/block/vdi.c
|
|
|
0a122b |
@@ -792,6 +792,7 @@ static BlockDriver bdrv_vdi = {
|
|
|
0a122b |
.bdrv_close = vdi_close,
|
|
|
0a122b |
.bdrv_reopen_prepare = vdi_reopen_prepare,
|
|
|
0a122b |
.bdrv_create = vdi_create,
|
|
|
0a122b |
+ .bdrv_has_zero_init = bdrv_has_zero_init_1,
|
|
|
0a122b |
.bdrv_co_get_block_status = vdi_co_get_block_status,
|
|
|
0a122b |
.bdrv_make_empty = vdi_make_empty,
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/include/block/block.h b/include/block/block.h
|
|
|
0a122b |
index 656570e..15ffbd2 100644
|
|
|
0a122b |
--- a/include/block/block.h
|
|
|
0a122b |
+++ b/include/block/block.h
|
|
|
0a122b |
@@ -300,6 +300,7 @@ void bdrv_drain_all(void);
|
|
|
0a122b |
|
|
|
0a122b |
int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
|
|
|
0a122b |
int bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
|
|
|
0a122b |
+int bdrv_has_zero_init_1(BlockDriverState *bs);
|
|
|
0a122b |
int bdrv_has_zero_init(BlockDriverState *bs);
|
|
|
0a122b |
int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num,
|
|
|
0a122b |
int nb_sectors, int *pnum);
|
|
|
0a122b |
--
|
|
|
0a122b |
1.7.11.7
|
|
|
0a122b |
|