summaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/inode.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/reiserfs/inode.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/reiserfs/inode.c')
-rw-r--r--fs/reiserfs/inode.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index ae9e5b308cf9..d5c2e9c865de 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -386,7 +386,7 @@ static int _get_block_create_0(struct inode *inode, sector_t block,
386 goto finished; 386 goto finished;
387 } 387 }
388 /* read file tail into part of page */ 388 /* read file tail into part of page */
389 offset = (cpu_key_k_offset(&key) - 1) & (PAGE_CACHE_SIZE - 1); 389 offset = (cpu_key_k_offset(&key) - 1) & (PAGE_SIZE - 1);
390 copy_item_head(&tmp_ih, ih); 390 copy_item_head(&tmp_ih, ih);
391 391
392 /* 392 /*
@@ -587,10 +587,10 @@ static int convert_tail_for_hole(struct inode *inode,
587 return -EIO; 587 return -EIO;
588 588
589 /* always try to read until the end of the block */ 589 /* always try to read until the end of the block */
590 tail_start = tail_offset & (PAGE_CACHE_SIZE - 1); 590 tail_start = tail_offset & (PAGE_SIZE - 1);
591 tail_end = (tail_start | (bh_result->b_size - 1)) + 1; 591 tail_end = (tail_start | (bh_result->b_size - 1)) + 1;
592 592
593 index = tail_offset >> PAGE_CACHE_SHIFT; 593 index = tail_offset >> PAGE_SHIFT;
594 /* 594 /*
595 * hole_page can be zero in case of direct_io, we are sure 595 * hole_page can be zero in case of direct_io, we are sure
596 * that we cannot get here if we write with O_DIRECT into tail page 596 * that we cannot get here if we write with O_DIRECT into tail page
@@ -629,7 +629,7 @@ static int convert_tail_for_hole(struct inode *inode,
629unlock: 629unlock:
630 if (tail_page != hole_page) { 630 if (tail_page != hole_page) {
631 unlock_page(tail_page); 631 unlock_page(tail_page);
632 page_cache_release(tail_page); 632 put_page(tail_page);
633 } 633 }
634out: 634out:
635 return retval; 635 return retval;
@@ -2189,11 +2189,11 @@ static int grab_tail_page(struct inode *inode,
2189 * we want the page with the last byte in the file, 2189 * we want the page with the last byte in the file,
2190 * not the page that will hold the next byte for appending 2190 * not the page that will hold the next byte for appending
2191 */ 2191 */
2192 unsigned long index = (inode->i_size - 1) >> PAGE_CACHE_SHIFT; 2192 unsigned long index = (inode->i_size - 1) >> PAGE_SHIFT;
2193 unsigned long pos = 0; 2193 unsigned long pos = 0;
2194 unsigned long start = 0; 2194 unsigned long start = 0;
2195 unsigned long blocksize = inode->i_sb->s_blocksize; 2195 unsigned long blocksize = inode->i_sb->s_blocksize;
2196 unsigned long offset = (inode->i_size) & (PAGE_CACHE_SIZE - 1); 2196 unsigned long offset = (inode->i_size) & (PAGE_SIZE - 1);
2197 struct buffer_head *bh; 2197 struct buffer_head *bh;
2198 struct buffer_head *head; 2198 struct buffer_head *head;
2199 struct page *page; 2199 struct page *page;
@@ -2251,7 +2251,7 @@ out:
2251 2251
2252unlock: 2252unlock:
2253 unlock_page(page); 2253 unlock_page(page);
2254 page_cache_release(page); 2254 put_page(page);
2255 return error; 2255 return error;
2256} 2256}
2257 2257
@@ -2265,7 +2265,7 @@ int reiserfs_truncate_file(struct inode *inode, int update_timestamps)
2265{ 2265{
2266 struct reiserfs_transaction_handle th; 2266 struct reiserfs_transaction_handle th;
2267 /* we want the offset for the first byte after the end of the file */ 2267 /* we want the offset for the first byte after the end of the file */
2268 unsigned long offset = inode->i_size & (PAGE_CACHE_SIZE - 1); 2268 unsigned long offset = inode->i_size & (PAGE_SIZE - 1);
2269 unsigned blocksize = inode->i_sb->s_blocksize; 2269 unsigned blocksize = inode->i_sb->s_blocksize;
2270 unsigned length; 2270 unsigned length;
2271 struct page *page = NULL; 2271 struct page *page = NULL;
@@ -2345,7 +2345,7 @@ int reiserfs_truncate_file(struct inode *inode, int update_timestamps)
2345 } 2345 }
2346 } 2346 }
2347 unlock_page(page); 2347 unlock_page(page);
2348 page_cache_release(page); 2348 put_page(page);
2349 } 2349 }
2350 2350
2351 reiserfs_write_unlock(inode->i_sb); 2351 reiserfs_write_unlock(inode->i_sb);
@@ -2354,7 +2354,7 @@ int reiserfs_truncate_file(struct inode *inode, int update_timestamps)
2354out: 2354out:
2355 if (page) { 2355 if (page) {
2356 unlock_page(page); 2356 unlock_page(page);
2357 page_cache_release(page); 2357 put_page(page);
2358 } 2358 }
2359 2359
2360 reiserfs_write_unlock(inode->i_sb); 2360 reiserfs_write_unlock(inode->i_sb);
@@ -2426,7 +2426,7 @@ research:
2426 } else if (is_direct_le_ih(ih)) { 2426 } else if (is_direct_le_ih(ih)) {
2427 char *p; 2427 char *p;
2428 p = page_address(bh_result->b_page); 2428 p = page_address(bh_result->b_page);
2429 p += (byte_offset - 1) & (PAGE_CACHE_SIZE - 1); 2429 p += (byte_offset - 1) & (PAGE_SIZE - 1);
2430 copy_size = ih_item_len(ih) - pos_in_item; 2430 copy_size = ih_item_len(ih) - pos_in_item;
2431 2431
2432 fs_gen = get_generation(inode->i_sb); 2432 fs_gen = get_generation(inode->i_sb);
@@ -2525,7 +2525,7 @@ static int reiserfs_write_full_page(struct page *page,
2525 struct writeback_control *wbc) 2525 struct writeback_control *wbc)
2526{ 2526{
2527 struct inode *inode = page->mapping->host; 2527 struct inode *inode = page->mapping->host;
2528 unsigned long end_index = inode->i_size >> PAGE_CACHE_SHIFT; 2528 unsigned long end_index = inode->i_size >> PAGE_SHIFT;
2529 int error = 0; 2529 int error = 0;
2530 unsigned long block; 2530 unsigned long block;
2531 sector_t last_block; 2531 sector_t last_block;
@@ -2535,7 +2535,7 @@ static int reiserfs_write_full_page(struct page *page,
2535 int checked = PageChecked(page); 2535 int checked = PageChecked(page);
2536 struct reiserfs_transaction_handle th; 2536 struct reiserfs_transaction_handle th;
2537 struct super_block *s = inode->i_sb; 2537 struct super_block *s = inode->i_sb;
2538 int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize; 2538 int bh_per_page = PAGE_SIZE / s->s_blocksize;
2539 th.t_trans_id = 0; 2539 th.t_trans_id = 0;
2540 2540
2541 /* no logging allowed when nonblocking or from PF_MEMALLOC */ 2541 /* no logging allowed when nonblocking or from PF_MEMALLOC */
@@ -2564,16 +2564,16 @@ static int reiserfs_write_full_page(struct page *page,
2564 if (page->index >= end_index) { 2564 if (page->index >= end_index) {
2565 unsigned last_offset; 2565 unsigned last_offset;
2566 2566
2567 last_offset = inode->i_size & (PAGE_CACHE_SIZE - 1); 2567 last_offset = inode->i_size & (PAGE_SIZE - 1);
2568 /* no file contents in this page */ 2568 /* no file contents in this page */
2569 if (page->index >= end_index + 1 || !last_offset) { 2569 if (page->index >= end_index + 1 || !last_offset) {
2570 unlock_page(page); 2570 unlock_page(page);
2571 return 0; 2571 return 0;
2572 } 2572 }
2573 zero_user_segment(page, last_offset, PAGE_CACHE_SIZE); 2573 zero_user_segment(page, last_offset, PAGE_SIZE);
2574 } 2574 }
2575 bh = head; 2575 bh = head;
2576 block = page->index << (PAGE_CACHE_SHIFT - s->s_blocksize_bits); 2576 block = page->index << (PAGE_SHIFT - s->s_blocksize_bits);
2577 last_block = (i_size_read(inode) - 1) >> inode->i_blkbits; 2577 last_block = (i_size_read(inode) - 1) >> inode->i_blkbits;
2578 /* first map all the buffers, logging any direct items we find */ 2578 /* first map all the buffers, logging any direct items we find */
2579 do { 2579 do {
@@ -2774,7 +2774,7 @@ static int reiserfs_write_begin(struct file *file,
2774 *fsdata = (void *)(unsigned long)flags; 2774 *fsdata = (void *)(unsigned long)flags;
2775 } 2775 }
2776 2776
2777 index = pos >> PAGE_CACHE_SHIFT; 2777 index = pos >> PAGE_SHIFT;
2778 page = grab_cache_page_write_begin(mapping, index, flags); 2778 page = grab_cache_page_write_begin(mapping, index, flags);
2779 if (!page) 2779 if (!page)
2780 return -ENOMEM; 2780 return -ENOMEM;
@@ -2822,7 +2822,7 @@ static int reiserfs_write_begin(struct file *file,
2822 } 2822 }
2823 if (ret) { 2823 if (ret) {
2824 unlock_page(page); 2824 unlock_page(page);
2825 page_cache_release(page); 2825 put_page(page);
2826 /* Truncate allocated blocks */ 2826 /* Truncate allocated blocks */
2827 reiserfs_truncate_failed_write(inode); 2827 reiserfs_truncate_failed_write(inode);
2828 } 2828 }
@@ -2909,7 +2909,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping,
2909 else 2909 else
2910 th = NULL; 2910 th = NULL;
2911 2911
2912 start = pos & (PAGE_CACHE_SIZE - 1); 2912 start = pos & (PAGE_SIZE - 1);
2913 if (unlikely(copied < len)) { 2913 if (unlikely(copied < len)) {
2914 if (!PageUptodate(page)) 2914 if (!PageUptodate(page))
2915 copied = 0; 2915 copied = 0;
@@ -2974,7 +2974,7 @@ out:
2974 if (locked) 2974 if (locked)
2975 reiserfs_write_unlock(inode->i_sb); 2975 reiserfs_write_unlock(inode->i_sb);
2976 unlock_page(page); 2976 unlock_page(page);
2977 page_cache_release(page); 2977 put_page(page);
2978 2978
2979 if (pos + len > inode->i_size) 2979 if (pos + len > inode->i_size)
2980 reiserfs_truncate_failed_write(inode); 2980 reiserfs_truncate_failed_write(inode);
@@ -2996,7 +2996,7 @@ int reiserfs_commit_write(struct file *f, struct page *page,
2996 unsigned from, unsigned to) 2996 unsigned from, unsigned to)
2997{ 2997{
2998 struct inode *inode = page->mapping->host; 2998 struct inode *inode = page->mapping->host;
2999 loff_t pos = ((loff_t) page->index << PAGE_CACHE_SHIFT) + to; 2999 loff_t pos = ((loff_t) page->index << PAGE_SHIFT) + to;
3000 int ret = 0; 3000 int ret = 0;
3001 int update_sd = 0; 3001 int update_sd = 0;
3002 struct reiserfs_transaction_handle *th = NULL; 3002 struct reiserfs_transaction_handle *th = NULL;
@@ -3181,7 +3181,7 @@ static void reiserfs_invalidatepage(struct page *page, unsigned int offset,
3181 struct inode *inode = page->mapping->host; 3181 struct inode *inode = page->mapping->host;
3182 unsigned int curr_off = 0; 3182 unsigned int curr_off = 0;
3183 unsigned int stop = offset + length; 3183 unsigned int stop = offset + length;
3184 int partial_page = (offset || length < PAGE_CACHE_SIZE); 3184 int partial_page = (offset || length < PAGE_SIZE);
3185 int ret = 1; 3185 int ret = 1;
3186 3186
3187 BUG_ON(!PageLocked(page)); 3187 BUG_ON(!PageLocked(page));