linux/drivers/md/persistent-data/dm-space-map-metadata.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2011 Red Hat, Inc.
 *
 * This file is released under the GPL.
 */

#include "dm-space-map.h"
#include "dm-space-map-common.h"
#include "dm-space-map-metadata.h"

#include <linux/list.h>
#include <linux/slab.h>
#include <linux/device-mapper.h>
#include <linux/kernel.h>

#define DM_MSG_PREFIX

/*----------------------------------------------------------------*/

/*
 * An edge triggered threshold.
 */
struct threshold {};

static void threshold_init(struct threshold *t)
{}

static void set_threshold(struct threshold *t, dm_block_t value,
			  dm_sm_threshold_fn fn, void *context)
{}

static bool below_threshold(struct threshold *t, dm_block_t value)
{}

static bool threshold_already_triggered(struct threshold *t)
{}

static void check_threshold(struct threshold *t, dm_block_t value)
{}

/*----------------------------------------------------------------*/

/*
 * Space map interface.
 *
 * The low level disk format is written using the standard btree and
 * transaction manager.  This means that performing disk operations may
 * cause us to recurse into the space map in order to allocate new blocks.
 * For this reason we have a pool of pre-allocated blocks large enough to
 * service any metadata_ll_disk operation.
 */

/*
 * FIXME: we should calculate this based on the size of the device.
 * Only the metadata space map needs this functionality.
 */
#define MAX_RECURSIVE_ALLOCATIONS

enum block_op_type {};

struct block_op {};

struct bop_ring_buffer {};

static void brb_init(struct bop_ring_buffer *brb)
{}

static bool brb_empty(struct bop_ring_buffer *brb)
{}

static unsigned int brb_next(struct bop_ring_buffer *brb, unsigned int old)
{}

static int brb_push(struct bop_ring_buffer *brb,
		    enum block_op_type type, dm_block_t b, dm_block_t e)
{}

static int brb_peek(struct bop_ring_buffer *brb, struct block_op *result)
{}

static int brb_pop(struct bop_ring_buffer *brb)
{}

/*----------------------------------------------------------------*/

struct sm_metadata {};

static int add_bop(struct sm_metadata *smm, enum block_op_type type, dm_block_t b, dm_block_t e)
{}

static int commit_bop(struct sm_metadata *smm, struct block_op *op)
{}

static void in(struct sm_metadata *smm)
{}

static int apply_bops(struct sm_metadata *smm)
{}

static int out(struct sm_metadata *smm)
{}

/*
 * When using the out() function above, we often want to combine an error
 * code for the operation run in the recursive context with that from
 * out().
 */
static int combine_errors(int r1, int r2)
{}

static int recursing(struct sm_metadata *smm)
{}

static void sm_metadata_destroy(struct dm_space_map *sm)
{}

static int sm_metadata_get_nr_blocks(struct dm_space_map *sm, dm_block_t *count)
{}

static int sm_metadata_get_nr_free(struct dm_space_map *sm, dm_block_t *count)
{}

static int sm_metadata_get_count(struct dm_space_map *sm, dm_block_t b,
				 uint32_t *result)
{}

static int sm_metadata_count_is_more_than_one(struct dm_space_map *sm,
					      dm_block_t b, int *result)
{}

static int sm_metadata_set_count(struct dm_space_map *sm, dm_block_t b,
				 uint32_t count)
{}

static int sm_metadata_inc_blocks(struct dm_space_map *sm, dm_block_t b, dm_block_t e)
{}

static int sm_metadata_dec_blocks(struct dm_space_map *sm, dm_block_t b, dm_block_t e)
{}

static int sm_metadata_new_block_(struct dm_space_map *sm, dm_block_t *b)
{}

static int sm_metadata_new_block(struct dm_space_map *sm, dm_block_t *b)
{}

static int sm_metadata_commit(struct dm_space_map *sm)
{}

static int sm_metadata_register_threshold_callback(struct dm_space_map *sm,
						   dm_block_t threshold,
						   dm_sm_threshold_fn fn,
						   void *context)
{}

static int sm_metadata_root_size(struct dm_space_map *sm, size_t *result)
{}

static int sm_metadata_copy_root(struct dm_space_map *sm, void *where_le, size_t max)
{}

static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks);

static const struct dm_space_map ops =;

/*----------------------------------------------------------------*/

/*
 * When a new space map is created that manages its own space.  We use
 * this tiny bootstrap allocator.
 */
static void sm_bootstrap_destroy(struct dm_space_map *sm)
{}

static int sm_bootstrap_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
{}

static int sm_bootstrap_get_nr_blocks(struct dm_space_map *sm, dm_block_t *count)
{}

static int sm_bootstrap_get_nr_free(struct dm_space_map *sm, dm_block_t *count)
{}

static int sm_bootstrap_get_count(struct dm_space_map *sm, dm_block_t b,
				  uint32_t *result)
{}

static int sm_bootstrap_count_is_more_than_one(struct dm_space_map *sm,
					       dm_block_t b, int *result)
{}

static int sm_bootstrap_set_count(struct dm_space_map *sm, dm_block_t b,
				  uint32_t count)
{}

static int sm_bootstrap_new_block(struct dm_space_map *sm, dm_block_t *b)
{}

static int sm_bootstrap_inc_blocks(struct dm_space_map *sm, dm_block_t b, dm_block_t e)
{}

static int sm_bootstrap_dec_blocks(struct dm_space_map *sm, dm_block_t b, dm_block_t e)
{}

static int sm_bootstrap_commit(struct dm_space_map *sm)
{}

static int sm_bootstrap_root_size(struct dm_space_map *sm, size_t *result)
{}

static int sm_bootstrap_copy_root(struct dm_space_map *sm, void *where,
				  size_t max)
{}

static const struct dm_space_map bootstrap_ops =;

/*----------------------------------------------------------------*/

static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
{}

/*----------------------------------------------------------------*/

struct dm_space_map *dm_sm_metadata_init(void)
{}

int dm_sm_metadata_create(struct dm_space_map *sm,
			  struct dm_transaction_manager *tm,
			  dm_block_t nr_blocks,
			  dm_block_t superblock)
{}

int dm_sm_metadata_open(struct dm_space_map *sm,
			struct dm_transaction_manager *tm,
			void *root_le, size_t len)
{}