예제 #1
0
파일: ref_info.c 프로젝트: lxl1140989/dmsdk
/*
  @dev_type : BCH_TYPE or NEMC_TYPE
  @init_flag: 0 open parameter
              1 init parameter
 */
ref_info *add_ref_info(int dev_type, int dev_id, int init_flag)
{
	struct list_head *pos;
	ref_info *refinfo = NULL;

	if (top == NULL){
		top = ndd_alloc(sizeof(ref_info));
		INIT_LIST_HEAD(top);
		ndd_debug("reflist top is created\n");
	}
	if(top->prev == top && top->next == top){
new:
		refinfo = alloc_new_node(dev_type,dev_id,init_flag);
		list_add_tail(&refinfo->head,top);
		ndd_debug("add :%d refinfo=%p  \n",__LINE__,refinfo);
	}else{
예제 #2
0
파일: file.c 프로젝트: sjtutravel/hmfs
/* dn->node_block should be writable */
int truncate_data_blocks_range(struct dnode_of_data *dn, int count)
{
	int nr_free = 0, ofs = dn->ofs_in_node;
	struct hmfs_sb_info *sbi = HMFS_SB(dn->inode->i_sb);
	struct hmfs_node *raw_node = (struct hmfs_node *)dn->node_block;
	struct hmfs_node *new_node = NULL;
	void *data_blk;
	block_t addr;
	nid_t nid;
	char sum_type;

	nid = le32_to_cpu(raw_node->footer.nid);
	sum_type = dn->level ? SUM_TYPE_DN : SUM_TYPE_INODE;
	new_node = alloc_new_node(sbi, nid, dn->inode, sum_type);

	if (IS_ERR(new_node))
		return PTR_ERR(new_node);
	for (; count > 0; count--, ofs++) {
		if (dn->level)
			addr = raw_node->dn.addr[ofs];
		else
			addr = raw_node->i.i_addr[ofs];
		if (addr == NULL_ADDR)
			continue;
		data_blk = ADDR(sbi, addr);
		if (dn->level)
			new_node->dn.addr[ofs] = NULL_ADDR;
		else
			new_node->i.i_addr[ofs] = NULL_ADDR;

		setup_summary_of_delete_block(sbi, addr);
		nr_free++;
	}
	if (nr_free) {
		dec_valid_block_count(sbi, dn->inode, nr_free);
		mark_inode_dirty(dn->inode);
	}

	return nr_free;
}