aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jfs
diff options
context:
space:
mode:
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>2016-04-01 08:29:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-04-04 13:41:08 -0400
commit09cbfeaf1a5a67bfb3201e0c83c810cecb2efa5a (patch)
tree6cdf210c9c0f981cd22544feeba701892ec19464 /fs/jfs
parentc05c2ec96bb8b7310da1055c7b9d786a3ec6dc0c (diff)
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time ago with promise that one day it will be possible to implement page cache with bigger chunks than PAGE_SIZE. This promise never materialized. And unlikely will. We have many places where PAGE_CACHE_SIZE assumed to be equal to PAGE_SIZE. And it's constant source of confusion on whether PAGE_CACHE_* or PAGE_* constant should be used in a particular case, especially on the border between fs and mm. Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much breakage to be doable. Let's stop pretending that pages in page cache are special. They are not. The changes are pretty straight-forward: - <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>; - <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>; - PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN}; - page_cache_get() -> get_page(); - page_cache_release() -> put_page(); This patch contains automated changes generated with coccinelle using script below. For some reason, coccinelle doesn't patch header files. I've called spatch for them manually. The only adjustment after coccinelle is revert of changes to PAGE_CAHCE_ALIGN definition: we are going to drop it later. There are few places in the code where coccinelle didn't reach. I'll fix them manually in a separate patch. Comments and documentation also will be addressed with the separate patch. virtual patch @@ expression E; @@ - E << (PAGE_CACHE_SHIFT - PAGE_SHIFT) + E @@ expression E; @@ - E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) + E @@ @@ - PAGE_CACHE_SHIFT + PAGE_SHIFT @@ @@ - PAGE_CACHE_SIZE + PAGE_SIZE @@ @@ - PAGE_CACHE_MASK + PAGE_MASK @@ expression E; @@ - PAGE_CACHE_ALIGN(E) + PAGE_ALIGN(E) @@ expression E; @@ - page_cache_get(E) + get_page(E) @@ expression E; @@ - page_cache_release(E) + put_page(E) Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/jfs')
-rw-r--r--fs/jfs/jfs_metapage.c42
-rw-r--r--fs/jfs/jfs_metapage.h4
-rw-r--r--fs/jfs/super.c2
3 files changed, 24 insertions, 24 deletions
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index a3eb316b1ac3..b60e015cc757 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -80,7 +80,7 @@ static inline void lock_metapage(struct metapage *mp)
80static struct kmem_cache *metapage_cache; 80static struct kmem_cache *metapage_cache;
81static mempool_t *metapage_mempool; 81static mempool_t *metapage_mempool;
82 82
83#define MPS_PER_PAGE (PAGE_CACHE_SIZE >> L2PSIZE) 83#define MPS_PER_PAGE (PAGE_SIZE >> L2PSIZE)
84 84
85#if MPS_PER_PAGE > 1 85#if MPS_PER_PAGE > 1
86 86
@@ -316,7 +316,7 @@ static void last_write_complete(struct page *page)
316 struct metapage *mp; 316 struct metapage *mp;
317 unsigned int offset; 317 unsigned int offset;
318 318
319 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) { 319 for (offset = 0; offset < PAGE_SIZE; offset += PSIZE) {
320 mp = page_to_mp(page, offset); 320 mp = page_to_mp(page, offset);
321 if (mp && test_bit(META_io, &mp->flag)) { 321 if (mp && test_bit(META_io, &mp->flag)) {
322 if (mp->lsn) 322 if (mp->lsn)
@@ -366,12 +366,12 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc)
366 int bad_blocks = 0; 366 int bad_blocks = 0;
367 367
368 page_start = (sector_t)page->index << 368 page_start = (sector_t)page->index <<
369 (PAGE_CACHE_SHIFT - inode->i_blkbits); 369 (PAGE_SHIFT - inode->i_blkbits);
370 BUG_ON(!PageLocked(page)); 370 BUG_ON(!PageLocked(page));
371 BUG_ON(PageWriteback(page)); 371 BUG_ON(PageWriteback(page));
372 set_page_writeback(page); 372 set_page_writeback(page);
373 373
374 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) { 374 for (offset = 0; offset < PAGE_SIZE; offset += PSIZE) {
375 mp = page_to_mp(page, offset); 375 mp = page_to_mp(page, offset);
376 376
377 if (!mp || !test_bit(META_dirty, &mp->flag)) 377 if (!mp || !test_bit(META_dirty, &mp->flag))
@@ -416,7 +416,7 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc)
416 bio = NULL; 416 bio = NULL;
417 } else 417 } else
418 inc_io(page); 418 inc_io(page);
419 xlen = (PAGE_CACHE_SIZE - offset) >> inode->i_blkbits; 419 xlen = (PAGE_SIZE - offset) >> inode->i_blkbits;
420 pblock = metapage_get_blocks(inode, lblock, &xlen); 420 pblock = metapage_get_blocks(inode, lblock, &xlen);
421 if (!pblock) { 421 if (!pblock) {
422 printk(KERN_ERR "JFS: metapage_get_blocks failed\n"); 422 printk(KERN_ERR "JFS: metapage_get_blocks failed\n");
@@ -485,7 +485,7 @@ static int metapage_readpage(struct file *fp, struct page *page)
485 struct inode *inode = page->mapping->host; 485 struct inode *inode = page->mapping->host;
486 struct bio *bio = NULL; 486 struct bio *bio = NULL;
487 int block_offset; 487 int block_offset;
488 int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits; 488 int blocks_per_page = PAGE_SIZE >> inode->i_blkbits;
489 sector_t page_start; /* address of page in fs blocks */ 489 sector_t page_start; /* address of page in fs blocks */
490 sector_t pblock; 490 sector_t pblock;
491 int xlen; 491 int xlen;
@@ -494,7 +494,7 @@ static int metapage_readpage(struct file *fp, struct page *page)
494 494
495 BUG_ON(!PageLocked(page)); 495 BUG_ON(!PageLocked(page));
496 page_start = (sector_t)page->index << 496 page_start = (sector_t)page->index <<
497 (PAGE_CACHE_SHIFT - inode->i_blkbits); 497 (PAGE_SHIFT - inode->i_blkbits);
498 498
499 block_offset = 0; 499 block_offset = 0;
500 while (block_offset < blocks_per_page) { 500 while (block_offset < blocks_per_page) {
@@ -542,7 +542,7 @@ static int metapage_releasepage(struct page *page, gfp_t gfp_mask)
542 int ret = 1; 542 int ret = 1;
543 int offset; 543 int offset;
544 544
545 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) { 545 for (offset = 0; offset < PAGE_SIZE; offset += PSIZE) {
546 mp = page_to_mp(page, offset); 546 mp = page_to_mp(page, offset);
547 547
548 if (!mp) 548 if (!mp)
@@ -568,7 +568,7 @@ static int metapage_releasepage(struct page *page, gfp_t gfp_mask)
568static void metapage_invalidatepage(struct page *page, unsigned int offset, 568static void metapage_invalidatepage(struct page *page, unsigned int offset,
569 unsigned int length) 569 unsigned int length)
570{ 570{
571 BUG_ON(offset || length < PAGE_CACHE_SIZE); 571 BUG_ON(offset || length < PAGE_SIZE);
572 572
573 BUG_ON(PageWriteback(page)); 573 BUG_ON(PageWriteback(page));
574 574
@@ -599,10 +599,10 @@ struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
599 inode->i_ino, lblock, absolute); 599 inode->i_ino, lblock, absolute);
600 600
601 l2bsize = inode->i_blkbits; 601 l2bsize = inode->i_blkbits;
602 l2BlocksPerPage = PAGE_CACHE_SHIFT - l2bsize; 602 l2BlocksPerPage = PAGE_SHIFT - l2bsize;
603 page_index = lblock >> l2BlocksPerPage; 603 page_index = lblock >> l2BlocksPerPage;
604 page_offset = (lblock - (page_index << l2BlocksPerPage)) << l2bsize; 604 page_offset = (lblock - (page_index << l2BlocksPerPage)) << l2bsize;
605 if ((page_offset + size) > PAGE_CACHE_SIZE) { 605 if ((page_offset + size) > PAGE_SIZE) {
606 jfs_err("MetaData crosses page boundary!!"); 606 jfs_err("MetaData crosses page boundary!!");
607 jfs_err("lblock = %lx, size = %d", lblock, size); 607 jfs_err("lblock = %lx, size = %d", lblock, size);
608 dump_stack(); 608 dump_stack();
@@ -621,7 +621,7 @@ struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
621 mapping = inode->i_mapping; 621 mapping = inode->i_mapping;
622 } 622 }
623 623
624 if (new && (PSIZE == PAGE_CACHE_SIZE)) { 624 if (new && (PSIZE == PAGE_SIZE)) {
625 page = grab_cache_page(mapping, page_index); 625 page = grab_cache_page(mapping, page_index);
626 if (!page) { 626 if (!page) {
627 jfs_err("grab_cache_page failed!"); 627 jfs_err("grab_cache_page failed!");
@@ -693,7 +693,7 @@ unlock:
693void grab_metapage(struct metapage * mp) 693void grab_metapage(struct metapage * mp)
694{ 694{
695 jfs_info("grab_metapage: mp = 0x%p", mp); 695 jfs_info("grab_metapage: mp = 0x%p", mp);
696 page_cache_get(mp->page); 696 get_page(mp->page);
697 lock_page(mp->page); 697 lock_page(mp->page);
698 mp->count++; 698 mp->count++;
699 lock_metapage(mp); 699 lock_metapage(mp);
@@ -706,12 +706,12 @@ void force_metapage(struct metapage *mp)
706 jfs_info("force_metapage: mp = 0x%p", mp); 706 jfs_info("force_metapage: mp = 0x%p", mp);
707 set_bit(META_forcewrite, &mp->flag); 707 set_bit(META_forcewrite, &mp->flag);
708 clear_bit(META_sync, &mp->flag); 708 clear_bit(META_sync, &mp->flag);
709 page_cache_get(page); 709 get_page(page);
710 lock_page(page); 710 lock_page(page);
711 set_page_dirty(page); 711 set_page_dirty(page);
712 write_one_page(page, 1); 712 write_one_page(page, 1);
713 clear_bit(META_forcewrite, &mp->flag); 713 clear_bit(META_forcewrite, &mp->flag);
714 page_cache_release(page); 714 put_page(page);
715} 715}
716 716
717void hold_metapage(struct metapage *mp) 717void hold_metapage(struct metapage *mp)
@@ -726,7 +726,7 @@ void put_metapage(struct metapage *mp)
726 unlock_page(mp->page); 726 unlock_page(mp->page);
727 return; 727 return;
728 } 728 }
729 page_cache_get(mp->page); 729 get_page(mp->page);
730 mp->count++; 730 mp->count++;
731 lock_metapage(mp); 731 lock_metapage(mp);
732 unlock_page(mp->page); 732 unlock_page(mp->page);
@@ -746,7 +746,7 @@ void release_metapage(struct metapage * mp)
746 assert(mp->count); 746 assert(mp->count);
747 if (--mp->count || mp->nohomeok) { 747 if (--mp->count || mp->nohomeok) {
748 unlock_page(page); 748 unlock_page(page);
749 page_cache_release(page); 749 put_page(page);
750 return; 750 return;
751 } 751 }
752 752
@@ -764,13 +764,13 @@ void release_metapage(struct metapage * mp)
764 drop_metapage(page, mp); 764 drop_metapage(page, mp);
765 765
766 unlock_page(page); 766 unlock_page(page);
767 page_cache_release(page); 767 put_page(page);
768} 768}
769 769
770void __invalidate_metapages(struct inode *ip, s64 addr, int len) 770void __invalidate_metapages(struct inode *ip, s64 addr, int len)
771{ 771{
772 sector_t lblock; 772 sector_t lblock;
773 int l2BlocksPerPage = PAGE_CACHE_SHIFT - ip->i_blkbits; 773 int l2BlocksPerPage = PAGE_SHIFT - ip->i_blkbits;
774 int BlocksPerPage = 1 << l2BlocksPerPage; 774 int BlocksPerPage = 1 << l2BlocksPerPage;
775 /* All callers are interested in block device's mapping */ 775 /* All callers are interested in block device's mapping */
776 struct address_space *mapping = 776 struct address_space *mapping =
@@ -788,7 +788,7 @@ void __invalidate_metapages(struct inode *ip, s64 addr, int len)
788 page = find_lock_page(mapping, lblock >> l2BlocksPerPage); 788 page = find_lock_page(mapping, lblock >> l2BlocksPerPage);
789 if (!page) 789 if (!page)
790 continue; 790 continue;
791 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) { 791 for (offset = 0; offset < PAGE_SIZE; offset += PSIZE) {
792 mp = page_to_mp(page, offset); 792 mp = page_to_mp(page, offset);
793 if (!mp) 793 if (!mp)
794 continue; 794 continue;
@@ -803,7 +803,7 @@ void __invalidate_metapages(struct inode *ip, s64 addr, int len)
803 remove_from_logsync(mp); 803 remove_from_logsync(mp);
804 } 804 }
805 unlock_page(page); 805 unlock_page(page);
806 page_cache_release(page); 806 put_page(page);
807 } 807 }
808} 808}
809 809
diff --git a/fs/jfs/jfs_metapage.h b/fs/jfs/jfs_metapage.h
index 337e9e51ac06..a869fb4a20d6 100644
--- a/fs/jfs/jfs_metapage.h
+++ b/fs/jfs/jfs_metapage.h
@@ -106,7 +106,7 @@ static inline void metapage_nohomeok(struct metapage *mp)
106 lock_page(page); 106 lock_page(page);
107 if (!mp->nohomeok++) { 107 if (!mp->nohomeok++) {
108 mark_metapage_dirty(mp); 108 mark_metapage_dirty(mp);
109 page_cache_get(page); 109 get_page(page);
110 wait_on_page_writeback(page); 110 wait_on_page_writeback(page);
111 } 111 }
112 unlock_page(page); 112 unlock_page(page);
@@ -128,7 +128,7 @@ static inline void metapage_wait_for_io(struct metapage *mp)
128static inline void _metapage_homeok(struct metapage *mp) 128static inline void _metapage_homeok(struct metapage *mp)
129{ 129{
130 if (!--mp->nohomeok) 130 if (!--mp->nohomeok)
131 page_cache_release(mp->page); 131 put_page(mp->page);
132} 132}
133 133
134static inline void metapage_homeok(struct metapage *mp) 134static inline void metapage_homeok(struct metapage *mp)
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 4f5d85ba8e23..78d599198bf5 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -596,7 +596,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
596 * Page cache is indexed by long. 596 * Page cache is indexed by long.
597 * I would use MAX_LFS_FILESIZE, but it's only half as big 597 * I would use MAX_LFS_FILESIZE, but it's only half as big
598 */ 598 */
599 sb->s_maxbytes = min(((u64) PAGE_CACHE_SIZE << 32) - 1, 599 sb->s_maxbytes = min(((u64) PAGE_SIZE << 32) - 1,
600 (u64)sb->s_maxbytes); 600 (u64)sb->s_maxbytes);
601#endif 601#endif
602 sb->s_time_gran = 1; 602 sb->s_time_gran = 1;