/* If the create succeeds, we fill in the inode information with d_instantiate().  */
static int nilfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd)
/* If the create succeeds, we fill in the inode information with d_instantiate().  */
static int nilfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd)
{
	struct inode *inode;
	struct nilfs_transaction_info ti;
	int err;
	err = nilfs_transaction_begin(dir->i_sb, &ti, 1);
	if (err)
		return err;
	inode = nilfs_new_inode(dir, mode);
	err = PTR_ERR(inode);
	if (!IS_ERR(inode)) {
		inode->i_op = &nilfs_file_inode_operations;
		inode->i_fop = &nilfs_file_operations;
		inode->i_mapping->a_ops = &nilfs_aops;
		nilfs_mark_inode_dirty(inode);
		err = nilfs_add_nondir(dentry, inode);
	}
	if (!err)
		err = nilfs_transaction_commit(dir->i_sb);
	else
		nilfs_transaction_abort(dir->i_sb);
	return err;
}