linux/fs/btrfs/transaction.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2007 Oracle.  All rights reserved.
 */

#ifndef BTRFS_TRANSACTION_H
#define BTRFS_TRANSACTION_H

#include <linux/atomic.h>
#include <linux/refcount.h>
#include <linux/list.h>
#include <linux/time64.h>
#include <linux/mutex.h>
#include <linux/wait.h>
#include "btrfs_inode.h"
#include "delayed-ref.h"
#include "extent-io-tree.h"
#include "block-rsv.h"
#include "messages.h"
#include "misc.h"

struct dentry;
struct inode;
struct btrfs_pending_snapshot;
struct btrfs_fs_info;
struct btrfs_root_item;
struct btrfs_root;
struct btrfs_path;

/* Radix-tree tag for roots that are part of the trasaction. */
#define BTRFS_ROOT_TRANS_TAG

enum btrfs_trans_state {};

#define BTRFS_TRANS_HAVE_FREE_BGS
#define BTRFS_TRANS_DIRTY_BG_RUN
#define BTRFS_TRANS_CACHE_ENOSPC

struct btrfs_transaction {};

enum {};

#define TRANS_START
#define TRANS_ATTACH
#define TRANS_JOIN
#define TRANS_JOIN_NOLOCK
#define TRANS_JOIN_NOSTART

#define TRANS_EXTWRITERS

struct btrfs_trans_handle {};

/*
 * The abort status can be changed between calls and is not protected by locks.
 * This accepts btrfs_transaction and btrfs_trans_handle as types. Once it's
 * set to a non-zero value it does not change, so the macro should be in checks
 * but is not necessary for further reads of the value.
 */
#define TRANS_ABORTED(trans)

struct btrfs_pending_snapshot {};

static inline void btrfs_set_inode_last_trans(struct btrfs_trans_handle *trans,
					      struct btrfs_inode *inode)
{}

/*
 * Make qgroup codes to skip given qgroupid, means the old/new_roots for
 * qgroup won't contain the qgroupid in it.
 */
static inline void btrfs_set_skip_qgroup(struct btrfs_trans_handle *trans,
					 u64 qgroupid)
{}

static inline void btrfs_clear_skip_qgroup(struct btrfs_trans_handle *trans)
{}

bool __cold abort_should_print_stack(int error);

/*
 * Call btrfs_abort_transaction as early as possible when an error condition is
 * detected, that way the exact stack trace is reported for some errors.
 */
#define btrfs_abort_transaction(trans, error)

int btrfs_end_transaction(struct btrfs_trans_handle *trans);
struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
						   unsigned int num_items);
struct btrfs_trans_handle *btrfs_start_transaction_fallback_global_rsv(
					struct btrfs_root *root,
					unsigned int num_items);
struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root);
struct btrfs_trans_handle *btrfs_join_transaction_spacecache(struct btrfs_root *root);
struct btrfs_trans_handle *btrfs_join_transaction_nostart(struct btrfs_root *root);
struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root);
struct btrfs_trans_handle *btrfs_attach_transaction_barrier(
					struct btrfs_root *root);
int btrfs_wait_for_commit(struct btrfs_fs_info *fs_info, u64 transid);

void btrfs_add_dead_root(struct btrfs_root *root);
void btrfs_maybe_wake_unfinished_drop(struct btrfs_fs_info *fs_info);
int btrfs_clean_one_deleted_snapshot(struct btrfs_fs_info *fs_info);
int btrfs_commit_transaction(struct btrfs_trans_handle *trans);
void btrfs_commit_transaction_async(struct btrfs_trans_handle *trans);
int btrfs_commit_current_transaction(struct btrfs_root *root);
int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans);
bool btrfs_should_end_transaction(struct btrfs_trans_handle *trans);
void btrfs_throttle(struct btrfs_fs_info *fs_info);
int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans,
				struct btrfs_root *root);
int btrfs_write_marked_extents(struct btrfs_fs_info *fs_info,
				struct extent_io_tree *dirty_pages, int mark);
int btrfs_wait_tree_log_extents(struct btrfs_root *root, int mark);
int btrfs_transaction_blocked(struct btrfs_fs_info *info);
void btrfs_put_transaction(struct btrfs_transaction *transaction);
void btrfs_add_dropped_root(struct btrfs_trans_handle *trans,
			    struct btrfs_root *root);
void btrfs_trans_release_chunk_metadata(struct btrfs_trans_handle *trans);
void __cold __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
				      const char *function,
				      unsigned int line, int error, bool first_hit);

int __init btrfs_transaction_init(void);
void __cold btrfs_transaction_exit(void);

#endif