public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Yuwen Chen <ywen.chen@foxmail.com>
To: senozhatsky@chromium.org
Cc: 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,
	ywen.chen@foxmail.com
Subject: Re: [PATCHv3 1/4] zram: introduce writeback bio batching support
Date: Tue, 18 Nov 2025 11:18:56 +0800	[thread overview]
Message-ID: <tencent_295C252FFDABBAEBA3088D5B72DCDE15EB05@qq.com> (raw)
In-Reply-To: <3nqzi2v72dsef2dte7iqe7wahrbzam33druh7klsh45zvefdm3@ab6stznzdxmh>

On Mon, 17 Nov 2025 10:19:22 -0500, Sergey Senozhatsky wrote:
> +static int zram_writeback_complete(struct zram *zram, struct zram_wb_req *req)
> +{
> +	u32 index;
> +	int err;
> +
> +	index = req->pps->index;
> +	release_pp_slot(zram, req->pps);
> +	req->pps = NULL;
> +
> +	err = blk_status_to_errno(req->bio.bi_status);
> +	if (err) {
> +		/*
> +		 * Failed wb requests should not be accounted in wb_limit
> +		 * (if enabled).
> +		 */
> +		zram_account_writeback_rollback(zram);
In this place, the index may be leaked.

> +		return err;
> +	}
> +
> +	atomic64_inc(&zram->stats.bd_writes);
> +	zram_slot_lock(zram, index);
> +	/*
> +	 * 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.

> +
> +	zram_free_page(zram, index);
> +	zram_set_flag(zram, index, ZRAM_WB);
> +	zram_set_handle(zram, index, req->blk_idx);
> +	atomic64_inc(&zram->stats.pages_stored);
> +
> +out:
> +	zram_slot_unlock(zram, index);
> +	return 0;
> +}


  reply	other threads:[~2025-11-18  3:19 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 [this message]
2025-11-18  3:36         ` Yuwen Chen
2025-11-18  3:47           ` Sergey Senozhatsky
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=tencent_295C252FFDABBAEBA3088D5B72DCDE15EB05@qq.com \
    --to=ywen.chen@foxmail.com \
    --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=senozhatsky@chromium.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