linux/fs/bcachefs/journal.c

// SPDX-License-Identifier: GPL-2.0
/*
 * bcachefs journalling code, for btree insertions
 *
 * Copyright 2012 Google, Inc.
 */

#include "bcachefs.h"
#include "alloc_foreground.h"
#include "bkey_methods.h"
#include "btree_gc.h"
#include "btree_update.h"
#include "btree_write_buffer.h"
#include "buckets.h"
#include "error.h"
#include "journal.h"
#include "journal_io.h"
#include "journal_reclaim.h"
#include "journal_sb.h"
#include "journal_seq_blacklist.h"
#include "trace.h"

static const char * const bch2_journal_errors[] =;

static inline bool journal_seq_unwritten(struct journal *j, u64 seq)
{}

static bool __journal_entry_is_open(union journal_res_state state)
{}

static inline unsigned nr_unwritten_journal_entries(struct journal *j)
{}

static bool journal_entry_is_open(struct journal *j)
{}

static void bch2_journal_buf_to_text(struct printbuf *out, struct journal *j, u64 seq)
{}

static void bch2_journal_bufs_to_text(struct printbuf *out, struct journal *j)
{}

static inline struct journal_buf *
journal_seq_to_buf(struct journal *j, u64 seq)
{}

static void journal_pin_list_init(struct journal_entry_pin_list *p, int count)
{}

/*
 * Detect stuck journal conditions and trigger shutdown. Technically the journal
 * can end up stuck for a variety of reasons, such as a blocked I/O, journal
 * reservation lockup, etc. Since this is a fatal error with potentially
 * unpredictable characteristics, we want to be fairly conservative before we
 * decide to shut things down.
 *
 * Consider the journal stuck when it appears full with no ability to commit
 * btree transactions, to discard journal buckets, nor acquire priority
 * (reserved watermark) reservation.
 */
static inline bool
journal_error_check_stuck(struct journal *j, int error, unsigned flags)
{}

void bch2_journal_do_writes(struct journal *j)
{}

/*
 * Final processing when the last reference of a journal buffer has been
 * dropped. Drop the pin list reference acquired at journal entry open and write
 * the buffer, if requested.
 */
void bch2_journal_buf_put_final(struct journal *j, u64 seq)
{}

/*
 * Returns true if journal entry is now closed:
 *
 * We don't close a journal_buf until the next journal_buf is finished writing,
 * and can be opened again - this also initializes the next journal_buf:
 */
static void __journal_entry_close(struct journal *j, unsigned closed_val, bool trace)
{}

void bch2_journal_halt(struct journal *j)
{}

static bool journal_entry_want_write(struct journal *j)
{}

bool bch2_journal_entry_close(struct journal *j)
{}

/*
 * should _only_ called from journal_res_get() - when we actually want a
 * journal reservation - journal entry is open means journal is dirty:
 */
static int journal_entry_open(struct journal *j)
{}

static bool journal_quiesced(struct journal *j)
{}

static void journal_quiesce(struct journal *j)
{}

static void journal_write_work(struct work_struct *work)
{}

static int __journal_res_get(struct journal *j, struct journal_res *res,
			     unsigned flags)
{}

/*
 * Essentially the entry function to the journaling code. When bcachefs is doing
 * a btree insert, it calls this function to get the current journal write.
 * Journal write is the structure used set up journal writes. The calling
 * function will then add its keys to the structure, queuing them for the next
 * write.
 *
 * To ensure forward progress, the current task must not be holding any
 * btree node write locks.
 */
int bch2_journal_res_get_slowpath(struct journal *j, struct journal_res *res,
				  unsigned flags)
{}

/* journal_entry_res: */

void bch2_journal_entry_res_resize(struct journal *j,
				   struct journal_entry_res *res,
				   unsigned new_u64s)
{}

/* journal flushing: */

/**
 * bch2_journal_flush_seq_async - wait for a journal entry to be written
 * @j:		journal object
 * @seq:	seq to flush
 * @parent:	closure object to wait with
 * Returns:	1 if @seq has already been flushed, 0 if @seq is being flushed,
 *		-EIO if @seq will never be flushed
 *
 * Like bch2_journal_wait_on_seq, except that it triggers a write immediately if
 * necessary
 */
int bch2_journal_flush_seq_async(struct journal *j, u64 seq,
				 struct closure *parent)
{}

int bch2_journal_flush_seq(struct journal *j, u64 seq, unsigned task_state)
{}

/*
 * bch2_journal_flush_async - if there is an open journal entry, or a journal
 * still being written, write it and wait for the write to complete
 */
void bch2_journal_flush_async(struct journal *j, struct closure *parent)
{}

int bch2_journal_flush(struct journal *j)
{}

/*
 * bch2_journal_noflush_seq - tell the journal not to issue any flushes before
 * @seq
 */
bool bch2_journal_noflush_seq(struct journal *j, u64 seq)
{}

int bch2_journal_meta(struct journal *j)
{}

/* block/unlock the journal: */

void bch2_journal_unblock(struct journal *j)
{}

void bch2_journal_block(struct journal *j)
{}

static struct journal_buf *__bch2_next_write_buffer_flush_journal_buf(struct journal *j, u64 max_seq)
{}

struct journal_buf *bch2_next_write_buffer_flush_journal_buf(struct journal *j, u64 max_seq)
{}

/* allocate journal on a device: */

static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr,
					 bool new_fs, struct closure *cl)
{}

/*
 * Allocate more journal space at runtime - not currently making use if it, but
 * the code works:
 */
int bch2_set_nr_journal_buckets(struct bch_fs *c, struct bch_dev *ca,
				unsigned nr)
{}

int bch2_dev_journal_alloc(struct bch_dev *ca, bool new_fs)
{}

int bch2_fs_journal_alloc(struct bch_fs *c)
{}

/* startup/shutdown: */

static bool bch2_journal_writing_to_device(struct journal *j, unsigned dev_idx)
{}

void bch2_dev_journal_stop(struct journal *j, struct bch_dev *ca)
{}

void bch2_fs_journal_stop(struct journal *j)
{}

int bch2_fs_journal_start(struct journal *j, u64 cur_seq)
{}

/* init/exit: */

void bch2_dev_journal_exit(struct bch_dev *ca)
{}

int bch2_dev_journal_init(struct bch_dev *ca, struct bch_sb *sb)
{}

void bch2_fs_journal_exit(struct journal *j)
{}

int bch2_fs_journal_init(struct journal *j)
{}

/* debug: */

static const char * const bch2_journal_flags_strs[] =;

void __bch2_journal_debug_to_text(struct printbuf *out, struct journal *j)
{}

void bch2_journal_debug_to_text(struct printbuf *out, struct journal *j)
{}

bool bch2_journal_seq_pins_to_text(struct printbuf *out, struct journal *j, u64 *seq)
{}

void bch2_journal_pins_to_text(struct printbuf *out, struct journal *j)
{}