Skip to content

Commit 9620ad8

Browse files
Matthew Wilcox (Oracle)torvalds
authored andcommitted
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: 1cf7a15 ("afs: Implement shared-writeable mmap") Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: David Howells <[email protected]> cc: [email protected] Link: https://lore.kernel.org/r/[email protected]/ Signed-off-by: Linus Torvalds <[email protected]>
1 parent b1edae0 commit 9620ad8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

fs/afs/write.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,7 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
837837
struct inode *inode = file_inode(file);
838838
struct afs_vnode *vnode = AFS_FS_I(inode);
839839
unsigned long priv;
840+
vm_fault_t ret = VM_FAULT_RETRY;
840841

841842
_enter("{{%llx:%llu}},{%lx}", vnode->fid.vid, vnode->fid.vnode, page->index);
842843

@@ -848,22 +849,22 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
848849
#ifdef CONFIG_AFS_FSCACHE
849850
if (PageFsCache(page) &&
850851
wait_on_page_fscache_killable(page) < 0)
851-
return VM_FAULT_RETRY;
852+
goto out;
852853
#endif
853854

854855
if (wait_on_page_writeback_killable(page))
855-
return VM_FAULT_RETRY;
856+
goto out;
856857

857858
if (lock_page_killable(page) < 0)
858-
return VM_FAULT_RETRY;
859+
goto out;
859860

860861
/* We mustn't change page->private until writeback is complete as that
861862
* details the portion of the page we need to write back and we might
862863
* need to redirty the page if there's a problem.
863864
*/
864865
if (wait_on_page_writeback_killable(page) < 0) {
865866
unlock_page(page);
866-
return VM_FAULT_RETRY;
867+
goto out;
867868
}
868869

869870
priv = afs_page_dirty(page, 0, thp_size(page));
@@ -877,8 +878,10 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
877878
}
878879
file_update_time(file);
879880

881+
ret = VM_FAULT_LOCKED;
882+
out:
880883
sb_end_pagefault(inode->i_sb);
881-
return VM_FAULT_LOCKED;
884+
return ret;
882885
}
883886

884887
/*

0 commit comments

Comments
 (0)