public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH v3] zram: do not forget to endio for partial discard requests
@ 2026-03-31  7:42 Sergey Senozhatsky
  2026-03-31 15:07 ` Christoph Hellwig
  2026-04-01  0:49 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Sergey Senozhatsky @ 2026-03-31  7:42 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Minchan Kim, Brian Geffon, linux-block, linux-mm,
	Sergey Senozhatsky, Qu Wenruo, Avinesh Kumar, Christoph Hellwig

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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] zram: do not forget to endio for partial discard requests
  2026-03-31  7:42 [PATCH v3] zram: do not forget to endio for partial discard requests Sergey Senozhatsky
@ 2026-03-31 15:07 ` Christoph Hellwig
  2026-04-01  0:49 ` Andrew Morton
  1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-03-31 15:07 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: Andrew Morton, Minchan Kim, Brian Geffon, linux-block, linux-mm,
	Qu Wenruo, Avinesh Kumar

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] zram: do not forget to endio for partial discard requests
  2026-03-31  7:42 [PATCH v3] zram: do not forget to endio for partial discard requests Sergey Senozhatsky
  2026-03-31 15:07 ` Christoph Hellwig
@ 2026-04-01  0:49 ` Andrew Morton
  2026-04-01  1:10   ` Sergey Senozhatsky
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2026-04-01  0:49 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: Minchan Kim, Brian Geffon, linux-block, linux-mm, Qu Wenruo,
	Avinesh Kumar, Christoph Hellwig

On Tue, 31 Mar 2026 16:42:44 +0900 Sergey Senozhatsky <senozhatsky@chromium.org> wrote:

> As reported by Qu Wenruo, the following
> 
>  getconf PAGESIZE
>  65536
>  blkdiscard -p 4k /dev/zram0
> 
> takes literally forever to complete.

I'm wondering how you measured this interval ;)

> 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>

Thanks.  I made several changes to the changelog from the earlier
discussion (Anivesh Reported-by:/Closes:) and added a cc:stable.

0120dd6e4e202 was a few years ago so no need to rush this into mainline
- target this to the upcoming merge window.


From: Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: zram: do not forget to endio for partial discard requests
Date: Tue, 31 Mar 2026 16:42:44 +0900

As reported by Qu Wenruo and Avinesh Kumar, 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().

Link: https://lkml.kernel.org/r/20260331074255.777019-1-senozhatsky@chromium.org
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
Tested-by: Qu Wenruo <wqu@suse.com>
Reported-by: Avinesh Kumar <avinesh.kumar@suse.com>
Closes: https://bugzilla.suse.com/show_bug.cgi?id=1256530
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Brian Geffon <bgeffon@google.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

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

--- a/drivers/block/zram/zram_drv.c~zram-do-not-forget-to-endio-for-partial-discard-requests
+++ a/drivers/block/zram/zram_drv.c
@@ -2678,7 +2678,7 @@ static void zram_bio_discard(struct zram
 	 */
 	if (offset) {
 		if (n <= (PAGE_SIZE - offset))
-			return;
+			goto end_bio;
 
 		n -= (PAGE_SIZE - offset);
 		index++;
@@ -2693,6 +2693,7 @@ static void zram_bio_discard(struct zram
 		n -= PAGE_SIZE;
 	}
 
+end_bio:
 	bio_endio(bio);
 }
 
_



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] zram: do not forget to endio for partial discard requests
  2026-04-01  0:49 ` Andrew Morton
@ 2026-04-01  1:10   ` Sergey Senozhatsky
  0 siblings, 0 replies; 4+ messages in thread
From: Sergey Senozhatsky @ 2026-04-01  1:10 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Sergey Senozhatsky, Minchan Kim, Brian Geffon, linux-block,
	linux-mm, Qu Wenruo, Avinesh Kumar, Christoph Hellwig

On (26/03/31 17:49), Andrew Morton wrote:
> On Tue, 31 Mar 2026 16:42:44 +0900 Sergey Senozhatsky <senozhatsky@chromium.org> wrote:
> 
> > As reported by Qu Wenruo, the following
> > 
> >  getconf PAGESIZE
> >  65536
> >  blkdiscard -p 4k /dev/zram0
> > 
> > takes literally forever to complete.
> 
> I'm wondering how you measured this interval ;)

:)

> > 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>
> 
> Thanks.  I made several changes to the changelog from the earlier
> discussion (Anivesh Reported-by:/Closes:) and added a cc:stable.

Thank you, sir!

> 
> 0120dd6e4e202 was a few years ago so no need to rush this into mainline
> - target this to the upcoming merge window.

Sounds good to me.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-01  1:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31  7:42 [PATCH v3] zram: do not forget to endio for partial discard requests Sergey Senozhatsky
2026-03-31 15:07 ` Christoph Hellwig
2026-04-01  0:49 ` Andrew Morton
2026-04-01  1:10   ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox