/* flushes any old transactions to disk ends the current transaction if it is too old  */
int reiserfs_flush_old_commits(struct super_block *sb)
/* flushes any old transactions to disk ends the current transaction if it is too old  */
int reiserfs_flush_old_commits(struct super_block *sb)
{
	time_t now;
	struct reiserfs_transaction_handle th;
	struct reiserfs_journal *journal = SB_JOURNAL(sb);
	now = get_seconds();
	if (list_empty(&journal->j_journal_list)) {
		return 0;
	}
	if (atomic_read(&journal->j_wcount) <= 0 &&
	    journal->j_trans_start_time > 0 &&
	    journal->j_len > 0 &&
	    (now - journal->j_trans_start_time) > journal->j_max_trans_age) {
		if (!journal_join(&th, sb, 1)) {
			reiserfs_prepare_for_journal(sb,
						     SB_BUFFER_WITH_SB(sb),
						     1);
			journal_mark_dirty(&th, sb,
					   SB_BUFFER_WITH_SB(sb));
			do_journal_end(&th, sb, 1, COMMIT_NOW | WAIT);
		}
	}
	return sb->s_dirt;
}