]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - mm/shmem.c
bootmem: print request details before BUG_ON(them)
[mv-sheeva.git] / mm / shmem.c
index 0ed075215e5f6e3e7905fdc4ac3f739062533b42..5941f980136367c8e0bc28c39b80f2acadee54c2 100644 (file)
  * Copyright (c) 2004, Luke Kenneth Casson Leighton <lkcl@lkcl.net>
  * Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
  *
+ * tiny-shmem:
+ * Copyright (c) 2004, 2008 Matt Mackall <mpm@selenic.com>
+ *
  * This file is released under the GPL.
  */
 
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/vfs.h>
+#include <linux/mount.h>
+#include <linux/file.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/swap.h>
+
+static struct vfsmount *shm_mnt;
+
+#ifdef CONFIG_SHMEM
 /*
  * This virtual memory filesystem is heavily based on the ramfs. It
  * extends ramfs by the ability to use swap and honor resource limits
  * which makes it a completely usable filesystem.
  */
 
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/fs.h>
 #include <linux/xattr.h>
 #include <linux/exportfs.h>
 #include <linux/generic_acl.h>
-#include <linux/mm.h>
 #include <linux/mman.h>
-#include <linux/file.h>
-#include <linux/swap.h>
 #include <linux/pagemap.h>
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/backing-dev.h>
 #include <linux/shmem_fs.h>
-#include <linux/mount.h>
 #include <linux/writeback.h>
 #include <linux/vfs.h>
 #include <linux/blkdev.h>
@@ -1444,7 +1452,6 @@ static int shmem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
        if (error)
                return ((error == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS);
 
-       mark_page_accessed(vmf->page);
        return ret | VM_FAULT_LOCKED;
 }
 
@@ -1513,8 +1520,8 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev)
        inode = new_inode(sb);
        if (inode) {
                inode->i_mode = mode;
-               inode->i_uid = current->fsuid;
-               inode->i_gid = current->fsgid;
+               inode->i_uid = current_fsuid();
+               inode->i_gid = current_fsgid();
                inode->i_blocks = 0;
                inode->i_mapping->backing_dev_info = &shmem_backing_dev_info;
                inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
@@ -2278,8 +2285,8 @@ static int shmem_fill_super(struct super_block *sb,
        sbinfo->max_blocks = 0;
        sbinfo->max_inodes = 0;
        sbinfo->mode = S_IRWXUGO | S_ISVTX;
-       sbinfo->uid = current->fsuid;
-       sbinfo->gid = current->fsgid;
+       sbinfo->uid = current_fsuid();
+       sbinfo->gid = current_fsgid();
        sbinfo->mpol = NULL;
        sb->s_fs_info = sbinfo;
 
@@ -2486,7 +2493,6 @@ static struct file_system_type tmpfs_fs_type = {
        .get_sb         = shmem_get_sb,
        .kill_sb        = kill_litter_super,
 };
-static struct vfsmount *shm_mnt;
 
 static int __init init_tmpfs(void)
 {
@@ -2525,7 +2531,51 @@ out4:
        shm_mnt = ERR_PTR(error);
        return error;
 }
-module_init(init_tmpfs)
+
+#else /* !CONFIG_SHMEM */
+
+/*
+ * tiny-shmem: simple shmemfs and tmpfs using ramfs code
+ *
+ * This is intended for small system where the benefits of the full
+ * shmem code (swap-backed and resource-limited) are outweighed by
+ * their complexity. On systems without swap this code should be
+ * effectively equivalent, but much lighter weight.
+ */
+
+#include <linux/ramfs.h>
+
+static struct file_system_type tmpfs_fs_type = {
+       .name           = "tmpfs",
+       .get_sb         = ramfs_get_sb,
+       .kill_sb        = kill_litter_super,
+};
+
+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;
+}
+
+int shmem_unuse(swp_entry_t entry, struct page *page)
+{
+       return 0;
+}
+
+#define shmem_file_operations ramfs_file_operations
+#define shmem_vm_ops generic_file_vm_ops
+#define shmem_get_inode ramfs_get_inode
+#define shmem_acct_size(a, b) 0
+#define shmem_unacct_size(a, b) do {} while (0)
+#define SHMEM_MAX_BYTES LLONG_MAX
+
+#endif /* CONFIG_SHMEM */
+
+/* common code */
 
 /**
  * shmem_file_setup - get an unlinked file living in tmpfs
@@ -2569,12 +2619,20 @@ struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags)
        if (!inode)
                goto close_file;
 
+#ifdef CONFIG_SHMEM
        SHMEM_I(inode)->flags = flags & VM_ACCOUNT;
+#endif
        d_instantiate(dentry, inode);
        inode->i_size = size;
        inode->i_nlink = 0;     /* It is unlinked */
        init_file(file, shm_mnt, dentry, FMODE_WRITE | FMODE_READ,
-                       &shmem_file_operations);
+                 &shmem_file_operations);
+
+#ifndef CONFIG_MMU
+       error = ramfs_nommu_expand_for_mapping(inode, size);
+       if (error)
+               goto close_file;
+#endif
        return file;
 
 close_file:
@@ -2606,3 +2664,5 @@ int shmem_zero_setup(struct vm_area_struct *vma)
        vma->vm_ops = &shmem_vm_ops;
        return 0;
 }
+
+module_init(init_tmpfs)