[Top] [All Lists]

[PATCH 1/8] xfs: mmap lock needs to be inside freeze protection

To: xfs@xxxxxxxxxxx
Subject: [PATCH 1/8] xfs: mmap lock needs to be inside freeze protection
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Fri, 29 May 2015 09:45:48 +1000
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1432856755-7859-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1432856755-7859-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

Lock ordering for the new mmap lock needs to be:

      page lock
        <fault processsing>

Right now xfs_vm_page_mkwrite gets this the wrong way around,
While technically it cannot deadlock due to the current freeze
ordering, it's still a landmine that might explode if we change
anything in future. Hence we need to nest the locks correctly.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
Reviewed-by: Jan Kara <jack@xxxxxxx>
Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx>
Signed-off-by: Dave Chinner <david@xxxxxxxxxxxxx>
 fs/xfs/xfs_file.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 3b75912..4a0af89 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -1487,15 +1487,20 @@ xfs_filemap_page_mkwrite(
        struct vm_fault         *vmf)
        struct xfs_inode        *ip = XFS_I(vma->vm_file->f_mapping->host);
-       int                     error;
+       int                     ret;
+       sb_start_pagefault(VFS_I(ip)->i_sb);
+       file_update_time(vma->vm_file);
        xfs_ilock(ip, XFS_MMAPLOCK_SHARED);
-       error = block_page_mkwrite(vma, vmf, xfs_get_blocks);
+       ret = __block_page_mkwrite(vma, vmf, xfs_get_blocks);
        xfs_iunlock(ip, XFS_MMAPLOCK_SHARED);
+       sb_end_pagefault(VFS_I(ip)->i_sb);
-       return error;
+       return block_page_mkwrite_return(ret);
 const struct file_operations xfs_file_operations = {

<Prev in Thread] Current Thread [Next in Thread>