quorum: Fix crash in quorum_aio_cb()
PATCH 1/1 quorum: Fix crash in quorum_aio_cb()
quorum_aio_cb() emits the QUORUM_REPORT_BAD event if there's an I/O error in a Quorum child. However sacb->aiocb must be correctly initialized for this to happen. read_quorum_children() and read_fifo_child() are not doing this, which results in a QEMU crash.
--- block/quorum.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
block/quorum.c +7 -5
@@ -646,8 +646,9 @@ static BlockAIOCB *read_quorum_children(QuorumAIOCB *acb) }for (i =0 ; i < s->num_children; i++) { -bdrv_aio_readv (s->children[i]->bs, acb->sector_num, &acb->qcrs[i].qiov, - acb->nb_sectors, quorum_aio_cb, &acb->qcrs[i]); + acb->qcrs[i].aiocb =bdrv_aio_readv (s->children[i]->bs, acb->sector_num, + &acb->qcrs[i].qiov, acb->nb_sectors, + quorum_aio_cb, &acb->qcrs[i]); }return &acb->common;
@@ -662,9 +663,10 @@ static BlockAIOCB *read_fifo_child(QuorumAIOCB *acb)qemu_iovec_init (&acb->qcrs[acb->child_iter].qiov, acb->qiov->niov);qemu_iovec_clone (&acb->qcrs[acb->child_iter].qiov, acb->qiov, acb->qcrs[acb->child_iter].buf); -bdrv_aio_readv (s->children[acb->child_iter]->bs, acb->sector_num, - &acb->qcrs[acb->child_iter].qiov, acb->nb_sectors, - quorum_aio_cb, &acb->qcrs[acb->child_iter]); + acb->qcrs[acb->child_iter].aiocb = +bdrv_aio_readv (s->children[acb->child_iter]->bs, acb->sector_num, + &acb->qcrs[acb->child_iter].qiov, acb->nb_sectors, + quorum_aio_cb, &acb->qcrs[acb->child_iter]);return &acb->common; }
Signature · 1 line
2.7.0
Quoted 4 lines · Alberto Garcia
quorum_aio_cb()emits theQUORUM_REPORT_BADevent if there's an I/O error in a Quorum child. Howeversacb->aiocbmust be correctly initialized for this to happen.read_quorum_children()andread_fifo_child()are not doing this, which results in a QEMU crash.
If we use FIFO mode, we don't call quorum_report_bad() in quorum_aio_cb(). But it is OK to iniialize sacb->aiocb for it.
Quoted 3 lines
Signed-off-by Alberto Garcia <[email protected]>Reviewed-by Max Reitz <[email protected]>
Quoted 35 lines
--- block/quorum.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)block/quorum.c +7
-5@@ -646,8 +646,9 @@ static BlockAIOCB *read_quorum_children(QuorumAIOCB *acb) }for (i =0 ; i < s->num_children; i++) { -bdrv_aio_readv (s->children[i]->bs, acb->sector_num, &acb->qcrs[i].qiov, - acb->nb_sectors, quorum_aio_cb, &acb->qcrs[i]); + acb->qcrs[i].aiocb =bdrv_aio_readv (s->children[i]->bs, acb->sector_num, + &acb->qcrs[i].qiov, acb->nb_sectors, + quorum_aio_cb, &acb->qcrs[i]); }return &acb->common;@@ -662,9 +663,10 @@ static BlockAIOCB *read_fifo_child(QuorumAIOCB *acb)qemu_iovec_init (&acb->qcrs[acb->child_iter].qiov, acb->qiov->niov);qemu_iovec_clone (&acb->qcrs[acb->child_iter].qiov, acb->qiov, acb->qcrs[acb->child_iter].buf); -bdrv_aio_readv (s->children[acb->child_iter]->bs, acb->sector_num, - &acb->qcrs[acb->child_iter].qiov, acb->nb_sectors, - quorum_aio_cb, &acb->qcrs[acb->child_iter]); + acb->qcrs[acb->child_iter].aiocb = +bdrv_aio_readv (s->children[acb->child_iter]->bs, acb->sector_num, + &acb->qcrs[acb->child_iter].qiov, acb->nb_sectors, + quorum_aio_cb, &acb->qcrs[acb->child_iter]);return &acb->common; }
Quoted 8 lines · Wen Congyang
Quoted 4 lines · Alberto Garcia
quorum_aio_cb()emits theQUORUM_REPORT_BADevent if there's an I/O error in a Quorum child. Howeversacb->aiocbmust be correctly initialized for this to happen.read_quorum_children()andread_fifo_child()are not doing this, which results in a QEMU crash.If we use FIFO mode, we don't call
quorum_report_bad()inquorum_aio_cb(). But it is OK to iniializesacb->aiocbfor it.
You're right. I still think it's a good idea to leave it initialized in case we change that in the future.
And now that we're at it, shouldn't we call quorum_report_bad() in FIFO mode as well? Or is there any reason not to do it?
Berto
Quoted 10 lines · Alberto Garcia
Quoted 8 lines · Wen Congyang
Quoted 4 lines · Alberto Garcia
quorum_aio_cb()emits theQUORUM_REPORT_BADevent if there's an I/O error in a Quorum child. Howeversacb->aiocbmust be correctly initialized for this to happen.read_quorum_children()andread_fifo_child()are not doing this, which results in a QEMU crash.If we use FIFO mode, we don't call
quorum_report_bad()inquorum_aio_cb(). But it is OK to iniializesacb->aiocbfor it.
Hi betro
Quoted 2 lines
You're right. I still think it's a good idea to leave it initialized in case we change that in the future.
Yes.
Quoted 3 lines
And now that we're at it, shouldn't we call
quorum_report_bad()in FIFO mode as well? Or is there any reason not to do it?
IMO, no reason not to do it.
Thanks
-Xie
Quoted 6 lines
Berto
Quoted 4 lines · Changlong Xie
Quoted 2 lines
And now that we're at it, shouldn't we call
quorum_report_bad()in FIFO mode as well? Or is there any reason not to do it?IMO, no reason not to do it.
I'll send a patch to fix that.
Thanks,
Berto