aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exofs
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/exofs
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/exofs')
-rw-r--r--fs/exofs/dir.c30
-rw-r--r--fs/exofs/inode.c34
-rw-r--r--fs/exofs/namei.c4
3 files changed, 34 insertions, 34 deletions
diff --git a/fs/exofs/dir.c b/fs/exofs/dir.c
index e5bb2abf77f9..547b93cbea63 100644
--- a/fs/exofs/dir.c
+++ b/fs/exofs/dir.c
@@ -41,16 +41,16 @@ static inline unsigned exofs_chunk_size(struct inode *inode)
41static inline void exofs_put_page(struct page *page) 41static inline void exofs_put_page(struct page *page)
42{ 42{
43 kunmap(page); 43 kunmap(page);
44 page_cache_release(page); 44 put_page(page);
45} 45}
46 46
47static unsigned exofs_last_byte(struct inode *inode, unsigned long page_nr) 47static unsigned exofs_last_byte(struct inode *inode, unsigned long page_nr)
48{ 48{
49 loff_t last_byte = inode->i_size; 49 loff_t last_byte = inode->i_size;
50 50
51 last_byte -= page_nr << PAGE_CACHE_SHIFT; 51 last_byte -= page_nr << PAGE_SHIFT;
52 if (last_byte > PAGE_CACHE_SIZE) 52 if (last_byte > PAGE_SIZE)
53 last_byte = PAGE_CACHE_SIZE; 53 last_byte = PAGE_SIZE;
54 return last_byte; 54 return last_byte;
55} 55}
56 56
@@ -85,13 +85,13 @@ static void exofs_check_page(struct page *page)
85 unsigned chunk_size = exofs_chunk_size(dir); 85 unsigned chunk_size = exofs_chunk_size(dir);
86 char *kaddr = page_address(page); 86 char *kaddr = page_address(page);
87 unsigned offs, rec_len; 87 unsigned offs, rec_len;
88 unsigned limit = PAGE_CACHE_SIZE; 88 unsigned limit = PAGE_SIZE;
89 struct exofs_dir_entry *p; 89 struct exofs_dir_entry *p;
90 char *error; 90 char *error;
91 91
92 /* if the page is the last one in the directory */ 92 /* if the page is the last one in the directory */
93 if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) { 93 if ((dir->i_size >> PAGE_SHIFT) == page->index) {
94 limit = dir->i_size & ~PAGE_CACHE_MASK; 94 limit = dir->i_size & ~PAGE_MASK;
95 if (limit & (chunk_size - 1)) 95 if (limit & (chunk_size - 1))
96 goto Ebadsize; 96 goto Ebadsize;
97 if (!limit) 97 if (!limit)
@@ -138,7 +138,7 @@ bad_entry:
138 EXOFS_ERR( 138 EXOFS_ERR(
139 "ERROR [exofs_check_page]: bad entry in directory(0x%lx): %s - " 139 "ERROR [exofs_check_page]: bad entry in directory(0x%lx): %s - "
140 "offset=%lu, inode=0x%llu, rec_len=%d, name_len=%d\n", 140 "offset=%lu, inode=0x%llu, rec_len=%d, name_len=%d\n",
141 dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT)+offs, 141 dir->i_ino, error, (page->index<<PAGE_SHIFT)+offs,
142 _LLU(le64_to_cpu(p->inode_no)), 142 _LLU(le64_to_cpu(p->inode_no)),
143 rec_len, p->name_len); 143 rec_len, p->name_len);
144 goto fail; 144 goto fail;
@@ -147,7 +147,7 @@ Eend:
147 EXOFS_ERR("ERROR [exofs_check_page]: " 147 EXOFS_ERR("ERROR [exofs_check_page]: "
148 "entry in directory(0x%lx) spans the page boundary" 148 "entry in directory(0x%lx) spans the page boundary"
149 "offset=%lu, inode=0x%llx\n", 149 "offset=%lu, inode=0x%llx\n",
150 dir->i_ino, (page->index<<PAGE_CACHE_SHIFT)+offs, 150 dir->i_ino, (page->index<<PAGE_SHIFT)+offs,
151 _LLU(le64_to_cpu(p->inode_no))); 151 _LLU(le64_to_cpu(p->inode_no)));
152fail: 152fail:
153 SetPageChecked(page); 153 SetPageChecked(page);
@@ -237,8 +237,8 @@ exofs_readdir(struct file *file, struct dir_context *ctx)
237{ 237{
238 loff_t pos = ctx->pos; 238 loff_t pos = ctx->pos;
239 struct inode *inode = file_inode(file); 239 struct inode *inode = file_inode(file);
240 unsigned int offset = pos & ~PAGE_CACHE_MASK; 240 unsigned int offset = pos & ~PAGE_MASK;
241 unsigned long n = pos >> PAGE_CACHE_SHIFT; 241 unsigned long n = pos >> PAGE_SHIFT;
242 unsigned long npages = dir_pages(inode); 242 unsigned long npages = dir_pages(inode);
243 unsigned chunk_mask = ~(exofs_chunk_size(inode)-1); 243 unsigned chunk_mask = ~(exofs_chunk_size(inode)-1);
244 int need_revalidate = (file->f_version != inode->i_version); 244 int need_revalidate = (file->f_version != inode->i_version);
@@ -254,7 +254,7 @@ exofs_readdir(struct file *file, struct dir_context *ctx)
254 if (IS_ERR(page)) { 254 if (IS_ERR(page)) {
255 EXOFS_ERR("ERROR: bad page in directory(0x%lx)\n", 255 EXOFS_ERR("ERROR: bad page in directory(0x%lx)\n",
256 inode->i_ino); 256 inode->i_ino);
257 ctx->pos += PAGE_CACHE_SIZE - offset; 257 ctx->pos += PAGE_SIZE - offset;
258 return PTR_ERR(page); 258 return PTR_ERR(page);
259 } 259 }
260 kaddr = page_address(page); 260 kaddr = page_address(page);
@@ -262,7 +262,7 @@ exofs_readdir(struct file *file, struct dir_context *ctx)
262 if (offset) { 262 if (offset) {
263 offset = exofs_validate_entry(kaddr, offset, 263 offset = exofs_validate_entry(kaddr, offset,
264 chunk_mask); 264 chunk_mask);
265 ctx->pos = (n<<PAGE_CACHE_SHIFT) + offset; 265 ctx->pos = (n<<PAGE_SHIFT) + offset;
266 } 266 }
267 file->f_version = inode->i_version; 267 file->f_version = inode->i_version;
268 need_revalidate = 0; 268 need_revalidate = 0;
@@ -449,7 +449,7 @@ int exofs_add_link(struct dentry *dentry, struct inode *inode)
449 kaddr = page_address(page); 449 kaddr = page_address(page);
450 dir_end = kaddr + exofs_last_byte(dir, n); 450 dir_end = kaddr + exofs_last_byte(dir, n);
451 de = (struct exofs_dir_entry *)kaddr; 451 de = (struct exofs_dir_entry *)kaddr;
452 kaddr += PAGE_CACHE_SIZE - reclen; 452 kaddr += PAGE_SIZE - reclen;
453 while ((char *)de <= kaddr) { 453 while ((char *)de <= kaddr) {
454 if ((char *)de == dir_end) { 454 if ((char *)de == dir_end) {
455 name_len = 0; 455 name_len = 0;
@@ -602,7 +602,7 @@ int exofs_make_empty(struct inode *inode, struct inode *parent)
602 kunmap_atomic(kaddr); 602 kunmap_atomic(kaddr);
603 err = exofs_commit_chunk(page, 0, chunk_size); 603 err = exofs_commit_chunk(page, 0, chunk_size);
604fail: 604fail:
605 page_cache_release(page); 605 put_page(page);
606 return err; 606 return err;
607} 607}
608 608
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index 9eaf595aeaf8..49e1bd00b4ec 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -317,7 +317,7 @@ static int read_exec(struct page_collect *pcol)
317 317
318 if (!pcol->ios) { 318 if (!pcol->ios) {
319 int ret = ore_get_rw_state(&pcol->sbi->layout, &oi->oc, true, 319 int ret = ore_get_rw_state(&pcol->sbi->layout, &oi->oc, true,
320 pcol->pg_first << PAGE_CACHE_SHIFT, 320 pcol->pg_first << PAGE_SHIFT,
321 pcol->length, &pcol->ios); 321 pcol->length, &pcol->ios);
322 322
323 if (ret) 323 if (ret)
@@ -383,7 +383,7 @@ static int readpage_strip(void *data, struct page *page)
383 struct inode *inode = pcol->inode; 383 struct inode *inode = pcol->inode;
384 struct exofs_i_info *oi = exofs_i(inode); 384 struct exofs_i_info *oi = exofs_i(inode);
385 loff_t i_size = i_size_read(inode); 385 loff_t i_size = i_size_read(inode);
386 pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT; 386 pgoff_t end_index = i_size >> PAGE_SHIFT;
387 size_t len; 387 size_t len;
388 int ret; 388 int ret;
389 389
@@ -397,9 +397,9 @@ static int readpage_strip(void *data, struct page *page)
397 pcol->that_locked_page = page; 397 pcol->that_locked_page = page;
398 398
399 if (page->index < end_index) 399 if (page->index < end_index)
400 len = PAGE_CACHE_SIZE; 400 len = PAGE_SIZE;
401 else if (page->index == end_index) 401 else if (page->index == end_index)
402 len = i_size & ~PAGE_CACHE_MASK; 402 len = i_size & ~PAGE_MASK;
403 else 403 else
404 len = 0; 404 len = 0;
405 405
@@ -442,8 +442,8 @@ try_again:
442 goto fail; 442 goto fail;
443 } 443 }
444 444
445 if (len != PAGE_CACHE_SIZE) 445 if (len != PAGE_SIZE)
446 zero_user(page, len, PAGE_CACHE_SIZE - len); 446 zero_user(page, len, PAGE_SIZE - len);
447 447
448 EXOFS_DBGMSG2(" readpage_strip(0x%lx, 0x%lx) len=0x%zx\n", 448 EXOFS_DBGMSG2(" readpage_strip(0x%lx, 0x%lx) len=0x%zx\n",
449 inode->i_ino, page->index, len); 449 inode->i_ino, page->index, len);
@@ -609,7 +609,7 @@ static void __r4w_put_page(void *priv, struct page *page)
609 609
610 if ((pcol->that_locked_page != page) && (ZERO_PAGE(0) != page)) { 610 if ((pcol->that_locked_page != page) && (ZERO_PAGE(0) != page)) {
611 EXOFS_DBGMSG2("index=0x%lx\n", page->index); 611 EXOFS_DBGMSG2("index=0x%lx\n", page->index);
612 page_cache_release(page); 612 put_page(page);
613 return; 613 return;
614 } 614 }
615 EXOFS_DBGMSG2("that_locked_page index=0x%lx\n", 615 EXOFS_DBGMSG2("that_locked_page index=0x%lx\n",
@@ -633,7 +633,7 @@ static int write_exec(struct page_collect *pcol)
633 633
634 BUG_ON(pcol->ios); 634 BUG_ON(pcol->ios);
635 ret = ore_get_rw_state(&pcol->sbi->layout, &oi->oc, false, 635 ret = ore_get_rw_state(&pcol->sbi->layout, &oi->oc, false,
636 pcol->pg_first << PAGE_CACHE_SHIFT, 636 pcol->pg_first << PAGE_SHIFT,
637 pcol->length, &pcol->ios); 637 pcol->length, &pcol->ios);
638 if (unlikely(ret)) 638 if (unlikely(ret))
639 goto err; 639 goto err;
@@ -696,7 +696,7 @@ static int writepage_strip(struct page *page,
696 struct inode *inode = pcol->inode; 696 struct inode *inode = pcol->inode;
697 struct exofs_i_info *oi = exofs_i(inode); 697 struct exofs_i_info *oi = exofs_i(inode);
698 loff_t i_size = i_size_read(inode); 698 loff_t i_size = i_size_read(inode);
699 pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT; 699 pgoff_t end_index = i_size >> PAGE_SHIFT;
700 size_t len; 700 size_t len;
701 int ret; 701 int ret;
702 702
@@ -708,9 +708,9 @@ static int writepage_strip(struct page *page,
708 708
709 if (page->index < end_index) 709 if (page->index < end_index)
710 /* in this case, the page is within the limits of the file */ 710 /* in this case, the page is within the limits of the file */
711 len = PAGE_CACHE_SIZE; 711 len = PAGE_SIZE;
712 else { 712 else {
713 len = i_size & ~PAGE_CACHE_MASK; 713 len = i_size & ~PAGE_MASK;
714 714
715 if (page->index > end_index || !len) { 715 if (page->index > end_index || !len) {
716 /* in this case, the page is outside the limits 716 /* in this case, the page is outside the limits
@@ -790,10 +790,10 @@ static int exofs_writepages(struct address_space *mapping,
790 long start, end, expected_pages; 790 long start, end, expected_pages;
791 int ret; 791 int ret;
792 792
793 start = wbc->range_start >> PAGE_CACHE_SHIFT; 793 start = wbc->range_start >> PAGE_SHIFT;
794 end = (wbc->range_end == LLONG_MAX) ? 794 end = (wbc->range_end == LLONG_MAX) ?
795 start + mapping->nrpages : 795 start + mapping->nrpages :
796 wbc->range_end >> PAGE_CACHE_SHIFT; 796 wbc->range_end >> PAGE_SHIFT;
797 797
798 if (start || end) 798 if (start || end)
799 expected_pages = end - start + 1; 799 expected_pages = end - start + 1;
@@ -881,15 +881,15 @@ int exofs_write_begin(struct file *file, struct address_space *mapping,
881 } 881 }
882 882
883 /* read modify write */ 883 /* read modify write */
884 if (!PageUptodate(page) && (len != PAGE_CACHE_SIZE)) { 884 if (!PageUptodate(page) && (len != PAGE_SIZE)) {
885 loff_t i_size = i_size_read(mapping->host); 885 loff_t i_size = i_size_read(mapping->host);
886 pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT; 886 pgoff_t end_index = i_size >> PAGE_SHIFT;
887 size_t rlen; 887 size_t rlen;
888 888
889 if (page->index < end_index) 889 if (page->index < end_index)
890 rlen = PAGE_CACHE_SIZE; 890 rlen = PAGE_SIZE;
891 else if (page->index == end_index) 891 else if (page->index == end_index)
892 rlen = i_size & ~PAGE_CACHE_MASK; 892 rlen = i_size & ~PAGE_MASK;
893 else 893 else
894 rlen = 0; 894 rlen = 0;
895 895
diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c
index c20d77df2679..622a686bb08b 100644
--- a/fs/exofs/namei.c
+++ b/fs/exofs/namei.c
@@ -292,11 +292,11 @@ static int exofs_rename(struct inode *old_dir, struct dentry *old_dentry,
292out_dir: 292out_dir:
293 if (dir_de) { 293 if (dir_de) {
294 kunmap(dir_page); 294 kunmap(dir_page);
295 page_cache_release(dir_page); 295 put_page(dir_page);
296 } 296 }
297out_old: 297out_old:
298 kunmap(old_page); 298 kunmap(old_page);
299 page_cache_release(old_page); 299 put_page(old_page);
300out: 300out:
301 return err; 301 return err;
302} 302}