From: Brian Geffon <bgeffon@google.com>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Minchan Kim <minchan@kernel.org>,
linux-block@vger.kernel.org, linux-mm@kvack.org,
gao xu <gaoxu2@honor.com>
Subject: Re: [PATCH] zram: do not permit params change after init
Date: Tue, 10 Mar 2026 10:01:27 -0400 [thread overview]
Message-ID: <CADyq12zF3cwzSFcKYiGAdJ_G-NVnydBRQn+x0fgNq1kVgof4Vg@mail.gmail.com> (raw)
In-Reply-To: <20260310060407.1133800-1-senozhatsky@chromium.org>
On Tue, Mar 10, 2026 at 2:04 AM Sergey Senozhatsky
<senozhatsky@chromium.org> wrote:
>
> First, algorithm_params_store(), like any sysfs handler,
> should grab device init lock.
>
> Second, like any write() sysfs handler, it should grab
> device init lock in exclusive mode.
comp_algorithm_store() and recomp_algorithm_store()?
>
> Third, it should not permit change of algos' parameters
> after device init, as this doesn't make sense - we cannot
> compress with one C/D dict and then just change C/D dict
> to a different one, for example.
>
> Fixes: 4eac932103a5d ("zram: introduce algorithm_params device attribute")
> Cc: gao xu <gaoxu2@honor.com>
> Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Acked-by: Brian Geffon <bgeffon@google.com>
> ---
> drivers/block/zram/zram_drv.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index c41e1257243f..7551c5e664a9 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -1769,6 +1769,10 @@ static ssize_t algorithm_params_store(struct device *dev,
> if (prio < ZRAM_PRIMARY_COMP || prio >= ZRAM_MAX_COMPS)
> return -EINVAL;
>
> + guard(rwsem_write)(&zram->dev_lock);
> + if (init_done(zram))
> + return -EBUSY;
> +
> ret = comp_params_store(zram, prio, level, dict_path, &deflate_params);
> return ret ? ret : len;
> }
> --
> 2.53.0.473.g4a7958ca14-goog
>
next prev parent reply other threads:[~2026-03-10 14:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 6:01 Sergey Senozhatsky
2026-03-10 14:01 ` Brian Geffon [this message]
2026-03-10 14:02 ` Brian Geffon
2026-03-11 8:27 ` 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=CADyq12zF3cwzSFcKYiGAdJ_G-NVnydBRQn+x0fgNq1kVgof4Vg@mail.gmail.com \
--to=bgeffon@google.com \
--cc=akpm@linux-foundation.org \
--cc=gaoxu2@honor.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--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