/* Return a pointer to a newly allocated handle, or NULL on failure  */
handle_t* jbd2_journal_start(journal_t *journal, int nblocks)
/* Return a pointer to a newly allocated handle, or NULL on failure  */
handle_t* jbd2_journal_start(journal_t *journal, int nblocks)
{
	handle_t *handle = journal_current_handle();
	int err;
	if (!journal)
		return ERR_PTR(-EROFS);
	if (handle) {
		J_ASSERT(handle->h_transaction->t_journal == journal);
		handle->h_ref++;
		return handle;
	}
	handle = new_handle(nblocks);
	if (!handle)
		return ERR_PTR(-ENOMEM);
	current->journal_info = handle;
	err = start_this_handle(journal, handle);
	if (err < 0) {
		jbd2_free_handle(handle);
		current->journal_info = NULL;
		handle = ERR_PTR(err);
		goto out;
	}
out:
	return handle;
}