[PATCH v3] zram: do not forget to endio for partial discard requests

Sergey Senozhatsky
2026-03-31T07:43:11Z

As reported by Qu Wenruo, the following

getconf PAGESIZE
65536
blkdiscard -p 4k /dev/zram0

takes literally forever to complete. zram doesn't support
partial discards and just returns immediately w/o doing any
discard work in such cases. The problem is that we forget
to endio on our way out, so blkdiscard sleeps forever in
submit_bio_wait(). Fix this by jumping to end_bio label,
which does bio_endio().

Fixes: 0120dd6e4e202 ("zram: make zram_bio_discard more self-contained")
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reported-by: Qu Wenruo <wqu@suse.com>
Closes: https://lore.kernel.org/linux-block/92361cd3-fb8b-482e-bc89-15ff1acb9a59@suse.com
Test-by: Qu Wenruo <wqu@suse.com>
Cc: Avinesh Kumar <avinesh.kumar@suse.com>
Cc: Christoph Hellwig <hch@lst.de>
---

v2->v3:
- updated commit message and added Avinesh Kumar

drivers/block/zram/zram_drv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index dcea703a6766..aca67d7144e4 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -2684,7 +2684,7 @@ static void zram_bio_discard(struct zram *zram, struct bio *bio)
*/
if (offset) {
if (n <= (PAGE_SIZE - offset))
- return;
+ goto end_bio;

n -= (PAGE_SIZE - offset);
index++;
@@ -2699,6 +2699,7 @@ static void zram_bio_discard(struct zram *zram, struct bio *bio)
n -= PAGE_SIZE;
}

+end_bio:
bio_endio(bio);
}

--
2.53.0.1018.g2bb0e51243-goog