We don't really want backlinks into the VFS, however, we need some way to
thrash old VFS cache entries when objects get destructed. Therefore, safe
a pointer to the root dentry in every domain.
We don't pin the dentry, as this would create circular dependencies.
Instead, we bind the dentry validity to the active lifetime of the domain.
Therefore, you can only access domain->dentry as long as it is active.
Once umount() is called, we deactivate the domain and thus drop the dentry
cache.
This backlink will be needed in a follow-up that flushes caches on object
destruction.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
#ifndef __KDBUS_DOMAIN_H
#define __KDBUS_DOMAIN_H
+#include <linux/fs.h>
#include <linux/hashtable.h>
#include <linux/idr.h>
#include <linux/kref.h>
* @user_hash: Accounting of user resources
* @user_idr: Map of all users; smallest possible index
* @user_namespace: User namespace, pinned at creation time
+ * @dentry: Root dentry of VFS mount (dont use outside of kdbusfs)
*/
struct kdbus_domain {
struct kdbus_node node;
DECLARE_HASHTABLE(user_hash, 6);
struct idr user_idr;
struct user_namespace *user_namespace;
+ struct dentry *dentry;
};
/**
*/
#include <linux/backing-dev.h>
+#include <linux/dcache.h>
#include <linux/fs.h>
#include <linux/fsnotify.h>
#include <linux/init.h>
sb->s_root->d_fsdata = &domain->node;
sb->s_d_op = &fs_super_dops;
+ /* sb holds root reference */
+ domain->dentry = sb->s_root;
+
ret = kdbus_domain_activate(domain);
if (ret < 0)
return ret;
if (domain) {
kdbus_domain_deactivate(domain);
+ domain->dentry = NULL;
}
kill_anon_super(sb);