Skip to content

mirror: Handle errors after READY cancel

Max Reitz qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest12 patches 22 repliesIn review
  2. v27 patches 23 repliesSuperseded
  3. v16 patches 9 repliesSuperseded

Changes in v3 from the cover letter

- Patch 1: After adding patch 11, I got a failed assertion in tests/unit/test-block-iothread (failing qemu_mutex_unlock_impl()). That is because before patch 11, for zero-length source devices, mirror clears .cancelled unconditionally before exiting. So even force-cancelled jobs are considered to be completed normally, which doesn’t seem quite right.
Anyway, test-block-iothread does some iothread switching, and cancelling jobs is not really prepared for that. This patch fixes that (I hope...).

- Patch 4: Split off from patch 5

- Patch 7:
- Added a long section in the commit message detailing every choice for every job_is_cancelled() invocation
- Use job_cancel_requested() in the assertion in job_completed_txn_abort(), because it is not quite clear whether soft-cancelled mirror jobs can end up in this path (it seems like a bug if that happens, but I think that’s something to fix in some other series)

- Patch 8: Added: This is kind of preparation for patch 9, but also just a bug fix in itself, I believe

- Patch 9: Moved the job_is_cancelled() check after the last yield point before the mirror_iteration() call

- Patch 10: Added: If force-cancelled jobs should not generate new I/O requests at all (except for forwarding something to the source device), then we need to stop doing active mirroring once the mirror job is force-cancelled

- Patch 11: Added: Clearing .cancelled seemed like a hack, so getting rid of it seems like a good thing to do
(And only with this patch, I can assert that .force_cancel can only be true when .cancelled is true also; if we tried it before this patch, tests/unit/test-block-iothread would fail.)

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12job: Context changes in job_completed_txn_abort()job.c+18 -54 replies
2/12mirror: Keep s->synced on errorblock/mirror.c+0 -10 replies
3/12mirror: Drop s->syncedblock/mirror.c+9 -100 replies
4/12job: Force-cancel jobs in a failed transactionjob.c+6 -12 replies
5/12job: @force parameter for job_cancel_sync{, _all}()block/replication.c blockdev.c include/qemu/job.h +8 more+55 -556 replies
6/12jobs: Give Job.force_cancel more meaningblock/backup.c block/mirror.c include/qemu/job.h +1 more+35 -90 replies
7/12job: Add job_cancel_requested()block/mirror.c include/qemu/job.h job.c+18 -92 replies
8/12mirror: Use job_is_cancelled()block/mirror.c+1 -12 replies
9/12mirror: Check job_is_cancelled() earlierblock/mirror.c+5 -52 replies
10/12mirror: Stop active mirroring after force-cancelblock/mirror.c+2 -02 replies
11/12mirror: Do not clear .cancelledblock/mirror.c job.c+3 -32 replies
12/12iotests: Add mirror-ready-cancel-error testtests/qemu-iotests/tests/mirror-ready-cancel-error tests/qemu-iotests/tests/mirror-ready-cancel-error.out+148 -00 replies

Reviews trailers per patch

All 12 patches have a Reviewed-by or Acked-by.

PatchEric BlakeVladimir Sementsov-OgievskiyKevin Wolf
1/12R-b R-b
2/12R-b R-b
3/12R-b R-b R-b
4/12R-b R-b
5/12R-b R-b
6/12R-b R-b R-b
7/12R-b R-b
8/12R-b R-b
9/12R-b R-b
10/12R-b R-b
11/12R-b R-b
12/12R-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v3 thread

Cover letter [PATCH for-6.2 v3 00/12] mirror: Handle errors after READY cancel

Hi,

v1 cover letter:
https://lists.nongnu.org/archive/html/qemu-block/2021-07/msg00705.html

v2 cover letter:
https://lists.nongnu.org/archive/html/qemu-block/2021-07/msg00747.html

