diff options
| author | Mister Oyster <oysterized@gmail.com> | 2017-12-31 02:50:24 +0100 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-12-31 02:51:14 +0100 |
| commit | a1bac3c7c00397f50a3479c26fe1bd760bea7fc9 (patch) | |
| tree | eecc44f4426dfe351ec82479c597426048254ce3 | |
| parent | 038dc45578aa6f60f972e417db9b5d0b732f60bc (diff) | |
Revert "ext4: fix data corruption for mmap writes"
This reverts commit 156b66c5bad7fa7621024c2537bfeb48e5a21da0.
| -rw-r--r-- | fs/ext4/inode.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index a0e2489d7..1580220e9 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1938,29 +1938,15 @@ static int ext4_writepage(struct page *page, static int mpage_submit_page(struct mpage_da_data *mpd, struct page *page) { int len; - loff_t size; + loff_t size = i_size_read(mpd->inode); int err; BUG_ON(page->index != mpd->first_page); - clear_page_dirty_for_io(page); - /* - * We have to be very careful here! Nothing protects writeback path - * against i_size changes and the page can be writeably mapped into - * page tables. So an application can be growing i_size and writing - * data through mmap while writeback runs. clear_page_dirty_for_io() - * write-protects our page in page tables and the page cannot get - * written to again until we release page lock. So only after - * clear_page_dirty_for_io() we are safe to sample i_size for - * ext4_bio_write_page() to zero-out tail of the written page. We rely - * on the barrier provided by TestClearPageDirty in - * clear_page_dirty_for_io() to make sure i_size is really sampled only - * after page tables are updated. - */ - size = i_size_read(mpd->inode); - if (page->index == size >> PAGE_SHIFT) - len = size & ~PAGE_MASK; + if (page->index == size >> PAGE_CACHE_SHIFT) + len = size & ~PAGE_CACHE_MASK; else - len = PAGE_SIZE; + len = PAGE_CACHE_SIZE; + clear_page_dirty_for_io(page); err = ext4_bio_write_page(&mpd->io_submit, page, len, mpd->wbc, false); if (!err) mpd->wbc->nr_to_write--; |
