aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/dir.c
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/nilfs2/dir.c
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/nilfs2/dir.c')
-rw-r--r--fs/nilfs2/dir.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index 6b8b92b19cec..e08f064e4bd7 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -58,7 +58,7 @@ static inline unsigned nilfs_chunk_size(struct inode *inode)
58static inline void nilfs_put_page(struct page *page) 58static inline void nilfs_put_page(struct page *page)
59{ 59{
60 kunmap(page); 60 kunmap(page);
61 page_cache_release(page); 61 put_page(page);
62} 62}
63 63
64/* 64/*
@@ -69,9 +69,9 @@ static unsigned nilfs_last_byte(struct inode *inode, unsigned long page_nr)
69{ 69{
70 unsigned last_byte = inode->i_size; 70 unsigned last_byte = inode->i_size;
71 71
72 last_byte -= page_nr << PAGE_CACHE_SHIFT; 72 last_byte -= page_nr << PAGE_SHIFT;
73 if (last_byte > PAGE_CACHE_SIZE) 73 if (last_byte > PAGE_SIZE)
74 last_byte = PAGE_CACHE_SIZE; 74 last_byte = PAGE_SIZE;
75 return last_byte; 75 return last_byte;
76} 76}
77 77
@@ -109,12 +109,12 @@ static void nilfs_check_page(struct page *page)
109 unsigned chunk_size = nilfs_chunk_size(dir); 109 unsigned chunk_size = nilfs_chunk_size(dir);
110 char *kaddr = page_address(page); 110 char *kaddr = page_address(page);
111 unsigned offs, rec_len; 111 unsigned offs, rec_len;
112 unsigned limit = PAGE_CACHE_SIZE; 112 unsigned limit = PAGE_SIZE;
113 struct nilfs_dir_entry *p; 113 struct nilfs_dir_entry *p;
114 char *error; 114 char *error;
115 115
116 if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) { 116 if ((dir->i_size >> PAGE_SHIFT) == page->index) {
117 limit = dir->i_size & ~PAGE_CACHE_MASK; 117 limit = dir->i_size & ~PAGE_MASK;
118 if (limit & (chunk_size - 1)) 118 if (limit & (chunk_size - 1))
119 goto Ebadsize; 119 goto Ebadsize;
120 if (!limit) 120 if (!limit)
@@ -161,7 +161,7 @@ Espan:
161bad_entry: 161bad_entry:
162 nilfs_error(sb, "nilfs_check_page", "bad entry in directory #%lu: %s - " 162 nilfs_error(sb, "nilfs_check_page", "bad entry in directory #%lu: %s - "
163 "offset=%lu, inode=%lu, rec_len=%d, name_len=%d", 163 "offset=%lu, inode=%lu, rec_len=%d, name_len=%d",
164 dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT)+offs, 164 dir->i_ino, error, (page->index<<PAGE_SHIFT)+offs,
165 (unsigned long) le64_to_cpu(p->inode), 165 (unsigned long) le64_to_cpu(p->inode),
166 rec_len, p->name_len); 166 rec_len, p->name_len);
167 goto fail; 167 goto fail;
@@ -170,7 +170,7 @@ Eend:
170 nilfs_error(sb, "nilfs_check_page", 170 nilfs_error(sb, "nilfs_check_page",
171 "entry in directory #%lu spans the page boundary" 171 "entry in directory #%lu spans the page boundary"
172 "offset=%lu, inode=%lu", 172 "offset=%lu, inode=%lu",
173 dir->i_ino, (page->index<<PAGE_CACHE_SHIFT)+offs, 173 dir->i_ino, (page->index<<PAGE_SHIFT)+offs,
174 (unsigned long) le64_to_cpu(p->inode)); 174 (unsigned long) le64_to_cpu(p->inode));
175fail: 175fail:
176 SetPageChecked(page); 176 SetPageChecked(page);
@@ -256,8 +256,8 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx)
256 loff_t pos = ctx->pos; 256 loff_t pos = ctx->pos;
257 struct inode *inode = file_inode(file); 257 struct inode *inode = file_inode(file);
258 struct super_block *sb = inode->i_sb; 258 struct super_block *sb = inode->i_sb;
259 unsigned int offset = pos & ~PAGE_CACHE_MASK; 259 unsigned int offset = pos & ~PAGE_MASK;
260 unsigned long n = pos >> PAGE_CACHE_SHIFT; 260 unsigned long n = pos >> PAGE_SHIFT;
261 unsigned long npages = dir_pages(inode); 261 unsigned long npages = dir_pages(inode);
262/* unsigned chunk_mask = ~(nilfs_chunk_size(inode)-1); */ 262/* unsigned chunk_mask = ~(nilfs_chunk_size(inode)-1); */
263 263
@@ -272,7 +272,7 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx)
272 if (IS_ERR(page)) { 272 if (IS_ERR(page)) {
273 nilfs_error(sb, __func__, "bad page in #%lu", 273 nilfs_error(sb, __func__, "bad page in #%lu",
274 inode->i_ino); 274 inode->i_ino);
275 ctx->pos += PAGE_CACHE_SIZE - offset; 275 ctx->pos += PAGE_SIZE - offset;
276 return -EIO; 276 return -EIO;
277 } 277 }
278 kaddr = page_address(page); 278 kaddr = page_address(page);
@@ -361,7 +361,7 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr,
361 if (++n >= npages) 361 if (++n >= npages)
362 n = 0; 362 n = 0;
363 /* next page is past the blocks we've got */ 363 /* next page is past the blocks we've got */
364 if (unlikely(n > (dir->i_blocks >> (PAGE_CACHE_SHIFT - 9)))) { 364 if (unlikely(n > (dir->i_blocks >> (PAGE_SHIFT - 9)))) {
365 nilfs_error(dir->i_sb, __func__, 365 nilfs_error(dir->i_sb, __func__,
366 "dir %lu size %lld exceeds block count %llu", 366 "dir %lu size %lld exceeds block count %llu",
367 dir->i_ino, dir->i_size, 367 dir->i_ino, dir->i_size,
@@ -401,7 +401,7 @@ ino_t nilfs_inode_by_name(struct inode *dir, const struct qstr *qstr)
401 if (de) { 401 if (de) {
402 res = le64_to_cpu(de->inode); 402 res = le64_to_cpu(de->inode);
403 kunmap(page); 403 kunmap(page);
404 page_cache_release(page); 404 put_page(page);
405 } 405 }
406 return res; 406 return res;
407} 407}
@@ -460,7 +460,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
460 kaddr = page_address(page); 460 kaddr = page_address(page);
461 dir_end = kaddr + nilfs_last_byte(dir, n); 461 dir_end = kaddr + nilfs_last_byte(dir, n);
462 de = (struct nilfs_dir_entry *)kaddr; 462 de = (struct nilfs_dir_entry *)kaddr;
463 kaddr += PAGE_CACHE_SIZE - reclen; 463 kaddr += PAGE_SIZE - reclen;
464 while ((char *)de <= kaddr) { 464 while ((char *)de <= kaddr) {
465 if ((char *)de == dir_end) { 465 if ((char *)de == dir_end) {
466 /* We hit i_size */ 466 /* We hit i_size */
@@ -603,7 +603,7 @@ int nilfs_make_empty(struct inode *inode, struct inode *parent)
603 kunmap_atomic(kaddr); 603 kunmap_atomic(kaddr);
604 nilfs_commit_chunk(page, mapping, 0, chunk_size); 604 nilfs_commit_chunk(page, mapping, 0, chunk_size);
605fail: 605fail:
606 page_cache_release(page); 606 put_page(page);
607 return err; 607 return err;
608} 608}
609 609