linux/drivers/md/dm-vdo/indexer/index-session.c

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

#include "index-session.h"

#include <linux/atomic.h>

#include "logger.h"
#include "memory-alloc.h"
#include "time-utils.h"

#include "funnel-requestqueue.h"
#include "index.h"
#include "index-layout.h"

/*
 * The index session contains a lock (the request_mutex) which ensures that only one thread can
 * change the state of its index at a time. The state field indicates the current state of the
 * index through a set of descriptive flags. The request_mutex must be notified whenever a
 * non-transient state flag is cleared. The request_mutex is also used to count the number of
 * requests currently in progress so that they can be drained when suspending or closing the index.
 *
 * If the index session is suspended shortly after opening an index, it may have to suspend during
 * a rebuild. Depending on the size of the index, a rebuild may take a significant amount of time,
 * so UDS allows the rebuild to be paused in order to suspend the session in a timely manner. When
 * the index session is resumed, the rebuild can continue from where it left off. If the index
 * session is shut down with a suspended rebuild, the rebuild progress is abandoned and the rebuild
 * will start from the beginning the next time the index is loaded. The mutex and status fields in
 * the index_load_context are used to record the state of any interrupted rebuild.
 */

enum index_session_flag_bit {};

enum index_session_flag {};

/* Release a reference to an index session. */
static void release_index_session(struct uds_index_session *index_session)
{}

/*
 * Acquire a reference to the index session for an asynchronous index request. The reference must
 * eventually be released with a corresponding call to release_index_session().
 */
static int get_index_session(struct uds_index_session *index_session)
{}

int uds_launch_request(struct uds_request *request)
{}

static void enter_callback_stage(struct uds_request *request)
{}

static inline void count_once(u64 *count_ptr)
{}

static void update_session_stats(struct uds_request *request)
{}

static void handle_callbacks(struct uds_request *request)
{}

static int __must_check make_empty_index_session(struct uds_index_session **index_session_ptr)
{}

int uds_create_index_session(struct uds_index_session **session)
{}

static int __must_check start_loading_index_session(struct uds_index_session *index_session)
{}

static void finish_loading_index_session(struct uds_index_session *index_session,
					 int result)
{}

static int initialize_index_session(struct uds_index_session *index_session,
				    enum uds_open_index_type open_type)
{}

static const char *get_open_type_string(enum uds_open_index_type open_type)
{}

/*
 * Open an index under the given session. This operation will fail if the
 * index session is suspended, or if there is already an open index.
 */
int uds_open_index(enum uds_open_index_type open_type,
		   const struct uds_parameters *parameters,
		   struct uds_index_session *session)
{}

static void wait_for_no_requests_in_progress(struct uds_index_session *index_session)
{}

static int __must_check save_index(struct uds_index_session *index_session)
{}

static void suspend_rebuild(struct uds_index_session *session)
{}

/*
 * Suspend index operation, draining all current index requests and preventing new index requests
 * from starting. Optionally saves all index data before returning.
 */
int uds_suspend_index_session(struct uds_index_session *session, bool save)
{}

static int replace_device(struct uds_index_session *session, struct block_device *bdev)
{}

/*
 * Resume index operation after being suspended. If the index is suspended and the supplied block
 * device differs from the current backing store, the index will start using the new backing store.
 */
int uds_resume_index_session(struct uds_index_session *session,
			     struct block_device *bdev)
{}

static int save_and_free_index(struct uds_index_session *index_session)
{}

/* Save and close the current index. */
int uds_close_index(struct uds_index_session *index_session)
{}

/* This will save and close an open index before destroying the session. */
int uds_destroy_index_session(struct uds_index_session *index_session)
{}

/* Wait until all callbacks for index operations are complete. */
int uds_flush_index_session(struct uds_index_session *index_session)
{}

/* Statistics collection is intended to be thread-safe. */
static void collect_stats(const struct uds_index_session *index_session,
			  struct uds_index_stats *stats)
{}

int uds_get_index_session_stats(struct uds_index_session *index_session,
				struct uds_index_stats *stats)
{}

void uds_wait_cond(struct cond_var *cv, struct mutex *mutex)
{}