vfs: Fix vmtruncate() regression

If __block_prepare_write() was failed in block_write_begin(), the
allocated blocks can be outside of ->i_size.

But new truncate_pagecache() in vmtuncate() does nothing if new < old.
It means the above usage is not working anymore.

So, this patch fixes it by removing "new < old" check. It would need
more cleanup/change. But, now -rc and truncate working is in progress,
so, this tried to fix it minimum change.

Acked-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by OGAWA Hirofumi and committed by Linus Torvalds cedabed4 e80c14e1

+13 -15
+13 -15
mm/truncate.c
··· 522 522 */ 523 523 void truncate_pagecache(struct inode *inode, loff_t old, loff_t new) 524 524 { 525 - if (new < old) { 526 - struct address_space *mapping = inode->i_mapping; 525 + struct address_space *mapping = inode->i_mapping; 527 526 528 - /* 529 - * unmap_mapping_range is called twice, first simply for 530 - * efficiency so that truncate_inode_pages does fewer 531 - * single-page unmaps. However after this first call, and 532 - * before truncate_inode_pages finishes, it is possible for 533 - * private pages to be COWed, which remain after 534 - * truncate_inode_pages finishes, hence the second 535 - * unmap_mapping_range call must be made for correctness. 536 - */ 537 - unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1); 538 - truncate_inode_pages(mapping, new); 539 - unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1); 540 - } 527 + /* 528 + * unmap_mapping_range is called twice, first simply for 529 + * efficiency so that truncate_inode_pages does fewer 530 + * single-page unmaps. However after this first call, and 531 + * before truncate_inode_pages finishes, it is possible for 532 + * private pages to be COWed, which remain after 533 + * truncate_inode_pages finishes, hence the second 534 + * unmap_mapping_range call must be made for correctness. 535 + */ 536 + unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1); 537 + truncate_inode_pages(mapping, new); 538 + unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1); 541 539 } 542 540 EXPORT_SYMBOL(truncate_pagecache); 543 541