diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2010-01-13 07:14:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-01-13 19:09:33 -0500 |
commit | cedabed49b39b4319bccc059a63344b6232b619c (patch) | |
tree | caa84b17d5cfe3a0f71a537cf55498f2019586db /mm/truncate.c | |
parent | e80c14e1ae3cb637d1959a6c9a199ba2e7af5910 (diff) |
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>
Diffstat (limited to 'mm/truncate.c')
-rw-r--r-- | mm/truncate.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/mm/truncate.c b/mm/truncate.c index 342deee22684..e87e37244829 100644 --- a/mm/truncate.c +++ b/mm/truncate.c | |||
@@ -522,22 +522,20 @@ EXPORT_SYMBOL_GPL(invalidate_inode_pages2); | |||
522 | */ | 522 | */ |
523 | void truncate_pagecache(struct inode *inode, loff_t old, loff_t new) | 523 | void truncate_pagecache(struct inode *inode, loff_t old, loff_t new) |
524 | { | 524 | { |
525 | if (new < old) { | 525 | struct address_space *mapping = inode->i_mapping; |
526 | struct address_space *mapping = inode->i_mapping; | 526 | |
527 | 527 | /* | |
528 | /* | 528 | * unmap_mapping_range is called twice, first simply for |
529 | * unmap_mapping_range is called twice, first simply for | 529 | * efficiency so that truncate_inode_pages does fewer |
530 | * efficiency so that truncate_inode_pages does fewer | 530 | * single-page unmaps. However after this first call, and |
531 | * single-page unmaps. However after this first call, and | 531 | * before truncate_inode_pages finishes, it is possible for |
532 | * before truncate_inode_pages finishes, it is possible for | 532 | * private pages to be COWed, which remain after |
533 | * private pages to be COWed, which remain after | 533 | * truncate_inode_pages finishes, hence the second |
534 | * truncate_inode_pages finishes, hence the second | 534 | * unmap_mapping_range call must be made for correctness. |
535 | * unmap_mapping_range call must be made for correctness. | 535 | */ |
536 | */ | 536 | unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1); |
537 | unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1); | 537 | truncate_inode_pages(mapping, new); |
538 | truncate_inode_pages(mapping, new); | 538 | unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1); |
539 | unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1); | ||
540 | } | ||
541 | } | 539 | } |
542 | EXPORT_SYMBOL(truncate_pagecache); | 540 | EXPORT_SYMBOL(truncate_pagecache); |
543 | 541 | ||