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

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

inode节点销毁:
static void destroy_inode(struct inode *inode){	BUG_ON(!list_empty(&inode->i_lru));	__destroy_inode(inode);	if (inode->i_sb->s_op->destroy_inode)		inode->i_sb->s_op->destroy_inode(inode);	else		call_rcu(&inode->i_rcu, i_callback);}
 
void __destroy_inode(struct inode *inode){	BUG_ON(inode_has_buffers(inode));	inode_detach_wb(inode);	security_inode_free(inode);	fsnotify_inode_delete(inode);	locks_free_lock_context(inode);	if (!inode->i_nlink) {		WARN_ON(atomic_long_read(&inode->i_sb->s_remove_count) == 0);		atomic_long_dec(&inode->i_sb->s_remove_count);	}#ifdef CONFIG_FS_POSIX_ACL	if (inode->i_acl && !is_uncached_acl(inode->i_acl))		posix_acl_release(inode->i_acl);	if (inode->i_default_acl && !is_uncached_acl(inode->i_default_acl))		posix_acl_release(inode->i_default_acl);#endif	this_cpu_dec(nr_inodes);}EXPORT_SYMBOL(__destroy_inode);
 
static void i_callback(struct rcu_head *head){	struct inode *inode = container_of(head, struct inode, i_rcu);	kmem_cache_free(inode_cachep, inode);}
 
1. evict
/* * Free the inode passed in, removing it from the lists it is still connected * to. We remove any pages still attached to the inode and wait for any IO that * is still in progress before finally destroying the inode. * * An inode must already be marked I_FREEING so that we avoid the inode being * moved back onto lists if we race with other code that manipulates the lists * (e.g. writeback_single_inode). The caller is responsible for setting this. * * An inode must already be removed from the LRU list before being evicted from * the cache. This should occur atomically with setting the I_FREEING state * flag, so no inodes here should ever be on the LRU when being evicted. */static void evict(struct inode *inode){	const struct super_operations *op = inode->i_sb->s_op;	BUG_ON(!(inode->i_state & I_FREEING));	BUG_ON(!list_empty(&inode->i_lru));	if (!list_empty(&inode->i_io_list))		inode_io_list_del(inode);	inode_sb_list_del(inode);	/*	 * Wait for flusher thread to be done with the inode so that filesystem	 * does not start destroying it while writeback is still running. Since	 * the inode has I_FREEING set, flusher thread won't start new work on	 * the inode.  We just have to wait for running writeback to finish.	 */	inode_wait_for_writeback(inode);	if (op->evict_inode) {		op->evict_inode(inode);	} else {		truncate_inode_pages_final(&inode->i_data);		clear_inode(inode);	}	if (S_ISBLK(inode->i_mode) && inode->i_bdev)		bd_forget(inode);	if (S_ISCHR(inode->i_mode) && inode->i_cdev)		cd_forget(inode);	remove_inode_hash(inode);	spin_lock(&inode->i_lock);	wake_up_bit(&inode->i_state, __I_NEW);	BUG_ON(inode->i_state != (I_FREEING | I_CLEAR));	spin_unlock(&inode->i_lock);	destroy_inode(inode);}

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

你可能感兴趣的文章
nginx反代 499 502 bad gateway 和timeout
查看>>
linux虚拟机安装tar.gz版jdk步骤详解
查看>>
Kubernetes集群搭建之CNI-Flanneld部署篇
查看>>
k8s web终端连接工具
查看>>
手绘VS码绘(一):静态图绘制(码绘使用P5.js)
查看>>
《达芬奇的人生密码》观后感
查看>>
基于“分形”编写的交互应用
查看>>
链睿和家乐福合作推出下一代零售业隐私保护技术
查看>>
Unifrax宣布新建SiFAB™生产线
查看>>
艾默生纪念谷轮™在空调和制冷领域的百年创新成就
查看>>
NEXO代币持有者获得20,428,359.89美元股息
查看>>
Piper Sandler为EverArc收购Perimeter Solutions提供咨询服务
查看>>
RMRK筹集600万美元,用于在Polkadot上建立先进的NFT系统标准
查看>>
JavaSE_day14 集合中的Map集合_键值映射关系
查看>>
异常 Java学习Day_15
查看>>
Mysql初始化的命令
查看>>
MySQL关键字的些许问题
查看>>
浅谈HTML
查看>>
css基础
查看>>
Servlet进阶和JSP基础
查看>>