<commit_before>/* $Id$ */

#include <sys/param.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "psc_util/journal.h"

#include "pathnames.h"
#include "slconfig.h"
#include "sljournal.h"
#include "slashd.h"
#include "sb.h"

sl_inum_t
slmds_get_inum(void)
{
	struct slmds_jent_inum *sji;

	if (++sbm.sbm_sbs->sbs_inum % SLMDS_INUM_ALLOC_SZ == 0) {
		sji = pjournal_alloclog(&sbm.sbm_pj);
		sji->sji_inum = sbm.sbm_sbs->sbs_inum;
		pjournal_logwrite(&sbm.sbm_pj, SLJ_MDS_PJET_INUM, sji);
		free(sji);
	}
	return (sbm.sbm_sbs->sbs_inum);
}

void
slmds_journal_recover(void)
{
	struct psc_journal_enthdr *pje;
	struct psc_journal_walker pjw;
	int rc, loslot;
	u32 logenid;

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

#if 0
	/* 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)
		psc_fatal("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)
		psc_fatal("pjournal_walk");
#endif
	free(pje);
}

void
sl_journal_init(struct psc_journal *pj, size_t nent, size_t entsz, int ra)
{
	char fn[PATH_MAX];<commit_msg>free -> psc_freel, missed this somehow<commit_after>/* $Id$ */

#include <sys/param.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "psc_util/journal.h"

#include "pathnames.h"
#include "slconfig.h"
#include "sljournal.h"
#include "slashd.h"
#include "sb.h"

sl_inum_t
slmds_get_inum(void)
{
	struct slmds_jent_inum *sji;

	if (++sbm.sbm_sbs->sbs_inum % SLMDS_INUM_ALLOC_SZ == 0) {
		sji = pjournal_alloclog(&sbm.sbm_pj);
		sji->sji_inum = sbm.sbm_sbs->sbs_inum;
		pjournal_logwrite(&sbm.sbm_pj, SLJ_MDS_PJET_INUM, sji);
		psc_freel(sji, PJ_PJESZ(&sbm.sbm_pj));
	}
	return (sbm.sbm_sbs->sbs_inum);
}

void
slmds_journal_recover(void)
{
	struct psc_journal_enthdr *pje;
	struct psc_journal_walker pjw;
	int rc, loslot;
	u32 logenid;

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

#if 0
	/* 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)
		psc_fatal("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)
		psc_fatal("pjournal_walk");
#endif
	psc_freel(pje, PJ_PJESZ(&sbm.sbm_pj));
}

void
sl_journal_init(struct psc_journal *pj, size_t nent, size_t entsz, int ra)
{
	char fn[PATH_MAX];
{'fraction_non_alphanumeric': 0.15871531025880886, 'fraction_numerical': 0.008107265357031494, 'mean_word_length': 4.1328, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 24, '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': '4182453', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1524, 'n_words': 299}