Skip to content

Commit

Permalink
ublk: Make ublks_max configurable
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Ming Lei <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
mikechristie authored and axboe committed Oct 17, 2023
1 parent 56974c0 commit 6eba24a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion drivers/block/ublk_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>");
Expand Down

0 comments on commit 6eba24a

Please sign in to comment.