| @@ -28,7 +28,6 @@ · 27 unmodified lines |
| 28 | 28 | #include <linux/file.h> |
| 29 | 29 | #include <linux/mm.h> |
| 30 | 30 | #include <linux/module.h> |
| 31 | | −#include <linux/percpu_counter.h> |
| 32 | 31 | #include <linux/swap.h> |
| 33 | 32 | |
| 34 | 33 | static struct vfsmount *shm_mnt; |
| @@ -51,6 +50,7 @@ static struct vfsmount *shm_mnt; · 16 unmodified lines |
| 51 | 50 | #include <linux/shmem_fs.h> |
| 52 | 51 | #include <linux/writeback.h> |
| 53 | 52 | #include <linux/blkdev.h> |
| 53 | +#include <linux/percpu_counter.h> |
| 54 | 54 | #include <linux/splice.h> |
| 55 | 55 | #include <linux/security.h> |
| 56 | 56 | #include <linux/swapops.h> |
| @@ -63,7 +63,6 @@ static struct vfsmount *shm_mnt; · 6 unmodified lines |
| 63 | 63 | #include <linux/magic.h> |
| 64 | 64 | |
| 65 | 65 | #include <asm/uaccess.h> |
| 66 | | −#include <asm/div64.h> |
| 67 | 66 | #include <asm/pgtable.h> |
| 68 | 67 | |
| 69 | 68 | #define BLOCKS_PER_PAGE (PAGE_CACHE_SIZE/512) |
| @@ -201,7 +200,7 @@ static void shmem_free_inode(struct super_block *sb) · 131 unmodified lines |
| 201 | 200 | } |
| 202 | 201 | |
| 203 | 202 | /** |
| 204 | | − * shmem_recalc_inode - recalculate the size of an inode |
| 203 | + * shmem_recalc_inode - recalculate the block usage of an inode |
| 205 | 204 | * @inode: inode to recalc |
| 206 | 205 | * |
| 207 | 206 | * 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 |
| 356 | 355 | end_writeback(inode); |
| 357 | 356 | } |
| 358 | 357 | |
| 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) |
| 360 | 360 | { |
| 361 | 361 | struct address_space *mapping = info->vfs_inode.i_mapping; |
| 362 | | − unsigned long idx; |
| 362 | + pgoff_t index; |
| 363 | 363 | int error; |
| 364 | 364 | |
| 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) |
| 367 | 367 | goto found; |
| 368 | 368 | return 0; |
| 369 | 369 | found: |
| 370 | 370 | spin_lock(&info->lock); |
| 371 | | − if (shmem_get_swap(info, idx).val != entry.val) { |
| 371 | + if (shmem_get_swap(info, index).val != swap.val) { |
| 372 | 372 | spin_unlock(&info->lock); |
| 373 | 373 | return 0; |
| 374 | 374 | } |
| @@ -387,15 +387,15 @@ found: · 12 unmodified lines |
| 387 | 387 | * but also to hold up shmem_evict_inode(): so inode cannot be freed |
| 388 | 388 | * beneath us (pagelock doesn't help until the page is in pagecache). |
| 389 | 389 | */ |
| 390 | | − error = add_to_page_cache_locked(page, mapping, idx, GFP_NOWAIT); |
| 390 | + error = add_to_page_cache_locked(page, mapping, index, GFP_NOWAIT); |
| 391 | 391 | /* which does mem_cgroup_uncharge_cache_page on error */ |
| 392 | 392 | |
| 393 | 393 | if (error != -ENOMEM) { |
| 394 | 394 | delete_from_swap_cache(page); |
| 395 | 395 | set_page_dirty(page); |
| 396 | | − shmem_put_swap(info, idx, (swp_entry_t){0}); |
| 396 | + shmem_put_swap(info, index, (swp_entry_t){0}); |
| 397 | 397 | info->swapped--; |
| 398 | | − swap_free(entry); |
| 398 | + swap_free(swap); |
| 399 | 399 | error = 1; /* not an error, but entry was found */ |
| 400 | 400 | } |
| 401 | 401 | spin_unlock(&info->lock); |
| @@ -405,9 +405,9 @@ found: · 3 unmodified lines |
| 405 | 405 | /* |
| 406 | 406 | * shmem_unuse() search for an eventually swapped out shmem page. |
| 407 | 407 | */ |
| 408 | | −int shmem_unuse(swp_entry_t entry, struct page *page) |
| 408 | +int shmem_unuse(swp_entry_t swap, struct page *page) |
| 409 | 409 | { |
| 410 | | − struct list_head *p, *next; |
| 410 | + struct list_head *this, *next; |
| 411 | 411 | struct shmem_inode_info *info; |
| 412 | 412 | int found = 0; |
| 413 | 413 | int error; |
| @@ -432,8 +432,8 @@ int shmem_unuse(swp_entry_t entry, struct page *page) · 18 unmodified lines |
| 432 | 432 | radix_tree_preload_end(); |
| 433 | 433 | |
| 434 | 434 | 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); |
| 437 | 437 | if (!info->swapped) { |
| 438 | 438 | spin_lock(&info->lock); |
| 439 | 439 | if (!info->swapped) |
| @@ -441,7 +441,7 @@ int shmem_unuse(swp_entry_t entry, struct page *page) · 1 unmodified line |
| 441 | 441 | spin_unlock(&info->lock); |
| 442 | 442 | } |
| 443 | 443 | if (info->swapped) |
| 444 | | − found = shmem_unuse_inode(info, entry, page); |
| 444 | + found = shmem_unuse_inode(info, swap, page); |
| 445 | 445 | cond_resched(); |
| 446 | 446 | if (found) |
| 447 | 447 | break; |
| @@ -467,7 +467,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) · 19 unmodified lines |
| 467 | 467 | struct shmem_inode_info *info; |
| 468 | 468 | swp_entry_t swap, oswap; |
| 469 | 469 | struct address_space *mapping; |
| 470 | | − unsigned long index; |
| 470 | + pgoff_t index; |
| 471 | 471 | struct inode *inode; |
| 472 | 472 | |
| 473 | 473 | BUG_ON(!PageLocked(page)); |
| @@ -577,35 +577,33 @@ static struct mempolicy *shmem_get_sbmpol(struct shmem_sb_info *sbinfo) · 103 unmodified lines |
| 577 | 577 | } |
| 578 | 578 | #endif /* CONFIG_TMPFS */ |
| 579 | 579 | |
| 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) |
| 582 | 582 | { |
| 583 | 583 | struct mempolicy mpol, *spol; |
| 584 | 584 | struct vm_area_struct pvma; |
| 585 | | − struct page *page; |
| 586 | 585 | |
| 587 | 586 | spol = mpol_cond_copy(&mpol, |
| 588 | | − mpol_shared_policy_lookup(&info->policy, idx)); |
| 587 | + mpol_shared_policy_lookup(&info->policy, index)); |
| 589 | 588 | |
| 590 | 589 | /* Create a pseudo vma that just contains the policy */ |
| 591 | 590 | pvma.vm_start = 0; |
| 592 | | − pvma.vm_pgoff = idx; |
| 591 | + pvma.vm_pgoff = index; |
| 593 | 592 | pvma.vm_ops = NULL; |
| 594 | 593 | pvma.vm_policy = spol; |
| 595 | | − page = swapin_readahead(entry, gfp, &pvma, 0); |
| 596 | | − return page; |
| 594 | + return swapin_readahead(swap, gfp, &pvma, 0); |
| 597 | 595 | } |
| 598 | 596 | |
| 599 | 597 | 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) |
| 601 | 599 | { |
| 602 | 600 | struct vm_area_struct pvma; |
| 603 | 601 | |
| 604 | 602 | /* Create a pseudo vma that just contains the policy */ |
| 605 | 603 | pvma.vm_start = 0; |
| 606 | | − pvma.vm_pgoff = idx; |
| 604 | + pvma.vm_pgoff = index; |
| 607 | 605 | 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); |
| 609 | 607 | |
| 610 | 608 | /* |
| 611 | 609 | * 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 |
| 614 | 612 | } |
| 615 | 613 | #else /* !CONFIG_NUMA */ |
| 616 | 614 | #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) |
| 618 | 616 | { |
| 619 | 617 | } |
| 620 | 618 | #endif /* CONFIG_TMPFS */ |
| 621 | 619 | |
| 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) |
| 624 | 622 | { |
| 625 | | − return swapin_readahead(entry, gfp, NULL, 0); |
| 623 | + return swapin_readahead(swap, gfp, NULL, 0); |
| 626 | 624 | } |
| 627 | 625 | |
| 628 | 626 | 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) |
| 630 | 628 | { |
| 631 | 629 | return alloc_page(gfp); |
| 632 | 630 | } |
| @@ -646,7 +644,7 @@ static inline struct mempolicy *shmem_get_sbmpol(struct shmem_sb_info *sbinfo) · 13 unmodified lines |
| 646 | 644 | * vm. If we swap it in we mark it dirty since we also free the swap |
| 647 | 645 | * entry since a page cannot live in both the swap and page cache |
| 648 | 646 | */ |
| 649 | | −static int shmem_getpage_gfp(struct inode *inode, pgoff_t idx, |
| 647 | +static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, |
| 650 | 648 | struct page **pagep, enum sgp_type sgp, gfp_t gfp, int *fault_type) |
| 651 | 649 | { |
| 652 | 650 | 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 |
| 657 | 655 | swp_entry_t swap; |
| 658 | 656 | int error; |
| 659 | 657 | |
| 660 | | − if (idx > (MAX_LFS_FILESIZE >> PAGE_CACHE_SHIFT)) |
| 658 | + if (index > (MAX_LFS_FILESIZE >> PAGE_CACHE_SHIFT)) |
| 661 | 659 | return -EFBIG; |
| 662 | 660 | repeat: |
| 663 | | − page = find_lock_page(mapping, idx); |
| 661 | + page = find_lock_page(mapping, index); |
| 664 | 662 | if (page) { |
| 665 | 663 | /* |
| 666 | 664 | * Once we can get the page lock, it must be uptodate: |
| @@ -681,7 +679,7 @@ repeat: · 14 unmodified lines |
| 681 | 679 | radix_tree_preload_end(); |
| 682 | 680 | |
| 683 | 681 | if (sgp != SGP_READ && !prealloc_page) { |
| 684 | | − prealloc_page = shmem_alloc_page(gfp, info, idx); |
| 682 | + prealloc_page = shmem_alloc_page(gfp, info, index); |
| 685 | 683 | if (prealloc_page) { |
| 686 | 684 | SetPageSwapBacked(prealloc_page); |
| 687 | 685 | if (mem_cgroup_cache_charge(prealloc_page, |
| @@ -694,7 +692,7 @@ repeat: · 6 unmodified lines |
| 694 | 692 | |
| 695 | 693 | spin_lock(&info->lock); |
| 696 | 694 | shmem_recalc_inode(inode); |
| 697 | | − swap = shmem_get_swap(info, idx); |
| 695 | + swap = shmem_get_swap(info, index); |
| 698 | 696 | if (swap.val) { |
| 699 | 697 | /* Look it up and read it in.. */ |
| 700 | 698 | page = lookup_swap_cache(swap); |
| @@ -703,9 +701,9 @@ repeat: · 2 unmodified lines |
| 703 | 701 | /* here we actually do the io */ |
| 704 | 702 | if (fault_type) |
| 705 | 703 | *fault_type |= VM_FAULT_MAJOR; |
| 706 | | − page = shmem_swapin(swap, gfp, info, idx); |
| 704 | + page = shmem_swapin(swap, gfp, info, index); |
| 707 | 705 | if (!page) { |
| 708 | | − swp_entry_t nswap = shmem_get_swap(info, idx); |
| 706 | + swp_entry_t nswap = shmem_get_swap(info, index); |
| 709 | 707 | if (nswap.val == swap.val) { |
| 710 | 708 | error = -ENOMEM; |
| 711 | 709 | goto out; |
| @@ -740,7 +738,7 @@ repeat: · 28 unmodified lines |
| 740 | 738 | } |
| 741 | 739 | |
| 742 | 740 | error = add_to_page_cache_locked(page, mapping, |
| 743 | | − idx, GFP_NOWAIT); |
| 741 | + index, GFP_NOWAIT); |
| 744 | 742 | if (error) { |
| 745 | 743 | spin_unlock(&info->lock); |
| 746 | 744 | if (error == -ENOMEM) { |
| @@ -762,14 +760,14 @@ repeat: · 15 unmodified lines |
| 762 | 760 | } |
| 763 | 761 | |
| 764 | 762 | 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}); |
| 766 | 764 | info->swapped--; |
| 767 | 765 | spin_unlock(&info->lock); |
| 768 | 766 | set_page_dirty(page); |
| 769 | 767 | swap_free(swap); |
| 770 | 768 | |
| 771 | 769 | } else if (sgp == SGP_READ) { |
| 772 | | − page = find_get_page(mapping, idx); |
| 770 | + page = find_get_page(mapping, index); |
| 773 | 771 | if (page && !trylock_page(page)) { |
| 774 | 772 | spin_unlock(&info->lock); |
| 775 | 773 | wait_on_page_locked(page); |
| @@ -793,12 +791,12 @@ repeat: · 17 unmodified lines |
| 793 | 791 | page = prealloc_page; |
| 794 | 792 | prealloc_page = NULL; |
| 795 | 793 | |
| 796 | | − swap = shmem_get_swap(info, idx); |
| 794 | + swap = shmem_get_swap(info, index); |
| 797 | 795 | if (swap.val) |
| 798 | 796 | mem_cgroup_uncharge_cache_page(page); |
| 799 | 797 | else |
| 800 | 798 | error = add_to_page_cache_lru(page, mapping, |
| 801 | | − idx, GFP_NOWAIT); |
| 799 | + index, GFP_NOWAIT); |
| 802 | 800 | /* |
| 803 | 801 | * At add_to_page_cache_lru() failure, |
| 804 | 802 | * uncharge will be done automatically. |
| @@ -841,7 +839,7 @@ nospace: · 36 unmodified lines |
| 841 | 839 | * but must also avoid reporting a spurious ENOSPC while working on a |
| 842 | 840 | * full tmpfs. |
| 843 | 841 | */ |
| 844 | | − page = find_get_page(mapping, idx); |
| 842 | + page = find_get_page(mapping, index); |
| 845 | 843 | spin_unlock(&info->lock); |
| 846 | 844 | if (page) { |
| 847 | 845 | page_cache_release(page); |
| @@ -872,20 +870,20 @@ static int shmem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) · 24 unmodified lines |
| 872 | 870 | } |
| 873 | 871 | |
| 874 | 872 | #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) |
| 876 | 874 | { |
| 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); |
| 879 | 877 | } |
| 880 | 878 | |
| 881 | 879 | static struct mempolicy *shmem_get_policy(struct vm_area_struct *vma, |
| 882 | 880 | unsigned long addr) |
| 883 | 881 | { |
| 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; |
| 886 | 884 | |
| 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); |
| 889 | 887 | } |
| 890 | 888 | #endif |
| 891 | 889 | |
| @@ -1016,7 +1014,8 @@ static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_ · 124 unmodified lines |
| 1016 | 1014 | { |
| 1017 | 1015 | struct inode *inode = filp->f_path.dentry->d_inode; |
| 1018 | 1016 | struct address_space *mapping = inode->i_mapping; |
| 1019 | | − unsigned long index, offset; |
| 1017 | + pgoff_t index; |
| 1018 | + unsigned long offset; |
| 1020 | 1019 | enum sgp_type sgp = SGP_READ; |
| 1021 | 1020 | |
| 1022 | 1021 | /* |
| @@ -1032,7 +1031,8 @@ static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_ · 9 unmodified lines |
| 1032 | 1031 | |
| 1033 | 1032 | for (;;) { |
| 1034 | 1033 | struct page *page = NULL; |
| 1035 | | − unsigned long end_index, nr, ret; |
| 1034 | + pgoff_t end_index; |
| 1035 | + unsigned long nr, ret; |
| 1036 | 1036 | loff_t i_size = i_size_read(inode); |
| 1037 | 1037 | |
| 1038 | 1038 | end_index = i_size >> PAGE_CACHE_SHIFT; |
| @@ -1270,8 +1270,9 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf) · 231 unmodified lines |
| 1270 | 1270 | buf->f_namelen = NAME_MAX; |
| 1271 | 1271 | if (sbinfo->max_blocks) { |
| 1272 | 1272 | 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); |
| 1275 | 1276 | } |
| 1276 | 1277 | if (sbinfo->max_inodes) { |
| 1277 | 1278 | 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 |
| 1480 | 1481 | static void *shmem_follow_link(struct dentry *dentry, struct nameidata *nd) |
| 1481 | 1482 | { |
| 1482 | 1483 | 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)); |
| 1485 | 1486 | if (page) |
| 1486 | 1487 | unlock_page(page); |
| 1487 | 1488 | return page; |
| @@ -1592,7 +1593,6 @@ out: · 104 unmodified lines |
| 1592 | 1593 | return err; |
| 1593 | 1594 | } |
| 1594 | 1595 | |
| 1595 | | − |
| 1596 | 1596 | static const struct xattr_handler *shmem_xattr_handlers[] = { |
| 1597 | 1597 | #ifdef CONFIG_TMPFS_POSIX_ACL |
| 1598 | 1598 | &generic_acl_access_handler, |
| @@ -2052,14 +2052,14 @@ static struct kmem_cache *shmem_inode_cachep; · 453 unmodified lines |
| 2052 | 2052 | |
| 2053 | 2053 | static struct inode *shmem_alloc_inode(struct super_block *sb) |
| 2054 | 2054 | { |
| 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) |
| 2058 | 2058 | return NULL; |
| 2059 | | − return &p->vfs_inode; |
| 2059 | + return &info->vfs_inode; |
| 2060 | 2060 | } |
| 2061 | 2061 | |
| 2062 | | −static void shmem_i_callback(struct rcu_head *head) |
| 2062 | +static void shmem_destroy_callback(struct rcu_head *head) |
| 2063 | 2063 | { |
| 2064 | 2064 | struct inode *inode = container_of(head, struct inode, i_rcu); |
| 2065 | 2065 | INIT_LIST_HEAD(&inode->i_dentry); |
| @@ -2072,25 +2072,24 @@ static void shmem_destroy_inode(struct inode *inode) · 6 unmodified lines |
| 2072 | 2072 | /* only struct inode is valid if it's an inline symlink */ |
| 2073 | 2073 | mpol_free_shared_policy(&SHMEM_I(inode)->policy); |
| 2074 | 2074 | } |
| 2075 | | − call_rcu(&inode->i_rcu, shmem_i_callback); |
| 2075 | + call_rcu(&inode->i_rcu, shmem_destroy_callback); |
| 2076 | 2076 | } |
| 2077 | 2077 | |
| 2078 | | −static void init_once(void *foo) |
| 2078 | +static void shmem_init_inode(void *foo) |
| 2079 | 2079 | { |
| 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); |
| 2083 | 2082 | } |
| 2084 | 2083 | |
| 2085 | | −static int init_inodecache(void) |
| 2084 | +static int shmem_init_inodecache(void) |
| 2086 | 2085 | { |
| 2087 | 2086 | shmem_inode_cachep = kmem_cache_create("shmem_inode_cache", |
| 2088 | 2087 | sizeof(struct shmem_inode_info), |
| 2089 | | − 0, SLAB_PANIC, init_once); |
| 2088 | + 0, SLAB_PANIC, shmem_init_inode); |
| 2090 | 2089 | return 0; |
| 2091 | 2090 | } |
| 2092 | 2091 | |
| 2093 | | −static void destroy_inodecache(void) |
| 2092 | +static void shmem_destroy_inodecache(void) |
| 2094 | 2093 | { |
| 2095 | 2094 | kmem_cache_destroy(shmem_inode_cachep); |
| 2096 | 2095 | } |
| @@ -2187,21 +2186,20 @@ static const struct vm_operations_struct shmem_vm_ops = { · 90 unmodified lines |
| 2187 | 2186 | #endif |
| 2188 | 2187 | }; |
| 2189 | 2188 | |
| 2190 | | − |
| 2191 | 2189 | static struct dentry *shmem_mount(struct file_system_type *fs_type, |
| 2192 | 2190 | int flags, const char *dev_name, void *data) |
| 2193 | 2191 | { |
| 2194 | 2192 | return mount_nodev(fs_type, flags, data, shmem_fill_super); |
| 2195 | 2193 | } |
| 2196 | 2194 | |
| 2197 | | −static struct file_system_type tmpfs_fs_type = { |
| 2195 | +static struct file_system_type shmem_fs_type = { |
| 2198 | 2196 | .owner = THIS_MODULE, |
| 2199 | 2197 | .name = "tmpfs", |
| 2200 | 2198 | .mount = shmem_mount, |
| 2201 | 2199 | .kill_sb = kill_litter_super, |
| 2202 | 2200 | }; |
| 2203 | 2201 | |
| 2204 | | −int __init init_tmpfs(void) |
| 2202 | +int __init shmem_init(void) |
| 2205 | 2203 | { |
| 2206 | 2204 | int error; |
| 2207 | 2205 | |
| @@ -2209,18 +2207,18 @@ int __init init_tmpfs(void) · 1 unmodified line |
| 2209 | 2207 | if (error) |
| 2210 | 2208 | goto out4; |
| 2211 | 2209 | |
| 2212 | | − error = init_inodecache(); |
| 2210 | + error = shmem_init_inodecache(); |
| 2213 | 2211 | if (error) |
| 2214 | 2212 | goto out3; |
| 2215 | 2213 | |
| 2216 | | − error = register_filesystem(&tmpfs_fs_type); |
| 2214 | + error = register_filesystem(&shmem_fs_type); |
| 2217 | 2215 | if (error) { |
| 2218 | 2216 | printk(KERN_ERR "Could not register tmpfs\n"); |
| 2219 | 2217 | goto out2; |
| 2220 | 2218 | } |
| 2221 | 2219 | |
| 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); |
| 2224 | 2222 | if (IS_ERR(shm_mnt)) { |
| 2225 | 2223 | error = PTR_ERR(shm_mnt); |
| 2226 | 2224 | printk(KERN_ERR "Could not kern_mount tmpfs\n"); |
| @@ -2229,9 +2227,9 @@ int __init init_tmpfs(void) · 2 unmodified lines |
| 2229 | 2227 | return 0; |
| 2230 | 2228 | |
| 2231 | 2229 | out1: |
| 2232 | | − unregister_filesystem(&tmpfs_fs_type); |
| 2230 | + unregister_filesystem(&shmem_fs_type); |
| 2233 | 2231 | out2: |
| 2234 | | − destroy_inodecache(); |
| 2232 | + shmem_destroy_inodecache(); |
| 2235 | 2233 | out3: |
| 2236 | 2234 | bdi_destroy(&shmem_backing_dev_info); |
| 2237 | 2235 | out4: |
| @@ -2241,37 +2239,37 @@ out4: · 3 unmodified lines |
| 2241 | 2239 | |
| 2242 | 2240 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR |
| 2243 | 2241 | /** |
| 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 |
| 2245 | 2243 | * @inode: the inode to be searched |
| 2246 | | − * @pgoff: the offset to be searched |
| 2244 | + * @index: the page offset to be searched |
| 2247 | 2245 | * @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 |
| 2249 | 2247 | * |
| 2250 | 2248 | * If a page is found, refcount of it is incremented. Callers should handle |
| 2251 | 2249 | * these refcount. |
| 2252 | 2250 | */ |
| 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) |
| 2255 | 2253 | { |
| 2256 | | − swp_entry_t entry = { .val = 0 }; |
| 2257 | | − struct page *page = NULL; |
| 2258 | 2254 | struct shmem_inode_info *info = SHMEM_I(inode); |
| 2255 | + struct page *page = NULL; |
| 2256 | + swp_entry_t swap = {0}; |
| 2259 | 2257 | |
| 2260 | | − if ((pgoff << PAGE_CACHE_SHIFT) >= i_size_read(inode)) |
| 2258 | + if ((index << PAGE_CACHE_SHIFT) >= i_size_read(inode)) |
| 2261 | 2259 | goto out; |
| 2262 | 2260 | |
| 2263 | 2261 | spin_lock(&info->lock); |
| 2264 | 2262 | #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); |
| 2268 | 2266 | else |
| 2269 | 2267 | #endif |
| 2270 | | − page = find_get_page(inode->i_mapping, pgoff); |
| 2268 | + page = find_get_page(inode->i_mapping, index); |
| 2271 | 2269 | spin_unlock(&info->lock); |
| 2272 | 2270 | out: |
| 2273 | 2271 | *pagep = page; |
| 2274 | | − *ent = entry; |
| 2272 | + *swapp = swap; |
| 2275 | 2273 | } |
| 2276 | 2274 | #endif |
| 2277 | 2275 | |
| @@ -2288,23 +2286,23 @@ out: · 10 unmodified lines |
| 2288 | 2286 | |
| 2289 | 2287 | #include <linux/ramfs.h> |
| 2290 | 2288 | |
| 2291 | | −static struct file_system_type tmpfs_fs_type = { |
| 2289 | +static struct file_system_type shmem_fs_type = { |
| 2292 | 2290 | .name = "tmpfs", |
| 2293 | 2291 | .mount = ramfs_mount, |
| 2294 | 2292 | .kill_sb = kill_litter_super, |
| 2295 | 2293 | }; |
| 2296 | 2294 | |
| 2297 | | −int __init init_tmpfs(void) |
| 2295 | +int __init shmem_init(void) |
| 2298 | 2296 | { |
| 2299 | | − BUG_ON(register_filesystem(&tmpfs_fs_type) != 0); |
| 2297 | + BUG_ON(register_filesystem(&shmem_fs_type) != 0); |
| 2300 | 2298 | |
| 2301 | | − shm_mnt = kern_mount(&tmpfs_fs_type); |
| 2299 | + shm_mnt = kern_mount(&shmem_fs_type); |
| 2302 | 2300 | BUG_ON(IS_ERR(shm_mnt)); |
| 2303 | 2301 | |
| 2304 | 2302 | return 0; |
| 2305 | 2303 | } |
| 2306 | 2304 | |
| 2307 | | −int shmem_unuse(swp_entry_t entry, struct page *page) |
| 2305 | +int shmem_unuse(swp_entry_t swap, struct page *page) |
| 2308 | 2306 | { |
| 2309 | 2307 | return 0; |
| 2310 | 2308 | } |
| @@ -2314,34 +2312,34 @@ int shmem_lock(struct file *file, int lock, struct user_struct *user) · 3 unmodified lines |
| 2314 | 2312 | return 0; |
| 2315 | 2313 | } |
| 2316 | 2314 | |
| 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) |
| 2318 | 2316 | { |
| 2319 | | − truncate_inode_pages_range(inode->i_mapping, start, end); |
| 2317 | + truncate_inode_pages_range(inode->i_mapping, lstart, lend); |
| 2320 | 2318 | } |
| 2321 | 2319 | EXPORT_SYMBOL_GPL(shmem_truncate_range); |
| 2322 | 2320 | |
| 2323 | 2321 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR |
| 2324 | 2322 | /** |
| 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 |
| 2326 | 2324 | * @inode: the inode to be searched |
| 2327 | | − * @pgoff: the offset to be searched |
| 2325 | + * @index: the page offset to be searched |
| 2328 | 2326 | * @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 |
| 2330 | 2328 | * |
| 2331 | 2329 | * If a page is found, refcount of it is incremented. Callers should handle |
| 2332 | 2330 | * these refcount. |
| 2333 | 2331 | */ |
| 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) |
| 2336 | 2334 | { |
| 2337 | 2335 | struct page *page = NULL; |
| 2338 | 2336 | |
| 2339 | | − if ((pgoff << PAGE_CACHE_SHIFT) >= i_size_read(inode)) |
| 2337 | + if ((index << PAGE_CACHE_SHIFT) >= i_size_read(inode)) |
| 2340 | 2338 | goto out; |
| 2341 | | − page = find_get_page(inode->i_mapping, pgoff); |
| 2339 | + page = find_get_page(inode->i_mapping, index); |
| 2342 | 2340 | out: |
| 2343 | 2341 | *pagep = page; |
| 2344 | | − *ent = (swp_entry_t){ .val = 0 }; |
| 2342 | + *swapp = (swp_entry_t){0}; |
| 2345 | 2343 | } |
| 2346 | 2344 | #endif |
| 2347 | 2345 | |