Linux block layer
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: linux-block@vger.kernel.org, ming.lei@redhat.com, axboe@kernel.dk
Cc: Mike Christie <michael.christie@oracle.com>
Subject: [PATCH v2 2/2] ublk: Make ublks_max configurable
Date: Thu, 12 Oct 2023 10:06:00 -0500	[thread overview]
Message-ID: <20231012150600.6198-3-michael.christie@oracle.com> (raw)
In-Reply-To: <20231012150600.6198-1-michael.christie@oracle.com>

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 | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index ba7c6f9ee136..b0bbda08ad45 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -2940,7 +2940,22 @@ 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)
+{
+	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, "%u\n", ublks_max);
+}
+
+static const struct kernel_param_ops ublk_max_ublks_ops = {
+	.set = ublk_set_max_ublks,
+	.get = ublk_get_max_ublks,
+};
+
+module_param_cb(ublks_max, &ublk_max_ublks_ops, &ublks_max, 0644);
 MODULE_PARM_DESC(ublks_max, "max number of ublk devices allowed to add(default: 64)");
 
 MODULE_AUTHOR("Ming Lei <ming.lei@redhat.com>");
-- 
2.34.1


  parent reply	other threads:[~2023-10-12 15:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 15:05 [PATCH v2 0/2] ublk: Allow more than 64 ublk devices Mike Christie
2023-10-12 15:05 ` [PATCH v2 1/2] ublk: Limit dev_id/ub_number values Mike Christie
2023-10-13  0:18   ` Ming Lei
2023-10-12 15:06 ` Mike Christie [this message]
2023-10-13  0:40   ` [PATCH v2 2/2] ublk: Make ublks_max configurable Ming Lei
2023-10-13  1:05 ` [PATCH v2 0/2] ublk: Allow more than 64 ublk devices Jens Axboe

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