[PATCH 2/4] blk-iocost: charge zone appends as page-counted sequential writes
From: Tao Cui
Date: Mon Sep 07 2026 - 22:22:51 EST
From: Tao Cui <cuitao@xxxxxxxxxx>
Zone append is a primary write operation for zoned devices; zoned
btrfs and f2fs use it for data writes. It is priced at zero, so the
zone append portion of zoned workloads runs outside the controller:
a 1%-weight cgroup issued 16000 appends at zero cost on a zoned
null_blk.
A zone append advances the zone write pointer and is therefore
sequential from the device's perspective; the actual sector is only
returned after completion, so the cursor-based seq/rand
classification doesn't apply. Price it as a page-counted sequential
write. After this patch, 16000 appends from the same cgroup are
charged 533264 usec (33us per append).
Also skip the cursor update for ZA bios: bi_sector is the zone
start, not the actual write position (which is only returned after
completion). Setting the cursor from ZA would misclassify subsequent
READ/WRITE bios.
Fixes: 7caa47151ab2 ("blkcg: implement blk-iocost")
Signed-off-by: Tao Cui <cuitao@xxxxxxxxxx>
---
block/blk-iocost.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index abc512532ed9..d7860ec1ad49 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -2557,6 +2557,17 @@ static void calc_vtime_cost_builtin(struct bio *bio, struct ioc_gq *iocg,
coef_randio = ioc->params.lcoefs[LCOEF_WRANDIO];
coef_page = ioc->params.lcoefs[LCOEF_WPAGE];
break;
+ case REQ_OP_ZONE_APPEND:
+ /*
+ * A zone append advances the zone write pointer and is
+ * therefore sequential from the device's perspective, so
+ * the cursor-based classification below doesn't apply.
+ * Compute the full cost here.
+ */
+ if (!is_merge)
+ cost += ioc->params.lcoefs[LCOEF_WSEQIO];
+ cost += pages * ioc->params.lcoefs[LCOEF_WPAGE];
+ goto out;
default:
goto out;
}
@@ -2717,7 +2728,9 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)
if (!iocg_activate(iocg, &now))
return;
- iocg->cursor = bio_end_sector(bio);
+ /* ZA bi_sector is zone start, not the write position */
+ if (bio_op(bio) != REQ_OP_ZONE_APPEND)
+ iocg->cursor = bio_end_sector(bio);
vtime = atomic64_read(&iocg->vtime);
cost = adjust_inuse_and_calc_cost(iocg, vtime, abs_cost, &now);
--
2.43.0