提交 d0fe13ba 编写于 作者: S Stanislav Kinsbursky 提交者: Trond Myklebust

SUNRPC: cleanup PipeFS redundant RPC inode usage

This patch removes redundant RPC inode references from PipeFS. These places are
actually where pipes operations are performed.
Signed-off-by: NStanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 ba9e0975
...@@ -132,28 +132,28 @@ EXPORT_SYMBOL_GPL(rpc_pipe_generic_upcall); ...@@ -132,28 +132,28 @@ EXPORT_SYMBOL_GPL(rpc_pipe_generic_upcall);
int int
rpc_queue_upcall(struct inode *inode, struct rpc_pipe_msg *msg) rpc_queue_upcall(struct inode *inode, struct rpc_pipe_msg *msg)
{ {
struct rpc_inode *rpci = RPC_I(inode); struct rpc_pipe *pipe = RPC_I(inode)->pipe;
int res = -EPIPE; int res = -EPIPE;
spin_lock(&rpci->pipe->lock); spin_lock(&pipe->lock);
if (rpci->pipe->ops == NULL) if (pipe->ops == NULL)
goto out; goto out;
if (rpci->pipe->nreaders) { if (pipe->nreaders) {
list_add_tail(&msg->list, &rpci->pipe->pipe); list_add_tail(&msg->list, &pipe->pipe);
rpci->pipe->pipelen += msg->len; pipe->pipelen += msg->len;
res = 0; res = 0;
} else if (rpci->pipe->flags & RPC_PIPE_WAIT_FOR_OPEN) { } else if (pipe->flags & RPC_PIPE_WAIT_FOR_OPEN) {
if (list_empty(&rpci->pipe->pipe)) if (list_empty(&pipe->pipe))
queue_delayed_work(rpciod_workqueue, queue_delayed_work(rpciod_workqueue,
&rpci->pipe->queue_timeout, &pipe->queue_timeout,
RPC_UPCALL_TIMEOUT); RPC_UPCALL_TIMEOUT);
list_add_tail(&msg->list, &rpci->pipe->pipe); list_add_tail(&msg->list, &pipe->pipe);
rpci->pipe->pipelen += msg->len; pipe->pipelen += msg->len;
res = 0; res = 0;
} }
out: out:
spin_unlock(&rpci->pipe->lock); spin_unlock(&pipe->lock);
wake_up(&rpci->pipe->waitq); wake_up(&pipe->waitq);
return res; return res;
} }
EXPORT_SYMBOL_GPL(rpc_queue_upcall); EXPORT_SYMBOL_GPL(rpc_queue_upcall);
...@@ -220,23 +220,23 @@ rpc_destroy_inode(struct inode *inode) ...@@ -220,23 +220,23 @@ rpc_destroy_inode(struct inode *inode)
static int static int
rpc_pipe_open(struct inode *inode, struct file *filp) rpc_pipe_open(struct inode *inode, struct file *filp)
{ {
struct rpc_inode *rpci = RPC_I(inode); struct rpc_pipe *pipe = RPC_I(inode)->pipe;
int first_open; int first_open;
int res = -ENXIO; int res = -ENXIO;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
if (rpci->pipe->ops == NULL) if (pipe->ops == NULL)
goto out; goto out;
first_open = rpci->pipe->nreaders == 0 && rpci->pipe->nwriters == 0; first_open = pipe->nreaders == 0 && pipe->nwriters == 0;
if (first_open && rpci->pipe->ops->open_pipe) { if (first_open && pipe->ops->open_pipe) {
res = rpci->pipe->ops->open_pipe(inode); res = pipe->ops->open_pipe(inode);
if (res) if (res)
goto out; goto out;
} }
if (filp->f_mode & FMODE_READ) if (filp->f_mode & FMODE_READ)
rpci->pipe->nreaders++; pipe->nreaders++;
if (filp->f_mode & FMODE_WRITE) if (filp->f_mode & FMODE_WRITE)
rpci->pipe->nwriters++; pipe->nwriters++;
res = 0; res = 0;
out: out:
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
...@@ -287,39 +287,39 @@ static ssize_t ...@@ -287,39 +287,39 @@ static ssize_t
rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset) rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
{ {
struct inode *inode = filp->f_path.dentry->d_inode; struct inode *inode = filp->f_path.dentry->d_inode;
struct rpc_inode *rpci = RPC_I(inode); struct rpc_pipe *pipe = RPC_I(inode)->pipe;
struct rpc_pipe_msg *msg; struct rpc_pipe_msg *msg;
int res = 0; int res = 0;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
if (rpci->pipe->ops == NULL) { if (pipe->ops == NULL) {
res = -EPIPE; res = -EPIPE;
goto out_unlock; goto out_unlock;
} }
msg = filp->private_data; msg = filp->private_data;
if (msg == NULL) { if (msg == NULL) {
spin_lock(&rpci->pipe->lock); spin_lock(&pipe->lock);
if (!list_empty(&rpci->pipe->pipe)) { if (!list_empty(&pipe->pipe)) {
msg = list_entry(rpci->pipe->pipe.next, msg = list_entry(pipe->pipe.next,
struct rpc_pipe_msg, struct rpc_pipe_msg,
list); list);
list_move(&msg->list, &rpci->pipe->in_upcall); list_move(&msg->list, &pipe->in_upcall);
rpci->pipe->pipelen -= msg->len; pipe->pipelen -= msg->len;
filp->private_data = msg; filp->private_data = msg;
msg->copied = 0; msg->copied = 0;
} }
spin_unlock(&rpci->pipe->lock); spin_unlock(&pipe->lock);
if (msg == NULL) if (msg == NULL)
goto out_unlock; goto out_unlock;
} }
/* NOTE: it is up to the callback to update msg->copied */ /* NOTE: it is up to the callback to update msg->copied */
res = rpci->pipe->ops->upcall(filp, msg, buf, len); res = pipe->ops->upcall(filp, msg, buf, len);
if (res < 0 || msg->len == msg->copied) { if (res < 0 || msg->len == msg->copied) {
filp->private_data = NULL; filp->private_data = NULL;
spin_lock(&rpci->pipe->lock); spin_lock(&pipe->lock);
list_del_init(&msg->list); list_del_init(&msg->list);
spin_unlock(&rpci->pipe->lock); spin_unlock(&pipe->lock);
rpci->pipe->ops->destroy_msg(msg); pipe->ops->destroy_msg(msg);
} }
out_unlock: out_unlock:
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
...@@ -330,13 +330,13 @@ static ssize_t ...@@ -330,13 +330,13 @@ static ssize_t
rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *offset) rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *offset)
{ {
struct inode *inode = filp->f_path.dentry->d_inode; struct inode *inode = filp->f_path.dentry->d_inode;
struct rpc_inode *rpci = RPC_I(inode); struct rpc_pipe *pipe = RPC_I(inode)->pipe;
int res; int res;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
res = -EPIPE; res = -EPIPE;
if (rpci->pipe->ops != NULL) if (pipe->ops != NULL)
res = rpci->pipe->ops->downcall(filp, buf, len); res = pipe->ops->downcall(filp, buf, len);
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
return res; return res;
} }
...@@ -344,16 +344,15 @@ rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *of ...@@ -344,16 +344,15 @@ rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *of
static unsigned int static unsigned int
rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait) rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait)
{ {
struct rpc_inode *rpci; struct rpc_pipe *pipe = RPC_I(filp->f_path.dentry->d_inode)->pipe;
unsigned int mask = 0; unsigned int mask = 0;
rpci = RPC_I(filp->f_path.dentry->d_inode); poll_wait(filp, &pipe->waitq, wait);
poll_wait(filp, &rpci->pipe->waitq, wait);
mask = POLLOUT | POLLWRNORM; mask = POLLOUT | POLLWRNORM;
if (rpci->pipe->ops == NULL) if (pipe->ops == NULL)
mask |= POLLERR | POLLHUP; mask |= POLLERR | POLLHUP;
if (filp->private_data || !list_empty(&rpci->pipe->pipe)) if (filp->private_data || !list_empty(&pipe->pipe))
mask |= POLLIN | POLLRDNORM; mask |= POLLIN | POLLRDNORM;
return mask; return mask;
} }
...@@ -362,23 +361,23 @@ static long ...@@ -362,23 +361,23 @@ static long
rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{ {
struct inode *inode = filp->f_path.dentry->d_inode; struct inode *inode = filp->f_path.dentry->d_inode;
struct rpc_inode *rpci = RPC_I(inode); struct rpc_pipe *pipe = RPC_I(inode)->pipe;
int len; int len;
switch (cmd) { switch (cmd) {
case FIONREAD: case FIONREAD:
spin_lock(&rpci->pipe->lock); spin_lock(&pipe->lock);
if (rpci->pipe->ops == NULL) { if (pipe->ops == NULL) {
spin_unlock(&rpci->pipe->lock); spin_unlock(&pipe->lock);
return -EPIPE; return -EPIPE;
} }
len = rpci->pipe->pipelen; len = pipe->pipelen;
if (filp->private_data) { if (filp->private_data) {
struct rpc_pipe_msg *msg; struct rpc_pipe_msg *msg;
msg = filp->private_data; msg = filp->private_data;
len += msg->len - msg->copied; len += msg->len - msg->copied;
} }
spin_unlock(&rpci->pipe->lock); spin_unlock(&pipe->lock);
return put_user(len, (int __user *)arg); return put_user(len, (int __user *)arg);
default: default:
return -EINVAL; return -EINVAL;
...@@ -808,7 +807,7 @@ static int rpc_rmdir_depopulate(struct dentry *dentry, ...@@ -808,7 +807,7 @@ static int rpc_rmdir_depopulate(struct dentry *dentry,
* @private: private data to associate with the pipe, for the caller's use * @private: private data to associate with the pipe, for the caller's use
* @ops: operations defining the behavior of the pipe: upcall, downcall, * @ops: operations defining the behavior of the pipe: upcall, downcall,
* release_pipe, open_pipe, and destroy_msg. * release_pipe, open_pipe, and destroy_msg.
* @flags: rpc_inode flags * @flags: rpc_pipe flags
* *
* Data is made available for userspace to read by calls to * Data is made available for userspace to read by calls to
* rpc_queue_upcall(). The actual reads will result in calls to * rpc_queue_upcall(). The actual reads will result in calls to
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册