[PATCH 04/12] zbd: fix write zone accounting
Shin'ichiro Kawasaki <[email protected]> Fri, 9 Jan 2026 11:35:55 +0900
| Newsgroups | org.kernel.vger.fio |
|---|---|
| Message-ID | <[email protected]> |
Currently, zbd_convert_to_write_zones() calls io_u_quiesce() when the number of write target zones hits one of the limits of write zones. This wait by io_u_quiesce() significantly degrade the performance. However, when the io_u_quiesce() is removed, the test case 58 of t/zbd/test-zbd-support fails with null_blk devices that have a max_active_zones limit set. The failure cause is an incorrect write target zone accounting in zbd_convert_to_write_zones(). This function checks the current write target zones, and selects one of them as the next write target zone. After the zone selection, it locks the zone. But when the zone is locked, another job might have removed the zone from the write target zones array. This caused an incorrect zone accounting and the test case failure. To avoid the incorrect zone accounting, call zbd_write_zone_get() after the selected zone gets locked. If the zone is removed from the write target zones array, the function adds the zone back to the array. Signed-off-by: Shin'ichiro Kawasaki <[email protected]> --- zbd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zbd.c b/zbd.c index 9d5a3bc3..e5f4c8f6 100644 --- a/zbd.c +++ b/zbd.c @@ -1661,7 +1661,12 @@ retry: z = zbd_get_zone(f, zone_idx); zone_lock(td, f, z); - if (zbd_zone_remainder(z) > 0) + /* + * The zone might be already removed from zbdi->write_zones[] by + * other jobs at this moment. Even if the zone has remainder, + * call zbd_write_zone_get() to ensure that it is in the array. + */ + if (zbd_zone_remainder(z) > 0 && zbd_write_zone_get(td, f, z)) goto out; pthread_mutex_lock(&zbdi->mutex); } -- 2.49.0