Re: [PATCHv3 1/4] zram: introduce writeback bio batching support

From: Yuwen Chen
Date: Mon Nov 17 2025 - 22:19:20 EST


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;
> +}