博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
inode节点hash处理
阅读量:4154 次
发布时间:2019-05-25

本文共 1844 字,大约阅读时间需要 6 分钟。

static struct hlist_head *inode_hashtable __read_mostly;
/* * Initialize the waitqueues and inode hash table. */void __init inode_init_early(void){	unsigned int loop;	/* If hashes are distributed across NUMA nodes, defer	 * hash allocation until vmalloc space is available.	 */	if (hashdist)		return;	inode_hashtable =		alloc_large_system_hash("Inode-cache",					sizeof(struct hlist_head),					ihash_entries,					14,					HASH_EARLY,					&i_hash_shift,					&i_hash_mask,					0,					0);	for (loop = 0; loop < (1U << i_hash_shift); loop++)		INIT_HLIST_HEAD(&inode_hashtable[loop]);}
static inline void insert_inode_hash(struct inode *inode){	__insert_inode_hash(inode, inode->i_ino);}
 
static unsigned long hash(struct super_block *sb, unsigned long hashval){	unsigned long tmp;	tmp = (hashval * (unsigned long)sb) ^ (GOLDEN_RATIO_PRIME + hashval) /			L1_CACHE_BYTES;	tmp = tmp ^ ((tmp ^ GOLDEN_RATIO_PRIME) >> i_hash_shift);	return tmp & i_hash_mask;}
/**
 *	__insert_inode_hash - hash an inode *	@inode: unhashed inode *	@hashval: unsigned long value used to locate this object in the *		inode_hashtable. * *	Add an inode to the inode hash for this superblock. */void __insert_inode_hash(struct inode *inode, unsigned long hashval){	struct hlist_head *b = inode_hashtable + hash(inode->i_sb, hashval);	spin_lock(&inode_hash_lock);	spin_lock(&inode->i_lock);	hlist_add_head(&inode->i_hash, b);	spin_unlock(&inode->i_lock);	spin_unlock(&inode_hash_lock);}EXPORT_SYMBOL(__insert_inode_hash);
 /** * 
__remove_inode_hash -
remove an inode from the hash *
@inode: inode to unhash * *
Remove an inode from the superblock. */void
__remove_inode_hash(struct inode *inode){
spin_lock(&inode_hash_lock);
spin_lock(&inode->i_lock);
hlist_del_init(&inode->i_hash);
spin_unlock(&inode->i_lock);
spin_unlock(&inode_hash_lock);}EXPORT_SYMBOL(__remove_inode_hash);

转载地址:http://ywhti.baihongyu.com/

你可能感兴趣的文章
进程创建时内存描述符处理
查看>>
进程创建时命名空间处理
查看>>
进程创建时IO处理
查看>>
进程创建时线程栈处理
查看>>
进程创建时pid分配
查看>>
进程创建时安全计算处理
查看>>
进程创建时cgroup处理
查看>>
进程创建时共享内存处理
查看>>
idle进程创建
查看>>
内核线程创建
查看>>
linux elf tool readelf
查看>>
linux tool objdump
查看>>
linux tool nm
查看>>
字节对齐
查看>>
Python-发邮件
查看>>
python写入csv文件的两种方法
查看>>
pandas学习笔记—dataframe与list相互转化
查看>>
Keras和TensorFlow设置GPU及其使用率
查看>>
python常见异常处理方法
查看>>
pandas学习笔记—merge()函数详解
查看>>