@@ -634,6 +634,7 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
if (ret < 0)
goto err_out2;
kn->ino = ret;
+ kn->generation = atomic_inc_return(&root->next_generation);
atomic_set(&kn->count, 1);
atomic_set(&kn->active, KN_DEACTIVATED_BIAS);
@@ -877,6 +878,7 @@ struct kernfs_root *kernfs_create_root(struct kernfs_syscall_ops *scops,
ida_init(&root->ino_ida);
INIT_LIST_HEAD(&root->supers);
+ atomic_set(&root->next_generation, 0);
kn = __kernfs_new_node(root, "", S_IFDIR | S_IRUGO | S_IXUGO,
KERNFS_DIR);
@@ -220,6 +220,7 @@ static void kernfs_init_inode(struct kernfs_node *kn, struct inode *inode)
inode->i_private = kn;
inode->i_mapping->a_ops = &kernfs_aops;
inode->i_op = &kernfs_iops;
+ inode->i_generation = kn->generation;
set_default_inode_attr(inode, kn->mode);
kernfs_refresh_inode(kn, inode);
@@ -135,6 +135,7 @@ struct kernfs_node {
umode_t mode;
unsigned int ino;
struct kernfs_iattrs *iattr;
+ u32 generation;
};
/*
@@ -170,6 +171,7 @@ struct kernfs_root {
struct list_head supers;
wait_queue_head_t deactivate_waitq;
+ atomic_t next_generation;
};
struct kernfs_open_file {