/* Roll from one trans in the sequence of PERMANENT transactions to the next: permanent transactions are only flushed out when committed with XFS_TRANS_RELEASE_LOG_RES, but we still want as soon as possible to let chunks of it go to the log. So we commit the chunk we've been working on and get a new transaction to continue.  */
int xfs_trans_roll(struct xfs_trans **tpp, struct xfs_inode *dp)
/* Roll from one trans in the sequence of PERMANENT transactions to the next: permanent transactions are only flushed out when committed with XFS_TRANS_RELEASE_LOG_RES, but we still want as soon as possible to let chunks of it go to the log. So we commit the chunk we've been working on and get a new transaction to continue.  */
int xfs_trans_roll(struct xfs_trans **tpp, struct xfs_inode *dp)
{
	struct xfs_trans	*trans;
	unsigned int		logres, count;
	int			error;
	trans = *tpp;
	xfs_trans_log_inode(trans, dp, XFS_ILOG_CORE);
	logres = trans->t_log_res;
	count = trans->t_log_count;
	*tpp = xfs_trans_dup(trans);
	error = xfs_trans_commit(trans, 0);
	if (error)
		return (error);
	trans = *tpp;
	xfs_log_ticket_put(trans->t_ticket);
	error = xfs_trans_reserve(trans, 0, logres, 0,
				  XFS_TRANS_PERM_LOG_RES, count);
	if (error)
		return error;
	xfs_trans_ijoin(trans, dp, XFS_ILOCK_EXCL);
	xfs_trans_ihold(trans, dp);
	return 0;
}