mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 14:41:27 +00:00
kernfs: convert kernfs_node->id from union kernfs_node_id to u64
kernfs_node->id is currently a union kernfs_node_id which represents either a 32bit (ino, gen) pair or u64 value. I can't see much value in the usage of the union - all that's needed is a 64bit ID which the current code is already limited to. Using a union makes the code unnecessarily complicated and prevents using 64bit ino without adding practical benefits. This patch drops union kernfs_node_id and makes kernfs_node->id a u64. ino is stored in the lower 32bits and gen upper. Accessors - kernfs[_id]_ino() and kernfs[_id]_gen() - are added to retrieve the ino and gen. This simplifies ID handling less cumbersome and will allow using 64bit inos on supported archs. This patch doesn't make any functional changes. Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
880df13161
commit
67c0496e87
12 changed files with 85 additions and 84 deletions
|
@ -532,7 +532,7 @@ void kernfs_put(struct kernfs_node *kn)
|
|||
kmem_cache_free(kernfs_iattrs_cache, kn->iattr);
|
||||
}
|
||||
spin_lock(&kernfs_idr_lock);
|
||||
idr_remove(&root->ino_idr, kn->id.ino);
|
||||
idr_remove(&root->ino_idr, kernfs_ino(kn));
|
||||
spin_unlock(&kernfs_idr_lock);
|
||||
kmem_cache_free(kernfs_node_cache, kn);
|
||||
|
||||
|
@ -639,8 +639,8 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
|
|||
idr_preload_end();
|
||||
if (ret < 0)
|
||||
goto err_out2;
|
||||
kn->id.ino = ret;
|
||||
kn->id.generation = gen;
|
||||
|
||||
kn->id = (u64)gen << 32 | ret;
|
||||
|
||||
atomic_set(&kn->count, 1);
|
||||
atomic_set(&kn->active, KN_DEACTIVATED_BIAS);
|
||||
|
@ -671,7 +671,7 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
|
|||
return kn;
|
||||
|
||||
err_out3:
|
||||
idr_remove(&root->ino_idr, kn->id.ino);
|
||||
idr_remove(&root->ino_idr, kernfs_ino(kn));
|
||||
err_out2:
|
||||
kmem_cache_free(kernfs_node_cache, kn);
|
||||
err_out1:
|
||||
|
@ -1656,7 +1656,7 @@ static int kernfs_fop_readdir(struct file *file, struct dir_context *ctx)
|
|||
const char *name = pos->name;
|
||||
unsigned int type = dt_type(pos);
|
||||
int len = strlen(name);
|
||||
ino_t ino = pos->id.ino;
|
||||
ino_t ino = kernfs_ino(pos);
|
||||
|
||||
ctx->pos = pos->hash;
|
||||
file->private_data = pos;
|
||||
|
|
|
@ -892,7 +892,7 @@ repeat:
|
|||
* have the matching @file available. Look up the inodes
|
||||
* and generate the events manually.
|
||||
*/
|
||||
inode = ilookup(info->sb, kn->id.ino);
|
||||
inode = ilookup(info->sb, kernfs_ino(kn));
|
||||
if (!inode)
|
||||
continue;
|
||||
|
||||
|
@ -901,7 +901,7 @@ repeat:
|
|||
if (parent) {
|
||||
struct inode *p_inode;
|
||||
|
||||
p_inode = ilookup(info->sb, parent->id.ino);
|
||||
p_inode = ilookup(info->sb, kernfs_ino(parent));
|
||||
if (p_inode) {
|
||||
fsnotify(p_inode, FS_MODIFY | FS_EVENT_ON_CHILD,
|
||||
inode, FSNOTIFY_EVENT_INODE, &name, 0);
|
||||
|
|
|
@ -201,7 +201,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->id.generation;
|
||||
inode->i_generation = kernfs_gen(kn);
|
||||
|
||||
set_default_inode_attr(inode, kn->mode);
|
||||
kernfs_refresh_inode(kn, inode);
|
||||
|
@ -247,7 +247,7 @@ struct inode *kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn)
|
|||
{
|
||||
struct inode *inode;
|
||||
|
||||
inode = iget_locked(sb, kn->id.ino);
|
||||
inode = iget_locked(sb, kernfs_ino(kn));
|
||||
if (inode && (inode->i_state & I_NEW))
|
||||
kernfs_init_inode(kn, inode);
|
||||
|
||||
|
|
|
@ -57,15 +57,14 @@ const struct super_operations kernfs_sops = {
|
|||
* Similar to kernfs_fh_get_inode, this one gets kernfs node from inode
|
||||
* number and generation
|
||||
*/
|
||||
struct kernfs_node *kernfs_get_node_by_id(struct kernfs_root *root,
|
||||
const union kernfs_node_id *id)
|
||||
struct kernfs_node *kernfs_get_node_by_id(struct kernfs_root *root, u64 id)
|
||||
{
|
||||
struct kernfs_node *kn;
|
||||
|
||||
kn = kernfs_find_and_get_node_by_ino(root, id->ino);
|
||||
kn = kernfs_find_and_get_node_by_ino(root, kernfs_id_ino(id));
|
||||
if (!kn)
|
||||
return NULL;
|
||||
if (kn->id.generation != id->generation) {
|
||||
if (kernfs_gen(kn) != kernfs_id_gen(id)) {
|
||||
kernfs_put(kn);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue