Commit 133a48ab authored by Trond Myklebust's avatar Trond Myklebust

NFS: Fix up commit deadlocks

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: 723c921e ("sched/wait, fs/nfs: Convert wait_on_atomic_t() usage to the new wait_var_event() API")
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 64a93dbf
...@@ -620,7 +620,7 @@ static void nfs_direct_commit_complete(struct nfs_commit_data *data) ...@@ -620,7 +620,7 @@ static void nfs_direct_commit_complete(struct nfs_commit_data *data)
nfs_unlock_and_release_request(req); nfs_unlock_and_release_request(req);
} }
if (atomic_dec_and_test(&cinfo.mds->rpcs_out)) if (nfs_commit_end(cinfo.mds))
nfs_direct_write_complete(dreq); nfs_direct_write_complete(dreq);
} }
......
...@@ -468,7 +468,6 @@ pnfs_bucket_alloc_ds_commits(struct list_head *list, ...@@ -468,7 +468,6 @@ pnfs_bucket_alloc_ds_commits(struct list_head *list,
goto out_error; goto out_error;
data->ds_commit_index = i; data->ds_commit_index = i;
list_add_tail(&data->list, list); list_add_tail(&data->list, list);
atomic_inc(&cinfo->mds->rpcs_out);
nreq++; nreq++;
} }
mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex); mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex);
...@@ -520,7 +519,6 @@ pnfs_generic_commit_pagelist(struct inode *inode, struct list_head *mds_pages, ...@@ -520,7 +519,6 @@ pnfs_generic_commit_pagelist(struct inode *inode, struct list_head *mds_pages,
data->ds_commit_index = -1; data->ds_commit_index = -1;
list_splice_init(mds_pages, &data->pages); list_splice_init(mds_pages, &data->pages);
list_add_tail(&data->list, &list); list_add_tail(&data->list, &list);
atomic_inc(&cinfo->mds->rpcs_out);
nreq++; nreq++;
} }
......
...@@ -1673,10 +1673,13 @@ static void nfs_commit_begin(struct nfs_mds_commit_info *cinfo) ...@@ -1673,10 +1673,13 @@ static void nfs_commit_begin(struct nfs_mds_commit_info *cinfo)
atomic_inc(&cinfo->rpcs_out); 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); wake_up_var(&cinfo->rpcs_out);
return true;
}
return false;
} }
void nfs_commitdata_release(struct nfs_commit_data *data) void nfs_commitdata_release(struct nfs_commit_data *data)
...@@ -1776,6 +1779,7 @@ void nfs_init_commit(struct nfs_commit_data *data, ...@@ -1776,6 +1779,7 @@ void nfs_init_commit(struct nfs_commit_data *data,
data->res.fattr = &data->fattr; data->res.fattr = &data->fattr;
data->res.verf = &data->verf; data->res.verf = &data->verf;
nfs_fattr_init(&data->fattr); nfs_fattr_init(&data->fattr);
nfs_commit_begin(cinfo->mds);
} }
EXPORT_SYMBOL_GPL(nfs_init_commit); EXPORT_SYMBOL_GPL(nfs_init_commit);
...@@ -1822,7 +1826,6 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how, ...@@ -1822,7 +1826,6 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how,
/* Set up the argument struct */ /* Set up the argument struct */
nfs_init_commit(data, head, NULL, cinfo); nfs_init_commit(data, head, NULL, cinfo);
atomic_inc(&cinfo->mds->rpcs_out);
if (NFS_SERVER(inode)->nfs_client->cl_minorversion) if (NFS_SERVER(inode)->nfs_client->cl_minorversion)
task_flags = RPC_TASK_MOVEABLE; task_flags = RPC_TASK_MOVEABLE;
return nfs_initiate_commit(NFS_CLIENT(inode), data, NFS_PROTO(inode), return nfs_initiate_commit(NFS_CLIENT(inode), data, NFS_PROTO(inode),
......
...@@ -568,6 +568,7 @@ extern int nfs_wb_page_cancel(struct inode *inode, struct page* page); ...@@ -568,6 +568,7 @@ extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
extern int nfs_commit_inode(struct inode *, int); extern int nfs_commit_inode(struct inode *, int);
extern struct nfs_commit_data *nfs_commitdata_alloc(bool never_fail); extern struct nfs_commit_data *nfs_commitdata_alloc(bool never_fail);
extern void nfs_commit_free(struct nfs_commit_data *data); extern void nfs_commit_free(struct nfs_commit_data *data);
bool nfs_commit_end(struct nfs_mds_commit_info *cinfo);
static inline int static inline int
nfs_have_writebacks(struct inode *inode) nfs_have_writebacks(struct inode *inode)
......
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