Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Trond Myklebust <Trond.Myklebust@netapp.com>

+9 -4
+1
include/linux/sunrpc/rpc_pipe_fs.h
··· 27 27 int pipelen; 28 28 int nreaders; 29 29 int nwriters; 30 + int nkern_readwriters; 30 31 wait_queue_head_t waitq; 31 32 #define RPC_PIPE_WAIT_FOR_OPEN 1 32 33 int flags;
+8 -4
net/sunrpc/rpc_pipe.c
··· 737 737 dput (dentry); 738 738 dentry = ERR_PTR(-EBUSY); 739 739 } 740 + rpci->nkern_readwriters++; 740 741 goto out; 741 742 } 742 743 inode = rpc_get_inode(dir->i_sb, S_IFIFO | S_IRUSR | S_IWUSR); ··· 750 749 rpci->private = private; 751 750 rpci->flags = flags; 752 751 rpci->ops = ops; 752 + rpci->nkern_readwriters = 1; 753 753 inode_dir_notify(dir, DN_CREATE); 754 754 dget(dentry); 755 755 out: ··· 775 773 parent = dget_parent(dentry); 776 774 dir = parent->d_inode; 777 775 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); 778 - rpc_close_pipes(dentry->d_inode); 779 - error = simple_unlink(dir, dentry); 780 - if (!error) 781 - d_delete(dentry); 776 + if (--RPC_I(dentry->d_inode)->nkern_readwriters == 0) { 777 + rpc_close_pipes(dentry->d_inode); 778 + error = simple_unlink(dir, dentry); 779 + if (!error) 780 + d_delete(dentry); 781 + } 782 782 dput(dentry); 783 783 mutex_unlock(&dir->i_mutex); 784 784 dput(parent);