Ejemplo n.º 1
0
static int gfs_fill_super_info(struct gfs_super_info *si, u32 ino)
{
	struct gfs_inode_info *inode;
	struct gfs_super *raw;
	struct buffer_head *bh;
	int err;
	mutex_init(&si->s_mutex);
	
	inode = gfs_iget_info(si->s_vfs_sb, ino);
	PDEBUG("ino=%d PTR_ERR=%li\n", (int) ino, (long)PTR_ERR(inode));
	if (IS_ERR(inode)) 
		return PTR_ERR(inode);
	
	si->s_super_inode = inode;
	bh = get_inode_data(inode,0);
	if(!bh)
		return -EIO;
	MARK();	
	raw = (struct gfs_super *) (bh->b_data + sizeof(struct gfs_inode));
	
	err = init_super_from_raw(si, raw);

	put_inode_data(inode,0);
	return err;
}
Ejemplo n.º 2
0
int gfs_write_inode(struct inode *inode, struct writeback_control *wbc)
{
	struct gfs_inode_info *gfs_inode = GFS_INODE(inode);
	struct gfs_inode *raw_inode;
	struct buffer_head *bh = get_inode_data(gfs_inode, 1);
	if(!bh) {
		PDEBUG("-EIO\n");
		return -EIO;
	}
	
	raw_inode = (struct gfs_inode *)bh->b_data;
	
	if(inode->i_ino == 0) {
		struct gfs_super *raw_super = (struct gfs_super *) (bh->b_data + sizeof(struct gfs_inode));
		init_raw_from_super(raw_super, inode->i_sb->s_fs_info);
	}

	gfs_init_raw_from_inode(raw_inode, gfs_inode);
	PDEBUG("Writing inode %ld %o %o\n", inode->i_ino, le32_to_cpu(raw_inode->i_mode), inode ->i_mode);	
	
	sync_inode_data(gfs_inode);
	put_inode_data(gfs_inode, 1);
	
	return 0;
}
Ejemplo n.º 3
0
struct inode *gfs_iget_new(struct gfs_super_info *sb)
{
	struct gfs_inode_info *inode;
	bool err = 0;
	u32 ino = grab_free_ino(sb, &err);
	if(err) {
		gfs_info("No more free space\n");
		return ERR_PTR(-ENOMEM);            /* TODO: Really ENOMEM ?*/
	}
	BUG_ON(!__is_bit_used(sb->s_inode_map, ino));
	inode = gfs_iget_info(sb->s_vfs_sb, ino);
	if(IS_ERR(inode)) {
		PDEBUG("get info\n");
		return ERR_CAST(inode);
	}
			
	BUG_ON(inode->vfs_inode.i_state & I_NEW);
	
	if(!get_inode_data(inode,1))
		goto err;
	RAW_INODE(inode)->i_flags = cpu_to_le32(GI_INO_USED);
	RAW_INODE(inode)->i_nlink = cpu_to_le32(1);
	set_nlink(VFS_INODE(inode), 1);
	put_inode_data(inode, 1);

	gfs_dbg("New ino: %ld %i\n",VFS_INODE(inode)->i_ino, VFS_INODE(inode)->i_nlink);
	
	return VFS_INODE(inode);
err:
	gfs_put_inode(inode);
	return ERR_PTR(-EIO);
}
Ejemplo n.º 4
0
int gfs_junk_inode(struct gfs_inode *inode)
{	
	if(!get_inode_data(inode, 1))
		return -ENOMEM;
	BUG_ON(inode->i_flags & GI_INO_JUNK);
	inode->i_flags |= GI_INO_JUNK;
	mark_inode_dirty(VFS_INODE(inode));
	
	put_inode_data(inode, 1);
	return 0;
}
Ejemplo n.º 5
0
static struct gfs_inode_info *gfs_iget_info(struct super_block *sb, u32 ino) 
{
	struct gfs_inode_info *gfs_inode;
	struct gfs_inode  *raw_inode;
	struct buffer_head   *bh;
	struct inode  *vfs_inode;
	PDEBUG("ino=%d\n", (int)ino);
	vfs_inode = iget_locked(sb, ino);
	if(!vfs_inode) 
		return ERR_PTR(-ENOMEM);
	

	gfs_inode = GFS_INODE(vfs_inode);
	
	if(vfs_inode->i_state &  I_NEW) {
		bh = get_inode_data(gfs_inode, 0);
		if(!bh) {
			PDEBUG("IO\n");
			return ERR_PTR(-EIO);
		}
		
		raw_inode = (struct gfs_inode*)bh->b_data;
		PDEBUG("Raw Inode %o\n", raw_inode->i_mode);
		
		gfs_init_inode_from_raw(gfs_inode, RAW_INODE(gfs_inode));

		gfs_inode->i_ex_inode = NULL;
		gfs_inode->i_exino = 0xabcd;


		
		put_inode_data(gfs_inode, 0);
		unlock_new_inode(vfs_inode);

	}
	print_inode(gfs_inode);
	return gfs_inode;
}
Ejemplo n.º 6
0
Archivo: inode.c Proyecto: qpig/sfs
void put_inode( struct m_inode *inode )
{
	put_inode_itable( inode );
	put_inode_data( inode );
	free_memery_inode( inode );
}