aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysv
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/sysv
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/sysv')
-rw-r--r--fs/sysv/dir.c18
-rw-r--r--fs/sysv/namei.c4
2 files changed, 11 insertions, 11 deletions
diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
index 63c1bcb224ee..c0f0a3e643eb 100644
--- a/fs/sysv/dir.c
+++ b/fs/sysv/dir.c
@@ -30,7 +30,7 @@ const struct file_operations sysv_dir_operations = {
30static inline void dir_put_page(struct page *page) 30static inline void dir_put_page(struct page *page)
31{ 31{
32 kunmap(page); 32 kunmap(page);
33 page_cache_release(page); 33 put_page(page);
34} 34}
35 35
36static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len) 36static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len)
@@ -73,8 +73,8 @@ static int sysv_readdir(struct file *file, struct dir_context *ctx)
73 if (pos >= inode->i_size) 73 if (pos >= inode->i_size)
74 return 0; 74 return 0;
75 75
76 offset = pos & ~PAGE_CACHE_MASK; 76 offset = pos & ~PAGE_MASK;
77 n = pos >> PAGE_CACHE_SHIFT; 77 n = pos >> PAGE_SHIFT;
78 78
79 for ( ; n < npages; n++, offset = 0) { 79 for ( ; n < npages; n++, offset = 0) {
80 char *kaddr, *limit; 80 char *kaddr, *limit;
@@ -85,7 +85,7 @@ static int sysv_readdir(struct file *file, struct dir_context *ctx)
85 continue; 85 continue;
86 kaddr = (char *)page_address(page); 86 kaddr = (char *)page_address(page);
87 de = (struct sysv_dir_entry *)(kaddr+offset); 87 de = (struct sysv_dir_entry *)(kaddr+offset);
88 limit = kaddr + PAGE_CACHE_SIZE - SYSV_DIRSIZE; 88 limit = kaddr + PAGE_SIZE - SYSV_DIRSIZE;
89 for ( ;(char*)de <= limit; de++, ctx->pos += sizeof(*de)) { 89 for ( ;(char*)de <= limit; de++, ctx->pos += sizeof(*de)) {
90 char *name = de->name; 90 char *name = de->name;
91 91
@@ -146,7 +146,7 @@ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_
146 if (!IS_ERR(page)) { 146 if (!IS_ERR(page)) {
147 kaddr = (char*)page_address(page); 147 kaddr = (char*)page_address(page);
148 de = (struct sysv_dir_entry *) kaddr; 148 de = (struct sysv_dir_entry *) kaddr;
149 kaddr += PAGE_CACHE_SIZE - SYSV_DIRSIZE; 149 kaddr += PAGE_SIZE - SYSV_DIRSIZE;
150 for ( ; (char *) de <= kaddr ; de++) { 150 for ( ; (char *) de <= kaddr ; de++) {
151 if (!de->inode) 151 if (!de->inode)
152 continue; 152 continue;
@@ -190,7 +190,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
190 goto out; 190 goto out;
191 kaddr = (char*)page_address(page); 191 kaddr = (char*)page_address(page);
192 de = (struct sysv_dir_entry *)kaddr; 192 de = (struct sysv_dir_entry *)kaddr;
193 kaddr += PAGE_CACHE_SIZE - SYSV_DIRSIZE; 193 kaddr += PAGE_SIZE - SYSV_DIRSIZE;
194 while ((char *)de <= kaddr) { 194 while ((char *)de <= kaddr) {
195 if (!de->inode) 195 if (!de->inode)
196 goto got_it; 196 goto got_it;
@@ -261,7 +261,7 @@ int sysv_make_empty(struct inode *inode, struct inode *dir)
261 kmap(page); 261 kmap(page);
262 262
263 base = (char*)page_address(page); 263 base = (char*)page_address(page);
264 memset(base, 0, PAGE_CACHE_SIZE); 264 memset(base, 0, PAGE_SIZE);
265 265
266 de = (struct sysv_dir_entry *) base; 266 de = (struct sysv_dir_entry *) base;
267 de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); 267 de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
@@ -273,7 +273,7 @@ int sysv_make_empty(struct inode *inode, struct inode *dir)
273 kunmap(page); 273 kunmap(page);
274 err = dir_commit_chunk(page, 0, 2 * SYSV_DIRSIZE); 274 err = dir_commit_chunk(page, 0, 2 * SYSV_DIRSIZE);
275fail: 275fail:
276 page_cache_release(page); 276 put_page(page);
277 return err; 277 return err;
278} 278}
279 279
@@ -296,7 +296,7 @@ int sysv_empty_dir(struct inode * inode)
296 296
297 kaddr = (char *)page_address(page); 297 kaddr = (char *)page_address(page);
298 de = (struct sysv_dir_entry *)kaddr; 298 de = (struct sysv_dir_entry *)kaddr;
299 kaddr += PAGE_CACHE_SIZE-SYSV_DIRSIZE; 299 kaddr += PAGE_SIZE-SYSV_DIRSIZE;
300 300
301 for ( ;(char *)de <= kaddr; de++) { 301 for ( ;(char *)de <= kaddr; de++) {
302 if (!de->inode) 302 if (!de->inode)
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c
index 11e83ed0b4bf..90b60c03b588 100644
--- a/fs/sysv/namei.c
+++ b/fs/sysv/namei.c
@@ -264,11 +264,11 @@ static int sysv_rename(struct inode * old_dir, struct dentry * old_dentry,
264out_dir: 264out_dir:
265 if (dir_de) { 265 if (dir_de) {
266 kunmap(dir_page); 266 kunmap(dir_page);
267 page_cache_release(dir_page); 267 put_page(dir_page);
268 } 268 }
269out_old: 269out_old:
270 kunmap(old_page); 270 kunmap(old_page);
271 page_cache_release(old_page); 271 put_page(old_page);
272out: 272out:
273 return err; 273 return err;
274} 274}