diff options
-rw-r--r-- | net/sunrpc/rpc_pipe.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index c9b57f47108c..3105efbb182d 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c | |||
@@ -126,13 +126,14 @@ rpc_close_pipes(struct inode *inode) | |||
126 | { | 126 | { |
127 | struct rpc_inode *rpci = RPC_I(inode); | 127 | struct rpc_inode *rpci = RPC_I(inode); |
128 | struct rpc_pipe_ops *ops; | 128 | struct rpc_pipe_ops *ops; |
129 | int need_release; | ||
129 | 130 | ||
130 | mutex_lock(&inode->i_mutex); | 131 | mutex_lock(&inode->i_mutex); |
131 | ops = rpci->ops; | 132 | ops = rpci->ops; |
132 | if (ops != NULL) { | 133 | if (ops != NULL) { |
133 | LIST_HEAD(free_list); | 134 | LIST_HEAD(free_list); |
134 | |||
135 | spin_lock(&inode->i_lock); | 135 | spin_lock(&inode->i_lock); |
136 | need_release = rpci->nreaders != 0 || rpci->nwriters != 0; | ||
136 | rpci->nreaders = 0; | 137 | rpci->nreaders = 0; |
137 | list_splice_init(&rpci->in_upcall, &free_list); | 138 | list_splice_init(&rpci->in_upcall, &free_list); |
138 | list_splice_init(&rpci->pipe, &free_list); | 139 | list_splice_init(&rpci->pipe, &free_list); |
@@ -141,7 +142,7 @@ rpc_close_pipes(struct inode *inode) | |||
141 | spin_unlock(&inode->i_lock); | 142 | spin_unlock(&inode->i_lock); |
142 | rpc_purge_list(rpci, &free_list, ops->destroy_msg, -EPIPE); | 143 | rpc_purge_list(rpci, &free_list, ops->destroy_msg, -EPIPE); |
143 | rpci->nwriters = 0; | 144 | rpci->nwriters = 0; |
144 | if (ops->release_pipe) | 145 | if (need_release && ops->release_pipe) |
145 | ops->release_pipe(inode); | 146 | ops->release_pipe(inode); |
146 | cancel_delayed_work_sync(&rpci->queue_timeout); | 147 | cancel_delayed_work_sync(&rpci->queue_timeout); |
147 | } | 148 | } |
@@ -196,6 +197,7 @@ rpc_pipe_release(struct inode *inode, struct file *filp) | |||
196 | { | 197 | { |
197 | struct rpc_inode *rpci = RPC_I(inode); | 198 | struct rpc_inode *rpci = RPC_I(inode); |
198 | struct rpc_pipe_msg *msg; | 199 | struct rpc_pipe_msg *msg; |
200 | int last_close; | ||
199 | 201 | ||
200 | mutex_lock(&inode->i_mutex); | 202 | mutex_lock(&inode->i_mutex); |
201 | if (rpci->ops == NULL) | 203 | if (rpci->ops == NULL) |
@@ -222,7 +224,8 @@ rpc_pipe_release(struct inode *inode, struct file *filp) | |||
222 | rpci->ops->destroy_msg, -EAGAIN); | 224 | rpci->ops->destroy_msg, -EAGAIN); |
223 | } | 225 | } |
224 | } | 226 | } |
225 | if (rpci->ops->release_pipe) | 227 | last_close = rpci->nwriters == 0 && rpci->nreaders == 0; |
228 | if (last_close && rpci->ops->release_pipe) | ||
226 | rpci->ops->release_pipe(inode); | 229 | rpci->ops->release_pipe(inode); |
227 | out: | 230 | out: |
228 | mutex_unlock(&inode->i_mutex); | 231 | mutex_unlock(&inode->i_mutex); |