[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20110429162817.2eb26efb.akpm@linux-foundation.org>
Date: Fri, 29 Apr 2011 16:28:17 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Jan Kara <jack@...e.cz>
Cc: LKML <linux-kernel@...r.kernel.org>, Greg KH <gregkh@...e.de>
Subject: Re: Allow setting of number of raw devices as a module parameter
On Fri, 29 Apr 2011 00:24:29 +0200
Jan Kara <jack@...e.cz> wrote:
> Allow setting of maximal number of raw devices as a module parameter. This
> requires changing of static array into a vmalloced one (the array is going to
> be too large for kmalloc).
>
Changelog failed to describe why the patch is needed. Lacking that
information, we have no reason to apply it.
> +static int max_raw_minors = MAX_RAW_MINORS;
I suppose we could remove MAX_RAW_MINORS and use CONFIG_MAX_RAW_DEVS
directly.
> +
> +module_param(max_raw_minors, int, 0);
> +MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
> +
> /*
> * Open/close code for raw IO.
> *
> @@ -131,7 +137,7 @@ static int bind_set(int number, u64 majo
> struct raw_device_data *rawdev;
> int err = 0;
>
> - if (number <= 0 || number >= MAX_RAW_MINORS)
> + if (number <= 0 || number >= max_raw_minors)
> return -EINVAL;
>
> if (MAJOR(dev) != major || MINOR(dev) != minor)
> @@ -318,12 +324,26 @@ static int __init raw_init(void)
> dev_t dev = MKDEV(RAW_MAJOR, 0);
> int ret;
>
> - ret = register_chrdev_region(dev, MAX_RAW_MINORS, "raw");
> + if (max_raw_minors < 1 || max_raw_minors > 65536) {
> + printk(KERN_WARNING "raw: invalid max_raw_minors (must be"
> + " between 1 and 65536), using %d\n", MAX_RAW_MINORS);
> + max_raw_minors = MAX_RAW_MINORS;
> + }
> +
> + raw_devices = vmalloc(sizeof(struct raw_device_data) * max_raw_minors);
> + if (!raw_devices) {
> + printk(KERN_ERR "Not enough memory for raw device structures\n");
> + ret = -ENOMEM;
> + goto error;
> + }
> + memset(raw_devices, 0, sizeof(struct raw_device_data) * max_raw_minors);
vzalloc().
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists