* [Qemu-devel] [question] savevm/delvm: Is it neccesary to perform bdrv_drain_all before savevm and delvm? @ 2014-10-20 13:48 Zhang Haoyu 2014-10-20 13:59 ` Kevin Wolf 0 siblings, 1 reply; 7+ messages in thread From: Zhang Haoyu @ 2014-10-20 13:48 UTC (permalink / raw) To: qemu-devel, Stefan Hajnoczi, Max Reitz, Kevin Wolf, Eric Blake Hi, I noticed that bdrv_drain_all is performed in load_vmstate before bdrv_snapshot_goto, and bdrv_drain_all is performed in qmp_transaction before internal_snapshot_prepare, so is it also neccesary to perform bdrv_drain_all in savevm and delvm? Thanks, Zhang Haoyu ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [question] savevm/delvm: Is it neccesary to perform bdrv_drain_all before savevm and delvm? 2014-10-20 13:48 [Qemu-devel] [question] savevm/delvm: Is it neccesary to perform bdrv_drain_all before savevm and delvm? Zhang Haoyu @ 2014-10-20 13:59 ` Kevin Wolf 2014-10-20 15:09 ` [Qemu-devel] [question] savevm/delvm: Is it necessary " Zhang Haoyu 0 siblings, 1 reply; 7+ messages in thread From: Kevin Wolf @ 2014-10-20 13:59 UTC (permalink / raw) To: Zhang Haoyu; +Cc: qemu-devel, Stefan Hajnoczi, Max Reitz Am 20.10.2014 um 15:48 hat Zhang Haoyu geschrieben: > Hi, > > I noticed that bdrv_drain_all is performed in load_vmstate before bdrv_snapshot_goto, > and bdrv_drain_all is performed in qmp_transaction before internal_snapshot_prepare, > so is it also neccesary to perform bdrv_drain_all in savevm and delvm? Definitely yes for savevm. do_savevm() calls it indirectly via vm_stop(), so that part looks okay. delvm doesn't affect the currently running VM, and therefore doesn't interfere with guest requests that are in flight. So I think that a bdrv_drain_all() isn't needed there. Kevin ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [question] savevm/delvm: Is it necessary to perform bdrv_drain_all before savevm and delvm? 2014-10-20 13:59 ` Kevin Wolf @ 2014-10-20 15:09 ` Zhang Haoyu 2014-10-20 16:07 ` Kevin Wolf 0 siblings, 1 reply; 7+ messages in thread From: Zhang Haoyu @ 2014-10-20 15:09 UTC (permalink / raw) To: Kevin Wolf, Zhang Haoyu; +Cc: qemu-devel, Stefan Hajnoczi, Max Reitz >> Hi, >> >> I noticed that bdrv_drain_all is performed in load_vmstate before bdrv_snapshot_goto, >> and bdrv_drain_all is performed in qmp_transaction before internal_snapshot_prepare, >> so is it also neccesary to perform bdrv_drain_all in savevm and delvm? > >Definitely yes for savevm. do_savevm() calls it indirectly via >vm_stop(), so that part looks okay. > Yes, you are right. >delvm doesn't affect the currently running VM, and therefore doesn't >interfere with guest requests that are in flight. So I think that a >bdrv_drain_all() isn't needed there. > I'm worried about that there are still pending IOs while deleting snapshot, then is it possible that there is concurrency problem between the process of deleting snapshot and the coroutine of io read/write(bdrv_co_do_rw) invoked by the pending IOs? This coroutine is also in main thread. Am I missing something? Thanks, Zhang Haoyu >Kevin ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [question] savevm/delvm: Is it necessary to perform bdrv_drain_all before savevm and delvm? 2014-10-20 15:09 ` [Qemu-devel] [question] savevm/delvm: Is it necessary " Zhang Haoyu @ 2014-10-20 16:07 ` Kevin Wolf 2014-10-21 1:13 ` Zhang Haoyu 0 siblings, 1 reply; 7+ messages in thread From: Kevin Wolf @ 2014-10-20 16:07 UTC (permalink / raw) To: Zhang Haoyu; +Cc: Zhang Haoyu, qemu-devel, Stefan Hajnoczi, Max Reitz Am 20.10.2014 um 17:09 hat Zhang Haoyu geschrieben: > >> Hi, > >> > >> I noticed that bdrv_drain_all is performed in load_vmstate before > bdrv_snapshot_goto, > >> and bdrv_drain_all is performed in qmp_transaction before > internal_snapshot_prepare, > >> so is it also neccesary to perform bdrv_drain_all in savevm and delvm? > > > >Definitely yes for savevm. do_savevm() calls it indirectly via > >vm_stop(), so that part looks okay. > > > Yes, you are right. > > >delvm doesn't affect the currently running VM, and therefore doesn't > >interfere with guest requests that are in flight. So I think that a > >bdrv_drain_all() isn't needed there. > > > I'm worried about that there are still pending IOs while deleting snapshot, > then is it possible that there is concurrency problem between the > process of deleting snapshot > and the coroutine of io read/write(bdrv_co_do_rw) invoked by the > pending IOs? > This coroutine is also in main thread. > Am I missing something? What kind of concurrency problem are you thinking of? I do see that there might be a chance of concurrency, but that doesn't automatically mean the requests are conflicting. Would you feel better with taking s->lock in qcow2_snapshot_delete()? This might actually be a valid concern. Kevin ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [question] savevm/delvm: Is it necessary to perform bdrv_drain_all before savevm and delvm? 2014-10-20 16:07 ` Kevin Wolf @ 2014-10-21 1:13 ` Zhang Haoyu 2014-10-21 7:19 ` Kevin Wolf 0 siblings, 1 reply; 7+ messages in thread From: Zhang Haoyu @ 2014-10-21 1:13 UTC (permalink / raw) To: Kevin Wolf, Zhang Haoyu; +Cc: qemu-devel, Stefan Hajnoczi, Max Reitz >> >> Hi, >> >> >> >> I noticed that bdrv_drain_all is performed in load_vmstate before >> bdrv_snapshot_goto, >> >> and bdrv_drain_all is performed in qmp_transaction before >> internal_snapshot_prepare, >> >> so is it also neccesary to perform bdrv_drain_all in savevm and delvm? >> > >> >Definitely yes for savevm. do_savevm() calls it indirectly via >> >vm_stop(), so that part looks okay. >> > >> Yes, you are right. >> >> >delvm doesn't affect the currently running VM, and therefore doesn't >> >interfere with guest requests that are in flight. So I think that a >> >bdrv_drain_all() isn't needed there. >> > >> I'm worried about that there are still pending IOs while deleting snapshot, >> then is it possible that there is concurrency problem between the >> process of deleting snapshot >> and the coroutine of io read/write(bdrv_co_do_rw) invoked by the >> pending IOs? >> This coroutine is also in main thread. >> Am I missing something? > >What kind of concurrency problem are you thinking of? > I have encountered two problem, 1) double-free of Qcow2DiscardRegion in qcow2_process_discards please see the discussing mail: [PATCH] qcow2: fix double-free of Qcow2DiscardRegion in qcow2_process_discards 2) qcow2 image is truncated to very huge size, but the size shown by qemu-img info is normal please see the discussing mail: [question] is it possible that big-endian l1 table offset referenced by other I/O while updating l1 table offset in qcow2_update_snapshot_refcount? I suspect that both of the two problems are concurrency problem mentioned above, please see the discussing mail. >I do see that there might be a chance of concurrency, but that doesn't >automatically mean the requests are conflicting. > >Would you feel better with taking s->lock in qcow2_snapshot_delete()? Both deleting snapshot and the coroutine of pending io read/write(bdrv_co_do_rw) are performed in main thread, could BDRVQcowState.lock work? Thanks, Zhang Haoyu >This might actually be a valid concern. > >Kevin ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [question] savevm/delvm: Is it necessary to perform bdrv_drain_all before savevm and delvm? 2014-10-21 1:13 ` Zhang Haoyu @ 2014-10-21 7:19 ` Kevin Wolf 2014-10-21 7:51 ` [Qemu-devel] [question] savevm/delvm: Is it necessary to performbdrv_drain_all " Zhang Haoyu 0 siblings, 1 reply; 7+ messages in thread From: Kevin Wolf @ 2014-10-21 7:19 UTC (permalink / raw) To: Zhang Haoyu; +Cc: Stefan Hajnoczi, qemu-devel, Zhang Haoyu, Max Reitz Am 21.10.2014 um 03:13 hat Zhang Haoyu geschrieben: > >> >> Hi, > >> >> > >> >> I noticed that bdrv_drain_all is performed in load_vmstate before > >> bdrv_snapshot_goto, > >> >> and bdrv_drain_all is performed in qmp_transaction before > >> internal_snapshot_prepare, > >> >> so is it also neccesary to perform bdrv_drain_all in savevm and delvm? > >> > > >> >Definitely yes for savevm. do_savevm() calls it indirectly via > >> >vm_stop(), so that part looks okay. > >> > > >> Yes, you are right. > >> > >> >delvm doesn't affect the currently running VM, and therefore doesn't > >> >interfere with guest requests that are in flight. So I think that a > >> >bdrv_drain_all() isn't needed there. > >> > > >> I'm worried about that there are still pending IOs while deleting snapshot, > >> then is it possible that there is concurrency problem between the > >> process of deleting snapshot > >> and the coroutine of io read/write(bdrv_co_do_rw) invoked by the > >> pending IOs? > >> This coroutine is also in main thread. > >> Am I missing something? > > > >What kind of concurrency problem are you thinking of? > > > I have encountered two problem, > 1) double-free of Qcow2DiscardRegion in qcow2_process_discards > please see the discussing mail: [PATCH] qcow2: fix double-free of Qcow2DiscardRegion in qcow2_process_discards > 2) qcow2 image is truncated to very huge size, but the size shown by qemu-img info is normal > please see the discussing mail: > [question] is it possible that big-endian l1 table offset referenced by other I/O while updating l1 table offset in qcow2_update_snapshot_refcount? Did you verify that the invalid value actually makes sense if byteswapped? For example, that there is no reserved bit set then? > I suspect that both of the two problems are concurrency problem mentioned above, > please see the discussing mail. > > > >I do see that there might be a chance of concurrency, but that doesn't > >automatically mean the requests are conflicting. > > > >Would you feel better with taking s->lock in qcow2_snapshot_delete()? > Both deleting snapshot and the coroutine of pending io read/write(bdrv_co_do_rw) > are performed in main thread, could BDRVQcowState.lock work? Yes. s->lock is not a mutex for threads, but a coroutine based one. The problem, however, is that qcow2_snapshot_delete() isn't execute in a coroutine, so we can't take s->lock here. We would either need to move it into a coroutine or add a bdrv_drain_all() indeed. This also means that we probably need to review all other cases where non-coroutine callbacks from BlockDriver might interfere with running requests. The original assumption that they are safe as long as they are not running in a coroutine seems to be wrong. Kevin ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [question] savevm/delvm: Is it necessary to performbdrv_drain_all before savevm and delvm? 2014-10-21 7:19 ` Kevin Wolf @ 2014-10-21 7:51 ` Zhang Haoyu 0 siblings, 0 replies; 7+ messages in thread From: Zhang Haoyu @ 2014-10-21 7:51 UTC (permalink / raw) To: Kevin Wolf; +Cc: Stefan Hajnoczi, qemu-devel, Zhang Haoyu, Max Reitz > >> >> Hi, > >> >> > >> >> I noticed that bdrv_drain_all is performed in load_vmstate before > >> bdrv_snapshot_goto, >> >> >> and bdrv_drain_all is performed in qmp_transaction before >> >> internal_snapshot_prepare, >> >> >> so is it also neccesary to perform bdrv_drain_all in savevm and delvm? >> >> > >> >> >Definitely yes for savevm. do_savevm() calls it indirectly via >> >> >vm_stop(), so that part looks okay. >> >> > >> >> Yes, you are right. >> >> >> >> >delvm doesn't affect the currently running VM, and therefore doesn't >> >> >interfere with guest requests that are in flight. So I think that a >> >> >bdrv_drain_all() isn't needed there. >> >> > >> >> I'm worried about that there are still pending IOs while deleting snapshot, >> >> then is it possible that there is concurrency problem between the >> >> process of deleting snapshot >> >> and the coroutine of io read/write(bdrv_co_do_rw) invoked by the >> >> pending IOs? >> >> This coroutine is also in main thread. >> >> Am I missing something? >> > >> >What kind of concurrency problem are you thinking of? >> > >> I have encountered two problem, >> 1) double-free of Qcow2DiscardRegion in qcow2_process_discards >> please see the discussing mail: [PATCH] qcow2: fix double-free of Qcow2DiscardRegion in qcow2_process_discards >> 2) qcow2 image is truncated to very huge size, but the size shown by qemu-img info is normal >> please see the discussing mail: >> [question] is it possible that big-endian l1 table offset referenced by other I/O while updating l1 table offset in qcow2_update_snapshot_refcount? > >Did you verify that the invalid value actually makes sense if >byteswapped? For example, that there is no reserved bit set then? > Yes, exactly, I have verified that those l2 table offset are invalid value if byte-swapped. >> I suspect that both of the two problems are concurrency problem mentioned above, >> please see the discussing mail. >> >> >> >I do see that there might be a chance of concurrency, but that doesn't >> >automatically mean the requests are conflicting. >> > >> >Would you feel better with taking s->lock in qcow2_snapshot_delete()? >> Both deleting snapshot and the coroutine of pending io read/write(bdrv_co_do_rw) >> are performed in main thread, could BDRVQcowState.lock work? > >Yes. s->lock is not a mutex for threads, but a coroutine based one. > Yes, you are right. >The problem, however, is that qcow2_snapshot_delete() isn't execute in a >coroutine, so we can't take s->lock here. We would either need to move >it into a coroutine or add a bdrv_drain_all() indeed. > I'm inclined to add bdrv_drain_all(), just keeping consistent with the other snapshot-related operations, like savevm, loadvm, internal_snapshot_prepare, etc. Thanks, Zhang Haoyu >This also means that we probably need to review all other cases where >non-coroutine callbacks from BlockDriver might interfere with running >requests. The original assumption that they are safe as long as they are >not running in a coroutine seems to be wrong. Agreed. > >Kevin ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-10-21 9:30 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-10-20 13:48 [Qemu-devel] [question] savevm/delvm: Is it neccesary to perform bdrv_drain_all before savevm and delvm? Zhang Haoyu 2014-10-20 13:59 ` Kevin Wolf 2014-10-20 15:09 ` [Qemu-devel] [question] savevm/delvm: Is it necessary " Zhang Haoyu 2014-10-20 16:07 ` Kevin Wolf 2014-10-21 1:13 ` Zhang Haoyu 2014-10-21 7:19 ` Kevin Wolf 2014-10-21 7:51 ` [Qemu-devel] [question] savevm/delvm: Is it necessary to performbdrv_drain_all " Zhang Haoyu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).