Linux block layer
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Mike Christie <michael.christie@oracle.com>
Cc: linux-block@vger.kernel.org, axboe@kernel.dk, ming.lei@redhat.com
Subject: Re: [PATCH 2/2] ublk: Make ublks_max configurable
Date: Tue, 3 Oct 2023 23:47:19 +0800	[thread overview]
Message-ID: <ZRw3hzwTkvA4D8Ee@fedora> (raw)
In-Reply-To: <20231001185448.48893-3-michael.christie@oracle.com>

On Sun, Oct 01, 2023 at 01:54:48PM -0500, Mike Christie wrote:
> We are converting tcmu applications to ublk, but have systems with up
> to 1k devices. This patch allows us to configure the ublks_max from
> userspace with the ublks_max modparam.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>  drivers/block/ublk_drv.c | 31 ++++++++++++++++++++++++++++++-
>  1 file changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index 18e352f8cd6d..2833a81e05c0 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -2940,7 +2940,36 @@ static void __exit ublk_exit(void)
>  module_init(ublk_init);
>  module_exit(ublk_exit);
>  
> -module_param(ublks_max, int, 0444);
> +static int ublk_set_max_ublks(const char *buf, const struct kernel_param *kp)
> +{
> +	unsigned int max;
> +	int ret;
> +
> +	ret = kstrtouint(buf, 10, &max);
> +	if (ret)
> +		return ret;
> +
> +	if (max > UBLK_MAX_UBLKS) {
> +		pr_warn("Invalid ublks_max. Max supported is %d\n",
> +			UBLK_MAX_UBLKS);
> +		return -EINVAL;
> +	}
> +
> +	ublks_max = max;
> +	return ret;

It might be nice to reuse builtin helper:

	return param_set_uint_minmax(buf, kp, 0, UBLK_MAX_UBLKS);

> +}
> +
> +static int ublk_get_max_ublks(char *buf, const struct kernel_param *kp)
> +{
> +	return sysfs_emit(buf, "%d\n", ublks_max);
> +}
> +
> +static const struct kernel_param_ops ublk_max_ublks_ops = {
> +	.set = ublk_set_max_ublks,
> +	.get = ublk_get_max_ublks,

Same with above, '.get    = param_get_int,' could be better.

Otherwise, this patch looks fine.

Thanks,
Ming


  reply	other threads:[~2023-10-03 15:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-01 18:54 [PATCH 0/2] ublk: Allow more than 64 ublk devices Mike Christie
2023-10-01 18:54 ` [PATCH 1/2] ublk: Limit dev_id/ub_number values Mike Christie
2023-10-02  6:08   ` Hannes Reinecke
2023-10-02 18:05     ` Mike Christie
2023-10-03 15:36   ` Ming Lei
2023-10-03 16:07     ` Mike Christie
2023-10-03 21:25       ` Mike Christie
2023-10-04 12:39       ` Ming Lei
2023-10-01 18:54 ` [PATCH 2/2] ublk: Make ublks_max configurable Mike Christie
2023-10-03 15:47   ` Ming Lei [this message]
2023-10-03 15:54     ` Mike Christie

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=ZRw3hzwTkvA4D8Ee@fedora \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=michael.christie@oracle.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