X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/4b6190b935dd75d8ddd514a05c7c7343e32c0cdc..3b6a05fc894d0c1a3d431045ee5a53955ba093a0:/lunaix-os/kernel/fs/vfs.c diff --git a/lunaix-os/kernel/fs/vfs.c b/lunaix-os/kernel/fs/vfs.c index c9431ba..d0fbb1c 100644 --- a/lunaix-os/kernel/fs/vfs.c +++ b/lunaix-os/kernel/fs/vfs.c @@ -112,10 +112,10 @@ inline struct hbucket* __dcache_hash(struct v_dnode* parent, uint32_t* hash) { uint32_t _hash = *hash; - // 与parent的指针值做加法,来减小碰撞的可能性。 - _hash += (uint32_t)parent; // 确保低位更加随机 _hash = _hash ^ (_hash >> VFS_HASHBITS); + // 与parent的指针值做加法,来减小碰撞的可能性。 + _hash += (uint32_t)parent; *hash = _hash; return &dnode_cache[_hash & VFS_HASH_MASK]; } @@ -163,6 +163,7 @@ vfs_dcache_remove(struct v_dnode* dnode) assert(dnode->ref_count == 1); llist_delete(&dnode->siblings); + llist_delete(&dnode->aka_list); hlist_delete(&dnode->hash_list); dnode->parent = NULL; @@ -225,8 +226,10 @@ void vfs_assign_inode(struct v_dnode* assign_to, struct v_inode* inode) { if (assign_to->inode) { + llist_delete(&assign_to->aka_list); assign_to->inode->link_count--; } + llist_append(&inode->aka_dnodes, &assign_to->aka_list); assign_to->inode = inode; inode->link_count++; } @@ -387,6 +390,7 @@ vfs_d_alloc(struct v_dnode* parent, struct hstr* name) memset(dnode, 0, sizeof(*dnode)); llist_init_head(&dnode->children); llist_init_head(&dnode->siblings); + llist_init_head(&dnode->aka_list); mutex_init(&dnode->lock); dnode->ref_count = ATOMIC_VAR_INIT(0); @@ -469,6 +473,7 @@ vfs_i_alloc(struct v_superblock* sb) memset(inode, 0, sizeof(*inode)); mutex_init(&inode->lock); llist_init_head(&inode->xattrs); + llist_init_head(&inode->aka_dnodes); sb->ops.init_inode(sb, inode);