kernfs: add kernfs_ops->open/release() callbacks

Add ->open/release() methods to kernfs_ops.  ->open() is called when
the file is opened and ->release() when the file is either released or
severed.  These callbacks can be used, for example, to manage
persistent caching objects over multiple seq_file iterations.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Acked-by: Zefan Li <lizefan@huawei.com>
This commit is contained in:
Tejun Heo
2016-12-27 14:49:03 -05:00
parent a1d82aff5d
commit 0e67db2f9f
4 changed files with 57 additions and 8 deletions

View File

@@ -468,7 +468,7 @@ static void kernfs_drain(struct kernfs_node *kn)
rwsem_release(&kn->dep_map, 1, _RET_IP_);
}
kernfs_unmap_bin_file(kn);
kernfs_drain_open_files(kn);
mutex_lock(&kernfs_mutex);
}