History

tmpfs: miscellaneous trivial cleanups

While it's at its least, make a number of boring nitpicky cleanups to shmem.c, mostly for consistency of variable naming. Things like "swap" instead of "entry", "pgoff_t index" instead of "unsigned long idx". And since everything else here is prefixed "shmem_", better change init_tmpfs() to shmem_init().

Hugh Dickins committed 15 years ago

Commit 41ffe5d1 parent 285b2c43 files · +109 −111Browse files

Unified · Split

3 files
  1. include/linux/shmem_fs.h +1 −1
  2. init/main.c +1 −1
  3. mm/shmem.c +107 −109
include/linux/shmem_fs.h+1−1
@@ -47,7 +47,7 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode) · 46 unmodified lines
4747 /*
4848 * Functions in mm/shmem.c called directly from elsewhere:
4949 */
50−extern int init_tmpfs(void);
50+extern int shmem_init(void);
5151 extern int shmem_fill_super(struct super_block *sb, void *data, int silent);
5252 extern struct file *shmem_file_setup(const char *name,
5353 loff_t size, unsigned long flags);
init/main.c+1−1
@@ -715,7 +715,7 @@ static void __init do_basic_setup(void) · 714 unmodified lines
715715 {
716716 cpuset_init_smp();
717717 usermodehelper_init();
718− init_tmpfs();
718+ shmem_init();
719719 driver_init();
720720 init_irq_proc();
721721 do_ctors();
mm/shmem.c+107−109
@@ -28,7 +28,6 @@ · 27 unmodified lines
2828 #include <linux/file.h>
2929 #include <linux/mm.h>
3030 #include <linux/module.h>
31−#include <linux/percpu_counter.h>
3231 #include <linux/swap.h>
3332
3433 static struct vfsmount *shm_mnt;
@@ -51,6 +50,7 @@ static struct vfsmount *shm_mnt; · 16 unmodified lines
5150 #include <linux/shmem_fs.h>
5251 #include <linux/writeback.h>
5352 #include <linux/blkdev.h>
53+#include <linux/percpu_counter.h>
5454 #include <linux/splice.h>
5555 #include <linux/security.h>
5656 #include <linux/swapops.h>
@@ -63,7 +63,6 @@ static struct vfsmount *shm_mnt; · 6 unmodified lines
6363 #include <linux/magic.h>
6464
6565 #include <asm/uaccess.h>
66−#include <asm/div64.h>
6766 #include <asm/pgtable.h>
6867
6968 #define BLOCKS_PER_PAGE (PAGE_CACHE_SIZE/512)
@@ -201,7 +200,7 @@ static void shmem_free_inode(struct super_block *sb) · 131 unmodified lines
201200 }
202201
203202 /**
204− * shmem_recalc_inode - recalculate the size of an inode
203+ * shmem_recalc_inode - recalculate the block usage of an inode
205204 * @inode: inode to recalc
206205 *
207206 * We have to calculate the free blocks since the mm can drop
@@ -356,19 +355,20 @@ static void shmem_evict_inode(struct inode *inode) · 148 unmodified lines
356355 end_writeback(inode);
357356 }
358357
359−static int shmem_unuse_inode(struct shmem_inode_info *info, swp_entry_t entry, struct page *page)
358+static int shmem_unuse_inode(struct shmem_inode_info *info,
359+ swp_entry_t swap, struct page *page)
360360 {
361361 struct address_space *mapping = info->vfs_inode.i_mapping;
362− unsigned long idx;
362+ pgoff_t index;
363363 int error;
364364
365− for (idx = 0; idx < SHMEM_NR_DIRECT; idx++)
366− if (shmem_get_swap(info, idx).val == entry.val)
365+ for (index = 0; index < SHMEM_NR_DIRECT; index++)
366+ if (shmem_get_swap(info, index).val == swap.val)
367367 goto found;
368368 return 0;
369369 found:
370370 spin_lock(&info->lock);
371− if (shmem_get_swap(info, idx).val != entry.val) {
371+ if (shmem_get_swap(info, index).val != swap.val) {
372372 spin_unlock(&info->lock);
373373 return 0;
374374 }
@@ -387,15 +387,15 @@ found: · 12 unmodified lines
387387 * but also to hold up shmem_evict_inode(): so inode cannot be freed
388388 * beneath us (pagelock doesn't help until the page is in pagecache).
389389 */
390− error = add_to_page_cache_locked(page, mapping, idx, GFP_NOWAIT);
390+ error = add_to_page_cache_locked(page, mapping, index, GFP_NOWAIT);
391391 /* which does mem_cgroup_uncharge_cache_page on error */
392392
393393 if (error != -ENOMEM) {
394394 delete_from_swap_cache(page);
395395 set_page_dirty(page);
396− shmem_put_swap(info, idx, (swp_entry_t){0});
396+ shmem_put_swap(info, index, (swp_entry_t){0});
397397 info->swapped--;
398− swap_free(entry);
398+ swap_free(swap);
399399 error = 1; /* not an error, but entry was found */
400400 }
401401 spin_unlock(&info->lock);
@@ -405,9 +405,9 @@ found: · 3 unmodified lines
405405 /*
406406 * shmem_unuse() search for an eventually swapped out shmem page.
407407 */
408−int shmem_unuse(swp_entry_t entry, struct page *page)
408+int shmem_unuse(swp_entry_t swap, struct page *page)
409409 {
410− struct list_head *p, *next;
410+ struct list_head *this, *next;
411411 struct shmem_inode_info *info;
412412 int found = 0;
413413 int error;
@@ -432,8 +432,8 @@ int shmem_unuse(swp_entry_t entry, struct page *page) · 18 unmodified lines
432432 radix_tree_preload_end();
433433
434434 mutex_lock(&shmem_swaplist_mutex);
435− list_for_each_safe(p, next, &shmem_swaplist) {
436− info = list_entry(p, struct shmem_inode_info, swaplist);
435+ list_for_each_safe(this, next, &shmem_swaplist) {
436+ info = list_entry(this, struct shmem_inode_info, swaplist);
437437 if (!info->swapped) {
438438 spin_lock(&info->lock);
439439 if (!info->swapped)
@@ -441,7 +441,7 @@ int shmem_unuse(swp_entry_t entry, struct page *page) · 1 unmodified line
441441 spin_unlock(&info->lock);
442442 }
443443 if (info->swapped)
444− found = shmem_unuse_inode(info, entry, page);
444+ found = shmem_unuse_inode(info, swap, page);
445445 cond_resched();
446446 if (found)
447447 break;
@@ -467,7 +467,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) · 19 unmodified lines
467467 struct shmem_inode_info *info;
468468 swp_entry_t swap, oswap;
469469 struct address_space *mapping;
470− unsigned long index;
470+ pgoff_t index;
471471 struct inode *inode;
472472
473473 BUG_ON(!PageLocked(page));
@@ -577,35 +577,33 @@ static struct mempolicy *shmem_get_sbmpol(struct shmem_sb_info *sbinfo) · 103 unmodified lines
577577 }
578578 #endif /* CONFIG_TMPFS */
579579
580−static struct page *shmem_swapin(swp_entry_t entry, gfp_t gfp,
581− struct shmem_inode_info *info, unsigned long idx)
580+static struct page *shmem_swapin(swp_entry_t swap, gfp_t gfp,
581+ struct shmem_inode_info *info, pgoff_t index)
582582 {
583583 struct mempolicy mpol, *spol;
584584 struct vm_area_struct pvma;
585− struct page *page;
586585
587586 spol = mpol_cond_copy(&mpol,
588− mpol_shared_policy_lookup(&info->policy, idx));
587+ mpol_shared_policy_lookup(&info->policy, index));
589588
590589 /* Create a pseudo vma that just contains the policy */
591590 pvma.vm_start = 0;
592− pvma.vm_pgoff = idx;
591+ pvma.vm_pgoff = index;
593592 pvma.vm_ops = NULL;
594593 pvma.vm_policy = spol;
595− page = swapin_readahead(entry, gfp, &pvma, 0);
596− return page;
594+ return swapin_readahead(swap, gfp, &pvma, 0);
597595 }
598596
599597 static struct page *shmem_alloc_page(gfp_t gfp,
600− struct shmem_inode_info *info, unsigned long idx)
598+ struct shmem_inode_info *info, pgoff_t index)
601599 {
602600 struct vm_area_struct pvma;
603601
604602 /* Create a pseudo vma that just contains the policy */
605603 pvma.vm_start = 0;
606− pvma.vm_pgoff = idx;
604+ pvma.vm_pgoff = index;
607605 pvma.vm_ops = NULL;
608− pvma.vm_policy = mpol_shared_policy_lookup(&info->policy, idx);
606+ pvma.vm_policy = mpol_shared_policy_lookup(&info->policy, index);
609607
610608 /*
611609 * alloc_page_vma() will drop the shared policy reference
@@ -614,19 +612,19 @@ static struct page *shmem_alloc_page(gfp_t gfp, · 2 unmodified lines
614612 }
615613 #else /* !CONFIG_NUMA */
616614 #ifdef CONFIG_TMPFS
617−static inline void shmem_show_mpol(struct seq_file *seq, struct mempolicy *p)
615+static inline void shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)
618616 {
619617 }
620618 #endif /* CONFIG_TMPFS */
621619
622−static inline struct page *shmem_swapin(swp_entry_t entry, gfp_t gfp,
623− struct shmem_inode_info *info, unsigned long idx)
620+static inline struct page *shmem_swapin(swp_entry_t swap, gfp_t gfp,
621+ struct shmem_inode_info *info, pgoff_t index)
624622 {
625− return swapin_readahead(entry, gfp, NULL, 0);
623+ return swapin_readahead(swap, gfp, NULL, 0);
626624 }
627625
628626 static inline struct page *shmem_alloc_page(gfp_t gfp,
629− struct shmem_inode_info *info, unsigned long idx)
627+ struct shmem_inode_info *info, pgoff_t index)
630628 {
631629 return alloc_page(gfp);
632630 }
@@ -646,7 +644,7 @@ static inline struct mempolicy *shmem_get_sbmpol(struct shmem_sb_info *sbinfo) · 13 unmodified lines
646644 * vm. If we swap it in we mark it dirty since we also free the swap
647645 * entry since a page cannot live in both the swap and page cache
648646 */
649−static int shmem_getpage_gfp(struct inode *inode, pgoff_t idx,
647+static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
650648 struct page **pagep, enum sgp_type sgp, gfp_t gfp, int *fault_type)
651649 {
652650 struct address_space *mapping = inode->i_mapping;
@@ -657,10 +655,10 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t idx, · 4 unmodified lines
657655 swp_entry_t swap;
658656 int error;
659657
660− if (idx > (MAX_LFS_FILESIZE >> PAGE_CACHE_SHIFT))
658+ if (index > (MAX_LFS_FILESIZE >> PAGE_CACHE_SHIFT))
661659 return -EFBIG;
662660 repeat:
663− page = find_lock_page(mapping, idx);
661+ page = find_lock_page(mapping, index);
664662 if (page) {
665663 /*
666664 * Once we can get the page lock, it must be uptodate:
@@ -681,7 +679,7 @@ repeat: · 14 unmodified lines
681679 radix_tree_preload_end();
682680
683681 if (sgp != SGP_READ && !prealloc_page) {
684− prealloc_page = shmem_alloc_page(gfp, info, idx);
682+ prealloc_page = shmem_alloc_page(gfp, info, index);
685683 if (prealloc_page) {
686684 SetPageSwapBacked(prealloc_page);
687685 if (mem_cgroup_cache_charge(prealloc_page,
@@ -694,7 +692,7 @@ repeat: · 6 unmodified lines
694692
695693 spin_lock(&info->lock);
696694 shmem_recalc_inode(inode);
697− swap = shmem_get_swap(info, idx);
695+ swap = shmem_get_swap(info, index);
698696 if (swap.val) {
699697 /* Look it up and read it in.. */
700698 page = lookup_swap_cache(swap);
@@ -703,9 +701,9 @@ repeat: · 2 unmodified lines
703701 /* here we actually do the io */
704702 if (fault_type)
705703 *fault_type |= VM_FAULT_MAJOR;
706− page = shmem_swapin(swap, gfp, info, idx);
704+ page = shmem_swapin(swap, gfp, info, index);
707705 if (!page) {
708− swp_entry_t nswap = shmem_get_swap(info, idx);
706+ swp_entry_t nswap = shmem_get_swap(info, index);
709707 if (nswap.val == swap.val) {
710708 error = -ENOMEM;
711709 goto out;
@@ -740,7 +738,7 @@ repeat: · 28 unmodified lines
740738 }
741739
742740 error = add_to_page_cache_locked(page, mapping,
743− idx, GFP_NOWAIT);
741+ index, GFP_NOWAIT);
744742 if (error) {
745743 spin_unlock(&info->lock);
746744 if (error == -ENOMEM) {
@@ -762,14 +760,14 @@ repeat: · 15 unmodified lines
762760 }
763761
764762 delete_from_swap_cache(page);
765− shmem_put_swap(info, idx, (swp_entry_t){0});
763+ shmem_put_swap(info, index, (swp_entry_t){0});
766764 info->swapped--;
767765 spin_unlock(&info->lock);
768766 set_page_dirty(page);
769767 swap_free(swap);
770768
771769 } else if (sgp == SGP_READ) {
772− page = find_get_page(mapping, idx);
770+ page = find_get_page(mapping, index);
773771 if (page && !trylock_page(page)) {
774772 spin_unlock(&info->lock);
775773 wait_on_page_locked(page);
@@ -793,12 +791,12 @@ repeat: · 17 unmodified lines
793791 page = prealloc_page;
794792 prealloc_page = NULL;
795793
796− swap = shmem_get_swap(info, idx);
794+ swap = shmem_get_swap(info, index);
797795 if (swap.val)
798796 mem_cgroup_uncharge_cache_page(page);
799797 else
800798 error = add_to_page_cache_lru(page, mapping,
801− idx, GFP_NOWAIT);
799+ index, GFP_NOWAIT);
802800 /*
803801 * At add_to_page_cache_lru() failure,
804802 * uncharge will be done automatically.
@@ -841,7 +839,7 @@ nospace: · 36 unmodified lines
841839 * but must also avoid reporting a spurious ENOSPC while working on a
842840 * full tmpfs.
843841 */
844− page = find_get_page(mapping, idx);
842+ page = find_get_page(mapping, index);
845843 spin_unlock(&info->lock);
846844 if (page) {
847845 page_cache_release(page);
@@ -872,20 +870,20 @@ static int shmem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) · 24 unmodified lines
872870 }
873871
874872 #ifdef CONFIG_NUMA
875−static int shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *new)
873+static int shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *mpol)
876874 {
877− struct inode *i = vma->vm_file->f_path.dentry->d_inode;
878− return mpol_set_shared_policy(&SHMEM_I(i)->policy, vma, new);
875+ struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
876+ return mpol_set_shared_policy(&SHMEM_I(inode)->policy, vma, mpol);
879877 }
880878
881879 static struct mempolicy *shmem_get_policy(struct vm_area_struct *vma,
882880 unsigned long addr)
883881 {
884− struct inode *i = vma->vm_file->f_path.dentry->d_inode;
885− unsigned long idx;
882+ struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
883+ pgoff_t index;
886884
887− idx = ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
888− return mpol_shared_policy_lookup(&SHMEM_I(i)->policy, idx);
885+ index = ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
886+ return mpol_shared_policy_lookup(&SHMEM_I(inode)->policy, index);
889887 }
890888 #endif
891889
@@ -1016,7 +1014,8 @@ static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_ · 124 unmodified lines
10161014 {
10171015 struct inode *inode = filp->f_path.dentry->d_inode;
10181016 struct address_space *mapping = inode->i_mapping;
1019− unsigned long index, offset;
1017+ pgoff_t index;
1018+ unsigned long offset;
10201019 enum sgp_type sgp = SGP_READ;
10211020
10221021 /*
@@ -1032,7 +1031,8 @@ static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_ · 9 unmodified lines
10321031
10331032 for (;;) {
10341033 struct page *page = NULL;
1035− unsigned long end_index, nr, ret;
1034+ pgoff_t end_index;
1035+ unsigned long nr, ret;
10361036 loff_t i_size = i_size_read(inode);
10371037
10381038 end_index = i_size >> PAGE_CACHE_SHIFT;
@@ -1270,8 +1270,9 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf) · 231 unmodified lines
12701270 buf->f_namelen = NAME_MAX;
12711271 if (sbinfo->max_blocks) {
12721272 buf->f_blocks = sbinfo->max_blocks;
1273− buf->f_bavail = buf->f_bfree =
1274− sbinfo->max_blocks - percpu_counter_sum(&sbinfo->used_blocks);
1273+ buf->f_bavail =
1274+ buf->f_bfree = sbinfo->max_blocks -
1275+ percpu_counter_sum(&sbinfo->used_blocks);
12751276 }
12761277 if (sbinfo->max_inodes) {
12771278 buf->f_files = sbinfo->max_inodes;
@@ -1480,8 +1481,8 @@ static void *shmem_follow_link_inline(struct dentry *dentry, struct nameidata *n · 202 unmodified lines
14801481 static void *shmem_follow_link(struct dentry *dentry, struct nameidata *nd)
14811482 {
14821483 struct page *page = NULL;
1483− int res = shmem_getpage(dentry->d_inode, 0, &page, SGP_READ, NULL);
1484− nd_set_link(nd, res ? ERR_PTR(res) : kmap(page));
1484+ int error = shmem_getpage(dentry->d_inode, 0, &page, SGP_READ, NULL);
1485+ nd_set_link(nd, error ? ERR_PTR(error) : kmap(page));
14851486 if (page)
14861487 unlock_page(page);
14871488 return page;
@@ -1592,7 +1593,6 @@ out: · 104 unmodified lines
15921593 return err;
15931594 }
15941595
1595−
15961596 static const struct xattr_handler *shmem_xattr_handlers[] = {
15971597 #ifdef CONFIG_TMPFS_POSIX_ACL
15981598 &generic_acl_access_handler,
@@ -2052,14 +2052,14 @@ static struct kmem_cache *shmem_inode_cachep; · 453 unmodified lines
20522052
20532053 static struct inode *shmem_alloc_inode(struct super_block *sb)
20542054 {
2055− struct shmem_inode_info *p;
2056− p = (struct shmem_inode_info *)kmem_cache_alloc(shmem_inode_cachep, GFP_KERNEL);
2057− if (!p)
2055+ struct shmem_inode_info *info;
2056+ info = kmem_cache_alloc(shmem_inode_cachep, GFP_KERNEL);
2057+ if (!info)
20582058 return NULL;
2059− return &p->vfs_inode;
2059+ return &info->vfs_inode;
20602060 }
20612061
2062−static void shmem_i_callback(struct rcu_head *head)
2062+static void shmem_destroy_callback(struct rcu_head *head)
20632063 {
20642064 struct inode *inode = container_of(head, struct inode, i_rcu);
20652065 INIT_LIST_HEAD(&inode->i_dentry);
@@ -2072,25 +2072,24 @@ static void shmem_destroy_inode(struct inode *inode) · 6 unmodified lines
20722072 /* only struct inode is valid if it's an inline symlink */
20732073 mpol_free_shared_policy(&SHMEM_I(inode)->policy);
20742074 }
2075− call_rcu(&inode->i_rcu, shmem_i_callback);
2075+ call_rcu(&inode->i_rcu, shmem_destroy_callback);
20762076 }
20772077
2078−static void init_once(void *foo)
2078+static void shmem_init_inode(void *foo)
20792079 {
2080− struct shmem_inode_info *p = (struct shmem_inode_info *) foo;
2081−
2082− inode_init_once(&p->vfs_inode);
2080+ struct shmem_inode_info *info = foo;
2081+ inode_init_once(&info->vfs_inode);
20832082 }
20842083
2085−static int init_inodecache(void)
2084+static int shmem_init_inodecache(void)
20862085 {
20872086 shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
20882087 sizeof(struct shmem_inode_info),
2089− 0, SLAB_PANIC, init_once);
2088+ 0, SLAB_PANIC, shmem_init_inode);
20902089 return 0;
20912090 }
20922091
2093−static void destroy_inodecache(void)
2092+static void shmem_destroy_inodecache(void)
20942093 {
20952094 kmem_cache_destroy(shmem_inode_cachep);
20962095 }
@@ -2187,21 +2186,20 @@ static const struct vm_operations_struct shmem_vm_ops = { · 90 unmodified lines
21872186 #endif
21882187 };
21892188
2190−
21912189 static struct dentry *shmem_mount(struct file_system_type *fs_type,
21922190 int flags, const char *dev_name, void *data)
21932191 {
21942192 return mount_nodev(fs_type, flags, data, shmem_fill_super);
21952193 }
21962194
2197−static struct file_system_type tmpfs_fs_type = {
2195+static struct file_system_type shmem_fs_type = {
21982196 .owner = THIS_MODULE,
21992197 .name = "tmpfs",
22002198 .mount = shmem_mount,
22012199 .kill_sb = kill_litter_super,
22022200 };
22032201
2204−int __init init_tmpfs(void)
2202+int __init shmem_init(void)
22052203 {
22062204 int error;
22072205
@@ -2209,18 +2207,18 @@ int __init init_tmpfs(void) · 1 unmodified line
22092207 if (error)
22102208 goto out4;
22112209
2212− error = init_inodecache();
2210+ error = shmem_init_inodecache();
22132211 if (error)
22142212 goto out3;
22152213
2216− error = register_filesystem(&tmpfs_fs_type);
2214+ error = register_filesystem(&shmem_fs_type);
22172215 if (error) {
22182216 printk(KERN_ERR "Could not register tmpfs\n");
22192217 goto out2;
22202218 }
22212219
2222− shm_mnt = vfs_kern_mount(&tmpfs_fs_type, MS_NOUSER,
2223− tmpfs_fs_type.name, NULL);
2220+ shm_mnt = vfs_kern_mount(&shmem_fs_type, MS_NOUSER,
2221+ shmem_fs_type.name, NULL);
22242222 if (IS_ERR(shm_mnt)) {
22252223 error = PTR_ERR(shm_mnt);
22262224 printk(KERN_ERR "Could not kern_mount tmpfs\n");
@@ -2229,9 +2227,9 @@ int __init init_tmpfs(void) · 2 unmodified lines
22292227 return 0;
22302228
22312229 out1:
2232− unregister_filesystem(&tmpfs_fs_type);
2230+ unregister_filesystem(&shmem_fs_type);
22332231 out2:
2234− destroy_inodecache();
2232+ shmem_destroy_inodecache();
22352233 out3:
22362234 bdi_destroy(&shmem_backing_dev_info);
22372235 out4:
@@ -2241,37 +2239,37 @@ out4: · 3 unmodified lines
22412239
22422240 #ifdef CONFIG_CGROUP_MEM_RES_CTLR
22432241 /**
2244− * mem_cgroup_get_shmem_target - find a page or entry assigned to the shmem file
2242+ * mem_cgroup_get_shmem_target - find page or swap assigned to the shmem file
22452243 * @inode: the inode to be searched
2246− * @pgoff: the offset to be searched
2244+ * @index: the page offset to be searched
22472245 * @pagep: the pointer for the found page to be stored
2248− * @ent: the pointer for the found swap entry to be stored
2246+ * @swapp: the pointer for the found swap entry to be stored
22492247 *
22502248 * If a page is found, refcount of it is incremented. Callers should handle
22512249 * these refcount.
22522250 */
2253−void mem_cgroup_get_shmem_target(struct inode *inode, pgoff_t pgoff,
2254− struct page **pagep, swp_entry_t *ent)
2251+void mem_cgroup_get_shmem_target(struct inode *inode, pgoff_t index,
2252+ struct page **pagep, swp_entry_t *swapp)
22552253 {
2256− swp_entry_t entry = { .val = 0 };
2257− struct page *page = NULL;
22582254 struct shmem_inode_info *info = SHMEM_I(inode);
2255+ struct page *page = NULL;
2256+ swp_entry_t swap = {0};
22592257
2260− if ((pgoff << PAGE_CACHE_SHIFT) >= i_size_read(inode))
2258+ if ((index << PAGE_CACHE_SHIFT) >= i_size_read(inode))
22612259 goto out;
22622260
22632261 spin_lock(&info->lock);
22642262 #ifdef CONFIG_SWAP
2265− entry = shmem_get_swap(info, pgoff);
2266− if (entry.val)
2267− page = find_get_page(&swapper_space, entry.val);
2263+ swap = shmem_get_swap(info, index);
2264+ if (swap.val)
2265+ page = find_get_page(&swapper_space, swap.val);
22682266 else
22692267 #endif
2270− page = find_get_page(inode->i_mapping, pgoff);
2268+ page = find_get_page(inode->i_mapping, index);
22712269 spin_unlock(&info->lock);
22722270 out:
22732271 *pagep = page;
2274− *ent = entry;
2272+ *swapp = swap;
22752273 }
22762274 #endif
22772275
@@ -2288,23 +2286,23 @@ out: · 10 unmodified lines
22882286
22892287 #include <linux/ramfs.h>
22902288
2291−static struct file_system_type tmpfs_fs_type = {
2289+static struct file_system_type shmem_fs_type = {
22922290 .name = "tmpfs",
22932291 .mount = ramfs_mount,
22942292 .kill_sb = kill_litter_super,
22952293 };
22962294
2297−int __init init_tmpfs(void)
2295+int __init shmem_init(void)
22982296 {
2299− BUG_ON(register_filesystem(&tmpfs_fs_type) != 0);
2297+ BUG_ON(register_filesystem(&shmem_fs_type) != 0);
23002298
2301− shm_mnt = kern_mount(&tmpfs_fs_type);
2299+ shm_mnt = kern_mount(&shmem_fs_type);
23022300 BUG_ON(IS_ERR(shm_mnt));
23032301
23042302 return 0;
23052303 }
23062304
2307−int shmem_unuse(swp_entry_t entry, struct page *page)
2305+int shmem_unuse(swp_entry_t swap, struct page *page)
23082306 {
23092307 return 0;
23102308 }
@@ -2314,34 +2312,34 @@ int shmem_lock(struct file *file, int lock, struct user_struct *user) · 3 unmodified lines
23142312 return 0;
23152313 }
23162314
2317−void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
2315+void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
23182316 {
2319− truncate_inode_pages_range(inode->i_mapping, start, end);
2317+ truncate_inode_pages_range(inode->i_mapping, lstart, lend);
23202318 }
23212319 EXPORT_SYMBOL_GPL(shmem_truncate_range);
23222320
23232321 #ifdef CONFIG_CGROUP_MEM_RES_CTLR
23242322 /**
2325− * mem_cgroup_get_shmem_target - find a page or entry assigned to the shmem file
2323+ * mem_cgroup_get_shmem_target - find page or swap assigned to the shmem file
23262324 * @inode: the inode to be searched
2327− * @pgoff: the offset to be searched
2325+ * @index: the page offset to be searched
23282326 * @pagep: the pointer for the found page to be stored
2329− * @ent: the pointer for the found swap entry to be stored
2327+ * @swapp: the pointer for the found swap entry to be stored
23302328 *
23312329 * If a page is found, refcount of it is incremented. Callers should handle
23322330 * these refcount.
23332331 */
2334−void mem_cgroup_get_shmem_target(struct inode *inode, pgoff_t pgoff,
2335− struct page **pagep, swp_entry_t *ent)
2332+void mem_cgroup_get_shmem_target(struct inode *inode, pgoff_t index,
2333+ struct page **pagep, swp_entry_t *swapp)
23362334 {
23372335 struct page *page = NULL;
23382336
2339− if ((pgoff << PAGE_CACHE_SHIFT) >= i_size_read(inode))
2337+ if ((index << PAGE_CACHE_SHIFT) >= i_size_read(inode))
23402338 goto out;
2341− page = find_get_page(inode->i_mapping, pgoff);
2339+ page = find_get_page(inode->i_mapping, index);
23422340 out:
23432341 *pagep = page;
2344− *ent = (swp_entry_t){ .val = 0 };
2342+ *swapp = (swp_entry_t){0};
23452343 }
23462344 #endif
23472345