>From 953153c75704a3954052b68c63b4cc3ad15b7a06 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Wed, 24 Sep 2014 14:27:57 -0400 Subject: [PATCH 7/7] dax: Call b_end_io outside the i_mmap_mutex Lockdep helpfully points out that ext4_convert_unwritten_extents will start a jbd transaction, and i_mmap_mutex is already nested inside the jbd2_handle lock. So move the call to b_end_io to after we drop the i_mmap_mutex; this only extends the window in which we can crash and the allocation will be lost; it does not introduce any new races. --- fs/dax.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 59be664..91b7561 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -309,17 +309,17 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, goto out; } - if (buffer_unwritten(bh) || buffer_new(bh)) { + if (buffer_unwritten(bh) || buffer_new(bh)) clear_page(addr); - if (bh->b_end_io) - bh->b_end_io(bh, 1); - } error = vm_insert_mixed(vma, vaddr, pfn); out: mutex_unlock(&mapping->i_mmap_mutex); + if (bh->b_end_io) + bh->b_end_io(bh, 1); + return error; } -- 2.1.0