aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/read_write.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/ecryptfs/read_write.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/ecryptfs/read_write.c')
-rw-r--r--fs/ecryptfs/read_write.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
index 09fe622274e4..158a3a39f82d 100644
--- a/fs/ecryptfs/read_write.c
+++ b/fs/ecryptfs/read_write.c
@@ -74,7 +74,7 @@ int ecryptfs_write_lower_page_segment(struct inode *ecryptfs_inode,
74 loff_t offset; 74 loff_t offset;
75 int rc; 75 int rc;
76 76
77 offset = ((((loff_t)page_for_lower->index) << PAGE_CACHE_SHIFT) 77 offset = ((((loff_t)page_for_lower->index) << PAGE_SHIFT)
78 + offset_in_page); 78 + offset_in_page);
79 virt = kmap(page_for_lower); 79 virt = kmap(page_for_lower);
80 rc = ecryptfs_write_lower(ecryptfs_inode, virt, offset, size); 80 rc = ecryptfs_write_lower(ecryptfs_inode, virt, offset, size);
@@ -123,9 +123,9 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
123 else 123 else
124 pos = offset; 124 pos = offset;
125 while (pos < (offset + size)) { 125 while (pos < (offset + size)) {
126 pgoff_t ecryptfs_page_idx = (pos >> PAGE_CACHE_SHIFT); 126 pgoff_t ecryptfs_page_idx = (pos >> PAGE_SHIFT);
127 size_t start_offset_in_page = (pos & ~PAGE_CACHE_MASK); 127 size_t start_offset_in_page = (pos & ~PAGE_MASK);
128 size_t num_bytes = (PAGE_CACHE_SIZE - start_offset_in_page); 128 size_t num_bytes = (PAGE_SIZE - start_offset_in_page);
129 loff_t total_remaining_bytes = ((offset + size) - pos); 129 loff_t total_remaining_bytes = ((offset + size) - pos);
130 130
131 if (fatal_signal_pending(current)) { 131 if (fatal_signal_pending(current)) {
@@ -165,7 +165,7 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
165 * Fill in zero values to the end of the page */ 165 * Fill in zero values to the end of the page */
166 memset(((char *)ecryptfs_page_virt 166 memset(((char *)ecryptfs_page_virt
167 + start_offset_in_page), 0, 167 + start_offset_in_page), 0,
168 PAGE_CACHE_SIZE - start_offset_in_page); 168 PAGE_SIZE - start_offset_in_page);
169 } 169 }
170 170
171 /* pos >= offset, we are now writing the data request */ 171 /* pos >= offset, we are now writing the data request */
@@ -186,7 +186,7 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
186 ecryptfs_page, 186 ecryptfs_page,
187 start_offset_in_page, 187 start_offset_in_page,
188 data_offset); 188 data_offset);
189 page_cache_release(ecryptfs_page); 189 put_page(ecryptfs_page);
190 if (rc) { 190 if (rc) {
191 printk(KERN_ERR "%s: Error encrypting " 191 printk(KERN_ERR "%s: Error encrypting "
192 "page; rc = [%d]\n", __func__, rc); 192 "page; rc = [%d]\n", __func__, rc);
@@ -262,7 +262,7 @@ int ecryptfs_read_lower_page_segment(struct page *page_for_ecryptfs,
262 loff_t offset; 262 loff_t offset;
263 int rc; 263 int rc;
264 264
265 offset = ((((loff_t)page_index) << PAGE_CACHE_SHIFT) + offset_in_page); 265 offset = ((((loff_t)page_index) << PAGE_SHIFT) + offset_in_page);
266 virt = kmap(page_for_ecryptfs); 266 virt = kmap(page_for_ecryptfs);
267 rc = ecryptfs_read_lower(virt, offset, size, ecryptfs_inode); 267 rc = ecryptfs_read_lower(virt, offset, size, ecryptfs_inode);
268 if (rc > 0) 268 if (rc > 0)