Skip to content

Commit 3e7b08e

Browse files
Trond Myklebustgregkh
authored andcommitted
NFS: Fix deadlocks in nfs_scan_commit_list()
[ Upstream commit 64a93db ] Partially revert commit 2ce209c ("NFS: Wait for requests that are locked on the commit list"), since it can lead to deadlocks between commit requests and nfs_join_page_group(). For now we should assume that any locked requests on the commit list are either about to be removed and committed by another task, or the writes they describe are about to be retransmitted. In either case, we should not need to worry. Fixes: 2ce209c ("NFS: Wait for requests that are locked on the commit list") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1494389 commit 3e7b08e

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

‎fs/nfs/write.c‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,25 +1034,11 @@ nfs_scan_commit_list(struct list_head *src, struct list_head *dst,
10341034
struct nfs_page *req, *tmp;
10351035
int ret = 0;
10361036

1037-
restart:
10381037
list_for_each_entry_safe(req, tmp, src, wb_list) {
10391038
kref_get(&req->wb_kref);
10401039
if (!nfs_lock_request(req)) {
1041-
int status;
1042-
1043-
/* Prevent deadlock with nfs_lock_and_join_requests */
1044-
if (!list_empty(dst)) {
1045-
nfs_release_request(req);
1046-
continue;
1047-
}
1048-
/* Ensure we make progress to prevent livelock */
1049-
mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex);
1050-
status = nfs_wait_on_request(req);
10511040
nfs_release_request(req);
1052-
mutex_lock(&NFS_I(cinfo->inode)->commit_mutex);
1053-
if (status < 0)
1054-
break;
1055-
goto restart;
1041+
continue;
10561042
}
10571043
nfs_request_remove_commit_list(req, cinfo);
10581044
clear_bit(PG_COMMIT_TO_DS, &req->wb_flags);
@@ -1924,6 +1910,7 @@ static int __nfs_commit_inode(struct inode *inode, int how,
19241910
int may_wait = how & FLUSH_SYNC;
19251911
int ret, nscan;
19261912

1913+
how &= ~FLUSH_SYNC;
19271914
nfs_init_cinfo_from_inode(&cinfo, inode);
19281915
nfs_commit_begin(cinfo.mds);
19291916
for (;;) {

0 commit comments

Comments
 (0)