Commit 32be3c01 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://patch.msgid.link/20260414081811.549755-2-hch@lst.de


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 5bdb4078
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -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);
	}
}