Skip to contentSkip to conversation

macio: Use blk_drain instead of blk_drain_all

PATCH Applied Fam Zheng 4 participants 7 messages Jun 12, 2016 – Jun 14, 2016

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 macio: Use blk_drain instead of blk_drain_all

We only care about the associated backend, so blk_drain is more appropriate here.

---
 hw/ide/macio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ide/macio.c +1 -1
index 78c10a0..a8c7321 100644
@@ -400,7 +400,7 @@ static void pmac_ide_flush(DBDMA_io *io)
     IDEState *s = idebus_active_if(&m->bus);
 
     if (s->bus->dma->aiocb) {
-        blk_drain_all();
+        blk_drain(s->blk);
     }
 }
 
Signature · 1 line
2.8.3
Reviewed-by on v1 1/1
#1 lore raw

Am 12.06.2016 um 08:56 hat Fam Zheng geschrieben:

Quoted 4 lines

We only care about the associated backend, so blk_drain is more appropriate here.

[ Cc: John ]

Quoted 9 lines
---
 hw/ide/macio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ide/macio.c +0 -0
index 78c10a0..a8c7321 100644

hw/ide/macio.c static void pmac_ide_flush(DBDMA_io *io) · line 405

Quoted 7 lines
hw/ide/macio.c +1 -1
@@ -400,7 +400,7 @@ static void pmac_ide_flush(DBDMA_io *io)
     IDEState *s = idebus_active_if(&m->bus);
 
     if (s->bus->dma->aiocb) {
-        blk_drain_all();
+        blk_drain(s->blk);
     }
 }

Looks good to me:

However, even this is still doing too much. We only need to drain the requests that come from this device and can ignore e.g. block job requests.

Now the part that I'm not completely sure about is whether the problem is here in the IDE emulation and it should track its own requests or whether it is blk_drain() that actually shouldn't drain the BDS but just all requests that came in through this specific BB.

I'm leaning towards the latter, but I'm unsure whether we have cases where we actually need to drain the whole root BDS. Any opinions?

Kevin

author
#2 lore raw
Quoted 33 lines · Kevin Wolf

Am 12.06.2016 um 08:56 hat Fam Zheng geschrieben:

Quoted 4 lines

We only care about the associated backend, so blk_drain is more appropriate here.

[ Cc: John ]

Quoted 9 lines
---
 hw/ide/macio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ide/macio.c +0 -0
index 78c10a0..a8c7321 100644

hw/ide/macio.c static void pmac_ide_flush(DBDMA_io *io) · line 405

Quoted 7 lines
hw/ide/macio.c +1 -1
@@ -400,7 +400,7 @@ static void pmac_ide_flush(DBDMA_io *io)
     IDEState *s = idebus_active_if(&m->bus);
 
     if (s->bus->dma->aiocb) {
-        blk_drain_all();
+        blk_drain(s->blk);
     }
 }

Looks good to me:

However, even this is still doing too much. We only need to drain the requests that come from this device and can ignore e.g. block job requests.

Quoted 7 lines

Now the part that I'm not completely sure about is whether the problem is here in the IDE emulation and it should track its own requests or whether it is blk_drain() that actually shouldn't drain the BDS but just all requests that came in through this specific BB.

I'm leaning towards the latter, but I'm unsure whether we have cases where we actually need to drain the whole root BDS. Any opinions?

I agree with you and think the latter is better in this case. I think the one in migration/block.c need to drain the whole root BDS, and others don't.

Fam

#3 lore raw
In reply to Kevin Wolf
Quoted 33 lines · Kevin Wolf

Am 12.06.2016 um 08:56 hat Fam Zheng geschrieben:

Quoted 4 lines

We only care about the associated backend, so blk_drain is more appropriate here.

[ Cc: John ]

Quoted 9 lines
---
 hw/ide/macio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ide/macio.c +0 -0
index 78c10a0..a8c7321 100644

hw/ide/macio.c static void pmac_ide_flush(DBDMA_io *io) · line 405

