diff mbox

[v2,42/45] block: Reset buffer alignment on detach

Message ID 1312376904-16115-43-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster Aug. 3, 2011, 1:08 p.m. UTC
BlockDriverState member buffer_alignment is initially 512.  The device
model may set them, with bdrv_set_buffer_alignment().  If the device
model gets detached (hot unplug), the device's alignment is left
behind.  Only okay because device hot unplug automatically destroys
the BlockDriverState.  But that's a questionable feature, best not to
rely on it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 block.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Comments

Kevin Wolf Sept. 2, 2011, 1:20 p.m. UTC | #1
Am 03.08.2011 15:08, schrieb Markus Armbruster:
> BlockDriverState member buffer_alignment is initially 512.  The device
> model may set them, with bdrv_set_buffer_alignment().  If the device
> model gets detached (hot unplug), the device's alignment is left
> behind.  Only okay because device hot unplug automatically destroys
> the BlockDriverState.  But that's a questionable feature, best not to
> rely on it.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Hm, I'm not sure about this... Maybe instead of doing it on open and
detach, which is a strange combination, the right thing would be to do
it on attach?

Kevin
Markus Armbruster Sept. 2, 2011, 3:32 p.m. UTC | #2
Kevin Wolf <kwolf@redhat.com> writes:

> Am 03.08.2011 15:08, schrieb Markus Armbruster:
>> BlockDriverState member buffer_alignment is initially 512.  The device
>> model may set them, with bdrv_set_buffer_alignment().  If the device
>> model gets detached (hot unplug), the device's alignment is left
>> behind.  Only okay because device hot unplug automatically destroys
>> the BlockDriverState.  But that's a questionable feature, best not to
>> rely on it.
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>
> Hm, I'm not sure about this... Maybe instead of doing it on open and
> detach, which is a strange combination, the right thing would be to do
> it on attach?

Maybe.  My readiness to rearrange code for neatness declines a bit
beyond PATCH#30 or so ;)
diff mbox

Patch

diff --git a/block.c b/block.c
index 67d9429..b0e54ef 100644
--- a/block.c
+++ b/block.c
@@ -761,6 +761,7 @@  void bdrv_detach_dev(BlockDriverState *bs, void *dev)
     bs->dev = NULL;
     bs->dev_ops = NULL;
     bs->dev_opaque = NULL;
+    bs->buffer_alignment = 512;
 }
 
 /* TODO change to return DeviceState * when all users are qdevified */