NFS: Fix up commit deadlocks
[ Upstream commit 133a48abf6ecc535d7eddc6da1c3e4c972445882 ]
If O_DIRECT bumps the commit_info rpcs_out field, then that could lead
to fsync() hangs. The fix is to ensure that O_DIRECT calls
nfs_commit_end().
Fixes: 723c921e7d
("sched/wait, fs/nfs: Convert wait_on_atomic_t() usage to the new wait_var_event() API")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
91e43a8500
commit
10f2108717
@@ -1649,10 +1649,13 @@ static void nfs_commit_begin(struct nfs_mds_commit_info *cinfo)
|
||||
atomic_inc(&cinfo->rpcs_out);
|
||||
}
|
||||
|
||||
static void nfs_commit_end(struct nfs_mds_commit_info *cinfo)
|
||||
bool nfs_commit_end(struct nfs_mds_commit_info *cinfo)
|
||||
{
|
||||
if (atomic_dec_and_test(&cinfo->rpcs_out))
|
||||
if (atomic_dec_and_test(&cinfo->rpcs_out)) {
|
||||
wake_up_var(&cinfo->rpcs_out);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void nfs_commitdata_release(struct nfs_commit_data *data)
|
||||
@@ -1752,6 +1755,7 @@ void nfs_init_commit(struct nfs_commit_data *data,
|
||||
data->res.fattr = &data->fattr;
|
||||
data->res.verf = &data->verf;
|
||||
nfs_fattr_init(&data->fattr);
|
||||
nfs_commit_begin(cinfo->mds);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nfs_init_commit);
|
||||
|
||||
@@ -1797,7 +1801,6 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how,
|
||||
|
||||
/* Set up the argument struct */
|
||||
nfs_init_commit(data, head, NULL, cinfo);
|
||||
atomic_inc(&cinfo->mds->rpcs_out);
|
||||
return nfs_initiate_commit(NFS_CLIENT(inode), data, NFS_PROTO(inode),
|
||||
data->mds_ops, how, RPC_TASK_CRED_NOREF);
|
||||
}
|
||||
|
Reference in New Issue
Block a user