diff options
| author | Christoph Hellwig <hch@lst.de> | 2026-04-14 10:17:46 +0200 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-04-15 13:58:36 -0600 |
| commit | 32be3c01c3b8e948a4326ab7e76c1c63dd3e27bc (patch) | |
| tree | dc9fbcd0063e30c7c41a2ad1b5819c0ebd4eac64 /drivers/block/zloop.c | |
| parent | 5bdb4078e1efba9650c03753616866192d680718 (diff) | |
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 <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://patch.msgid.link/20260414081811.549755-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/zloop.c')
| -rw-r--r-- | drivers/block/zloop.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c index 8baf642037fd..672948d3653e 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); } } |
