/* Start a commit of the current running transaction (if any). Returns true if a transaction is going to be committed (or is currently already committing), and fills its tid in at *ptid  */
int journal_start_commit(journal_t *journal, tid_t *ptid)
/* Start a commit of the current running transaction (if any). Returns true if a transaction is going to be committed (or is currently already committing), and fills its tid in at *ptid  */
int journal_start_commit(journal_t *journal, tid_t *ptid)
{
	int ret = 0;
	spin_lock(&journal->j_state_lock);
	if (journal->j_running_transaction) {
		tid_t tid = journal->j_running_transaction->t_tid;
		__log_start_commit(journal, tid);
		if (ptid)
			*ptid = tid;
		ret = 1;
	} else if (journal->j_committing_transaction) {
		if (ptid)
			*ptid = journal->j_committing_transaction->t_tid;
		ret = 1;
	}
	spin_unlock(&journal->j_state_lock);
	return ret;
}