public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Jan Kara <jack@suse.cz>
Cc: LKML <linux-kernel@vger.kernel.org>, Greg KH <gregkh@suse.de>
Subject: Re: Allow setting of number of raw devices as a module parameter
Date: Fri, 29 Apr 2011 16:28:17 -0700	[thread overview]
Message-ID: <20110429162817.2eb26efb.akpm@linux-foundation.org> (raw)
In-Reply-To: <1304029469-19672-1-git-send-email-jack@suse.cz>

On Fri, 29 Apr 2011 00:24:29 +0200
Jan Kara <jack@suse.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().



  parent reply	other threads:[~2011-04-29 23:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-28 22:24 Allow setting of number of raw devices as a module parameter Jan Kara
2011-04-29 23:19 ` Greg KH
2011-04-29 23:28 ` Andrew Morton [this message]
2011-04-30  0:07   ` Greg KH
2011-04-30  5:09     ` Dave Jones
2011-04-30  5:42       ` Greg KH
2011-04-30 10:29   ` Alan Cox
2011-04-30 15:34     ` Greg KH
2011-04-30 15:41       ` Alan Cox
2011-04-30 15:47         ` Greg KH
2011-05-02 19:22         ` Jan Kara
2011-05-03  9:42           ` Alan Cox
2011-04-30 12:15 ` Arnd Bergmann
2011-05-02 19:39   ` Jan Kara
2011-05-02 19:44     ` Arnd Bergmann
2011-05-02 21:11       ` Jan Kara
2011-05-03 10:55         ` Arnd Bergmann
2011-05-03 16:26           ` Jan Kara
2011-05-03 17:30             ` Arnd Bergmann

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=20110429162817.2eb26efb.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=gregkh@suse.de \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.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