aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2017-05-12 18:46:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-12 18:57:16 -0400
commitfb26a1cbed8c90025572d48bc9eabe59f7571e88 (patch)
tree900f3fb406c1c78f42d8d036c89de2a8fc452993
parentcd656375f94632d7b5af57bf67b7b5c0270c591c (diff)
ext4: return to starting transaction in ext4_dax_huge_fault()
DAX will return to locking exceptional entry before mapping blocks for a page fault to fix possible races with concurrent writes. To avoid lock inversion between exceptional entry lock and transaction start, start the transaction already in ext4_dax_huge_fault(). Fixes: 9f141d6ef6258a3a37a045842d9ba7e68f368956 Link: http://lkml.kernel.org/r/20170510085419.27601-4-jack@suse.cz Signed-off-by: Jan Kara <jack@suse.cz> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/ext4/file.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index cefa9835f275..831fd6beebf0 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -257,6 +257,7 @@ static int ext4_dax_huge_fault(struct vm_fault *vmf,
257 enum page_entry_size pe_size) 257 enum page_entry_size pe_size)
258{ 258{
259 int result; 259 int result;
260 handle_t *handle = NULL;
260 struct inode *inode = file_inode(vmf->vma->vm_file); 261 struct inode *inode = file_inode(vmf->vma->vm_file);
261 struct super_block *sb = inode->i_sb; 262 struct super_block *sb = inode->i_sb;
262 bool write = vmf->flags & FAULT_FLAG_WRITE; 263 bool write = vmf->flags & FAULT_FLAG_WRITE;
@@ -264,12 +265,24 @@ static int ext4_dax_huge_fault(struct vm_fault *vmf,
264 if (write) { 265 if (write) {
265 sb_start_pagefault(sb); 266 sb_start_pagefault(sb);
266 file_update_time(vmf->vma->vm_file); 267 file_update_time(vmf->vma->vm_file);
268 down_read(&EXT4_I(inode)->i_mmap_sem);
269 handle = ext4_journal_start_sb(sb, EXT4_HT_WRITE_PAGE,
270 EXT4_DATA_TRANS_BLOCKS(sb));
271 } else {
272 down_read(&EXT4_I(inode)->i_mmap_sem);
267 } 273 }
268 down_read(&EXT4_I(inode)->i_mmap_sem); 274 if (!IS_ERR(handle))
269 result = dax_iomap_fault(vmf, pe_size, &ext4_iomap_ops); 275 result = dax_iomap_fault(vmf, pe_size, &ext4_iomap_ops);
270 up_read(&EXT4_I(inode)->i_mmap_sem); 276 else
271 if (write) 277 result = VM_FAULT_SIGBUS;
278 if (write) {
279 if (!IS_ERR(handle))
280 ext4_journal_stop(handle);
281 up_read(&EXT4_I(inode)->i_mmap_sem);
272 sb_end_pagefault(sb); 282 sb_end_pagefault(sb);
283 } else {
284 up_read(&EXT4_I(inode)->i_mmap_sem);
285 }
273 286
274 return result; 287 return result;
275} 288}