]> Pileus Git - ~andy/linux/commit
pipe: take allocation and freeing of pipe_inode_info out of ->i_mutex
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 21 Mar 2013 06:21:19 +0000 (02:21 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 9 Apr 2013 18:12:59 +0000 (14:12 -0400)
commitba5bb147330a8737b6b5a812cc774c79c070704b
tree3043bd880634f47275a2083c53ed98ce2c1c70bc
parent18c03cfd403b88852f75f200206983ee6df28423
pipe: take allocation and freeing of pipe_inode_info out of ->i_mutex

* new field - pipe->files; number of struct file over that pipe (all
  sharing the same inode, of course); protected by inode->i_lock.
* pipe_release() decrements pipe->files, clears inode->i_pipe when
  if the counter has reached 0 (all under ->i_lock) and, in that case,
  frees pipe after having done pipe_unlock()
* fifo_open() starts with grabbing ->i_lock, and either bumps pipe->files
  if ->i_pipe was non-NULL or allocates a new pipe (dropping and regaining
  ->i_lock) and rechecks ->i_pipe; if it's still NULL, inserts new pipe
  there, otherwise bumps ->i_pipe->files and frees the one we'd allocated.
  At that point we know that ->i_pipe is non-NULL and won't go away, so
  we can do pipe_lock() on it and proceed as we used to.  If we end up
  failing, decrement pipe->files and if it reaches 0 clear ->i_pipe and
  free the sucker after pipe_unlock().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/pipe.c
include/linux/pipe_fs_i.h