<commit_before>/* $Id$ */

#include "psc_util/journal.h"


#define SLASH_INUM_ALLOC_SZ	1024	/* allocate 1024 inums at a time */

#define SLASH_PJET_VOID		0
#define SLASH_PJET_INUM		1

struct slash_jent_inum {
	struct psc_journal_enthdr	sji_hdr;
	slash_inum_t			sji_inum;
};

slash_inum_t
slash_get_inum(struct slash_sb_mem *sbm)
{
	struct slash_jent_inum *sji;

	if (++sbm->sbm_inum % INUM_ALLOC_SZ == 0) {
		sji = pjournal_alloclog(sbm->sbm_pj);
		sji->sgi_inum = sbm->sbm_inum;
		pjournal_writelog(sbm->sbm_pj, SLASH_PJET_INUM, sji);
		free(sji);
	}
	return (sbm->sbm_inum);
}

void
slash_journal_recover(struct slash_sb_mem *sbm)
{
	struct psc_journal_enthdr *pje;
	struct psc_journal_walker pjw;
	u32 logen;
	int loslot;

	logen = -1;
	loslot = 0; /* gcc */
	memset(&pjw, 0, sizeof(pjw));
	pje = pjournal_alloclog(pj);

	/* Locate the start of the lowest gen ID. */
	while ((rc = pjournal_walk(sbm->sbm_pj, &pjw, pje)) == 0) {
		if ((int)(pje->pje_gen - logen) < 0) {
			/*
			 * XXX if we wrapped, we should rescan from the
			 * beginning to find even earlier generations.
			 */
			loslot = pjw->pjw_pos;
			logen = pje->pje_gen;
		}
	}
	if (rc == -1)
		pfatal("pjournal_walk");

	/* Walk starting from where the last unapplied entry was stored. */
	memset(&pjw, 0, sizeof(pjw));
	pjw.pjw_pos = pjw.pjw_stop = loslot;
	while ((rc = pjournal_walk(sbm->sbm_pj, &pjw, pje)) == 0) {
	}
	if (rc == -1)
		pfatal("pjournal_walk");
	free(pje);
}<commit_msg>initial bits for simple transactions, much more work needed<commit_after>/* $Id$ */

#include "psc_util/journal.h"


#define SLASH_INUM_ALLOC_SZ	1024	/* allocate 1024 inums at a time */

#define SLASH_PJET_VOID		0
#define SLASH_PJET_INUM		1

struct slash_jent_inum {
	struct psc_journal_enthdr	sji_hdr;
	slash_inum_t			sji_inum;
};

slash_inum_t
slash_get_inum(struct slash_sb_mem *sbm)
{
	struct slash_jent_inum *sji;

	if (++sbm->sbm_inum % INUM_ALLOC_SZ == 0) {
		sji = pjournal_alloclog(sbm->sbm_pj);
		sji->sgi_inum = sbm->sbm_inum;
		pjournal_writelog(sbm->sbm_pj, SLASH_PJET_INUM, sji);
		free(sji);
	}
	return (sbm->sbm_inum);
}

void
slash_journal_recover(struct slash_sb_mem *sbm)
{
	struct psc_journal_enthdr *pje;
	struct psc_journal_walker pjw;
	u32 logenid;
	int loslot;

	logenid = -1;
	loslot = 0; /* gcc */
	memset(&pjw, 0, sizeof(pjw));
	pje = pjournal_alloclog(pj);

	/* Locate the start of the lowest gen ID. */
	while ((rc = pjournal_walk(sbm->sbm_pj, &pjw, pje)) == 0) {
		if ((int)(pje->pje_genid - logenid) < 0) {
			/*
			 * XXX if we wrapped, we should rescan from the
			 * beginning to find even earlier generations.
			 */
			loslot = pjw->pjw_pos;
			logenid = pje->pje_genid;
		}
	}
	if (rc == -1)
		pfatal("pjournal_walk");

	/* Walk starting from where the last unapplied entry was stored. */
	memset(&pjw, 0, sizeof(pjw));
	pjw.pjw_pos = pjw.pjw_stop = loslot;
	while ((rc = pjournal_walk(sbm->sbm_pj, &pjw, pje)) == 0) {
	}
	if (rc == -1)
		pfatal("pjournal_walk");
	free(pje);
}
{'fraction_non_alphanumeric': 0.1404040404040404, 'fraction_numerical': 0.014814814814814815, 'mean_word_length': 3.959933222036728, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2429818', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1354, 'n_words': 286}