summaryrefslogtreecommitdiffstats
path: root/fs/squashfs/file.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/squashfs/file.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/squashfs/file.c')
-rw-r--r--fs/squashfs/file.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index e5c9689062ba..437de9e89221 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -175,7 +175,7 @@ static long long read_indexes(struct super_block *sb, int n,
175{ 175{
176 int err, i; 176 int err, i;
177 long long block = 0; 177 long long block = 0;
178 __le32 *blist = kmalloc(PAGE_CACHE_SIZE, GFP_KERNEL); 178 __le32 *blist = kmalloc(PAGE_SIZE, GFP_KERNEL);
179 179
180 if (blist == NULL) { 180 if (blist == NULL) {
181 ERROR("read_indexes: Failed to allocate block_list\n"); 181 ERROR("read_indexes: Failed to allocate block_list\n");
@@ -183,7 +183,7 @@ static long long read_indexes(struct super_block *sb, int n,
183 } 183 }
184 184
185 while (n) { 185 while (n) {
186 int blocks = min_t(int, n, PAGE_CACHE_SIZE >> 2); 186 int blocks = min_t(int, n, PAGE_SIZE >> 2);
187 187
188 err = squashfs_read_metadata(sb, blist, start_block, 188 err = squashfs_read_metadata(sb, blist, start_block,
189 offset, blocks << 2); 189 offset, blocks << 2);
@@ -377,7 +377,7 @@ void squashfs_copy_cache(struct page *page, struct squashfs_cache_entry *buffer,
377 struct inode *inode = page->mapping->host; 377 struct inode *inode = page->mapping->host;
378 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; 378 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
379 void *pageaddr; 379 void *pageaddr;
380 int i, mask = (1 << (msblk->block_log - PAGE_CACHE_SHIFT)) - 1; 380 int i, mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1;
381 int start_index = page->index & ~mask, end_index = start_index | mask; 381 int start_index = page->index & ~mask, end_index = start_index | mask;
382 382
383 /* 383 /*
@@ -387,9 +387,9 @@ void squashfs_copy_cache(struct page *page, struct squashfs_cache_entry *buffer,
387 * been called to fill. 387 * been called to fill.
388 */ 388 */
389 for (i = start_index; i <= end_index && bytes > 0; i++, 389 for (i = start_index; i <= end_index && bytes > 0; i++,
390 bytes -= PAGE_CACHE_SIZE, offset += PAGE_CACHE_SIZE) { 390 bytes -= PAGE_SIZE, offset += PAGE_SIZE) {
391 struct page *push_page; 391 struct page *push_page;
392 int avail = buffer ? min_t(int, bytes, PAGE_CACHE_SIZE) : 0; 392 int avail = buffer ? min_t(int, bytes, PAGE_SIZE) : 0;
393 393
394 TRACE("bytes %d, i %d, available_bytes %d\n", bytes, i, avail); 394 TRACE("bytes %d, i %d, available_bytes %d\n", bytes, i, avail);
395 395
@@ -404,14 +404,14 @@ void squashfs_copy_cache(struct page *page, struct squashfs_cache_entry *buffer,
404 404
405 pageaddr = kmap_atomic(push_page); 405 pageaddr = kmap_atomic(push_page);
406 squashfs_copy_data(pageaddr, buffer, offset, avail); 406 squashfs_copy_data(pageaddr, buffer, offset, avail);
407 memset(pageaddr + avail, 0, PAGE_CACHE_SIZE - avail); 407 memset(pageaddr + avail, 0, PAGE_SIZE - avail);
408 kunmap_atomic(pageaddr); 408 kunmap_atomic(pageaddr);
409 flush_dcache_page(push_page); 409 flush_dcache_page(push_page);
410 SetPageUptodate(push_page); 410 SetPageUptodate(push_page);
411skip_page: 411skip_page:
412 unlock_page(push_page); 412 unlock_page(push_page);
413 if (i != page->index) 413 if (i != page->index)
414 page_cache_release(push_page); 414 put_page(push_page);
415 } 415 }
416} 416}
417 417
@@ -454,7 +454,7 @@ static int squashfs_readpage(struct file *file, struct page *page)
454{ 454{
455 struct inode *inode = page->mapping->host; 455 struct inode *inode = page->mapping->host;
456 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; 456 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
457 int index = page->index >> (msblk->block_log - PAGE_CACHE_SHIFT); 457 int index = page->index >> (msblk->block_log - PAGE_SHIFT);
458 int file_end = i_size_read(inode) >> msblk->block_log; 458 int file_end = i_size_read(inode) >> msblk->block_log;
459 int res; 459 int res;
460 void *pageaddr; 460 void *pageaddr;
@@ -462,8 +462,8 @@ static int squashfs_readpage(struct file *file, struct page *page)
462 TRACE("Entered squashfs_readpage, page index %lx, start block %llx\n", 462 TRACE("Entered squashfs_readpage, page index %lx, start block %llx\n",
463 page->index, squashfs_i(inode)->start); 463 page->index, squashfs_i(inode)->start);
464 464
465 if (page->index >= ((i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> 465 if (page->index >= ((i_size_read(inode) + PAGE_SIZE - 1) >>
466 PAGE_CACHE_SHIFT)) 466 PAGE_SHIFT))
467 goto out; 467 goto out;
468 468
469 if (index < file_end || squashfs_i(inode)->fragment_block == 469 if (index < file_end || squashfs_i(inode)->fragment_block ==
@@ -487,7 +487,7 @@ error_out:
487 SetPageError(page); 487 SetPageError(page);
488out: 488out:
489 pageaddr = kmap_atomic(page); 489 pageaddr = kmap_atomic(page);
490 memset(pageaddr, 0, PAGE_CACHE_SIZE); 490 memset(pageaddr, 0, PAGE_SIZE);
491 kunmap_atomic(pageaddr); 491 kunmap_atomic(pageaddr);
492 flush_dcache_page(page); 492 flush_dcache_page(page);
493 if (!PageError(page)) 493 if (!PageError(page))