aboutsummaryrefslogtreecommitdiffstats
path: root/fs/splice.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/splice.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/splice.c')
-rw-r--r--fs/splice.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/fs/splice.c b/fs/splice.c
index 9947b5c69664..b018eb485019 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -88,7 +88,7 @@ out_unlock:
88static void page_cache_pipe_buf_release(struct pipe_inode_info *pipe, 88static void page_cache_pipe_buf_release(struct pipe_inode_info *pipe,
89 struct pipe_buffer *buf) 89 struct pipe_buffer *buf)
90{ 90{
91 page_cache_release(buf->page); 91 put_page(buf->page);
92 buf->flags &= ~PIPE_BUF_FLAG_LRU; 92 buf->flags &= ~PIPE_BUF_FLAG_LRU;
93} 93}
94 94
@@ -268,7 +268,7 @@ EXPORT_SYMBOL_GPL(splice_to_pipe);
268 268
269void spd_release_page(struct splice_pipe_desc *spd, unsigned int i) 269void spd_release_page(struct splice_pipe_desc *spd, unsigned int i)
270{ 270{
271 page_cache_release(spd->pages[i]); 271 put_page(spd->pages[i]);
272} 272}
273 273
274/* 274/*
@@ -328,9 +328,9 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
328 if (splice_grow_spd(pipe, &spd)) 328 if (splice_grow_spd(pipe, &spd))
329 return -ENOMEM; 329 return -ENOMEM;
330 330
331 index = *ppos >> PAGE_CACHE_SHIFT; 331 index = *ppos >> PAGE_SHIFT;
332 loff = *ppos & ~PAGE_CACHE_MASK; 332 loff = *ppos & ~PAGE_MASK;
333 req_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 333 req_pages = (len + loff + PAGE_SIZE - 1) >> PAGE_SHIFT;
334 nr_pages = min(req_pages, spd.nr_pages_max); 334 nr_pages = min(req_pages, spd.nr_pages_max);
335 335
336 /* 336 /*
@@ -365,7 +365,7 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
365 error = add_to_page_cache_lru(page, mapping, index, 365 error = add_to_page_cache_lru(page, mapping, index,
366 mapping_gfp_constraint(mapping, GFP_KERNEL)); 366 mapping_gfp_constraint(mapping, GFP_KERNEL));
367 if (unlikely(error)) { 367 if (unlikely(error)) {
368 page_cache_release(page); 368 put_page(page);
369 if (error == -EEXIST) 369 if (error == -EEXIST)
370 continue; 370 continue;
371 break; 371 break;
@@ -385,7 +385,7 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
385 * Now loop over the map and see if we need to start IO on any 385 * Now loop over the map and see if we need to start IO on any
386 * pages, fill in the partial map, etc. 386 * pages, fill in the partial map, etc.
387 */ 387 */
388 index = *ppos >> PAGE_CACHE_SHIFT; 388 index = *ppos >> PAGE_SHIFT;
389 nr_pages = spd.nr_pages; 389 nr_pages = spd.nr_pages;
390 spd.nr_pages = 0; 390 spd.nr_pages = 0;
391 for (page_nr = 0; page_nr < nr_pages; page_nr++) { 391 for (page_nr = 0; page_nr < nr_pages; page_nr++) {
@@ -397,7 +397,7 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
397 /* 397 /*
398 * this_len is the max we'll use from this page 398 * this_len is the max we'll use from this page
399 */ 399 */
400 this_len = min_t(unsigned long, len, PAGE_CACHE_SIZE - loff); 400 this_len = min_t(unsigned long, len, PAGE_SIZE - loff);
401 page = spd.pages[page_nr]; 401 page = spd.pages[page_nr];
402 402
403 if (PageReadahead(page)) 403 if (PageReadahead(page))
@@ -426,7 +426,7 @@ retry_lookup:
426 error = -ENOMEM; 426 error = -ENOMEM;
427 break; 427 break;
428 } 428 }
429 page_cache_release(spd.pages[page_nr]); 429 put_page(spd.pages[page_nr]);
430 spd.pages[page_nr] = page; 430 spd.pages[page_nr] = page;
431 } 431 }
432 /* 432 /*
@@ -456,7 +456,7 @@ fill_it:
456 * i_size must be checked after PageUptodate. 456 * i_size must be checked after PageUptodate.
457 */ 457 */
458 isize = i_size_read(mapping->host); 458 isize = i_size_read(mapping->host);
459 end_index = (isize - 1) >> PAGE_CACHE_SHIFT; 459 end_index = (isize - 1) >> PAGE_SHIFT;
460 if (unlikely(!isize || index > end_index)) 460 if (unlikely(!isize || index > end_index))
461 break; 461 break;
462 462
@@ -470,7 +470,7 @@ fill_it:
470 /* 470 /*
471 * max good bytes in this page 471 * max good bytes in this page
472 */ 472 */
473 plen = ((isize - 1) & ~PAGE_CACHE_MASK) + 1; 473 plen = ((isize - 1) & ~PAGE_MASK) + 1;
474 if (plen <= loff) 474 if (plen <= loff)
475 break; 475 break;
476 476
@@ -494,8 +494,8 @@ fill_it:
494 * we got, 'nr_pages' is how many pages are in the map. 494 * we got, 'nr_pages' is how many pages are in the map.
495 */ 495 */
496 while (page_nr < nr_pages) 496 while (page_nr < nr_pages)
497 page_cache_release(spd.pages[page_nr++]); 497 put_page(spd.pages[page_nr++]);
498 in->f_ra.prev_pos = (loff_t)index << PAGE_CACHE_SHIFT; 498 in->f_ra.prev_pos = (loff_t)index << PAGE_SHIFT;
499 499
500 if (spd.nr_pages) 500 if (spd.nr_pages)
501 error = splice_to_pipe(pipe, &spd); 501 error = splice_to_pipe(pipe, &spd);
@@ -636,8 +636,8 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
636 goto shrink_ret; 636 goto shrink_ret;
637 } 637 }
638 638
639 offset = *ppos & ~PAGE_CACHE_MASK; 639 offset = *ppos & ~PAGE_MASK;
640 nr_pages = (len + offset + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 640 nr_pages = (len + offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
641 641
642 for (i = 0; i < nr_pages && i < spd.nr_pages_max && len; i++) { 642 for (i = 0; i < nr_pages && i < spd.nr_pages_max && len; i++) {
643 struct page *page; 643 struct page *page;
@@ -647,7 +647,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
647 if (!page) 647 if (!page)
648 goto err; 648 goto err;
649 649
650 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset); 650 this_len = min_t(size_t, len, PAGE_SIZE - offset);
651 vec[i].iov_base = (void __user *) page_address(page); 651 vec[i].iov_base = (void __user *) page_address(page);
652 vec[i].iov_len = this_len; 652 vec[i].iov_len = this_len;
653 spd.pages[i] = page; 653 spd.pages[i] = page;