aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ntfs/super.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/ntfs/super.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/ntfs/super.c')
-rw-r--r--fs/ntfs/super.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 1b38abdaa3ed..ab2b0930054e 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -826,11 +826,11 @@ static bool parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b)
826 * We cannot support mft record sizes above the PAGE_CACHE_SIZE since 826 * We cannot support mft record sizes above the PAGE_CACHE_SIZE since
827 * we store $MFT/$DATA, the table of mft records in the page cache. 827 * we store $MFT/$DATA, the table of mft records in the page cache.
828 */ 828 */
829 if (vol->mft_record_size > PAGE_CACHE_SIZE) { 829 if (vol->mft_record_size > PAGE_SIZE) {
830 ntfs_error(vol->sb, "Mft record size (%i) exceeds the " 830 ntfs_error(vol->sb, "Mft record size (%i) exceeds the "
831 "PAGE_CACHE_SIZE on your system (%lu). " 831 "PAGE_CACHE_SIZE on your system (%lu). "
832 "This is not supported. Sorry.", 832 "This is not supported. Sorry.",
833 vol->mft_record_size, PAGE_CACHE_SIZE); 833 vol->mft_record_size, PAGE_SIZE);
834 return false; 834 return false;
835 } 835 }
836 /* We cannot support mft record sizes below the sector size. */ 836 /* We cannot support mft record sizes below the sector size. */
@@ -1096,7 +1096,7 @@ static bool check_mft_mirror(ntfs_volume *vol)
1096 1096
1097 ntfs_debug("Entering."); 1097 ntfs_debug("Entering.");
1098 /* Compare contents of $MFT and $MFTMirr. */ 1098 /* Compare contents of $MFT and $MFTMirr. */
1099 mrecs_per_page = PAGE_CACHE_SIZE / vol->mft_record_size; 1099 mrecs_per_page = PAGE_SIZE / vol->mft_record_size;
1100 BUG_ON(!mrecs_per_page); 1100 BUG_ON(!mrecs_per_page);
1101 BUG_ON(!vol->mftmirr_size); 1101 BUG_ON(!vol->mftmirr_size);
1102 mft_page = mirr_page = NULL; 1102 mft_page = mirr_page = NULL;
@@ -1615,20 +1615,20 @@ static bool load_and_init_attrdef(ntfs_volume *vol)
1615 if (!vol->attrdef) 1615 if (!vol->attrdef)
1616 goto iput_failed; 1616 goto iput_failed;
1617 index = 0; 1617 index = 0;
1618 max_index = i_size >> PAGE_CACHE_SHIFT; 1618 max_index = i_size >> PAGE_SHIFT;
1619 size = PAGE_CACHE_SIZE; 1619 size = PAGE_SIZE;
1620 while (index < max_index) { 1620 while (index < max_index) {
1621 /* Read the attrdef table and copy it into the linear buffer. */ 1621 /* Read the attrdef table and copy it into the linear buffer. */
1622read_partial_attrdef_page: 1622read_partial_attrdef_page:
1623 page = ntfs_map_page(ino->i_mapping, index); 1623 page = ntfs_map_page(ino->i_mapping, index);
1624 if (IS_ERR(page)) 1624 if (IS_ERR(page))
1625 goto free_iput_failed; 1625 goto free_iput_failed;
1626 memcpy((u8*)vol->attrdef + (index++ << PAGE_CACHE_SHIFT), 1626 memcpy((u8*)vol->attrdef + (index++ << PAGE_SHIFT),
1627 page_address(page), size); 1627 page_address(page), size);
1628 ntfs_unmap_page(page); 1628 ntfs_unmap_page(page);
1629 }; 1629 };
1630 if (size == PAGE_CACHE_SIZE) { 1630 if (size == PAGE_SIZE) {
1631 size = i_size & ~PAGE_CACHE_MASK; 1631 size = i_size & ~PAGE_MASK;
1632 if (size) 1632 if (size)
1633 goto read_partial_attrdef_page; 1633 goto read_partial_attrdef_page;
1634 } 1634 }
@@ -1684,20 +1684,20 @@ static bool load_and_init_upcase(ntfs_volume *vol)
1684 if (!vol->upcase) 1684 if (!vol->upcase)
1685 goto iput_upcase_failed; 1685 goto iput_upcase_failed;
1686 index = 0; 1686 index = 0;
1687 max_index = i_size >> PAGE_CACHE_SHIFT; 1687 max_index = i_size >> PAGE_SHIFT;
1688 size = PAGE_CACHE_SIZE; 1688 size = PAGE_SIZE;
1689 while (index < max_index) { 1689 while (index < max_index) {
1690 /* Read the upcase table and copy it into the linear buffer. */ 1690 /* Read the upcase table and copy it into the linear buffer. */
1691read_partial_upcase_page: 1691read_partial_upcase_page:
1692 page = ntfs_map_page(ino->i_mapping, index); 1692 page = ntfs_map_page(ino->i_mapping, index);
1693 if (IS_ERR(page)) 1693 if (IS_ERR(page))
1694 goto iput_upcase_failed; 1694 goto iput_upcase_failed;
1695 memcpy((char*)vol->upcase + (index++ << PAGE_CACHE_SHIFT), 1695 memcpy((char*)vol->upcase + (index++ << PAGE_SHIFT),
1696 page_address(page), size); 1696 page_address(page), size);
1697 ntfs_unmap_page(page); 1697 ntfs_unmap_page(page);
1698 }; 1698 };
1699 if (size == PAGE_CACHE_SIZE) { 1699 if (size == PAGE_SIZE) {
1700 size = i_size & ~PAGE_CACHE_MASK; 1700 size = i_size & ~PAGE_MASK;
1701 if (size) 1701 if (size)
1702 goto read_partial_upcase_page; 1702 goto read_partial_upcase_page;
1703 } 1703 }
@@ -2474,11 +2474,11 @@ static s64 get_nr_free_clusters(ntfs_volume *vol)
2474 * multiples of PAGE_CACHE_SIZE, rounding up so that if we have one 2474 * multiples of PAGE_CACHE_SIZE, rounding up so that if we have one
2475 * full and one partial page max_index = 2. 2475 * full and one partial page max_index = 2.
2476 */ 2476 */
2477 max_index = (((vol->nr_clusters + 7) >> 3) + PAGE_CACHE_SIZE - 1) >> 2477 max_index = (((vol->nr_clusters + 7) >> 3) + PAGE_SIZE - 1) >>
2478 PAGE_CACHE_SHIFT; 2478 PAGE_SHIFT;
2479 /* Use multiples of 4 bytes, thus max_size is PAGE_CACHE_SIZE / 4. */ 2479 /* Use multiples of 4 bytes, thus max_size is PAGE_CACHE_SIZE / 4. */
2480 ntfs_debug("Reading $Bitmap, max_index = 0x%lx, max_size = 0x%lx.", 2480 ntfs_debug("Reading $Bitmap, max_index = 0x%lx, max_size = 0x%lx.",
2481 max_index, PAGE_CACHE_SIZE / 4); 2481 max_index, PAGE_SIZE / 4);
2482 for (index = 0; index < max_index; index++) { 2482 for (index = 0; index < max_index; index++) {
2483 unsigned long *kaddr; 2483 unsigned long *kaddr;
2484 2484
@@ -2491,7 +2491,7 @@ static s64 get_nr_free_clusters(ntfs_volume *vol)
2491 if (IS_ERR(page)) { 2491 if (IS_ERR(page)) {
2492 ntfs_debug("read_mapping_page() error. Skipping " 2492 ntfs_debug("read_mapping_page() error. Skipping "
2493 "page (index 0x%lx).", index); 2493 "page (index 0x%lx).", index);
2494 nr_free -= PAGE_CACHE_SIZE * 8; 2494 nr_free -= PAGE_SIZE * 8;
2495 continue; 2495 continue;
2496 } 2496 }
2497 kaddr = kmap_atomic(page); 2497 kaddr = kmap_atomic(page);
@@ -2503,9 +2503,9 @@ static s64 get_nr_free_clusters(ntfs_volume *vol)
2503 * ntfs_readpage(). 2503 * ntfs_readpage().
2504 */ 2504 */
2505 nr_free -= bitmap_weight(kaddr, 2505 nr_free -= bitmap_weight(kaddr,
2506 PAGE_CACHE_SIZE * BITS_PER_BYTE); 2506 PAGE_SIZE * BITS_PER_BYTE);
2507 kunmap_atomic(kaddr); 2507 kunmap_atomic(kaddr);
2508 page_cache_release(page); 2508 put_page(page);
2509 } 2509 }
2510 ntfs_debug("Finished reading $Bitmap, last index = 0x%lx.", index - 1); 2510 ntfs_debug("Finished reading $Bitmap, last index = 0x%lx.", index - 1);
2511 /* 2511 /*
@@ -2549,7 +2549,7 @@ static unsigned long __get_nr_free_mft_records(ntfs_volume *vol,
2549 ntfs_debug("Entering."); 2549 ntfs_debug("Entering.");
2550 /* Use multiples of 4 bytes, thus max_size is PAGE_CACHE_SIZE / 4. */ 2550 /* Use multiples of 4 bytes, thus max_size is PAGE_CACHE_SIZE / 4. */
2551 ntfs_debug("Reading $MFT/$BITMAP, max_index = 0x%lx, max_size = " 2551 ntfs_debug("Reading $MFT/$BITMAP, max_index = 0x%lx, max_size = "
2552 "0x%lx.", max_index, PAGE_CACHE_SIZE / 4); 2552 "0x%lx.", max_index, PAGE_SIZE / 4);
2553 for (index = 0; index < max_index; index++) { 2553 for (index = 0; index < max_index; index++) {
2554 unsigned long *kaddr; 2554 unsigned long *kaddr;
2555 2555
@@ -2562,7 +2562,7 @@ static unsigned long __get_nr_free_mft_records(ntfs_volume *vol,
2562 if (IS_ERR(page)) { 2562 if (IS_ERR(page)) {
2563 ntfs_debug("read_mapping_page() error. Skipping " 2563 ntfs_debug("read_mapping_page() error. Skipping "
2564 "page (index 0x%lx).", index); 2564 "page (index 0x%lx).", index);
2565 nr_free -= PAGE_CACHE_SIZE * 8; 2565 nr_free -= PAGE_SIZE * 8;
2566 continue; 2566 continue;
2567 } 2567 }
2568 kaddr = kmap_atomic(page); 2568 kaddr = kmap_atomic(page);
@@ -2574,9 +2574,9 @@ static unsigned long __get_nr_free_mft_records(ntfs_volume *vol,
2574 * ntfs_readpage(). 2574 * ntfs_readpage().
2575 */ 2575 */
2576 nr_free -= bitmap_weight(kaddr, 2576 nr_free -= bitmap_weight(kaddr,
2577 PAGE_CACHE_SIZE * BITS_PER_BYTE); 2577 PAGE_SIZE * BITS_PER_BYTE);
2578 kunmap_atomic(kaddr); 2578 kunmap_atomic(kaddr);
2579 page_cache_release(page); 2579 put_page(page);
2580 } 2580 }
2581 ntfs_debug("Finished reading $MFT/$BITMAP, last index = 0x%lx.", 2581 ntfs_debug("Finished reading $MFT/$BITMAP, last index = 0x%lx.",
2582 index - 1); 2582 index - 1);
@@ -2618,17 +2618,17 @@ static int ntfs_statfs(struct dentry *dentry, struct kstatfs *sfs)
2618 /* Type of filesystem. */ 2618 /* Type of filesystem. */
2619 sfs->f_type = NTFS_SB_MAGIC; 2619 sfs->f_type = NTFS_SB_MAGIC;
2620 /* Optimal transfer block size. */ 2620 /* Optimal transfer block size. */
2621 sfs->f_bsize = PAGE_CACHE_SIZE; 2621 sfs->f_bsize = PAGE_SIZE;
2622 /* 2622 /*
2623 * Total data blocks in filesystem in units of f_bsize and since 2623 * Total data blocks in filesystem in units of f_bsize and since
2624 * inodes are also stored in data blocs ($MFT is a file) this is just 2624 * inodes are also stored in data blocs ($MFT is a file) this is just
2625 * the total clusters. 2625 * the total clusters.
2626 */ 2626 */
2627 sfs->f_blocks = vol->nr_clusters << vol->cluster_size_bits >> 2627 sfs->f_blocks = vol->nr_clusters << vol->cluster_size_bits >>
2628 PAGE_CACHE_SHIFT; 2628 PAGE_SHIFT;
2629 /* Free data blocks in filesystem in units of f_bsize. */ 2629 /* Free data blocks in filesystem in units of f_bsize. */
2630 size = get_nr_free_clusters(vol) << vol->cluster_size_bits >> 2630 size = get_nr_free_clusters(vol) << vol->cluster_size_bits >>
2631 PAGE_CACHE_SHIFT; 2631 PAGE_SHIFT;
2632 if (size < 0LL) 2632 if (size < 0LL)
2633 size = 0LL; 2633 size = 0LL;
2634 /* Free blocks avail to non-superuser, same as above on NTFS. */ 2634 /* Free blocks avail to non-superuser, same as above on NTFS. */
@@ -2643,7 +2643,7 @@ static int ntfs_statfs(struct dentry *dentry, struct kstatfs *sfs)
2643 * have one full and one partial page max_index = 2. 2643 * have one full and one partial page max_index = 2.
2644 */ 2644 */
2645 max_index = ((((mft_ni->initialized_size >> vol->mft_record_size_bits) 2645 max_index = ((((mft_ni->initialized_size >> vol->mft_record_size_bits)
2646 + 7) >> 3) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 2646 + 7) >> 3) + PAGE_SIZE - 1) >> PAGE_SHIFT;
2647 read_unlock_irqrestore(&mft_ni->size_lock, flags); 2647 read_unlock_irqrestore(&mft_ni->size_lock, flags);
2648 /* Number of inodes in filesystem (at this point in time). */ 2648 /* Number of inodes in filesystem (at this point in time). */
2649 sfs->f_files = size; 2649 sfs->f_files = size;
@@ -2766,14 +2766,14 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
2766 goto err_out_now; 2766 goto err_out_now;
2767 2767
2768 /* We support sector sizes up to the PAGE_CACHE_SIZE. */ 2768 /* We support sector sizes up to the PAGE_CACHE_SIZE. */
2769 if (bdev_logical_block_size(sb->s_bdev) > PAGE_CACHE_SIZE) { 2769 if (bdev_logical_block_size(sb->s_bdev) > PAGE_SIZE) {
2770 if (!silent) 2770 if (!silent)
2771 ntfs_error(sb, "Device has unsupported sector size " 2771 ntfs_error(sb, "Device has unsupported sector size "
2772 "(%i). The maximum supported sector " 2772 "(%i). The maximum supported sector "
2773 "size on this architecture is %lu " 2773 "size on this architecture is %lu "
2774 "bytes.", 2774 "bytes.",
2775 bdev_logical_block_size(sb->s_bdev), 2775 bdev_logical_block_size(sb->s_bdev),
2776 PAGE_CACHE_SIZE); 2776 PAGE_SIZE);
2777 goto err_out_now; 2777 goto err_out_now;
2778 } 2778 }
2779 /* 2779 /*