Commit 9620ad86 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Linus Torvalds

afs: Re-enable freezing once a page fault is interrupted

If a task is killed during a page fault, it does not currently call
sb_end_pagefault(), which means that the filesystem cannot be frozen
at any time thereafter.  This may be reported by lockdep like this:

====================================
WARNING: fsstress/10757 still has locks held!
5.13.0-rc4-build4+ #91 Not tainted
------------------------------------
1 lock held by fsstress/10757:
 #0: ffff888104eac530
 (
sb_pagefaults

as filesystem freezing is modelled as a lock.

Fix this by removing all the direct returns from within the function,
and using 'ret' to indicate whether we were interrupted or successful.

Fixes: 1cf7a151 ("afs: Implement shared-writeable mmap")
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
cc: linux-afs@lists.infradead.org
Link: https://lore.kernel.org/r/20210616154900.1958373-1-willy@infradead.org/Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b1edae0d
...@@ -837,6 +837,7 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf) ...@@ -837,6 +837,7 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
struct afs_vnode *vnode = AFS_FS_I(inode); struct afs_vnode *vnode = AFS_FS_I(inode);
unsigned long priv; unsigned long priv;
vm_fault_t ret = VM_FAULT_RETRY;
_enter("{{%llx:%llu}},{%lx}", vnode->fid.vid, vnode->fid.vnode, page->index); _enter("{{%llx:%llu}},{%lx}", vnode->fid.vid, vnode->fid.vnode, page->index);
...@@ -848,14 +849,14 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf) ...@@ -848,14 +849,14 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
#ifdef CONFIG_AFS_FSCACHE #ifdef CONFIG_AFS_FSCACHE
if (PageFsCache(page) && if (PageFsCache(page) &&
wait_on_page_fscache_killable(page) < 0) wait_on_page_fscache_killable(page) < 0)
return VM_FAULT_RETRY; goto out;
#endif #endif
if (wait_on_page_writeback_killable(page)) if (wait_on_page_writeback_killable(page))
return VM_FAULT_RETRY; goto out;
if (lock_page_killable(page) < 0) if (lock_page_killable(page) < 0)
return VM_FAULT_RETRY; goto out;
/* We mustn't change page->private until writeback is complete as that /* We mustn't change page->private until writeback is complete as that
* details the portion of the page we need to write back and we might * details the portion of the page we need to write back and we might
...@@ -863,7 +864,7 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf) ...@@ -863,7 +864,7 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
*/ */
if (wait_on_page_writeback_killable(page) < 0) { if (wait_on_page_writeback_killable(page) < 0) {
unlock_page(page); unlock_page(page);
return VM_FAULT_RETRY; goto out;
} }
priv = afs_page_dirty(page, 0, thp_size(page)); priv = afs_page_dirty(page, 0, thp_size(page));
...@@ -877,8 +878,10 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf) ...@@ -877,8 +878,10 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
} }
file_update_time(file); file_update_time(file);
ret = VM_FAULT_LOCKED;
out:
sb_end_pagefault(inode->i_sb); sb_end_pagefault(inode->i_sb);
return VM_FAULT_LOCKED; return ret;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment