linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Yuwen Chen <ywen.chen@foxmail.com>
Cc: senozhatsky@chromium.org, akpm@linux-foundation.org,
	 bgeffon@google.com, licayy@outlook.com,
	linux-block@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, minchan@google.com, minchan@kernel.org,
	 richardycc@google.com
Subject: Re: [PATCHv3 1/4] zram: introduce writeback bio batching support
Date: Tue, 18 Nov 2025 12:47:17 +0900	[thread overview]
Message-ID: <ysxyj7q5fuwfbvbh2o5ewsl4plzaaw2wcvn3qemjgzz43hvboq@d2k736awhhpi> (raw)
In-Reply-To: <tencent_900337D4388F6BEDF9525EFA974CD7669106@qq.com>

On (25/11/18 11:36), Yuwen Chen wrote:
> On Tue, 18 Nov 2025 11:18:56 +0800, Yuwen Chen wrote:
> >> +	/*
> >> +	 * We release slot lock during writeback so slot can change under us:
> >> +	 * slot_free() or slot_free() and zram_write_page(). In both cases
> >> +	 * slot loses ZRAM_PP_SLOT flag. No concurrent post-processing can
> >> +	 * set ZRAM_PP_SLOT on such slots until current post-processing
> >> +	 * finishes.
> >> +	 */
> >> +	if (!zram_test_flag(zram, index, ZRAM_PP_SLOT))
> >> +		goto out;
> >In this place, the index may be leaked.
> 
> To be precise, blk_idx may be leaked.

Ah, I see what you mean. Agreed.

I guess I'll just send out v4 later today, given that we have two
fixups in the queue already.

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

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 0a5f11e0c523..8e91dc071b65 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -886,6 +886,7 @@ static int zram_writeback_complete(struct zram *zram, struct zram_wb_req *req)
 		 * (if enabled).
 		 */
 		zram_account_writeback_rollback(zram);
+		free_block_bdev(zram, req->blk_idx);
 		return err;
 	}
 
@@ -898,8 +899,10 @@ static int zram_writeback_complete(struct zram *zram, struct zram_wb_req *req)
 	 * set ZRAM_PP_SLOT on such slots until current post-processing
 	 * finishes.
 	 */
-	if (!zram_test_flag(zram, index, ZRAM_PP_SLOT))
+	if (!zram_test_flag(zram, index, ZRAM_PP_SLOT)) {
+		free_block_bdev(zram, req->blk_idx);
 		goto out;
+	}
 
 	zram_free_page(zram, index);
 	zram_set_flag(zram, index, ZRAM_WB);
-- 
2.52.0.rc1.455.g30608eb744-goog




  reply	other threads:[~2025-11-18  3:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-15  2:34 [PATCHv3 0/4] zram: introduce writeback bio batching Sergey Senozhatsky
2025-11-15  2:34 ` [PATCHv3 1/4] zram: introduce writeback bio batching support Sergey Senozhatsky
2025-11-17 15:19   ` Brian Geffon
2025-11-18  2:08     ` Yuwen Chen
2025-11-18  2:14       ` Sergey Senozhatsky
2025-11-18  3:18         ` Yuwen Chen
2025-11-18  3:36         ` Yuwen Chen
2025-11-18  3:47           ` Sergey Senozhatsky [this message]
2025-11-18  3:48     ` Yuwen Chen
2025-11-18  7:00   ` Sergey Senozhatsky
2025-11-15  2:34 ` [PATCHv3 2/4] zram: add writeback batch size device attr Sergey Senozhatsky
2025-11-15  2:34 ` [PATCHv3 3/4] zram: take write lock in wb limit store handlers Sergey Senozhatsky
2025-11-15  2:34 ` [PATCHv3 4/4] zram: drop wb_limit_lock Sergey Senozhatsky

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=ysxyj7q5fuwfbvbh2o5ewsl4plzaaw2wcvn3qemjgzz43hvboq@d2k736awhhpi \
    --to=senozhatsky@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=bgeffon@google.com \
    --cc=licayy@outlook.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@google.com \
    --cc=minchan@kernel.org \
    --cc=richardycc@google.com \
    --cc=ywen.chen@foxmail.com \
    /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