From: Damien Le Moal <dlemoal@kernel.org>
To: raoxu <raoxu@uniontech.com>
Cc: axboe@kernel.dk, hch@lst.de, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] zloop: restore finished zones with reduced capacity
Date: Mon, 3 Aug 2026 22:04:32 +0900 [thread overview]
Message-ID: <78d0627b-e711-4ce2-84ac-6e501898407c@kernel.org> (raw)
In-Reply-To: <2D18C0B4D202858C+20260731061139.1190909-1-raoxu@uniontech.com>
On 7/31/26 15:11, raoxu wrote:
> 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 &&
The problem comes from at least zloop_finish_zone() which truncates a zone file
to zlo->zone_size << SECTOR_SHIFT instead of zlo->zone_capacity << SECTOR_SHIFT.
So I think that is what we need to fix.
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2026-08-03 13:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 6:11 [PATCH] zloop: restore finished zones with reduced capacity raoxu
2026-08-03 13:04 ` Damien Le Moal [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=78d0627b-e711-4ce2-84ac-6e501898407c@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=raoxu@uniontech.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox