Commit 293e20b8 authored by Scott Mayhew's avatar Scott Mayhew Committed by Kleber Sacilotto de Souza

nfsd: fix a warning in __cld_pipe_upcall()

BugLink: https://bugs.launchpad.net/bugs/1858489

[ Upstream commit b493fd31 ]

__cld_pipe_upcall() emits a "do not call blocking ops when
!TASK_RUNNING" warning due to the dput() call in rpc_queue_upcall().
Fix it by using a completion instead of hand coding the wait.
Signed-off-by: default avatarScott Mayhew <smayhew@redhat.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent c1c3724a
...@@ -655,7 +655,7 @@ struct cld_net { ...@@ -655,7 +655,7 @@ struct cld_net {
struct cld_upcall { struct cld_upcall {
struct list_head cu_list; struct list_head cu_list;
struct cld_net *cu_net; struct cld_net *cu_net;
struct task_struct *cu_task; struct completion cu_done;
struct cld_msg cu_msg; struct cld_msg cu_msg;
}; };
...@@ -664,23 +664,18 @@ __cld_pipe_upcall(struct rpc_pipe *pipe, struct cld_msg *cmsg) ...@@ -664,23 +664,18 @@ __cld_pipe_upcall(struct rpc_pipe *pipe, struct cld_msg *cmsg)
{ {
int ret; int ret;
struct rpc_pipe_msg msg; struct rpc_pipe_msg msg;
struct cld_upcall *cup = container_of(cmsg, struct cld_upcall, cu_msg);
memset(&msg, 0, sizeof(msg)); memset(&msg, 0, sizeof(msg));
msg.data = cmsg; msg.data = cmsg;
msg.len = sizeof(*cmsg); msg.len = sizeof(*cmsg);
/*
* Set task state before we queue the upcall. That prevents
* wake_up_process in the downcall from racing with schedule.
*/
set_current_state(TASK_UNINTERRUPTIBLE);
ret = rpc_queue_upcall(pipe, &msg); ret = rpc_queue_upcall(pipe, &msg);
if (ret < 0) { if (ret < 0) {
set_current_state(TASK_RUNNING);
goto out; goto out;
} }
schedule(); wait_for_completion(&cup->cu_done);
if (msg.errno < 0) if (msg.errno < 0)
ret = msg.errno; ret = msg.errno;
...@@ -747,7 +742,7 @@ cld_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) ...@@ -747,7 +742,7 @@ cld_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
if (copy_from_user(&cup->cu_msg, src, mlen) != 0) if (copy_from_user(&cup->cu_msg, src, mlen) != 0)
return -EFAULT; return -EFAULT;
wake_up_process(cup->cu_task); complete(&cup->cu_done);
return mlen; return mlen;
} }
...@@ -762,7 +757,7 @@ cld_pipe_destroy_msg(struct rpc_pipe_msg *msg) ...@@ -762,7 +757,7 @@ cld_pipe_destroy_msg(struct rpc_pipe_msg *msg)
if (msg->errno >= 0) if (msg->errno >= 0)
return; return;
wake_up_process(cup->cu_task); complete(&cup->cu_done);
} }
static const struct rpc_pipe_ops cld_upcall_ops = { static const struct rpc_pipe_ops cld_upcall_ops = {
...@@ -893,7 +888,7 @@ alloc_cld_upcall(struct cld_net *cn) ...@@ -893,7 +888,7 @@ alloc_cld_upcall(struct cld_net *cn)
goto restart_search; goto restart_search;
} }
} }
new->cu_task = current; init_completion(&new->cu_done);
new->cu_msg.cm_vers = CLD_UPCALL_VERSION; new->cu_msg.cm_vers = CLD_UPCALL_VERSION;
put_unaligned(cn->cn_xid++, &new->cu_msg.cm_xid); put_unaligned(cn->cn_xid++, &new->cu_msg.cm_xid);
new->cu_net = cn; new->cu_net = cn;
......
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