Commit 03a1256f authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: Add a field to track the number of kernel users of an rpc_pipe

This allows us to correctly deduce when we need to remove the pipe.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 62e1761c
...@@ -27,6 +27,7 @@ struct rpc_inode { ...@@ -27,6 +27,7 @@ struct rpc_inode {
int pipelen; int pipelen;
int nreaders; int nreaders;
int nwriters; int nwriters;
int nkern_readwriters;
wait_queue_head_t waitq; wait_queue_head_t waitq;
#define RPC_PIPE_WAIT_FOR_OPEN 1 #define RPC_PIPE_WAIT_FOR_OPEN 1
int flags; int flags;
......
...@@ -737,6 +737,7 @@ rpc_mkpipe(struct dentry *parent, const char *name, void *private, struct rpc_pi ...@@ -737,6 +737,7 @@ rpc_mkpipe(struct dentry *parent, const char *name, void *private, struct rpc_pi
dput (dentry); dput (dentry);
dentry = ERR_PTR(-EBUSY); dentry = ERR_PTR(-EBUSY);
} }
rpci->nkern_readwriters++;
goto out; goto out;
} }
inode = rpc_get_inode(dir->i_sb, S_IFIFO | S_IRUSR | S_IWUSR); inode = rpc_get_inode(dir->i_sb, S_IFIFO | S_IRUSR | S_IWUSR);
...@@ -749,6 +750,7 @@ rpc_mkpipe(struct dentry *parent, const char *name, void *private, struct rpc_pi ...@@ -749,6 +750,7 @@ rpc_mkpipe(struct dentry *parent, const char *name, void *private, struct rpc_pi
rpci->private = private; rpci->private = private;
rpci->flags = flags; rpci->flags = flags;
rpci->ops = ops; rpci->ops = ops;
rpci->nkern_readwriters = 1;
inode_dir_notify(dir, DN_CREATE); inode_dir_notify(dir, DN_CREATE);
dget(dentry); dget(dentry);
out: out:
...@@ -773,10 +775,12 @@ rpc_unlink(struct dentry *dentry) ...@@ -773,10 +775,12 @@ rpc_unlink(struct dentry *dentry)
parent = dget_parent(dentry); parent = dget_parent(dentry);
dir = parent->d_inode; dir = parent->d_inode;
mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
rpc_close_pipes(dentry->d_inode); if (--RPC_I(dentry->d_inode)->nkern_readwriters == 0) {
error = simple_unlink(dir, dentry); rpc_close_pipes(dentry->d_inode);
if (!error) error = simple_unlink(dir, dentry);
d_delete(dentry); if (!error)
d_delete(dentry);
}
dput(dentry); dput(dentry);
mutex_unlock(&dir->i_mutex); mutex_unlock(&dir->i_mutex);
dput(parent); dput(parent);
......
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