diff -uNr 17-rc1-removepage/mm/shmem.c c/mm/shmem.c --- 17-rc1-removepage/mm/shmem.c Sun Dec 16 11:31:21 2001 +++ c/mm/shmem.c Sun Dec 16 15:04:34 2001 @@ -36,15 +36,28 @@ #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long)) #define SHMEM_SB(sb) (&sb->u.shmem_sb) +#define SHMEM_NOSWAP(info) ((info)->locked == 2) static struct super_operations shmem_ops; static struct address_space_operations shmem_aops; +static struct address_space_operations shmem_noswap_aops; static struct file_operations shmem_file_operations; static struct inode_operations shmem_inode_operations; static struct file_operations shmem_dir_operations; static struct inode_operations shmem_dir_inode_operations; static struct vm_operations_struct shmem_vm_ops; +static struct super_block *shmem_read_super(struct super_block * sb, void * data, int silent); + +#ifdef CONFIG_TMPFS +/* type "shm" will be tagged obsolete in 2.5 */ +static DECLARE_FSTYPE(shmem_fs_type, "shm", shmem_read_super, FS_LITTER); +static DECLARE_FSTYPE(tmpfs_fs_type, "tmpfs", shmem_read_super, FS_LITTER); +static DECLARE_FSTYPE(ramfs2_fs_type, "ramfs2", shmem_read_super, FS_LITTER); +#else +static DECLARE_FSTYPE(tmpfs_fs_type, "tmpfs", shmem_read_super, FS_LITTER|FS_NOMOUNT); +#endif + LIST_HEAD (shmem_inodes); static spinlock_t shmem_ilock = SPIN_LOCK_UNLOCKED; atomic_t shmem_nrpages = ATOMIC_INIT(0); @@ -299,8 +312,11 @@ struct shmem_inode_info * info = SHMEM_I(inode); struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); - down(&info->sem); inode->i_ctime = inode->i_mtime = CURRENT_TIME; + if (SHMEM_NOSWAP(info)) + return; + + down(&info->sem); spin_lock (&info->lock); index = (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; @@ -352,6 +368,9 @@ unsigned long idx; int offset; + if (SHMEM_NOSWAP(info)) + return 0; + idx = 0; spin_lock (&info->lock); offset = shmem_clear_swp (entry, info->i_direct, SHMEM_NR_DIRECT); @@ -484,6 +503,9 @@ if (page) return page; + if (SHMEM_NOSWAP(info)) + goto noswap_alloc; + entry = shmem_alloc_entry (info, idx); if (IS_ERR(entry)) return (void *)entry; @@ -543,6 +565,7 @@ info->swapped--; spin_unlock (&info->lock); } else { + noswap_alloc: sbinfo = SHMEM_SB(inode->i_sb); spin_unlock (&info->lock); spin_lock (&sbinfo->stat_lock); @@ -628,8 +651,11 @@ struct inode * inode = file->f_dentry->d_inode; struct shmem_inode_info * info = SHMEM_I(inode); + if (SHMEM_NOSWAP(info)) + return; + down(&info->sem); - info->locked = lock; + info->locked = (lock != 0); up(&info->sem); } @@ -668,12 +694,19 @@ inode->i_blksize = PAGE_CACHE_SIZE; inode->i_blocks = 0; inode->i_rdev = NODEV; - inode->i_mapping->a_ops = &shmem_aops; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; info = SHMEM_I(inode); info->inode = inode; spin_lock_init (&info->lock); sema_init (&info->sem, 1); + + if (sb->s_type == &ramfs2_fs_type) { + info->locked = 2; + inode->i_mapping->a_ops = &shmem_noswap_aops; + } else { + inode->i_mapping->a_ops = &shmem_aops; + } + switch (mode & S_IFMT) { default: init_special_inode(inode, mode, dev); @@ -1310,6 +1343,11 @@ +static struct address_space_operations shmem_noswap_aops = { + removepage: shmem_removepage, + writepage: fail_writepage, +}; + static struct address_space_operations shmem_aops = { removepage: shmem_removepage, writepage: shmem_writepage, @@ -1363,13 +1401,6 @@ nopage: shmem_nopage, }; -#ifdef CONFIG_TMPFS -/* type "shm" will be tagged obsolete in 2.5 */ -static DECLARE_FSTYPE(shmem_fs_type, "shm", shmem_read_super, FS_LITTER); -static DECLARE_FSTYPE(tmpfs_fs_type, "tmpfs", shmem_read_super, FS_LITTER); -#else -static DECLARE_FSTYPE(tmpfs_fs_type, "tmpfs", shmem_read_super, FS_LITTER|FS_NOMOUNT); -#endif static struct vfsmount *shm_mnt; static int __init init_shmem_fs(void) @@ -1382,6 +1413,11 @@ return error; } #ifdef CONFIG_TMPFS + if ((error = register_filesystem(&ramfs2_fs_type))) { + printk (KERN_ERR "Could not register ramfs2\n"); + return error; + } + if ((error = register_filesystem(&shmem_fs_type))) { printk (KERN_ERR "Could not register shm fs\n"); return error; @@ -1407,6 +1443,7 @@ { #ifdef CONFIG_TMPFS unregister_filesystem(&shmem_fs_type); + unregister_filesystem(&ramfs2_fs_type); #endif unregister_filesystem(&tmpfs_fs_type); mntput(shm_mnt);