aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 6824cb1bd1bb..86bf43d6dfcd 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1976,21 +1976,27 @@ static int ext4_writepage(struct page *page,
1976 len = PAGE_CACHE_SIZE; 1976 len = PAGE_CACHE_SIZE;
1977 1977
1978 page_bufs = page_buffers(page); 1978 page_bufs = page_buffers(page);
1979 /*
1980 * We cannot do block allocation or other extent handling in this
1981 * function. If there are buffers needing that, we have to redirty
1982 * the page. But we may reach here when we do a journal commit via
1983 * journal_submit_inode_data_buffers() and in that case we must write
1984 * allocated buffers to achieve data=ordered mode guarantees.
1985 */
1979 if (ext4_walk_page_buffers(NULL, page_bufs, 0, len, NULL, 1986 if (ext4_walk_page_buffers(NULL, page_bufs, 0, len, NULL,
1980 ext4_bh_delay_or_unwritten)) { 1987 ext4_bh_delay_or_unwritten)) {
1981 /*
1982 * We don't want to do block allocation, so redirty
1983 * the page and return. We may reach here when we do
1984 * a journal commit via journal_submit_inode_data_buffers.
1985 * We can also reach here via shrink_page_list but it
1986 * should never be for direct reclaim so warn if that
1987 * happens
1988 */
1989 WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD)) ==
1990 PF_MEMALLOC);
1991 redirty_page_for_writepage(wbc, page); 1988 redirty_page_for_writepage(wbc, page);
1992 unlock_page(page); 1989 if (current->flags & PF_MEMALLOC) {
1993 return 0; 1990 /*
1991 * For memory cleaning there's no point in writing only
1992 * some buffers. So just bail out. Warn if we came here
1993 * from direct reclaim.
1994 */
1995 WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD))
1996 == PF_MEMALLOC);
1997 unlock_page(page);
1998 return 0;
1999 }
1994 } 2000 }
1995 2001
1996 if (PageChecked(page) && ext4_should_journal_data(inode)) 2002 if (PageChecked(page) && ext4_should_journal_data(inode))