提交 0dd1334f 编写于 作者: H Hisashi Hifumi 提交者: Linus Torvalds

fix invalidate_inode_pages2_range() to not clear ret

DIO invalidates page cache through invalidate_inode_pages2_range().
invalidate_inode_pages2_range() sets ret=-EIO when
invalidate_complete_page2() fails, but this ret is cleared if
do_launder_page() succeed on a page of next index.

In this case, dio is carried out even if invalidate_complete_page2() fails
on some pages.

This can cause inconsistency between memory and blocks on HDD because the
page cache still exists.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: NHisashi Hifumi <hifumi.hisashi@oss.ntt.co.jp>
Cc: Badari Pulavarty <pbadari@us.ibm.com>
Cc: Ken Chen <kenchen@google.com>
Cc: Zach Brown <zach.brown@oracle.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Chuck Lever <cel@citi.umich.edu>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 ddc81ed2
...@@ -391,6 +391,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping, ...@@ -391,6 +391,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping,
pgoff_t next; pgoff_t next;
int i; int i;
int ret = 0; int ret = 0;
int ret2 = 0;
int did_range_unmap = 0; int did_range_unmap = 0;
int wrapped = 0; int wrapped = 0;
...@@ -438,9 +439,13 @@ int invalidate_inode_pages2_range(struct address_space *mapping, ...@@ -438,9 +439,13 @@ int invalidate_inode_pages2_range(struct address_space *mapping,
} }
} }
BUG_ON(page_mapped(page)); BUG_ON(page_mapped(page));
ret = do_launder_page(mapping, page); ret2 = do_launder_page(mapping, page);
if (ret == 0 && !invalidate_complete_page2(mapping, page)) if (ret2 == 0) {
ret = -EIO; if (!invalidate_complete_page2(mapping, page))
ret2 = -EIO;
}
if (ret2 < 0)
ret = ret2;
unlock_page(page); unlock_page(page);
} }
pagevec_release(&pvec); pagevec_release(&pvec);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册