]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
kernfs: invoke dir_ops while holding active ref of the target node
authorTejun Heo <tj@kernel.org>
Mon, 3 Feb 2014 19:09:08 +0000 (14:09 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Feb 2014 23:52:48 +0000 (15:52 -0800)
commit07c7530dd46728e25e938d0eb291f8085435c365
treeaf31cc0ecb79794e1294b7781350afc45c1657d2
parentce8b04aa6c9bdf211b921fdd18c040ea29516b97
kernfs: invoke dir_ops while holding active ref of the target node

kernfs_dir_ops are currently being invoked without any active
reference, which makes it tricky for the invoked operations to
determine whether the objects associated those nodes are safe to
access and will remain that way for the duration of such operations.

kernfs already has active_ref mechanism to deal with this which makes
the removal of a given node the synchronization point for gating the
file operations.  There's no reason for dir_ops to be any different.
Update the dir_ops handling so that active_ref is held while the
dir_ops are executing.  This guarantees that while a dir_ops is
executing the target nodes stay alive.

As kernfs_dir_ops doesn't have any in-kernel user at this point, this
doesn't affect anybody.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/kernfs/dir.c
include/linux/kernfs.h