diff mbox

[09/55] block: Don't let locked flag prevent medium load

Message ID 1311179069-27882-10-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster July 20, 2011, 4:23 p.m. UTC
Commit aea2a33c made bdrv_eject() obey the locked flag.  Correct for
medium eject (eject_flag set), incorrect for medium load (eject_flag
clear).  See MMC-5 Table 341 "Actions for Lock/Unlock/Eject".

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

Comments

Kevin Wolf July 22, 2011, 2:51 p.m. UTC | #1
Am 20.07.2011 18:23, schrieb Markus Armbruster:
> Commit aea2a33c made bdrv_eject() obey the locked flag.  Correct for
> medium eject (eject_flag set), incorrect for medium load (eject_flag
> clear).  See MMC-5 Table 341 "Actions for Lock/Unlock/Eject".
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

SCSI doesn't really matter here, this is about host state. The comment
for bdrv_set_locked only talks about eject, so it's probably right anyway.

Kevin

> ---
>  block.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 594bcab..6727274 100644
> --- a/block.c
> +++ b/block.c
> @@ -2769,7 +2769,7 @@ int bdrv_eject(BlockDriverState *bs, int eject_flag)
>  {
>      BlockDriver *drv = bs->drv;
>  
> -    if (bs->locked) {
> +    if (eject_flag && bs->locked) {
>          return -EBUSY;
>      }
>
Markus Armbruster July 22, 2011, 3:33 p.m. UTC | #2
Kevin Wolf <kwolf@redhat.com> writes:

> Am 20.07.2011 18:23, schrieb Markus Armbruster:
>> Commit aea2a33c made bdrv_eject() obey the locked flag.  Correct for
>> medium eject (eject_flag set), incorrect for medium load (eject_flag
>> clear).  See MMC-5 Table 341 "Actions for Lock/Unlock/Eject".
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>
> SCSI doesn't really matter here, this is about host state. The comment
> for bdrv_set_locked only talks about eject, so it's probably right anyway.

For what it's worth, PATCH 28/55 moves this check to the device models,
where MMC-5 clearly applies.
diff mbox

Patch

diff --git a/block.c b/block.c
index 594bcab..6727274 100644
--- a/block.c
+++ b/block.c
@@ -2769,7 +2769,7 @@  int bdrv_eject(BlockDriverState *bs, int eject_flag)
 {
     BlockDriver *drv = bs->drv;
 
-    if (bs->locked) {
+    if (eject_flag && bs->locked) {
         return -EBUSY;
     }