aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cramfs
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/cramfs
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/cramfs')
-rw-r--r--fs/cramfs/inode.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index b862bc219cd7..2096654dd26d 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -152,7 +152,7 @@ static struct inode *get_cramfs_inode(struct super_block *sb,
152 */ 152 */
153#define BLKS_PER_BUF_SHIFT (2) 153#define BLKS_PER_BUF_SHIFT (2)
154#define BLKS_PER_BUF (1 << BLKS_PER_BUF_SHIFT) 154#define BLKS_PER_BUF (1 << BLKS_PER_BUF_SHIFT)
155#define BUFFER_SIZE (BLKS_PER_BUF*PAGE_CACHE_SIZE) 155#define BUFFER_SIZE (BLKS_PER_BUF*PAGE_SIZE)
156 156
157static unsigned char read_buffers[READ_BUFFERS][BUFFER_SIZE]; 157static unsigned char read_buffers[READ_BUFFERS][BUFFER_SIZE];
158static unsigned buffer_blocknr[READ_BUFFERS]; 158static unsigned buffer_blocknr[READ_BUFFERS];
@@ -173,8 +173,8 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i
173 173
174 if (!len) 174 if (!len)
175 return NULL; 175 return NULL;
176 blocknr = offset >> PAGE_CACHE_SHIFT; 176 blocknr = offset >> PAGE_SHIFT;
177 offset &= PAGE_CACHE_SIZE - 1; 177 offset &= PAGE_SIZE - 1;
178 178
179 /* Check if an existing buffer already has the data.. */ 179 /* Check if an existing buffer already has the data.. */
180 for (i = 0; i < READ_BUFFERS; i++) { 180 for (i = 0; i < READ_BUFFERS; i++) {
@@ -184,14 +184,14 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i
184 continue; 184 continue;
185 if (blocknr < buffer_blocknr[i]) 185 if (blocknr < buffer_blocknr[i])
186 continue; 186 continue;
187 blk_offset = (blocknr - buffer_blocknr[i]) << PAGE_CACHE_SHIFT; 187 blk_offset = (blocknr - buffer_blocknr[i]) << PAGE_SHIFT;
188 blk_offset += offset; 188 blk_offset += offset;
189 if (blk_offset + len > BUFFER_SIZE) 189 if (blk_offset + len > BUFFER_SIZE)
190 continue; 190 continue;
191 return read_buffers[i] + blk_offset; 191 return read_buffers[i] + blk_offset;
192 } 192 }
193 193
194 devsize = mapping->host->i_size >> PAGE_CACHE_SHIFT; 194 devsize = mapping->host->i_size >> PAGE_SHIFT;
195 195
196 /* Ok, read in BLKS_PER_BUF pages completely first. */ 196 /* Ok, read in BLKS_PER_BUF pages completely first. */
197 for (i = 0; i < BLKS_PER_BUF; i++) { 197 for (i = 0; i < BLKS_PER_BUF; i++) {
@@ -213,7 +213,7 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i
213 wait_on_page_locked(page); 213 wait_on_page_locked(page);
214 if (!PageUptodate(page)) { 214 if (!PageUptodate(page)) {
215 /* asynchronous error */ 215 /* asynchronous error */
216 page_cache_release(page); 216 put_page(page);
217 pages[i] = NULL; 217 pages[i] = NULL;
218 } 218 }
219 } 219 }
@@ -229,12 +229,12 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i
229 struct page *page = pages[i]; 229 struct page *page = pages[i];
230 230
231 if (page) { 231 if (page) {
232 memcpy(data, kmap(page), PAGE_CACHE_SIZE); 232 memcpy(data, kmap(page), PAGE_SIZE);
233 kunmap(page); 233 kunmap(page);
234 page_cache_release(page); 234 put_page(page);
235 } else 235 } else
236 memset(data, 0, PAGE_CACHE_SIZE); 236 memset(data, 0, PAGE_SIZE);
237 data += PAGE_CACHE_SIZE; 237 data += PAGE_SIZE;
238 } 238 }
239 return read_buffers[buffer] + offset; 239 return read_buffers[buffer] + offset;
240} 240}
@@ -353,7 +353,7 @@ static int cramfs_statfs(struct dentry *dentry, struct kstatfs *buf)
353 u64 id = huge_encode_dev(sb->s_bdev->bd_dev); 353 u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
354 354
355 buf->f_type = CRAMFS_MAGIC; 355 buf->f_type = CRAMFS_MAGIC;
356 buf->f_bsize = PAGE_CACHE_SIZE; 356 buf->f_bsize = PAGE_SIZE;
357 buf->f_blocks = CRAMFS_SB(sb)->blocks; 357 buf->f_blocks = CRAMFS_SB(sb)->blocks;
358 buf->f_bfree = 0; 358 buf->f_bfree = 0;
359 buf->f_bavail = 0; 359 buf->f_bavail = 0;
@@ -496,7 +496,7 @@ static int cramfs_readpage(struct file *file, struct page *page)
496 int bytes_filled; 496 int bytes_filled;
497 void *pgdata; 497 void *pgdata;
498 498
499 maxblock = (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 499 maxblock = (inode->i_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
500 bytes_filled = 0; 500 bytes_filled = 0;
501 pgdata = kmap(page); 501 pgdata = kmap(page);
502 502
@@ -516,14 +516,14 @@ static int cramfs_readpage(struct file *file, struct page *page)
516 516
517 if (compr_len == 0) 517 if (compr_len == 0)
518 ; /* hole */ 518 ; /* hole */
519 else if (unlikely(compr_len > (PAGE_CACHE_SIZE << 1))) { 519 else if (unlikely(compr_len > (PAGE_SIZE << 1))) {
520 pr_err("bad compressed blocksize %u\n", 520 pr_err("bad compressed blocksize %u\n",
521 compr_len); 521 compr_len);
522 goto err; 522 goto err;
523 } else { 523 } else {
524 mutex_lock(&read_mutex); 524 mutex_lock(&read_mutex);
525 bytes_filled = cramfs_uncompress_block(pgdata, 525 bytes_filled = cramfs_uncompress_block(pgdata,
526 PAGE_CACHE_SIZE, 526 PAGE_SIZE,
527 cramfs_read(sb, start_offset, compr_len), 527 cramfs_read(sb, start_offset, compr_len),
528 compr_len); 528 compr_len);
529 mutex_unlock(&read_mutex); 529 mutex_unlock(&read_mutex);
@@ -532,7 +532,7 @@ static int cramfs_readpage(struct file *file, struct page *page)
532 } 532 }
533 } 533 }
534 534
535 memset(pgdata + bytes_filled, 0, PAGE_CACHE_SIZE - bytes_filled); 535 memset(pgdata + bytes_filled, 0, PAGE_SIZE - bytes_filled);
536 flush_dcache_page(page); 536 flush_dcache_page(page);
537 kunmap(page); 537 kunmap(page);
538 SetPageUptodate(page); 538 SetPageUptodate(page);