[PATCH 7/7] dax: Call b_end_io outside the i_mmap_mutex

From: Matthew Wilcox
Date: Wed Sep 24 2014 - 14:27:57 EST


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


--cNdxnHkX5QqsyA0e--
--
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/