Changes in v3:
- Patch 1: After adding patch 11, I got a failed assertion in tests/unit/test-block-iothread (failing qemu_mutex_unlock_impl()). That is because before patch 11, for zero-length source devices, mirror clears .cancelled unconditionally before exiting. So even force-cancelled jobs are considered to be completed normally, which doesn’t seem quite right.
Anyway, test-block-iothread does some iothread switching, and cancelling jobs is not really prepared for that. This patch fixes that (I hope...).

- Patch 4: Split off from patch 5

- Patch 7:
- Added a long section in the commit message detailing every choice for every job_is_cancelled() invocation
- Use job_cancel_requested() in the assertion in job_completed_txn_abort(), because it is not quite clear whether soft-cancelled mirror jobs can end up in this path (it seems like a bug if that happens, but I think that’s something to fix in some other series)

- Patch 8: Added: This is kind of preparation for patch 9, but also just a bug fix in itself, I believe

- Patch 9: Moved the job_is_cancelled() check after the last yield point before the mirror_iteration() call

- Patch 10: Added: If force-cancelled jobs should not generate new I/O requests at all (except for forwarding something to the source device), then we need to stop doing active mirroring once the mirror job is force-cancelled

- Patch 11: Added: Clearing .cancelled seemed like a hack, so getting rid of it seems like a good thing to do
(And only with this patch, I can assert that .force_cancel can only be true when .cancelled is true also; if we tried it before this patch, tests/unit/test-block-iothread would fail.)

The discussion around v2 has shown that there are probably more bugs in the job code, but I think this series is becoming long enough that we should tackle those in a different series.

git-backport-diff against v1:

Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/12:[down] 'job: Context changes in job_completed_txn_abort()' 002/12:[----] [--] 'mirror: Keep s->synced on error' 003/12:[----] [--] 'mirror: Drop s->synced'
004/12:[down] 'job: Force-cancel jobs in a failed transaction' 005/12:[0007] [FC] 'job: @force parameter for job_cancel_sync{,_all}()' 006/12:[----] [--] 'jobs: Give Job.force_cancel more meaning' 007/12:[0002] [FC] 'job: Add job_cancel_requested()' 008/12:[down] 'mirror: Use job_is_cancelled()'
009/12:[0007] [FC] 'mirror: Check job_is_cancelled() earlier' 010/12:[down] 'mirror: Stop active mirroring after force-cancel' 011/12:[down] 'mirror: Do not clear .cancelled' 012/12:[----] [--] 'iotests: Add mirror-ready-cancel-error test'

Max Reitz (12):
job: Context changes in job_completed_txn_abort()
mirror: Keep s->synced on error
mirror: Drop s->synced
job: Force-cancel jobs in a failed transaction
job: @force parameter for job_cancel_sync{,_all}()
jobs: Give Job.force_cancel more meaning
job: Add job_cancel_requested()
mirror: Use job_is_cancelled()
mirror: Check job_is_cancelled() earlier
mirror: Stop active mirroring after force-cancel
mirror: Do not clear .cancelled
iotests: Add mirror-ready-cancel-error test

 include/qemu/job.h                            |  29 +++-
 block/backup.c                                |   3 +-
 block/mirror.c                                |  56 ++++---
 block/replication.c                           |   4 +-
 blockdev.c                                    |   4 +-
 job.c                                         |  67 ++++++--
 qemu-nbd.c                                    |   2 +-
 softmmu/runstate.c                            |   2 +-
 storage-daemon/qemu-storage-daemon.c          |   2 +-
 tests/unit/test-block-iothread.c              |   2 +-
 tests/unit/test-blockjob.c                    |   2 +-
 tests/qemu-iotests/109.out                    |  60 +++-----
 .../tests/mirror-ready-cancel-error           | 143 ++++++++++++++++++
 .../tests/mirror-ready-cancel-error.out       |   5 +
 tests/qemu-iotests/tests/qsd-jobs.out         |   2 +-
 15 files changed, 292 insertions(+), 91 deletions(-)
 create mode 100755 tests/qemu-iotests/tests/mirror-ready-cancel-error
 create mode 100644 tests/qemu-iotests/tests/mirror-ready-cancel-error.out
Signature · 1 line
2.31.1