aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fuse/dev.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/fuse/dev.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/fuse/dev.c')
-rw-r--r--fs/fuse/dev.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ebb5e37455a0..cbece1221417 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -897,7 +897,7 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
897 return err; 897 return err;
898 } 898 }
899 899
900 page_cache_get(newpage); 900 get_page(newpage);
901 901
902 if (!(buf->flags & PIPE_BUF_FLAG_LRU)) 902 if (!(buf->flags & PIPE_BUF_FLAG_LRU))
903 lru_cache_add_file(newpage); 903 lru_cache_add_file(newpage);
@@ -912,12 +912,12 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
912 912
913 if (err) { 913 if (err) {
914 unlock_page(newpage); 914 unlock_page(newpage);
915 page_cache_release(newpage); 915 put_page(newpage);
916 return err; 916 return err;
917 } 917 }
918 918
919 unlock_page(oldpage); 919 unlock_page(oldpage);
920 page_cache_release(oldpage); 920 put_page(oldpage);
921 cs->len = 0; 921 cs->len = 0;
922 922
923 return 0; 923 return 0;
@@ -951,7 +951,7 @@ static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page,
951 fuse_copy_finish(cs); 951 fuse_copy_finish(cs);
952 952
953 buf = cs->pipebufs; 953 buf = cs->pipebufs;
954 page_cache_get(page); 954 get_page(page);
955 buf->page = page; 955 buf->page = page;
956 buf->offset = offset; 956 buf->offset = offset;
957 buf->len = count; 957 buf->len = count;
@@ -1435,7 +1435,7 @@ out_unlock:
1435 1435
1436out: 1436out:
1437 for (; page_nr < cs.nr_segs; page_nr++) 1437 for (; page_nr < cs.nr_segs; page_nr++)
1438 page_cache_release(bufs[page_nr].page); 1438 put_page(bufs[page_nr].page);
1439 1439
1440 kfree(bufs); 1440 kfree(bufs);
1441 return ret; 1441 return ret;
@@ -1632,8 +1632,8 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size,
1632 goto out_up_killsb; 1632 goto out_up_killsb;
1633 1633
1634 mapping = inode->i_mapping; 1634 mapping = inode->i_mapping;
1635 index = outarg.offset >> PAGE_CACHE_SHIFT; 1635 index = outarg.offset >> PAGE_SHIFT;
1636 offset = outarg.offset & ~PAGE_CACHE_MASK; 1636 offset = outarg.offset & ~PAGE_MASK;
1637 file_size = i_size_read(inode); 1637 file_size = i_size_read(inode);
1638 end = outarg.offset + outarg.size; 1638 end = outarg.offset + outarg.size;
1639 if (end > file_size) { 1639 if (end > file_size) {
@@ -1652,13 +1652,13 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size,
1652 if (!page) 1652 if (!page)
1653 goto out_iput; 1653 goto out_iput;
1654 1654
1655 this_num = min_t(unsigned, num, PAGE_CACHE_SIZE - offset); 1655 this_num = min_t(unsigned, num, PAGE_SIZE - offset);
1656 err = fuse_copy_page(cs, &page, offset, this_num, 0); 1656 err = fuse_copy_page(cs, &page, offset, this_num, 0);
1657 if (!err && offset == 0 && 1657 if (!err && offset == 0 &&
1658 (this_num == PAGE_CACHE_SIZE || file_size == end)) 1658 (this_num == PAGE_SIZE || file_size == end))
1659 SetPageUptodate(page); 1659 SetPageUptodate(page);
1660 unlock_page(page); 1660 unlock_page(page);
1661 page_cache_release(page); 1661 put_page(page);
1662 1662
1663 if (err) 1663 if (err)
1664 goto out_iput; 1664 goto out_iput;
@@ -1697,7 +1697,7 @@ static int fuse_retrieve(struct fuse_conn *fc, struct inode *inode,
1697 size_t total_len = 0; 1697 size_t total_len = 0;
1698 int num_pages; 1698 int num_pages;
1699 1699
1700 offset = outarg->offset & ~PAGE_CACHE_MASK; 1700 offset = outarg->offset & ~PAGE_MASK;
1701 file_size = i_size_read(inode); 1701 file_size = i_size_read(inode);
1702 1702
1703 num = outarg->size; 1703 num = outarg->size;
@@ -1720,7 +1720,7 @@ static int fuse_retrieve(struct fuse_conn *fc, struct inode *inode,
1720 req->page_descs[0].offset = offset; 1720 req->page_descs[0].offset = offset;
1721 req->end = fuse_retrieve_end; 1721 req->end = fuse_retrieve_end;
1722 1722
1723 index = outarg->offset >> PAGE_CACHE_SHIFT; 1723 index = outarg->offset >> PAGE_SHIFT;
1724 1724
1725 while (num && req->num_pages < num_pages) { 1725 while (num && req->num_pages < num_pages) {
1726 struct page *page; 1726 struct page *page;
@@ -1730,7 +1730,7 @@ static int fuse_retrieve(struct fuse_conn *fc, struct inode *inode,
1730 if (!page) 1730 if (!page)
1731 break; 1731 break;
1732 1732
1733 this_num = min_t(unsigned, num, PAGE_CACHE_SIZE - offset); 1733 this_num = min_t(unsigned, num, PAGE_SIZE - offset);
1734 req->pages[req->num_pages] = page; 1734 req->pages[req->num_pages] = page;
1735 req->page_descs[req->num_pages].length = this_num; 1735 req->page_descs[req->num_pages].length = this_num;
1736 req->num_pages++; 1736 req->num_pages++;