[PATCH v2 0/1] Fix race condition in throttle_group_restart_queue()

Alberto Garcia posted 1 patch 3 weeks, 5 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/cover.1773313028.git.berto@igalia.com
Maintainers: Alberto Garcia <berto@igalia.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
There is a newer version of this series
block/throttle-groups.c | 70 +++++++++++++++++++++++++++++++----------
1 file changed, 54 insertions(+), 16 deletions(-)
[PATCH v2 0/1] Fix race condition in throttle_group_restart_queue()
Posted by Alberto Garcia 3 weeks, 5 days ago
Hi,

here's version two of the patch. The important change is that now
throttle_group_restart_tgm() is protected by tg->lock and there's new
logic there.

Note that in case (2) it is theoretically possible for two different
tgms to run throttle_group_restart_queue() in parallel, but I think
this is safe because the actual restart of the queue is once more
protected by the lock.

The alternative that I initially considered (doing nothing if another
tgm is waiting for a timer) is probably not a good idea because
throttle_group_restart_tgm() is used by callers who want to drain a
tgm so I think that the requests should be processed immediately:

    if (qatomic_fetch_inc(&tgm->io_limits_disabled) == 0) {
        throttle_group_restart_tgm(tgm);
    }

Once more, please test this carefully to see if it solves issue #3194.
I have only run the basic qemu iotests and I haven't touched this code
in a long time :)

Regards,

Berto

Alberto Garcia (1):
  throttle-group: Fix race condition in throttle_group_restart_queue()

 block/throttle-groups.c | 70 +++++++++++++++++++++++++++++++----------
 1 file changed, 54 insertions(+), 16 deletions(-)

-- 
2.47.3