mirror of
https://gitlab.com/qemu-project/qemu.git
synced 2026-08-26 22:23:12 -04:00
bdrv_query_blk_stats() reads BlockAcctStats's counters, latency histogram, and per-interval TimedAverage stats without stats->lock, while block_account_one_io() updates the same fields under that lock from an iothread. timed_average_min()/max()/avg() make this worse than a stale read: they call check_expirations(), which can reset a window's sum/count/min/max -- a write, not just a read -- so this is a genuine race with a concurrent writer, not merely a slower reader like the scalar counters. Take stats->lock for the whole call, both to close the race and to make the returned snapshot internally consistent (previously each field could reflect a different instant relative to concurrent updates). block_acct_queue_depth() used to take the lock itself on every call; since bdrv_query_blk_stats() is its only caller and now already holds the lock, that would self-deadlock. Make it require the caller to hold stats->lock instead (documented and asserted). Signed-off-by: Denis V. Lunev <den@openvz.org> CC: Kevin Wolf <kwolf@redhat.com> CC: Hanna Reitz <hreitz@redhat.com> CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> CC: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Message-ID: <20260724111311.4086859-3-den@openvz.org> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
||
|---|---|---|
| .. | ||
| accounting.h | ||
| aio_task.h | ||
| block-common.h | ||
| block-copy.h | ||
| block-global-state.h | ||
| block-hmp-cmds.h | ||
| block-io.h | ||
| block.h | ||
| block_backup.h | ||
| block_int-common.h | ||
| block_int-global-state.h | ||
| block_int-io.h | ||
| block_int.h | ||
| blockjob.h | ||
| blockjob_int.h | ||
| dirty-bitmap.h | ||
| export.h | ||
| fuse.h | ||
| graph-lock.h | ||
| nbd.h | ||
| nvme.h | ||
| qapi.h | ||
| qdict.h | ||
| raw-aio.h | ||
| replication.h | ||
| reqlist.h | ||
| snapshot.h | ||
| thread-pool.h | ||
| throttle-groups.h | ||
| ufs.h | ||
| write-threshold.h | ||