mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-30 06:54:28 -05:00
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>
This commit is contained in:
committed by
Linus Torvalds
parent
c05c2ec96b
commit
09cbfeaf1a
@@ -41,7 +41,7 @@
|
||||
#endif
|
||||
|
||||
#define BIO_MAX_PAGES 256
|
||||
#define BIO_MAX_SIZE (BIO_MAX_PAGES << PAGE_CACHE_SHIFT)
|
||||
#define BIO_MAX_SIZE (BIO_MAX_PAGES << PAGE_SHIFT)
|
||||
#define BIO_MAX_SECTORS (BIO_MAX_SIZE >> 9)
|
||||
|
||||
/*
|
||||
|
||||
@@ -1372,7 +1372,7 @@ unsigned char *read_dev_sector(struct block_device *, sector_t, Sector *);
|
||||
|
||||
static inline void put_dev_sector(Sector p)
|
||||
{
|
||||
page_cache_release(p.v);
|
||||
put_page(p.v);
|
||||
}
|
||||
|
||||
static inline bool __bvec_gap_to_prev(struct request_queue *q,
|
||||
|
||||
@@ -43,7 +43,7 @@ enum bh_state_bits {
|
||||
*/
|
||||
};
|
||||
|
||||
#define MAX_BUF_PER_PAGE (PAGE_CACHE_SIZE / 512)
|
||||
#define MAX_BUF_PER_PAGE (PAGE_SIZE / 512)
|
||||
|
||||
struct page;
|
||||
struct buffer_head;
|
||||
@@ -263,7 +263,7 @@ void buffer_init(void);
|
||||
static inline void attach_page_buffers(struct page *page,
|
||||
struct buffer_head *head)
|
||||
{
|
||||
page_cache_get(page);
|
||||
get_page(page);
|
||||
SetPagePrivate(page);
|
||||
set_page_private(page, (unsigned long)head);
|
||||
}
|
||||
|
||||
@@ -176,8 +176,8 @@ extern void ceph_put_snap_context(struct ceph_snap_context *sc);
|
||||
*/
|
||||
static inline int calc_pages_for(u64 off, u64 len)
|
||||
{
|
||||
return ((off+len+PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT) -
|
||||
(off >> PAGE_CACHE_SHIFT);
|
||||
return ((off+len+PAGE_SIZE-1) >> PAGE_SHIFT) -
|
||||
(off >> PAGE_SHIFT);
|
||||
}
|
||||
|
||||
extern struct kmem_cache *ceph_inode_cachep;
|
||||
|
||||
@@ -262,7 +262,7 @@ struct f2fs_node {
|
||||
/*
|
||||
* For NAT entries
|
||||
*/
|
||||
#define NAT_ENTRY_PER_BLOCK (PAGE_CACHE_SIZE / sizeof(struct f2fs_nat_entry))
|
||||
#define NAT_ENTRY_PER_BLOCK (PAGE_SIZE / sizeof(struct f2fs_nat_entry))
|
||||
|
||||
struct f2fs_nat_entry {
|
||||
__u8 version; /* latest version of cached nat entry */
|
||||
@@ -282,7 +282,7 @@ struct f2fs_nat_block {
|
||||
* Not allow to change this.
|
||||
*/
|
||||
#define SIT_VBLOCK_MAP_SIZE 64
|
||||
#define SIT_ENTRY_PER_BLOCK (PAGE_CACHE_SIZE / sizeof(struct f2fs_sit_entry))
|
||||
#define SIT_ENTRY_PER_BLOCK (PAGE_SIZE / sizeof(struct f2fs_sit_entry))
|
||||
|
||||
/*
|
||||
* Note that f2fs_sit_entry->vblocks has the following bit-field information.
|
||||
|
||||
@@ -929,7 +929,7 @@ static inline struct file *get_file(struct file *f)
|
||||
/* Page cache limit. The filesystems should put that into their s_maxbytes
|
||||
limits, otherwise bad things can happen in VM. */
|
||||
#if BITS_PER_LONG==32
|
||||
#define MAX_LFS_FILESIZE (((loff_t)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
|
||||
#define MAX_LFS_FILESIZE (((loff_t)PAGE_SIZE << (BITS_PER_LONG-1))-1)
|
||||
#elif BITS_PER_LONG==64
|
||||
#define MAX_LFS_FILESIZE ((loff_t)0x7fffffffffffffffLL)
|
||||
#endif
|
||||
@@ -2067,7 +2067,7 @@ extern int generic_update_time(struct inode *, struct timespec *, int);
|
||||
/* /sys/fs */
|
||||
extern struct kobject *fs_kobj;
|
||||
|
||||
#define MAX_RW_COUNT (INT_MAX & PAGE_CACHE_MASK)
|
||||
#define MAX_RW_COUNT (INT_MAX & PAGE_MASK)
|
||||
|
||||
#ifdef CONFIG_MANDATORY_FILE_LOCKING
|
||||
extern int locks_mandatory_locked(struct file *);
|
||||
|
||||
@@ -184,7 +184,7 @@ nfs_list_entry(struct list_head *head)
|
||||
static inline
|
||||
loff_t req_offset(struct nfs_page *req)
|
||||
{
|
||||
return (((loff_t)req->wb_index) << PAGE_CACHE_SHIFT) + req->wb_offset;
|
||||
return (((loff_t)req->wb_index) << PAGE_SHIFT) + req->wb_offset;
|
||||
}
|
||||
|
||||
#endif /* _LINUX_NFS_PAGE_H */
|
||||
|
||||
@@ -390,13 +390,13 @@ static inline pgoff_t page_to_pgoff(struct page *page)
|
||||
return page->index << compound_order(page);
|
||||
|
||||
if (likely(!PageTransTail(page)))
|
||||
return page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
|
||||
return page->index;
|
||||
|
||||
/*
|
||||
* We don't initialize ->index for tail pages: calculate based on
|
||||
* head page
|
||||
*/
|
||||
pgoff = compound_head(page)->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
|
||||
pgoff = compound_head(page)->index;
|
||||
pgoff += page - compound_head(page);
|
||||
return pgoff;
|
||||
}
|
||||
@@ -406,12 +406,12 @@ static inline pgoff_t page_to_pgoff(struct page *page)
|
||||
*/
|
||||
static inline loff_t page_offset(struct page *page)
|
||||
{
|
||||
return ((loff_t)page->index) << PAGE_CACHE_SHIFT;
|
||||
return ((loff_t)page->index) << PAGE_SHIFT;
|
||||
}
|
||||
|
||||
static inline loff_t page_file_offset(struct page *page)
|
||||
{
|
||||
return ((loff_t)page_file_index(page)) << PAGE_CACHE_SHIFT;
|
||||
return ((loff_t)page_file_index(page)) << PAGE_SHIFT;
|
||||
}
|
||||
|
||||
extern 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,
|
||||
return linear_hugepage_index(vma, address);
|
||||
pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
|
||||
pgoff += vma->vm_pgoff;
|
||||
return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT);
|
||||
return pgoff;
|
||||
}
|
||||
|
||||
extern void __lock_page(struct page *page);
|
||||
@@ -671,8 +671,8 @@ static inline int add_to_page_cache(struct page *page,
|
||||
|
||||
static inline unsigned long dir_pages(struct inode *inode)
|
||||
{
|
||||
return (unsigned long)(inode->i_size + PAGE_CACHE_SIZE - 1) >>
|
||||
PAGE_CACHE_SHIFT;
|
||||
return (unsigned long)(inode->i_size + PAGE_SIZE - 1) >>
|
||||
PAGE_SHIFT;
|
||||
}
|
||||
|
||||
#endif /* _LINUX_PAGEMAP_H */
|
||||
|
||||
@@ -435,7 +435,7 @@ struct backing_dev_info;
|
||||
/* only sparc can not include linux/pagemap.h in this file
|
||||
* so leave page_cache_release and release_pages undeclared... */
|
||||
#define free_page_and_swap_cache(page) \
|
||||
page_cache_release(page)
|
||||
put_page(page)
|
||||
#define free_pages_and_swap_cache(pages, nr) \
|
||||
release_pages((pages), (nr), false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user