From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 5/5] tiny-shmem: use call_once()
Date: Tue, 11 Mar 2008 00:05:37 +0900 [thread overview]
Message-ID: <20080310150531.GD6407@APFDCB5C> (raw)
In-Reply-To: <20080310150308.GC6407@APFDCB5C>
This patch defers mounting tmpfs till shmem_file_setup() is
called first time by using call_once().
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
mm/tiny-shmem.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
Index: 2.6-rc/mm/tiny-shmem.c
===================================================================
--- 2.6-rc.orig/mm/tiny-shmem.c
+++ 2.6-rc/mm/tiny-shmem.c
@@ -19,6 +19,7 @@
#include <linux/module.h>
#include <linux/swap.h>
#include <linux/ramfs.h>
+#include <linux/once.h>
static struct file_system_type tmpfs_fs_type = {
.name = "tmpfs",
@@ -26,19 +27,23 @@ static struct file_system_type tmpfs_fs_
.kill_sb = kill_litter_super,
};
-static struct vfsmount *shm_mnt;
-
static int __init init_tmpfs(void)
{
BUG_ON(register_filesystem(&tmpfs_fs_type) != 0);
- shm_mnt = kern_mount(&tmpfs_fs_type);
- BUG_ON(IS_ERR(shm_mnt));
-
return 0;
}
module_init(init_tmpfs)
+static struct vfsmount *shm_mnt;
+
+static int init_shm_mnt(void)
+{
+ shm_mnt = kern_mount(&tmpfs_fs_type);
+
+ return IS_ERR(shm_mnt) ? PTR_ERR(shm_mnt) : 0;
+}
+
/*
* shmem_file_setup - get an unlinked file living in tmpfs
*
@@ -53,9 +58,11 @@ struct file *shmem_file_setup(char *name
struct inode *inode;
struct dentry *dentry, *root;
struct qstr this;
+ static DEFINE_ONCE(once);
- if (IS_ERR(shm_mnt))
- return (void *)shm_mnt;
+ error = call_once(&once, init_shm_mnt);
+ if (error)
+ return ERR_PTR(error);
error = -ENOMEM;
this.name = name;
next prev parent reply other threads:[~2008-03-10 15:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080310145704.GA6396@APFDCB5C>
[not found] ` <20080310150026.GA6407@APFDCB5C>
2008-03-10 15:01 ` [PATCH 3/5] hugetlbfs: use call_once() Akinobu Mita
2008-03-10 15:03 ` [PATCH 4/5] shmem: " Akinobu Mita
2008-03-10 15:05 ` Akinobu Mita [this message]
2008-03-10 22:15 ` Hugh Dickins
2008-03-11 12:29 ` Akinobu Mita
2008-03-11 13:41 ` Hugh Dickins
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=20080310150531.GD6407@APFDCB5C \
--to=akinobu.mita@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).