diff options
Diffstat (limited to 'fs/buffer.c')
-rw-r--r-- | fs/buffer.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/fs/buffer.c b/fs/buffer.c index 4342ab0ad99a..d597758dd129 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -426,8 +426,10 @@ __find_get_block_slow(struct block_device *bdev, sector_t block) | |||
426 | if (all_mapped) { | 426 | if (all_mapped) { |
427 | printk("__find_get_block_slow() failed. " | 427 | printk("__find_get_block_slow() failed. " |
428 | "block=%llu, b_blocknr=%llu\n", | 428 | "block=%llu, b_blocknr=%llu\n", |
429 | (unsigned long long)block, (unsigned long long)bh->b_blocknr); | 429 | (unsigned long long)block, |
430 | printk("b_state=0x%08lx, b_size=%u\n", bh->b_state, bh->b_size); | 430 | (unsigned long long)bh->b_blocknr); |
431 | printk("b_state=0x%08lx, b_size=%zu\n", | ||
432 | bh->b_state, bh->b_size); | ||
431 | printk("device blocksize: %d\n", 1 << bd_inode->i_blkbits); | 433 | printk("device blocksize: %d\n", 1 << bd_inode->i_blkbits); |
432 | } | 434 | } |
433 | out_unlock: | 435 | out_unlock: |
@@ -1590,11 +1592,10 @@ EXPORT_SYMBOL(try_to_release_page); | |||
1590 | * point. Because the caller is about to free (and possibly reuse) those | 1592 | * point. Because the caller is about to free (and possibly reuse) those |
1591 | * blocks on-disk. | 1593 | * blocks on-disk. |
1592 | */ | 1594 | */ |
1593 | int block_invalidatepage(struct page *page, unsigned long offset) | 1595 | void block_invalidatepage(struct page *page, unsigned long offset) |
1594 | { | 1596 | { |
1595 | struct buffer_head *head, *bh, *next; | 1597 | struct buffer_head *head, *bh, *next; |
1596 | unsigned int curr_off = 0; | 1598 | unsigned int curr_off = 0; |
1597 | int ret = 1; | ||
1598 | 1599 | ||
1599 | BUG_ON(!PageLocked(page)); | 1600 | BUG_ON(!PageLocked(page)); |
1600 | if (!page_has_buffers(page)) | 1601 | if (!page_has_buffers(page)) |
@@ -1621,19 +1622,18 @@ int block_invalidatepage(struct page *page, unsigned long offset) | |||
1621 | * so real IO is not possible anymore. | 1622 | * so real IO is not possible anymore. |
1622 | */ | 1623 | */ |
1623 | if (offset == 0) | 1624 | if (offset == 0) |
1624 | ret = try_to_release_page(page, 0); | 1625 | try_to_release_page(page, 0); |
1625 | out: | 1626 | out: |
1626 | return ret; | 1627 | return; |
1627 | } | 1628 | } |
1628 | EXPORT_SYMBOL(block_invalidatepage); | 1629 | EXPORT_SYMBOL(block_invalidatepage); |
1629 | 1630 | ||
1630 | int do_invalidatepage(struct page *page, unsigned long offset) | 1631 | void do_invalidatepage(struct page *page, unsigned long offset) |
1631 | { | 1632 | { |
1632 | int (*invalidatepage)(struct page *, unsigned long); | 1633 | void (*invalidatepage)(struct page *, unsigned long); |
1633 | invalidatepage = page->mapping->a_ops->invalidatepage; | 1634 | invalidatepage = page->mapping->a_ops->invalidatepage ? : |
1634 | if (invalidatepage == NULL) | 1635 | block_invalidatepage; |
1635 | invalidatepage = block_invalidatepage; | 1636 | (*invalidatepage)(page, offset); |
1636 | return (*invalidatepage)(page, offset); | ||
1637 | } | 1637 | } |
1638 | 1638 | ||
1639 | /* | 1639 | /* |
@@ -1735,6 +1735,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page, | |||
1735 | sector_t block; | 1735 | sector_t block; |
1736 | sector_t last_block; | 1736 | sector_t last_block; |
1737 | struct buffer_head *bh, *head; | 1737 | struct buffer_head *bh, *head; |
1738 | const unsigned blocksize = 1 << inode->i_blkbits; | ||
1738 | int nr_underway = 0; | 1739 | int nr_underway = 0; |
1739 | 1740 | ||
1740 | BUG_ON(!PageLocked(page)); | 1741 | BUG_ON(!PageLocked(page)); |
@@ -1742,7 +1743,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page, | |||
1742 | last_block = (i_size_read(inode) - 1) >> inode->i_blkbits; | 1743 | last_block = (i_size_read(inode) - 1) >> inode->i_blkbits; |
1743 | 1744 | ||
1744 | if (!page_has_buffers(page)) { | 1745 | if (!page_has_buffers(page)) { |
1745 | create_empty_buffers(page, 1 << inode->i_blkbits, | 1746 | create_empty_buffers(page, blocksize, |
1746 | (1 << BH_Dirty)|(1 << BH_Uptodate)); | 1747 | (1 << BH_Dirty)|(1 << BH_Uptodate)); |
1747 | } | 1748 | } |
1748 | 1749 | ||
@@ -1777,6 +1778,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page, | |||
1777 | clear_buffer_dirty(bh); | 1778 | clear_buffer_dirty(bh); |
1778 | set_buffer_uptodate(bh); | 1779 | set_buffer_uptodate(bh); |
1779 | } else if (!buffer_mapped(bh) && buffer_dirty(bh)) { | 1780 | } else if (!buffer_mapped(bh) && buffer_dirty(bh)) { |
1781 | WARN_ON(bh->b_size != blocksize); | ||
1780 | err = get_block(inode, block, bh, 1); | 1782 | err = get_block(inode, block, bh, 1); |
1781 | if (err) | 1783 | if (err) |
1782 | goto recover; | 1784 | goto recover; |
@@ -1930,6 +1932,7 @@ static int __block_prepare_write(struct inode *inode, struct page *page, | |||
1930 | if (buffer_new(bh)) | 1932 | if (buffer_new(bh)) |
1931 | clear_buffer_new(bh); | 1933 | clear_buffer_new(bh); |
1932 | if (!buffer_mapped(bh)) { | 1934 | if (!buffer_mapped(bh)) { |
1935 | WARN_ON(bh->b_size != blocksize); | ||
1933 | err = get_block(inode, block, bh, 1); | 1936 | err = get_block(inode, block, bh, 1); |
1934 | if (err) | 1937 | if (err) |
1935 | break; | 1938 | break; |
@@ -2085,6 +2088,7 @@ int block_read_full_page(struct page *page, get_block_t *get_block) | |||
2085 | 2088 | ||
2086 | fully_mapped = 0; | 2089 | fully_mapped = 0; |
2087 | if (iblock < lblock) { | 2090 | if (iblock < lblock) { |
2091 | WARN_ON(bh->b_size != blocksize); | ||
2088 | err = get_block(inode, iblock, bh, 0); | 2092 | err = get_block(inode, iblock, bh, 0); |
2089 | if (err) | 2093 | if (err) |
2090 | SetPageError(page); | 2094 | SetPageError(page); |
@@ -2406,6 +2410,7 @@ int nobh_prepare_write(struct page *page, unsigned from, unsigned to, | |||
2406 | create = 1; | 2410 | create = 1; |
2407 | if (block_start >= to) | 2411 | if (block_start >= to) |
2408 | create = 0; | 2412 | create = 0; |
2413 | map_bh.b_size = blocksize; | ||
2409 | ret = get_block(inode, block_in_file + block_in_page, | 2414 | ret = get_block(inode, block_in_file + block_in_page, |
2410 | &map_bh, create); | 2415 | &map_bh, create); |
2411 | if (ret) | 2416 | if (ret) |
@@ -2666,6 +2671,7 @@ int block_truncate_page(struct address_space *mapping, | |||
2666 | 2671 | ||
2667 | err = 0; | 2672 | err = 0; |
2668 | if (!buffer_mapped(bh)) { | 2673 | if (!buffer_mapped(bh)) { |
2674 | WARN_ON(bh->b_size != blocksize); | ||
2669 | err = get_block(inode, iblock, bh, 0); | 2675 | err = get_block(inode, iblock, bh, 0); |
2670 | if (err) | 2676 | if (err) |
2671 | goto unlock; | 2677 | goto unlock; |
@@ -2752,6 +2758,7 @@ sector_t generic_block_bmap(struct address_space *mapping, sector_t block, | |||
2752 | struct inode *inode = mapping->host; | 2758 | struct inode *inode = mapping->host; |
2753 | tmp.b_state = 0; | 2759 | tmp.b_state = 0; |
2754 | tmp.b_blocknr = 0; | 2760 | tmp.b_blocknr = 0; |
2761 | tmp.b_size = 1 << inode->i_blkbits; | ||
2755 | get_block(inode, block, &tmp, 0); | 2762 | get_block(inode, block, &tmp, 0); |
2756 | return tmp.b_blocknr; | 2763 | return tmp.b_blocknr; |
2757 | } | 2764 | } |
@@ -3004,7 +3011,7 @@ out: | |||
3004 | } | 3011 | } |
3005 | EXPORT_SYMBOL(try_to_free_buffers); | 3012 | EXPORT_SYMBOL(try_to_free_buffers); |
3006 | 3013 | ||
3007 | int block_sync_page(struct page *page) | 3014 | void block_sync_page(struct page *page) |
3008 | { | 3015 | { |
3009 | struct address_space *mapping; | 3016 | struct address_space *mapping; |
3010 | 3017 | ||
@@ -3012,7 +3019,6 @@ int block_sync_page(struct page *page) | |||
3012 | mapping = page_mapping(page); | 3019 | mapping = page_mapping(page); |
3013 | if (mapping) | 3020 | if (mapping) |
3014 | blk_run_backing_dev(mapping->backing_dev_info, page); | 3021 | blk_run_backing_dev(mapping->backing_dev_info, page); |
3015 | return 0; | ||
3016 | } | 3022 | } |
3017 | 3023 | ||
3018 | /* | 3024 | /* |