linux/drivers/md/dm-vdo/vdo.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright 2023 Red Hat
 */

#ifndef VDO_H
#define VDO_H

#include <linux/atomic.h>
#include <linux/blk_types.h>
#include <linux/completion.h>
#include <linux/dm-kcopyd.h>
#include <linux/list.h>
#include <linux/spinlock.h>

#include "admin-state.h"
#include "encodings.h"
#include "funnel-workqueue.h"
#include "packer.h"
#include "physical-zone.h"
#include "statistics.h"
#include "thread-registry.h"
#include "types.h"

enum notifier_state {};

/**
 * typedef vdo_read_only_notification_fn - A function to notify a listener that the VDO has gone
 *                                         read-only.
 * @listener: The object to notify.
 * @parent: The completion to notify in order to acknowledge the notification.
 */
vdo_read_only_notification_fn;

/*
 * An object to be notified when the VDO enters read-only mode
 */
struct read_only_listener {};

struct vdo_thread {};

/* Keep struct bio statistics atomically */
struct atomic_bio_stats {};

/* Counters are atomic since updates can arrive concurrently from arbitrary threads. */
struct atomic_statistics {};

struct read_only_notifier {};

/*
 * The thread ID returned when the current thread is not a vdo thread, or can not be determined
 * (usually due to being at interrupt context).
 */
#define VDO_INVALID_THREAD_ID

struct thread_config {};

struct thread_count_config;

struct vdo_super_block {};

struct data_vio_pool;

struct vdo_administrator {};

struct vdo {};

/**
 * vdo_uses_bio_ack_queue() - Indicate whether the vdo is configured to use a separate work queue
 *                            for acknowledging received and processed bios.
 * @vdo: The vdo.
 *
 * Note that this directly controls the handling of write operations, but the compile-time flag
 * VDO_USE_BIO_ACK_QUEUE_FOR_READ is also checked for read operations.
 *
 * Return: Whether a bio-acknowledgement work queue is in use.
 */
static inline bool vdo_uses_bio_ack_queue(struct vdo *vdo)
{}

/**
 * typedef vdo_filter_fn - Method type for vdo matching methods.
 *
 * A filter function returns false if the vdo doesn't match.
 */
vdo_filter_fn;

void vdo_initialize_device_registry_once(void);
struct vdo * __must_check vdo_find_matching(vdo_filter_fn filter, const void *context);

int __must_check vdo_make_thread(struct vdo *vdo, thread_id_t thread_id,
				 const struct vdo_work_queue_type *type,
				 unsigned int queue_count, void *contexts[]);

static inline int __must_check vdo_make_default_thread(struct vdo *vdo,
						       thread_id_t thread_id)
{}

int __must_check vdo_make(unsigned int instance, struct device_config *config,
			  char **reason, struct vdo **vdo_ptr);

void vdo_destroy(struct vdo *vdo);

void vdo_load_super_block(struct vdo *vdo, struct vdo_completion *parent);

struct block_device * __must_check vdo_get_backing_device(const struct vdo *vdo);

const char * __must_check vdo_get_device_name(const struct dm_target *target);

int __must_check vdo_synchronous_flush(struct vdo *vdo);

const struct admin_state_code * __must_check vdo_get_admin_state(const struct vdo *vdo);

bool vdo_set_compressing(struct vdo *vdo, bool enable);

bool vdo_get_compressing(struct vdo *vdo);

void vdo_fetch_statistics(struct vdo *vdo, struct vdo_statistics *stats);

thread_id_t vdo_get_callback_thread_id(void);

enum vdo_state __must_check vdo_get_state(const struct vdo *vdo);

void vdo_set_state(struct vdo *vdo, enum vdo_state state);

void vdo_save_components(struct vdo *vdo, struct vdo_completion *parent);

int vdo_register_read_only_listener(struct vdo *vdo, void *listener,
				    vdo_read_only_notification_fn notification,
				    thread_id_t thread_id);

int vdo_enable_read_only_entry(struct vdo *vdo);

void vdo_wait_until_not_entering_read_only_mode(struct vdo_completion *parent);

void vdo_allow_read_only_mode_entry(struct vdo_completion *parent);

void vdo_enter_read_only_mode(struct vdo *vdo, int error_code);

bool __must_check vdo_is_read_only(struct vdo *vdo);

bool __must_check vdo_in_read_only_mode(const struct vdo *vdo);

bool __must_check vdo_in_recovery_mode(const struct vdo *vdo);

void vdo_enter_recovery_mode(struct vdo *vdo);

void vdo_assert_on_admin_thread(const struct vdo *vdo, const char *name);

void vdo_assert_on_logical_zone_thread(const struct vdo *vdo, zone_count_t logical_zone,
				       const char *name);

void vdo_assert_on_physical_zone_thread(const struct vdo *vdo, zone_count_t physical_zone,
					const char *name);

int __must_check vdo_get_physical_zone(const struct vdo *vdo, physical_block_number_t pbn,
				       struct physical_zone **zone_ptr);

void vdo_dump_status(const struct vdo *vdo);

#endif /* VDO_H */