)]}'
{
  "commit": "c8bf923d5eeed0b2bbe26feb37bb399ec1a894f5",
  "tree": "e2e6be8b52b711ef47b4dbf84f0bd6f8602aca23",
  "parents": [
    "652b0dd80815cdb03db9320572be1cc9f9f664a1"
  ],
  "author": {
    "name": "Stefan Hajnoczi",
    "email": "stefanha@redhat.com",
    "time": "Tue Sep 12 19:10:34 2023 -0400"
  },
  "committer": {
    "name": "Kevin Wolf",
    "email": "kwolf@redhat.com",
    "time": "Wed Sep 20 17:46:01 2023 +0200"
  },
  "message": "test-bdrv-drain: avoid race with BH in IOThread drain test\n\nThis patch fixes a race condition in test-bdrv-drain that is difficult\nto reproduce. test-bdrv-drain sometimes fails without an error message\non the block pull request sent by Kevin Wolf on Sep 4, 2023. I was able\nto reproduce it locally and found that \"block-backend: process I/O in\nthe current AioContext\" (in this patch series) is the first commit where\nit reproduces.\n\nI do not know why \"block-backend: process I/O in the current AioContext\"\nexposes this bug. It might be related to the fact that the test\u0027s preadv\nrequest runs in the main thread instead of IOThread a after my commit.\nThat might simply change the timing of the test.\n\nNow on to the race condition in test-bdrv-drain. The main thread\nschedules a BH in IOThread a and then drains the BDS:\n\n  aio_bh_schedule_oneshot(ctx_a, test_iothread_main_thread_bh, \u0026data);\n\n  /* The request is running on the IOThread a. Draining its block device\n   * will make sure that it has completed as far as the BDS is concerned,\n   * but the drain in this thread can continue immediately after\n   * bdrv_dec_in_flight() and aio_ret might be assigned only slightly\n   * later. */\n  do_drain_begin(drain_type, bs);\n\nIf the BH completes before do_drain_begin() then there is nothing to\nworry about.\n\nIf the BH invokes bdrv_flush() before do_drain_begin(), then\ndo_drain_begin() waits for it to complete.\n\nThe problematic case is when do_drain_begin() runs before the BH enters\nbdrv_flush(). Then do_drain_begin() misses the BH and the drain\nmechanism has failed in quiescing I/O.\n\nFix this by incrementing the in_flight counter so that do_drain_begin()\nwaits for test_iothread_main_thread_bh().\n\nSigned-off-by: Stefan Hajnoczi \u003cstefanha@redhat.com\u003e\nMessage-ID: \u003c20230912231037.826804-3-stefanha@redhat.com\u003e\nReviewed-by: Eric Blake \u003ceblake@redhat.com\u003e\nReviewed-by: Kevin Wolf \u003ckwolf@redhat.com\u003e\nSigned-off-by: Kevin Wolf \u003ckwolf@redhat.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "b040a73bb9dece8dba3f90b0483db69a1c380c65",
      "old_mode": 33188,
      "old_path": "tests/unit/test-bdrv-drain.c",
      "new_id": "0b603e7c57b633376fc2d56cd4224260f7133ab3",
      "new_mode": 33188,
      "new_path": "tests/unit/test-bdrv-drain.c"
    }
  ]
}
