public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Damien Le Moal <dlemoal@kernel.org>
Cc: linux-block@vger.kernel.org
Subject: [PATCH 1/6] zloop: fix write pointer calculation in zloop_forget_cache
Date: Tue, 14 Apr 2026 10:17:46 +0200	[thread overview]
Message-ID: <20260414081811.549755-2-hch@lst.de> (raw)
In-Reply-To: <20260414081811.549755-1-hch@lst.de>

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>
---
 drivers/block/zloop.c | 13 +++++++++++--
 1 file 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);
 	}
 }
 
-- 
2.53.0


  reply	other threads:[~2026-04-14  8:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-14  8:17 zloop fixes Christoph Hellwig
2026-04-14  8:17 ` Christoph Hellwig [this message]
2026-04-14  9:26   ` [PATCH 1/6] zloop: fix write pointer calculation in zloop_forget_cache Damien Le Moal
2026-04-14  8:17 ` [PATCH 2/6] zloop: use vfs_truncate Christoph Hellwig
2026-04-14  9:26   ` Damien Le Moal
2026-04-14  8:17 ` [PATCH 3/6] zloop: improve the unaligned write pointer warning Christoph Hellwig
2026-04-14  9:27   ` Damien Le Moal
2026-04-14  8:17 ` [PATCH 4/6] zloop: set RQF_QUIET when completing requests on deleted devices Christoph Hellwig
2026-04-14  9:28   ` Damien Le Moal
2026-04-14  8:17 ` [PATCH 5/6] zloop: factor out zloop_mark_{full,empty} helpers Christoph Hellwig
2026-04-14  9:29   ` Damien Le Moal
2026-04-14  8:17 ` [PATCH 6/6] zloop: remove irq-safe locking Christoph Hellwig
2026-04-14  9:30   ` Damien Le Moal
2026-04-14 16:20 ` zloop fixes Johannes Thumshirn
2026-04-15 20:03 ` 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=20260414081811.549755-2-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=dlemoal@kernel.org \
    --cc=linux-block@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