From: John Zielinski <grim@undead.cc>
To: William Lee Irwin III <wli@holomorphy.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Rootfs mounted from user space - problem with umount
Date: Sat, 29 Nov 2003 15:02:32 -0500 [thread overview]
Message-ID: <3FC8FB58.6080708@undead.cc> (raw)
In-Reply-To: <20031129094435.GS14258@holomorphy.com>
William Lee Irwin III wrote:
>Cool! So when do we get a swappable initrd's/initramfs's?
>
>
>
It was 5 in the morning and I ran out of cola. :( Here's the updated
patch. I added an extra error check just in case we ran out of memory
initializing shm's inode cache. Shm defaults to half of available ram
which should be a good limit. Otherwise the machine might not boot if
we fill up ram with that early on. And we can probably remount it with
a new set of limits later. Can the swap device be started in early
userspace?
Just found something while testing. Looks like we do need CONFIG_TMPFS
or else we get a kernel oops on bootup. I'll force that if SHM_ROOTFS
is selected. It adds some extra code that the internal kernel use of
shmem didn't need. If you already use tmpfs that won't matter and
ramfs can now be deselected.
Let me know if you find anything wrong with this.
diff -urNX dontdiff linux-2.6.0-test9/drivers/block/Kconfig linux/drivers/block/Kconfig
--- linux-2.6.0-test9/drivers/block/Kconfig 2003-10-25 14:43:07.000000000 -0400
+++ linux/drivers/block/Kconfig 2003-11-29 14:50:02.000000000 -0500
@@ -320,6 +320,22 @@
"real" root file system, etc. See <file:Documentation/initrd.txt>
for details.
+config SHM_ROOTFS
+ bool "Use tmpfs (shm) instead of ramfs for rootfs"
+ depends on BLK_DEV_INITRD
+ default n
+ select TMPFS
+ help
+ This option switches rootfs so that it uses tmpfs rather than ramfs
+ for it's file storage. This makes rootfs swappable so having a large
+ initrd or initramfs image won't eat up valuable RAM.
+
+config RAMFS_ROOTFS
+ bool
+ depends on !SHM_ROOTFS
+ default y
+ select RAMFS
+
config LBD
bool "Support for Large Block Devices"
depends on X86 || MIPS32 || PPC32 || ARCH_S390_31 || SUPERH
diff -urNX dontdiff linux-2.6.0-test9/fs/Kconfig linux/fs/Kconfig
--- linux-2.6.0-test9/fs/Kconfig 2003-10-25 14:43:51.000000000 -0400
+++ linux/fs/Kconfig 2003-11-28 23:20:48.000000000 -0500
@@ -879,8 +879,8 @@
config HUGETLB_PAGE
def_bool HUGETLBFS
-config RAMFS
- bool
+config RAMFS
+ tristate "Ramfs file system support"
default y
---help---
Ramfs is a file system which keeps all files in RAM. It allows
diff -urNX dontdiff linux-2.6.0-test9/fs/ramfs/inode.c linux/fs/ramfs/inode.c
--- linux-2.6.0-test9/fs/ramfs/inode.c 2003-10-25 14:43:21.000000000 -0400
+++ linux/fs/ramfs/inode.c 2003-11-29 00:13:33.000000000 -0500
@@ -204,22 +204,26 @@
return get_sb_nodev(fs_type, flags, data, ramfs_fill_super);
}
+#ifdef CONFIG_RAMFS_ROOTFS
static struct super_block *rootfs_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data)
{
return get_sb_nodev(fs_type, flags|MS_NOUSER, data, ramfs_fill_super);
}
+#endif
static struct file_system_type ramfs_fs_type = {
.name = "ramfs",
.get_sb = ramfs_get_sb,
.kill_sb = kill_litter_super,
};
+#ifdef CONFIG_RAMFS_ROOTFS
static struct file_system_type rootfs_fs_type = {
.name = "rootfs",
.get_sb = rootfs_get_sb,
.kill_sb = kill_litter_super,
};
+#endif
static int __init init_ramfs_fs(void)
{
@@ -234,9 +238,11 @@
module_init(init_ramfs_fs)
module_exit(exit_ramfs_fs)
+#ifdef CONFIG_RAMFS_ROOTFS
int __init init_rootfs(void)
{
return register_filesystem(&rootfs_fs_type);
}
+#endif
MODULE_LICENSE("GPL");
diff -urNX dontdiff linux-2.6.0-test9/mm/shmem.c linux/mm/shmem.c
--- linux-2.6.0-test9/mm/shmem.c 2003-10-25 14:43:30.000000000 -0400
+++ linux/mm/shmem.c 2003-11-29 14:24:37.000000000 -0500
@@ -1773,7 +1773,7 @@
sb->s_fs_info = NULL;
}
-static kmem_cache_t *shmem_inode_cachep;
+static kmem_cache_t *shmem_inode_cachep = NULL;
static struct inode *shmem_alloc_inode(struct super_block *sb)
{
@@ -1801,12 +1801,14 @@
static int init_inodecache(void)
{
- shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
- sizeof(struct shmem_inode_info),
- 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
- init_once, NULL);
- if (shmem_inode_cachep == NULL)
- return -ENOMEM;
+ if (!shmem_inode_cachep) {
+ shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
+ sizeof(struct shmem_inode_info),
+ 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
+ init_once, NULL);
+ if (shmem_inode_cachep == NULL)
+ return -ENOMEM;
+ }
return 0;
}
@@ -2008,3 +2010,24 @@
}
EXPORT_SYMBOL(shmem_file_setup);
+
+#ifdef CONFIG_SHM_ROOTFS
+static struct super_block *rootfs_get_sb(struct file_system_type *fs_type,
+ int flags, const char *dev_name, void *data)
+{
+ return get_sb_single(fs_type, flags, data, shmem_fill_super);
+}
+
+static struct file_system_type rootfs_fs_type = {
+ .name = "rootfs",
+ .get_sb = rootfs_get_sb,
+ .kill_sb = kill_litter_super,
+};
+
+int __init init_rootfs(void)
+{
+ if (init_inodecache())
+ panic("Can't initialize shm inode cache");
+ return register_filesystem(&rootfs_fs_type);
+}
+#endif
John
next prev parent reply other threads:[~2003-11-29 20:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-29 5:24 Rootfs mounted from user space - problem with umount John Zielinski
2003-11-29 5:31 ` William Lee Irwin III
2003-11-29 6:14 ` John Zielinski
2003-11-29 6:21 ` William Lee Irwin III
2003-11-29 9:40 ` John Zielinski
2003-11-29 9:44 ` William Lee Irwin III
2003-11-29 20:02 ` John Zielinski [this message]
2003-11-29 20:20 ` John Zielinski
2003-11-29 20:25 ` William Lee Irwin III
2003-11-29 21:05 ` John Zielinski
2003-11-29 21:17 ` Sean Neakums
2003-11-29 21:42 ` John Zielinski
2003-11-30 0:38 ` [OT] " Sean Neakums
2003-11-29 5:38 ` Valdis.Kletnieks
2003-11-29 6:25 ` John Zielinski
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=3FC8FB58.6080708@undead.cc \
--to=grim@undead.cc \
--cc=linux-kernel@vger.kernel.org \
--cc=wli@holomorphy.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;
as well as URLs for NNTP newsgroup(s).