Re: [PATCH v7 07/22] Replace the XIP page fault handler with the DAX page fault handler
From: Matthew Wilcox
Date: Wed Jul 30 2014 - 17:02:48 EST
On Wed, Jul 30, 2014 at 11:52:29AM +0200, Jan Kara wrote:
> I see the problem now. How about an attached patch? Do you see other
> lockdep warnings with it?
This patch fixes the problem, thanks! Regardless of DAX, I think this
patch should be applied in order to avoid creating a dependency between
i_mmap_mutex and jbd2_handle.
I've now run into a different problem with COW pages ... more later.
> >From c01c905cf3c4c6304a5ea9836389d9cf0d575884 Mon Sep 17 00:00:00 2001
> From: Jan Kara <jack@xxxxxxx>
> Date: Wed, 30 Jul 2014 11:49:07 +0200
> Subject: [PATCH] ext4: Avoid lock inversion between i_mmap_mutex and
> transaction start
>
> When DAX is enabled, it uses i_mmap_mutex as a protection against
> truncate during page fault. This inevitably forces i_mmap_mutex to rank
> outside of a transaction start and thus we have to avoid calling
> pagecache purging operations when transaction is started.
>
> Signed-off-by: Jan Kara <jack@xxxxxxx>
> ---
> fs/ext4/inode.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 8a064734e6eb..494a8645d63e 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3631,13 +3631,19 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
> if (IS_SYNC(inode))
> ext4_handle_sync(handle);
>
> - /* Now release the pages again to reduce race window */
> + inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
> + ext4_mark_inode_dirty(handle, inode);
> + ext4_journal_stop(handle);
> +
> + /*
> + * Now release the pages again to reduce race window. This has to happen
> + * outside of a transaction to avoid lock inversion on i_mmap_mutex
> + * when DAX is enabled.
> + */
> if (last_block_offset > first_block_offset)
> truncate_pagecache_range(inode, first_block_offset,
> last_block_offset);
> -
> - inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
> - ext4_mark_inode_dirty(handle, inode);
> + goto out_dio;
> out_stop:
> ext4_journal_stop(handle);
> out_dio:
> --
> 1.8.1.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/