summaryrefslogtreecommitdiffstats
path: root/include/linux/pagemap.h
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 /include/linux/pagemap.h
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 'include/linux/pagemap.h')
-rw-r--r--include/linux/pagemap.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 1ebd65c91422..f396ccb900cc 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -390,13 +390,13 @@ static inline pgoff_t page_to_pgoff(struct page *page)
390 return page->index << compound_order(page); 390 return page->index << compound_order(page);
391 391
392 if (likely(!PageTransTail(page))) 392 if (likely(!PageTransTail(page)))
393 return page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); 393 return page->index;
394 394
395 /* 395 /*
396 * We don't initialize ->index for tail pages: calculate based on 396 * We don't initialize ->index for tail pages: calculate based on
397 * head page 397 * head page
398 */ 398 */
399 pgoff = compound_head(page)->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); 399 pgoff = compound_head(page)->index;
400 pgoff += page - compound_head(page); 400 pgoff += page - compound_head(page);
401 return pgoff; 401 return pgoff;
402} 402}
@@ -406,12 +406,12 @@ static inline pgoff_t page_to_pgoff(struct page *page)
406 */ 406 */
407static inline loff_t page_offset(struct page *page) 407static inline loff_t page_offset(struct page *page)
408{ 408{
409 return ((loff_t)page->index) << PAGE_CACHE_SHIFT; 409 return ((loff_t)page->index) << PAGE_SHIFT;
410} 410}
411 411
412static inline loff_t page_file_offset(struct page *page) 412static inline loff_t page_file_offset(struct page *page)
413{ 413{
414 return ((loff_t)page_file_index(page)) << PAGE_CACHE_SHIFT; 414 return ((loff_t)page_file_index(page)) << PAGE_SHIFT;
415} 415}
416 416
417extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma, 417extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma,
@@ -425,7 +425,7 @@ static inline pgoff_t linear_page_index(struct vm_area_struct *vma,
425 return linear_hugepage_index(vma, address); 425 return linear_hugepage_index(vma, address);
426 pgoff = (address - vma->vm_start) >> PAGE_SHIFT; 426 pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
427 pgoff += vma->vm_pgoff; 427 pgoff += vma->vm_pgoff;
428 return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT); 428 return pgoff;
429} 429}
430 430
431extern void __lock_page(struct page *page); 431extern void __lock_page(struct page *page);
@@ -671,8 +671,8 @@ static inline int add_to_page_cache(struct page *page,
671 671
672static inline unsigned long dir_pages(struct inode *inode) 672static inline unsigned long dir_pages(struct inode *inode)
673{ 673{
674 return (unsigned long)(inode->i_size + PAGE_CACHE_SIZE - 1) >> 674 return (unsigned long)(inode->i_size + PAGE_SIZE - 1) >>
675 PAGE_CACHE_SHIFT; 675 PAGE_SHIFT;
676} 676}
677 677
678#endif /* _LINUX_PAGEMAP_H */ 678#endif /* _LINUX_PAGEMAP_H */