From: Christoph Hellwig Date: Tue, 14 Apr 2026 08:17:46 +0000 (+0200) Subject: zloop: fix write pointer calculation in zloop_forget_cache X-Git-Tag: v7.1-rc1~10^2~20 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=32be3c01c3b8e948a4326ab7e76c1c63dd3e27bc;p=thirdparty%2Fkernel%2Flinux.git zloop: fix write pointer calculation in zloop_forget_cache The write pointer is absolute and in sector units, so we need to convert it to a relative byte address first. Fixes: c505448748f7 ("zloop: forget write cache on force removal") Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: Johannes Thumshirn Link: https://patch.msgid.link/20260414081811.549755-2-hch@lst.de Signed-off-by: Jens Axboe --- diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c index 8baf642037fd8..672948d3653e3 100644 --- a/drivers/block/zloop.c +++ b/drivers/block/zloop.c @@ -1401,8 +1401,17 @@ static void zloop_forget_cache(struct zloop_device *zlo) zlo->disk->part0, ret); continue; } - if (old_wp < zone->wp) - zloop_truncate(file, old_wp); + + if (old_wp > zone->wp) + continue; + /* + * This should not happen, if we recored a full zone, it can't + * be active. + */ + if (WARN_ON_ONCE(old_wp == ULLONG_MAX)) + continue; + + zloop_truncate(file, (old_wp - zone->start) << SECTOR_SHIFT); } }