Linux block layer
 help / color / mirror / Atom feed
* [PATCH] zloop: restore finished zones with reduced capacity
@ 2026-07-31  6:11 raoxu
  2026-08-03 13:04 ` Damien Le Moal
  0 siblings, 1 reply; 7+ messages in thread
From: raoxu @ 2026-07-31  6:11 UTC (permalink / raw)
  To: dlemoal; +Cc: axboe, hch, linux-block, linux-kernel, raoxu, stable

From: Xu Rao <raoxu@uniontech.com>

zloop_finish_zone() truncates a finished sequential zone backing file to
zone_size. When zone_capacity is smaller than zone_size,
zloop_update_seq_zone() rejects that file when the device is re-added
because it treats every file larger than zone_capacity as invalid.

Documentation/admin-guide/blockdev/zoned_loop.rst, section "Overview",
states that a zone finish operation truncates the backing file to the zone
size. A file whose size equals zone_size is therefore a valid
representation of a finished zone.

Accept both zone_capacity and zone_size as full-zone representations. Keep
rejecting all other files larger than zone_capacity.

Fixes: eb0570c7df23 ("block: new zoned loop block device driver")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
 drivers/block/zloop.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
index 55eeb6aac0ea..b69d798f203c 100644
--- a/drivers/block/zloop.c
+++ b/drivers/block/zloop.c
@@ -324,7 +324,8 @@ static int zloop_update_seq_zone(struct zloop_device *zlo, unsigned int zone_no)
 	}
 
 	file_sectors = stat.size >> SECTOR_SHIFT;
-	if (file_sectors > zlo->zone_capacity) {
+	if (file_sectors > zlo->zone_capacity &&
+	    file_sectors != zlo->zone_size) {
 		pr_err("Zone %u file too large (%llu sectors > %llu)\n",
 		       zone_no, file_sectors, zlo->zone_capacity);
 		return -EINVAL;
@@ -339,7 +340,8 @@ static int zloop_update_seq_zone(struct zloop_device *zlo, unsigned int zone_no)
 	spin_lock(&zone->wp_lock);
 	if (!file_sectors) {
 		zloop_mark_empty(zlo, zone);
-	} else if (file_sectors == zlo->zone_capacity) {
+	} else if (file_sectors == zlo->zone_capacity ||
+		   file_sectors == zlo->zone_size) {
 		zloop_mark_full(zlo, zone);
 	} else {
 		if (zone->cond != BLK_ZONE_COND_IMP_OPEN &&
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-08-04 13:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31  6:11 [PATCH] zloop: restore finished zones with reduced capacity raoxu
2026-08-03 13:04 ` Damien Le Moal
2026-08-04  2:34   ` [PATCH v2] zloop: truncate finished zones to zone capacity raoxu
2026-08-04  4:26     ` Damien Le Moal
2026-08-04 12:36     ` Christoph Hellwig
2026-08-04 12:37     ` Christoph Hellwig
2026-08-04 13:00     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox