linux/drivers/md/persistent-data/dm-block-manager.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2011 Red Hat, Inc.
 *
 * This file is released under the GPL.
 */
#include "dm-block-manager.h"
#include "dm-persistent-data-internal.h"

#include <linux/dm-bufio.h>
#include <linux/crc32c.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/rwsem.h>
#include <linux/device-mapper.h>
#include <linux/stacktrace.h>
#include <linux/sched/task.h>

#define DM_MSG_PREFIX

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

#ifdef CONFIG_DM_DEBUG_BLOCK_MANAGER_LOCKING

/*
 * This is a read/write semaphore with a couple of differences.
 *
 * i) There is a restriction on the number of concurrent read locks that
 * may be held at once.  This is just an implementation detail.
 *
 * ii) Recursive locking attempts are detected and return EINVAL.  A stack
 * trace is also emitted for the previous lock acquisition.
 *
 * iii) Priority is given to write locks.
 */
#define MAX_HOLDERS
#define MAX_STACK

struct stack_store {};

struct block_lock {};

struct waiter {};

static unsigned int __find_holder(struct block_lock *lock,
			      struct task_struct *task)
{}

/* call this *after* you increment lock->count */
static void __add_holder(struct block_lock *lock, struct task_struct *task)
{}

/* call this *before* you decrement lock->count */
static void __del_holder(struct block_lock *lock, struct task_struct *task)
{}

static int __check_holder(struct block_lock *lock)
{}

static void __wait(struct waiter *w)
{}

static void __wake_waiter(struct waiter *w)
{}

/*
 * We either wake a few readers or a single writer.
 */
static void __wake_many(struct block_lock *lock)
{}

static void bl_init(struct block_lock *lock)
{}

static int __available_for_read(struct block_lock *lock)
{}

static int bl_down_read(struct block_lock *lock)
{}

static int bl_down_read_nonblock(struct block_lock *lock)
{}

static void bl_up_read(struct block_lock *lock)
{}

static int bl_down_write(struct block_lock *lock)
{}

static void bl_up_write(struct block_lock *lock)
{}

static void report_recursive_bug(dm_block_t b, int r)
{}

#else  /* !CONFIG_DM_DEBUG_BLOCK_MANAGER_LOCKING */

#define bl_init
#define bl_down_read
#define bl_down_read_nonblock
#define bl_up_read
#define bl_down_write
#define bl_up_write
#define report_recursive_bug

#endif /* CONFIG_DM_DEBUG_BLOCK_MANAGER_LOCKING */

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

/*
 * Block manager is currently implemented using dm-bufio.  struct
 * dm_block_manager and struct dm_block map directly onto a couple of
 * structs in the bufio interface.  I want to retain the freedom to move
 * away from bufio in the future.  So these structs are just cast within
 * this .c file, rather than making it through to the public interface.
 */
static struct dm_buffer *to_buffer(struct dm_block *b)
{}

dm_block_t dm_block_location(struct dm_block *b)
{}
EXPORT_SYMBOL_GPL();

void *dm_block_data(struct dm_block *b)
{}
EXPORT_SYMBOL_GPL();

struct buffer_aux {};

static void dm_block_manager_alloc_callback(struct dm_buffer *buf)
{}

static void dm_block_manager_write_callback(struct dm_buffer *buf)
{}

/*
 * -------------------------------------------------------------
 * Public interface
 *--------------------------------------------------------------
 */
struct dm_block_manager {};

struct dm_block_manager *dm_block_manager_create(struct block_device *bdev,
						 unsigned int block_size,
						 unsigned int max_held_per_thread)
{}
EXPORT_SYMBOL_GPL();

void dm_block_manager_destroy(struct dm_block_manager *bm)
{}
EXPORT_SYMBOL_GPL();

void dm_block_manager_reset(struct dm_block_manager *bm)
{}
EXPORT_SYMBOL_GPL();

unsigned int dm_bm_block_size(struct dm_block_manager *bm)
{}
EXPORT_SYMBOL_GPL();

dm_block_t dm_bm_nr_blocks(struct dm_block_manager *bm)
{}

static int dm_bm_validate_buffer(struct dm_block_manager *bm,
				 struct dm_buffer *buf,
				 struct buffer_aux *aux,
				 const struct dm_block_validator *v)
{}
int dm_bm_read_lock(struct dm_block_manager *bm, dm_block_t b,
		    const struct dm_block_validator *v,
		    struct dm_block **result)
{}
EXPORT_SYMBOL_GPL();

int dm_bm_write_lock(struct dm_block_manager *bm,
		     dm_block_t b, const struct dm_block_validator *v,
		     struct dm_block **result)
{}
EXPORT_SYMBOL_GPL();

int dm_bm_read_try_lock(struct dm_block_manager *bm,
			dm_block_t b, const struct dm_block_validator *v,
			struct dm_block **result)
{}

int dm_bm_write_lock_zero(struct dm_block_manager *bm,
			  dm_block_t b, const struct dm_block_validator *v,
			  struct dm_block **result)
{}
EXPORT_SYMBOL_GPL();

void dm_bm_unlock(struct dm_block *b)
{}
EXPORT_SYMBOL_GPL();

int dm_bm_flush(struct dm_block_manager *bm)
{}
EXPORT_SYMBOL_GPL();

void dm_bm_prefetch(struct dm_block_manager *bm, dm_block_t b)
{}

bool dm_bm_is_read_only(struct dm_block_manager *bm)
{}
EXPORT_SYMBOL_GPL();

void dm_bm_set_read_only(struct dm_block_manager *bm)
{}
EXPORT_SYMBOL_GPL();

void dm_bm_set_read_write(struct dm_block_manager *bm)
{}
EXPORT_SYMBOL_GPL();

u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor)
{}
EXPORT_SYMBOL_GPL();

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

MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_DESCRIPTION();

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