mm: tiny-shmem fix lock ordering: mmap_sem vs i_mutex
[linux-2.6.git] / mm / tiny-shmem.c
index c13a2161bca286fd65f75ee087c9990c22d8d744..d17cb6f6ab1029cdad5ef6a67523be159ff12211 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <linux/fs.h>
 #include <linux/init.h>
-#include <linux/devfs_fs_kernel.h>
 #include <linux/vfs.h>
 #include <linux/mount.h>
 #include <linux/file.h>
@@ -31,21 +30,20 @@ static struct vfsmount *shm_mnt;
 
 static int __init init_tmpfs(void)
 {
-       register_filesystem(&tmpfs_fs_type);
-#ifdef CONFIG_TMPFS
-       devfs_mk_dir("shm");
-#endif
+       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)
 
-/*
+/**
  * shmem_file_setup - get an unlinked file living in tmpfs
- *
  * @name: name for dentry (to be seen in /proc/<pid>/maps
  * @size: size to be set for the file
- *
+ * @flags: vm_flags
  */
 struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags)
 {
@@ -80,11 +78,8 @@ struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags)
        d_instantiate(dentry, inode);
        inode->i_size = size;
        inode->i_nlink = 0;     /* It is unlinked */
-       file->f_vfsmnt = mntget(shm_mnt);
-       file->f_dentry = dentry;
-       file->f_mapping = inode->i_mapping;
-       file->f_op = &ramfs_file_operations;
-       file->f_mode = FMODE_WRITE | FMODE_READ;
+       init_file(file, shm_mnt, dentry, FMODE_WRITE | FMODE_READ,
+                       &ramfs_file_operations);
        return file;
 
 close_file:
@@ -95,9 +90,8 @@ put_memory:
        return ERR_PTR(error);
 }
 
-/*
+/**
  * shmem_zero_setup - setup a shared anonymous mapping
- *
  * @vma: the vma to be mmapped is prepared by do_mmap_pgoff
  */
 int shmem_zero_setup(struct vm_area_struct *vma)
@@ -120,3 +114,14 @@ int shmem_unuse(swp_entry_t entry, struct page *page)
 {
        return 0;
 }
+
+#ifndef CONFIG_MMU
+unsigned long shmem_get_unmapped_area(struct file *file,
+                                     unsigned long addr,
+                                     unsigned long len,
+                                     unsigned long pgoff,
+                                     unsigned long flags)
+{
+       return ramfs_nommu_get_unmapped_area(file, addr, len, pgoff, flags);
+}
+#endif