Quoted 7 lines
hw/ide/macio.c +1 -1
@@ -400,7 +400,7 @@ static void pmac_ide_flush(DBDMA_io *io)
     IDEState *s = idebus_active_if(&m->bus);
 
     if (s->bus->dma->aiocb) {
-        blk_drain_all();
+        blk_drain(s->blk);
     }
 }

Looks good to me:

However, even this is still doing too much. We only need to drain the requests that come from this device and can ignore e.g. block job requests.

Quoted 7 lines

Now the part that I'm not completely sure about is whether the problem is here in the IDE emulation and it should track its own requests or whether it is blk_drain() that actually shouldn't drain the BDS but just all requests that came in through this specific BB.

I'm leaning towards the latter, but I'm unsure whether we have cases where we actually need to drain the whole root BDS. Any opinions?

There seem to be two distinct drain use cases:

1. Complete all requests that have been submitted via this BB.

2. Quiesce the BDS sub-graph so operations can be performed without in-flight I/O intefering.

Device emulation usually needs #1. Live migration and monitor commands need #2.

We could distinguish the two by making blk_drain() have #1 semantics only. Users that need #2 must use new blk_drained_begin()/blk_drained_end() functions so the quiescent region is explicit.

Stefan

Reviewed-by on v1 1/1
#4 lore raw
In reply to Fam Zheng
Quoted 14 lines · Fam Zheng

We only care about the associated backend, so blk_drain is more appropriate here.

---
 hw/ide/macio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ide/macio.c +0 -0
index 78c10a0..a8c7321 100644

hw/ide/macio.c static void pmac_ide_flush(DBDMA_io *io) · line 406

Quoted 8 lines
hw/ide/macio.c +1 -1
@@ -400,7 +400,7 @@ static void pmac_ide_flush(DBDMA_io *io)
     IDEState *s = idebus_active_if(&m->bus);
 
     if (s->bus->dma->aiocb) {
-        blk_drain_all();
+        blk_drain(s->blk);
     }
 }
 

Shall I take this through my tree?

author
#5 lore raw
Quoted 28 lines · John Snow
Quoted 14 lines · Fam Zheng

We only care about the associated backend, so blk_drain is more appropriate here.

---
 hw/ide/macio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ide/macio.c +0 -0
index 78c10a0..a8c7321 100644

hw/ide/macio.c static void pmac_ide_flush(DBDMA_io *io) · line 406

Quoted 8 lines
hw/ide/macio.c +1 -1
@@ -400,7 +400,7 @@ static void pmac_ide_flush(DBDMA_io *io)
     IDEState *s = idebus_active_if(&m->bus);
 
     if (s->bus->dma->aiocb) {
-        blk_drain_all();
+        blk_drain(s->blk);
     }
 }
 
Quoted 1 line

Shall I take this through my tree?

I think that MAINTAINERS says so. :)

Fam

Applied
#6 lore raw
Quoted 29 lines · Fam Zheng
Quoted 28 lines · John Snow
Quoted 14 lines · Fam Zheng

We only care about the associated backend, so blk_drain is more appropriate here.

---
 hw/ide/macio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ide/macio.c +0 -0
index 78c10a0..a8c7321 100644

hw/ide/macio.c static void pmac_ide_flush(DBDMA_io *io) · line 406

Quoted 8 lines
hw/ide/macio.c +1 -1
@@ -400,7 +400,7 @@ static void pmac_ide_flush(DBDMA_io *io)
     IDEState *s = idebus_active_if(&m->bus);
 
     if (s->bus->dma->aiocb) {
-        blk_drain_all();
+        blk_drain(s->blk);
     }
 }
 
Quoted 6 lines
Quoted 1 line

Shall I take this through my tree?

I think that MAINTAINERS says so. :)

Fam

For now, then:

Thanks, applied to my IDE tree:

https://github.com/jnsnow/qemu/commits/ide
https://github.com/jnsnow/qemu.git

--js