Skip to contentSkip to conversation

block-backend: allow flush on devices with open tray

PATCH Superseded John Snow 5 participants 8 messages Jun 10, 2016 – Jun 15, 2016 Block layer

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

John Snow

author
#0 lore raw

PATCH 1/1 block-backend: allow flush on devices with open tray

If a device still has an attached BDS because the medium has not yet been removed, we will be unable to migrate to a new host because blk_flush will return an error for that backend.

Replace the call to blk_is_available to blk_is_inserted to weaken the check and allow flushes from the backend to work, while still disallowing flushes from the frontend/device model to work.

This fixes a regression present in 2.6.0 caused by the following commit:
fe1a9cbc339bb54d20f1ca4c1e8788d16944d5cf
block: Move some bdrv_*_all() functions to BB

---
 block/block-backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/block-backend.c +1 -1
index 34500e6..d1e875e 100644
@@ -1122,7 +1122,7 @@ int blk_co_flush(BlockBackend *blk)
 
 int blk_flush(BlockBackend *blk)
 {
-    if (!blk_is_available(blk)) {
+    if (!blk_is_inserted(blk)) {
         return -ENOMEDIUM;
     }
 
Signature · 1 line
2.4.11
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · John Snow

If a device still has an attached BDS because the medium has not yet been removed, we will be unable to migrate to a new host because blk_flush will return an error for that backend.

Replace the call to blk_is_available to blk_is_inserted to weaken the check and allow flushes from the backend to work, while still disallowing flushes from the frontend/device model to work.

Quoted 8 lines

This fixes a regression present in 2.6.0 caused by the following commit:
fe1a9cbc339bb54d20f1ca4c1e8788d16944d5cf
block: Move some bdrv_*_all() functions to BB

---
 block/block-backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Worth testsuite coverage to prevent future regressions?

At any rate,

Quoted 15 lines
block/block-backend.c +1 -1
index 34500e6..d1e875e 100644
@@ -1122,7 +1122,7 @@ int blk_co_flush(BlockBackend *blk)
 
 int blk_flush(BlockBackend *blk)
 {
-    if (!blk_is_available(blk)) {
+    if (!blk_is_inserted(blk)) {
         return -ENOMEDIUM;
     }
 
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#2 lore raw
Quoted 13 lines · Eric Blake
Quoted 12 lines · John Snow

If a device still has an attached BDS because the medium has not yet been removed, we will be unable to migrate to a new host because blk_flush will return an error for that backend.

Replace the call to blk_is_available to blk_is_inserted to weaken the check and allow flushes from the backend to work, while still disallowing flushes from the frontend/device model to work.

This fixes a regression present in 2.6.0 caused by the following commit:
fe1a9cbc339bb54d20f1ca4c1e8788d16944d5cf
block: Move some bdrv_*_all() functions to BB

Quoted 7 lines
Quoted 4 lines
---
 block/block-backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Worth testsuite coverage to prevent future regressions?

I'll look into it.

(Ugh, migration tests. wah. etc.)

--js

Quoted 19 lines

At any rate,

Quoted 15 lines
block/block-backend.c +1 -1
index 34500e6..d1e875e 100644
@@ -1122,7 +1122,7 @@ int blk_co_flush(BlockBackend *blk)
 
 int blk_flush(BlockBackend *blk)
 {
-    if (!blk_is_available(blk)) {
+    if (!blk_is_inserted(blk)) {
         return -ENOMEDIUM;
     }
 
Reviewed-by on v1 1/1
#3 lore raw
In reply to John Snow
Quoted 34 lines · John Snow

If a device still has an attached BDS because the medium has not yet been removed, we will be unable to migrate to a new host because blk_flush will return an error for that backend.

Replace the call to blk_is_available to blk_is_inserted to weaken the check and allow flushes from the backend to work, while still disallowing flushes from the frontend/device model to work.

This fixes a regression present in 2.6.0 caused by the following commit:
fe1a9cbc339bb54d20f1ca4c1e8788d16944d5cf
block: Move some bdrv_*_all() functions to BB

---
 block/block-backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/block-backend.c +1 -1
index 34500e6..d1e875e 100644
@@ -1122,7 +1122,7 @@ int blk_co_flush(BlockBackend *blk)
 
 int blk_flush(BlockBackend *blk)
 {
-    if (!blk_is_available(blk)) {
+    if (!blk_is_inserted(blk)) {
         return -ENOMEDIUM;
     }
 
Signature · 1 line
2.4.11
#4 lore raw
In reply to John Snow
Quoted 8 lines · John Snow

If a device still has an attached BDS because the medium has not yet been removed, we will be unable to migrate to a new host because blk_flush will return an error for that backend.

Replace the call to blk_is_available to blk_is_inserted to weaken the check and allow flushes from the backend to work, while still disallowing flushes from the frontend/device model to work.

Quoted 8 lines

This fixes a regression present in 2.6.0 caused by the following commit:
fe1a9cbc339bb54d20f1ca4c1e8788d16944d5cf
block: Move some bdrv_*_all() functions to BB

---
 block/block-backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I'm still not sure we shouldn't do the same for blk_{co,aio}_flush(). I guess you exclude them here because you specifically want to fix the issue mentioned in the commit message, but then we could just make blk_flush_all() ignore an -ENOMEDIUM.

I personally think we should make all blk_*flush() functions use blk_is_inserted() instead of blk_is_available(). As we have discussed on IRC, there are probably not that many cases a guest can flush a medium in an open tray anyway (because the main use case are read-only CD-ROMs), and even if so, that wouldn't change any data, so even if the guest can actually flush something on an open tray, I don't think anyone would complain.

Max

Quoted 14 lines
block/block-backend.c +1 -1
index 34500e6..d1e875e 100644
@@ -1122,7 +1122,7 @@ int blk_co_flush(BlockBackend *blk)
 
 int blk_flush(BlockBackend *blk)
 {
-    if (!blk_is_available(blk)) {
+    if (!blk_is_inserted(blk)) {
         return -ENOMEDIUM;
     }
 
author
#5 lore raw
Quoted 18 lines · Max Reitz
Quoted 8 lines · John Snow

If a device still has an attached BDS because the medium has not yet been removed, we will be unable to migrate to a new host because blk_flush will return an error for that backend.

Replace the call to blk_is_available to blk_is_inserted to weaken the check and allow flushes from the backend to work, while still disallowing flushes from the frontend/device model to work.

Quoted 8 lines

This fixes a regression present in 2.6.0 caused by the following commit:
fe1a9cbc339bb54d20f1ca4c1e8788d16944d5cf
block: Move some bdrv_*_all() functions to BB

---
 block/block-backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 4 lines

I'm still not sure we shouldn't do the same for blk_{co,aio}_flush(). I guess you exclude them here because you specifically want to fix the issue mentioned in the commit message, but then we could just make blk_flush_all() ignore an -ENOMEDIUM.

Yeah, I didn't investigate the full path. Just making the minimal fixes. Is there a concern that this may still leave certain pathways broken when the CDROM tray is open?

I don't know of any immediately without digging again.

Quoted 11 lines

I personally think we should make all blk_*flush() functions use blk_is_inserted() instead of blk_is_available(). As we have discussed on IRC, there are probably not that many cases a guest can flush a medium in an open tray anyway (because the main use case are read-only CD-ROMs), and even if so, that wouldn't change any data, so even if the guest can actually flush something on an open tray, I don't think anyone would complain.

Max

I have difficulty making pragmatic arguments when purity is at stake, but I've already wandered outside of my device model, so I will defer to your judgment.

Quoted 6 lines
Quoted 6 lines
block/block-backend.c +0 -0
index 34500e6..d1e875e 100644
@@ -1122,7 +1122,7 @@ int blk_co_flush(BlockBackend *blk)
 
Quoted 10 lines

block/block-backend.c int blk_co_flush(BlockBackend *blk) · line 1128

Quoted 8 lines
block/block-backend.c +1 -1
 int blk_flush(BlockBackend *blk)
 {
-    if (!blk_is_available(blk)) {
+    if (!blk_is_inserted(blk)) {
         return -ENOMEDIUM;
     }
 

Is this a NACK unless I attempt to address the wider design issue?

#6 lore raw
Quoted 65 lines · John Snow
Quoted 18 lines · Max Reitz
Quoted 8 lines · John Snow

If a device still has an attached BDS because the medium has not yet been removed, we will be unable to migrate to a new host because blk_flush will return an error for that backend.

Replace the call to blk_is_available to blk_is_inserted to weaken the check and allow flushes from the backend to work, while still disallowing flushes from the frontend/device model to work.

Quoted 8 lines

This fixes a regression present in 2.6.0 caused by the following commit:
fe1a9cbc339bb54d20f1ca4c1e8788d16944d5cf
block: Move some bdrv_*_all() functions to BB

---
 block/block-backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 4 lines

I'm still not sure we shouldn't do the same for blk_{co,aio}_flush(). I guess you exclude them here because you specifically want to fix the issue mentioned in the commit message, but then we could just make blk_flush_all() ignore an -ENOMEDIUM.

Yeah, I didn't investigate the full path. Just making the minimal fixes. Is there a concern that this may still leave certain pathways broken when the CDROM tray is open?

I don't know of any immediately without digging again.

Quoted 11 lines

I personally think we should make all blk_*flush() functions use blk_is_inserted() instead of blk_is_available(). As we have discussed on IRC, there are probably not that many cases a guest can flush a medium in an open tray anyway (because the main use case are read-only CD-ROMs), and even if so, that wouldn't change any data, so even if the guest can actually flush something on an open tray, I don't think anyone would complain.

Max

I have difficulty making pragmatic arguments when purity is at stake, but I've already wandered outside of my device model, so I will defer to your judgment.

Quoted 6 lines
Quoted 6 lines
block/block-backend.c +0 -0
index 34500e6..d1e875e 100644
@@ -1122,7 +1122,7 @@ int blk_co_flush(BlockBackend *blk)
 
Quoted 10 lines

block/block-backend.c int blk_co_flush(BlockBackend *blk) · line 1128

Quoted 8 lines
block/block-backend.c +1 -1
 int blk_flush(BlockBackend *blk)
 {
-    if (!blk_is_available(blk)) {
+    if (!blk_is_inserted(blk)) {
         return -ENOMEDIUM;
     }
 
Quoted 1 line

Is this a NACK unless I attempt to address the wider design issue?

I just don't see a point in using blk_is_inserted() here but blk_is_available() in the other blk_*flush() functions. If blk_is_inserted() is correct for blk_flush(), it should be correct for blk_co_flush() and blk_aio_flush(), too.

Maybe I should emphasize that I decided between is_available() and is_inserted() basically on what felt right to me. There's not really that much research behind it, so changing it is completely fine.

Max

#7 lore raw

Am 14.06.2016 um 18:13 hat Max Reitz geschrieben:

Quoted 66 lines · John Snow
Quoted 65 lines · Max Reitz
Quoted 18 lines · John Snow
Quoted 8 lines

If a device still has an attached BDS because the medium has not yet been removed, we will be unable to migrate to a new host because blk_flush will return an error for that backend.

Replace the call to blk_is_available to blk_is_inserted to weaken the check and allow flushes from the backend to work, while still disallowing flushes from the frontend/device model to work.

Quoted 8 lines

This fixes a regression present in 2.6.0 caused by the following commit:
fe1a9cbc339bb54d20f1ca4c1e8788d16944d5cf
block: Move some bdrv_*_all() functions to BB

---
 block/block-backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 4 lines

I'm still not sure we shouldn't do the same for blk_{co,aio}_flush(). I guess you exclude them here because you specifically want to fix the issue mentioned in the commit message, but then we could just make blk_flush_all() ignore an -ENOMEDIUM.

Yeah, I didn't investigate the full path. Just making the minimal fixes. Is there a concern that this may still leave certain pathways broken when the CDROM tray is open?

I don't know of any immediately without digging again.

Quoted 11 lines

I personally think we should make all blk_*flush() functions use blk_is_inserted() instead of blk_is_available(). As we have discussed on IRC, there are probably not that many cases a guest can flush a medium in an open tray anyway (because the main use case are read-only CD-ROMs), and even if so, that wouldn't change any data, so even if the guest can actually flush something on an open tray, I don't think anyone would complain.

Max

I have difficulty making pragmatic arguments when purity is at stake, but I've already wandered outside of my device model, so I will defer to your judgment.

Quoted 16 lines
Quoted 14 lines
block/block-backend.c +1 -1
index 34500e6..d1e875e 100644
@@ -1122,7 +1122,7 @@ int blk_co_flush(BlockBackend *blk)
 
 int blk_flush(BlockBackend *blk)
 {
-    if (!blk_is_available(blk)) {
+    if (!blk_is_inserted(blk)) {
         return -ENOMEDIUM;
     }
 
Quoted 6 lines
Quoted 1 line

Is this a NACK unless I attempt to address the wider design issue?

I just don't see a point in using blk_is_inserted() here but blk_is_available() in the other blk_*flush() functions. If blk_is_inserted() is correct for blk_flush(), it should be correct for blk_co_flush() and blk_aio_flush(), too.

I agree, if we can, we should keep the behaviour consistent between all interfaces types (sync/AIO/coroutine, byte-based/sector-based) for the same operation.

Eric also rightfully said that we need a test cases, so a v2 would be good anyway.

Kevin