From: Andrew Morton <akpm@osdl.org>
To: thockin@sun.com
Cc: torvalds@osdl.org, viro@parcelfarce.linux.theplanet.co.uk,
linux-kernel@vger.kernel.org
Subject: Re: PATCH - raise max_anon limit
Date: Wed, 11 Feb 2004 14:48:44 -0800 [thread overview]
Message-ID: <20040211144844.0e4a2888.akpm@osdl.org> (raw)
In-Reply-To: <20040211222849.GL9155@sun.com>
Tim Hockin <thockin@sun.com> wrote:
>
> > Wanna test this?
>
> sure:
>
> -------------------
> sysfs: could not mount!
> Unable to handle kernel paging request at virtual address ffffff01
Bah, ordering problem.
25-akpm/fs/super.c | 36 +++++++++++++++++++++---------------
25-akpm/include/linux/fs.h | 1 +
25-akpm/init/main.c | 1 +
3 files changed, 23 insertions(+), 15 deletions(-)
diff -puN fs/super.c~max_anon-use-idr fs/super.c
--- 25/fs/super.c~max_anon-use-idr Wed Feb 11 14:42:15 2004
+++ 25-akpm/fs/super.c Wed Feb 11 14:47:16 2004
@@ -23,6 +23,8 @@
#include <linux/config.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/init.h>
+#include <asm/semaphore.h>
#include <linux/smp_lock.h>
#include <linux/acct.h>
#include <linux/blkdev.h>
@@ -33,6 +35,7 @@
#include <linux/security.h>
#include <linux/vfs.h>
#include <linux/writeback.h> /* for the emergency remount stuff */
+#include <linux/idr.h>
#include <asm/uaccess.h>
@@ -536,38 +539,41 @@ void emergency_remount(void)
* filesystems which don't use real block-devices. -- jrs
*/
-enum {Max_anon = 256};
-static unsigned long unnamed_dev_in_use[Max_anon/(8*sizeof(unsigned long))];
-static spinlock_t unnamed_dev_lock = SPIN_LOCK_UNLOCKED;/* protects the above */
+static struct idr unnamed_dev_idr;
+static DECLARE_MUTEX(unnamed_dev_sem);
int set_anon_super(struct super_block *s, void *data)
{
int dev;
- spin_lock(&unnamed_dev_lock);
- dev = find_first_zero_bit(unnamed_dev_in_use, Max_anon);
- if (dev == Max_anon) {
- spin_unlock(&unnamed_dev_lock);
- return -EMFILE;
+
+ down(&unnamed_dev_sem);
+ if (idr_pre_get(&unnamed_dev_idr) == 0) {
+ up(&unnamed_dev_sem);
+ return -ENOMEM;
}
- set_bit(dev, unnamed_dev_in_use);
- spin_unlock(&unnamed_dev_lock);
+ dev = idr_get_new(&unnamed_dev_idr, NULL);
+ up(&unnamed_dev_sem);
s->s_dev = MKDEV(0, dev);
return 0;
}
-
EXPORT_SYMBOL(set_anon_super);
void kill_anon_super(struct super_block *sb)
{
int slot = MINOR(sb->s_dev);
+
generic_shutdown_super(sb);
- spin_lock(&unnamed_dev_lock);
- clear_bit(slot, unnamed_dev_in_use);
- spin_unlock(&unnamed_dev_lock);
+ down(&unnamed_dev_sem);
+ idr_remove(&unnamed_dev_idr, slot);
+ up(&unnamed_dev_sem);
}
-
EXPORT_SYMBOL(kill_anon_super);
+void __init unnamed_dev_init(void)
+{
+ idr_init(&unnamed_dev_idr);
+}
+
void kill_litter_super(struct super_block *sb)
{
if (sb->s_root)
diff -puN include/linux/fs.h~max_anon-use-idr include/linux/fs.h
--- 25/include/linux/fs.h~max_anon-use-idr Wed Feb 11 14:45:52 2004
+++ 25-akpm/include/linux/fs.h Wed Feb 11 14:46:06 2004
@@ -1051,6 +1051,7 @@ struct super_block *sget(struct file_sys
void *data);
struct super_block *get_sb_pseudo(struct file_system_type *, char *,
struct super_operations *ops, unsigned long);
+void unnamed_dev_init(void);
/* Alas, no aliases. Too much hassle with bringing module.h everywhere */
#define fops_get(fops) \
diff -puN init/main.c~max_anon-use-idr init/main.c
--- 25/init/main.c~max_anon-use-idr Wed Feb 11 14:48:12 2004
+++ 25-akpm/init/main.c Wed Feb 11 14:48:15 2004
@@ -473,6 +473,7 @@ asmlinkage void __init start_kernel(void
fork_init(num_physpages);
proc_caches_init();
buffer_init();
+ unnamed_dev_init();
security_scaffolding_startup();
vfs_caches_init(num_physpages);
radix_tree_init();
_
next prev parent reply other threads:[~2004-02-11 22:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-06 22:15 Tim Hockin
2004-02-07 8:55 ` Andrew Morton
2004-02-07 9:48 ` viro
2004-02-11 20:33 ` Tim Hockin
2004-02-11 20:38 ` Linus Torvalds
2004-02-11 21:09 ` Tim Hockin
2004-02-11 21:53 ` Andrew Morton
2004-02-11 22:28 ` Tim Hockin
2004-02-11 22:48 ` Andrew Morton [this message]
[not found] ` <20040211233852.GN9155@sun.com>
[not found] ` <20040211155754.5068332c.akpm@osdl.org>
[not found] ` <20040212003840.GO9155@sun.com>
[not found] ` <20040211164233.5f233595.akpm@osdl.org>
2004-02-12 1:08 ` Tim Hockin
2004-02-12 1:20 ` Andrew Morton
2004-02-12 2:22 ` Tim Hockin
2004-02-12 17:26 ` Jim Houston
2004-02-12 18:49 ` Tim Hockin
2004-02-13 2:01 ` Jamie Lokier
2004-02-12 22:03 ` Andrew Morton
2004-02-13 1:12 ` George Anzinger
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=20040211144844.0e4a2888.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thockin@sun.com \
--cc=torvalds@osdl.org \
--cc=viro@parcelfarce.linux.theplanet.co.uk \
/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
all inboxes | Powered by JetHome®