Commit 4fcb4290 authored by Matthew Sakai's avatar Matthew Sakai Committed by Mike Snitzer

dm vdo: add vdo type declarations, constants, and simple data structures

Add definitions of constants defining the fixed parameters of a VDO
volume, and the default and maximum values of configurable or dynamic
parameters.

Add definitions of internal status codes used for internal
communication within the module and for logging.

Add definitions of types and structs used to manage the processing of
an I/O operation.
Co-developed-by: default avatarJ. corwin Coburn <corwin@hurlbutnet.net>
Signed-off-by: default avatarJ. corwin Coburn <corwin@hurlbutnet.net>
Co-developed-by: default avatarMichael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: default avatarMichael Sclafani <dm-devel@lists.linux.dev>
Signed-off-by: default avatarMatthew Sakai <msakai@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
parent 03d1089e
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2023 Red Hat
*/
#include "types.h"
/* The maximum logical space is 4 petabytes, which is 1 terablock. */
const block_count_t MAXIMUM_VDO_LOGICAL_BLOCKS = 1024ULL * 1024 * 1024 * 1024;
/* The maximum physical space is 256 terabytes, which is 64 gigablocks. */
const block_count_t MAXIMUM_VDO_PHYSICAL_BLOCKS = 1024ULL * 1024 * 1024 * 64;
/* unit test minimum */
const block_count_t MINIMUM_VDO_SLAB_JOURNAL_BLOCKS = 2;
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright 2023 Red Hat
*/
#ifndef VDO_CONSTANTS_H
#define VDO_CONSTANTS_H
#include <linux/blkdev.h>
#include "types.h"
enum {
/*
* The maximum number of contiguous PBNs which will go to a single bio submission queue,
* assuming there is more than one queue.
*/
VDO_BIO_ROTATION_INTERVAL_LIMIT = 1024,
/** The number of entries on a block map page */
VDO_BLOCK_MAP_ENTRIES_PER_PAGE = 812,
/** The origin of the flat portion of the block map */
VDO_BLOCK_MAP_FLAT_PAGE_ORIGIN = 1,
/*
* The height of a block map tree. Assuming a root count of 60 and 812 entries per page,
* this is big enough to represent almost 95 PB of logical space.
*/
VDO_BLOCK_MAP_TREE_HEIGHT = 5,
/** The default number of bio submission queues. */
DEFAULT_VDO_BIO_SUBMIT_QUEUE_COUNT = 4,
/** The number of contiguous PBNs to be submitted to a single bio queue. */
DEFAULT_VDO_BIO_SUBMIT_QUEUE_ROTATE_INTERVAL = 64,
/** The number of trees in the arboreal block map */
DEFAULT_VDO_BLOCK_MAP_TREE_ROOT_COUNT = 60,
/** The default size of the recovery journal, in blocks */
DEFAULT_VDO_RECOVERY_JOURNAL_SIZE = 32 * 1024,
/** The default size of each slab journal, in blocks */
DEFAULT_VDO_SLAB_JOURNAL_SIZE = 224,
/*
* The initial size of lbn_operations and pbn_operations, which is based upon the expected
* maximum number of outstanding VIOs. This value was chosen to make it highly unlikely
* that the maps would need to be resized.
*/
VDO_LOCK_MAP_CAPACITY = 10000,
/** The maximum number of logical zones */
MAX_VDO_LOGICAL_ZONES = 60,
/** The maximum number of physical zones */
MAX_VDO_PHYSICAL_ZONES = 16,
/** The base-2 logarithm of the maximum blocks in one slab */
MAX_VDO_SLAB_BITS = 23,
/** The maximum number of slabs the slab depot supports */
MAX_VDO_SLABS = 8192,
/*
* The maximum number of block map pages to load simultaneously during recovery or rebuild.
*/
MAXIMUM_SIMULTANEOUS_VDO_BLOCK_MAP_RESTORATION_READS = 1024,
/** The maximum number of entries in the slab summary */
MAXIMUM_VDO_SLAB_SUMMARY_ENTRIES = MAX_VDO_SLABS * MAX_VDO_PHYSICAL_ZONES,
/** The maximum number of total threads in a VDO thread configuration. */
MAXIMUM_VDO_THREADS = 100,
/** The maximum number of VIOs in the system at once */
MAXIMUM_VDO_USER_VIOS = 2048,
/** The only physical block size supported by VDO */
VDO_BLOCK_SIZE = 4096,
/** The number of sectors per block */
VDO_SECTORS_PER_BLOCK = (VDO_BLOCK_SIZE >> SECTOR_SHIFT),
/** The size of a sector that will not be torn */
VDO_SECTOR_SIZE = 512,
/** The physical block number reserved for storing the zero block */
VDO_ZERO_BLOCK = 0,
};
/** The maximum logical space is 4 petabytes, which is 1 terablock. */
extern const block_count_t MAXIMUM_VDO_LOGICAL_BLOCKS;
/** The maximum physical space is 256 terabytes, which is 64 gigablocks. */
extern const block_count_t MAXIMUM_VDO_PHYSICAL_BLOCKS;
/** unit test minimum */
extern const block_count_t MINIMUM_VDO_SLAB_JOURNAL_BLOCKS;
#endif /* VDO_CONSTANTS_H */
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2023 Red Hat
*/
#include "status-codes.h"
#include "errors.h"
#include "logger.h"
#include "permassert.h"
#include "uds-threads.h"
const struct error_info vdo_status_list[] = {
{ "VDO_NOT_IMPLEMENTED", "Not implemented" },
{ "VDO_OUT_OF_RANGE", "Out of range" },
{ "VDO_REF_COUNT_INVALID", "Reference count would become invalid" },
{ "VDO_NO_SPACE", "Out of space" },
{ "VDO_UNEXPECTED_EOF", "Unexpected EOF on block read" },
{ "VDO_BAD_CONFIGURATION", "Bad configuration option" },
{ "VDO_SOCKET_ERROR", "Socket error" },
{ "VDO_BAD_ALIGNMENT", "Mis-aligned block reference" },
{ "VDO_COMPONENT_BUSY", "Prior operation still in progress" },
{ "VDO_BAD_PAGE", "Corrupt or incorrect page" },
{ "VDO_UNSUPPORTED_VERSION", "Unsupported component version" },
{ "VDO_INCORRECT_COMPONENT", "Component id mismatch in decoder" },
{ "VDO_PARAMETER_MISMATCH", "Parameters have conflicting values" },
{ "VDO_BLOCK_SIZE_TOO_SMALL", "The block size is too small" },
{ "VDO_UNKNOWN_PARTITION", "No partition exists with a given id" },
{ "VDO_PARTITION_EXISTS", "A partition already exists with a given id" },
{ "VDO_NOT_READ_ONLY", "The device is not in read-only mode" },
{ "VDO_INCREMENT_TOO_SMALL", "Physical block growth of too few blocks" },
{ "VDO_CHECKSUM_MISMATCH", "Incorrect checksum" },
{ "VDO_RECOVERY_JOURNAL_FULL", "The recovery journal is full" },
{ "VDO_LOCK_ERROR", "A lock is held incorrectly" },
{ "VDO_READ_ONLY", "The device is in read-only mode" },
{ "VDO_SHUTTING_DOWN", "The device is shutting down" },
{ "VDO_CORRUPT_JOURNAL", "Recovery journal entries corrupted" },
{ "VDO_TOO_MANY_SLABS", "Exceeds maximum number of slabs supported" },
{ "VDO_INVALID_FRAGMENT", "Compressed block fragment is invalid" },
{ "VDO_RETRY_AFTER_REBUILD", "Retry operation after rebuilding finishes" },
{ "VDO_UNKNOWN_COMMAND", "The extended command is not known" },
{ "VDO_COMMAND_ERROR", "Bad extended command parameters" },
{ "VDO_CANNOT_DETERMINE_SIZE", "Cannot determine config sizes to fit" },
{ "VDO_BAD_MAPPING", "Invalid page mapping" },
{ "VDO_READ_CACHE_BUSY", "Read cache has no free slots" },
{ "VDO_BIO_CREATION_FAILED", "Bio creation failed" },
{ "VDO_BAD_MAGIC", "Bad magic number" },
{ "VDO_BAD_NONCE", "Bad nonce" },
{ "VDO_JOURNAL_OVERFLOW", "Journal sequence number overflow" },
{ "VDO_INVALID_ADMIN_STATE", "Invalid operation for current state" },
{ "VDO_CANT_ADD_SYSFS_NODE", "Failed to add sysfs node" },
};
static atomic_t vdo_status_codes_registered = ATOMIC_INIT(0);
static int status_code_registration_result;
static void do_status_code_registration(void)
{
int result;
BUILD_BUG_ON((VDO_STATUS_CODE_LAST - VDO_STATUS_CODE_BASE) !=
ARRAY_SIZE(vdo_status_list));
result = uds_register_error_block("VDO Status", VDO_STATUS_CODE_BASE,
VDO_STATUS_CODE_BLOCK_END, vdo_status_list,
sizeof(vdo_status_list));
/*
* The following test handles cases where libvdo is statically linked against both the test
* modules and the test driver (because multiple instances of this module call their own
* copy of this function once each, resulting in multiple calls to register_error_block
* which is shared in libuds).
*/
if (result == UDS_DUPLICATE_NAME)
result = UDS_SUCCESS;
status_code_registration_result = (result == UDS_SUCCESS) ? VDO_SUCCESS : result;
}
/**
* vdo_register_status_codes() - Register the VDO status codes if needed.
* Return: A success or error code.
*/
int vdo_register_status_codes(void)
{
uds_perform_once(&vdo_status_codes_registered, do_status_code_registration);
return status_code_registration_result;
}
/**
* vdo_map_to_system_error() - Given an error code, return a value we can return to the OS.
* @error: The error code to convert.
*
* The input error code may be a system-generated value (such as -EIO), an errno macro used in our
* code (such as EIO), or a UDS or VDO status code; the result must be something the rest of the OS
* can consume (negative errno values such as -EIO, in the case of the kernel).
*
* Return: A system error code value.
*/
int vdo_map_to_system_error(int error)
{
char error_name[UDS_MAX_ERROR_NAME_SIZE];
char error_message[UDS_MAX_ERROR_MESSAGE_SIZE];
/* 0 is success, negative a system error code */
if (likely(error <= 0))
return error;
if (error < 1024)
return -error;
/* VDO or UDS error */
switch (error) {
case VDO_NO_SPACE:
return -ENOSPC;
case VDO_READ_ONLY:
return -EIO;
default:
uds_log_info("%s: mapping internal status code %d (%s: %s) to EIO",
__func__, error,
uds_string_error_name(error, error_name, sizeof(error_name)),
uds_string_error(error, error_message, sizeof(error_message)));
return -EIO;
}
}
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright 2023 Red Hat
*/
#ifndef VDO_STATUS_CODES_H
#define VDO_STATUS_CODES_H
#include "errors.h"
enum {
UDS_BLOCK_SIZE = UDS_ERROR_CODE_BLOCK_END - UDS_ERROR_CODE_BASE,
VDO_BLOCK_START = UDS_ERROR_CODE_BLOCK_END,
VDO_BLOCK_END = VDO_BLOCK_START + UDS_BLOCK_SIZE,
PRP_BLOCK_START = VDO_BLOCK_END,
PRP_BLOCK_END = PRP_BLOCK_START + UDS_BLOCK_SIZE,
};
/* VDO-specific status codes. */
enum vdo_status_codes {
/* successful result */
VDO_SUCCESS,
/* base of all VDO errors */
VDO_STATUS_CODE_BASE = VDO_BLOCK_START,
/* we haven't written this yet */
VDO_NOT_IMPLEMENTED = VDO_STATUS_CODE_BASE,
/* input out of range */
VDO_OUT_OF_RANGE,
/* an invalid reference count would result */
VDO_REF_COUNT_INVALID,
/* a free block could not be allocated */
VDO_NO_SPACE,
/* unexpected EOF on block read */
VDO_UNEXPECTED_EOF,
/* improper or missing configuration option */
VDO_BAD_CONFIGURATION,
/* socket opening or binding problem */
VDO_SOCKET_ERROR,
/* read or write on non-aligned offset */
VDO_BAD_ALIGNMENT,
/* prior operation still in progress */
VDO_COMPONENT_BUSY,
/* page contents incorrect or corrupt data */
VDO_BAD_PAGE,
/* unsupported version of some component */
VDO_UNSUPPORTED_VERSION,
/* component id mismatch in decoder */
VDO_INCORRECT_COMPONENT,
/* parameters have conflicting values */
VDO_PARAMETER_MISMATCH,
/* the block size is too small */
VDO_BLOCK_SIZE_TOO_SMALL,
/* no partition exists with a given id */
VDO_UNKNOWN_PARTITION,
/* a partition already exists with a given id */
VDO_PARTITION_EXISTS,
/* the VDO is not in read-only mode */
VDO_NOT_READ_ONLY,
/* physical block growth of too few blocks */
VDO_INCREMENT_TOO_SMALL,
/* incorrect checksum */
VDO_CHECKSUM_MISMATCH,
/* the recovery journal is full */
VDO_RECOVERY_JOURNAL_FULL,
/* a lock is held incorrectly */
VDO_LOCK_ERROR,
/* the VDO is in read-only mode */
VDO_READ_ONLY,
/* the VDO is shutting down */
VDO_SHUTTING_DOWN,
/* the recovery journal has corrupt entries */
VDO_CORRUPT_JOURNAL,
/* exceeds maximum number of slabs supported */
VDO_TOO_MANY_SLABS,
/* a compressed block fragment is invalid */
VDO_INVALID_FRAGMENT,
/* action is unsupported while rebuilding */
VDO_RETRY_AFTER_REBUILD,
/* the extended command is not known */
VDO_UNKNOWN_COMMAND,
/* bad extended command parameters */
VDO_COMMAND_ERROR,
/* cannot determine sizes to fit */
VDO_CANNOT_DETERMINE_SIZE,
/* a block map entry is invalid */
VDO_BAD_MAPPING,
/* read cache has no free slots */
VDO_READ_CACHE_BUSY,
/* bio_add_page failed */
VDO_BIO_CREATION_FAILED,
/* bad magic number */
VDO_BAD_MAGIC,
/* bad nonce */
VDO_BAD_NONCE,
/* sequence number overflow */
VDO_JOURNAL_OVERFLOW,
/* the VDO is not in a state to perform an admin operation */
VDO_INVALID_ADMIN_STATE,
/* failure adding a sysfs node */
VDO_CANT_ADD_SYSFS_NODE,
/* one more than last error code */
VDO_STATUS_CODE_LAST,
VDO_STATUS_CODE_BLOCK_END = VDO_BLOCK_END
};
extern const struct error_info vdo_status_list[];
int vdo_register_status_codes(void);
int vdo_map_to_system_error(int error);
#endif /* VDO_STATUS_CODES_H */
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2023 Red Hat
*/
#include "wait-queue.h"
#include <linux/device-mapper.h>
#include "permassert.h"
#include "status-codes.h"
/**
* vdo_enqueue_waiter() - Add a waiter to the tail end of a wait queue.
* @queue: The queue to which to add the waiter.
* @waiter: The waiter to add to the queue.
*
* The waiter must not already be waiting in a queue.
*
* Return: VDO_SUCCESS or an error code.
*/
void vdo_enqueue_waiter(struct wait_queue *queue, struct waiter *waiter)
{
BUG_ON(waiter->next_waiter != NULL);
if (queue->last_waiter == NULL) {
/*
* The queue is empty, so form the initial circular list by self-linking the
* initial waiter.
*/
waiter->next_waiter = waiter;
} else {
/* Splice the new waiter in at the end of the queue. */
waiter->next_waiter = queue->last_waiter->next_waiter;
queue->last_waiter->next_waiter = waiter;
}
/* In both cases, the waiter we added to the ring becomes the last waiter. */
queue->last_waiter = waiter;
queue->queue_length += 1;
}
/**
* vdo_transfer_all_waiters() - Transfer all waiters from one wait queue to a second queue,
* emptying the first queue.
* @from_queue: The queue containing the waiters to move.
* @to_queue: The queue that will receive the waiters from the first queue.
*/
void vdo_transfer_all_waiters(struct wait_queue *from_queue, struct wait_queue *to_queue)
{
/* If the source queue is empty, there's nothing to do. */
if (!vdo_has_waiters(from_queue))
return;
if (vdo_has_waiters(to_queue)) {
/*
* Both queues are non-empty. Splice the two circular lists together by swapping
* the next (head) pointers in the list tails.
*/
struct waiter *from_head = from_queue->last_waiter->next_waiter;
struct waiter *to_head = to_queue->last_waiter->next_waiter;
to_queue->last_waiter->next_waiter = from_head;
from_queue->last_waiter->next_waiter = to_head;
}
to_queue->last_waiter = from_queue->last_waiter;
to_queue->queue_length += from_queue->queue_length;
vdo_initialize_wait_queue(from_queue);
}
/**
* vdo_notify_all_waiters() - Notify all the entries waiting in a queue.
* @queue: The wait queue containing the waiters to notify.
* @callback: The function to call to notify each waiter, or NULL to invoke the callback field
* registered in each waiter.
* @context: The context to pass to the callback function.
*
* Notifies all the entries waiting in a queue to continue execution by invoking a callback
* function on each of them in turn. The queue is copied and emptied before invoking any callbacks,
* and only the waiters that were in the queue at the start of the call will be notified.
*/
void vdo_notify_all_waiters(struct wait_queue *queue, waiter_callback_fn callback,
void *context)
{
/*
* Copy and empty the queue first, avoiding the possibility of an infinite loop if entries
* are returned to the queue by the callback function.
*/
struct wait_queue waiters;
vdo_initialize_wait_queue(&waiters);
vdo_transfer_all_waiters(queue, &waiters);
/* Drain the copied queue, invoking the callback on every entry. */
while (vdo_has_waiters(&waiters))
vdo_notify_next_waiter(&waiters, callback, context);
}
/**
* vdo_get_first_waiter() - Return the waiter that is at the head end of a wait queue.
* @queue: The queue from which to get the first waiter.
*
* Return: The first (oldest) waiter in the queue, or NULL if the queue is empty.
*/
struct waiter *vdo_get_first_waiter(const struct wait_queue *queue)
{
struct waiter *last_waiter = queue->last_waiter;
if (last_waiter == NULL) {
/* There are no waiters, so we're done. */
return NULL;
}
/* The queue is circular, so the last entry links to the head of the queue. */
return last_waiter->next_waiter;
}
/**
* vdo_dequeue_matching_waiters() - Remove all waiters that match based on the specified matching
* method and append them to a wait_queue.
* @queue: The wait queue to process.
* @match_method: The method to determine matching.
* @match_context: Contextual info for the match method.
* @matched_queue: A wait_queue to store matches.
*/
void vdo_dequeue_matching_waiters(struct wait_queue *queue, waiter_match_fn match_method,
void *match_context, struct wait_queue *matched_queue)
{
struct wait_queue matched_waiters, iteration_queue;
vdo_initialize_wait_queue(&matched_waiters);
vdo_initialize_wait_queue(&iteration_queue);
vdo_transfer_all_waiters(queue, &iteration_queue);
while (vdo_has_waiters(&iteration_queue)) {
struct waiter *waiter = vdo_dequeue_next_waiter(&iteration_queue);
vdo_enqueue_waiter((match_method(waiter, match_context) ?
&matched_waiters : queue), waiter);
}
vdo_transfer_all_waiters(&matched_waiters, matched_queue);
}
/**
* vdo_dequeue_next_waiter() - Remove the first waiter from the head end of a wait queue.
* @queue: The wait queue from which to remove the first entry.
*
* The caller will be responsible for waking the waiter by invoking the correct callback function
* to resume its execution.
*
* Return: The first (oldest) waiter in the queue, or NULL if the queue is empty.
*/
struct waiter *vdo_dequeue_next_waiter(struct wait_queue *queue)
{
struct waiter *first_waiter = vdo_get_first_waiter(queue);
struct waiter *last_waiter = queue->last_waiter;
if (first_waiter == NULL)
return NULL;
if (first_waiter == last_waiter) {
/* The queue has a single entry, so just empty it out by nulling the tail. */
queue->last_waiter = NULL;
} else {
/*
* The queue has more than one entry, so splice the first waiter out of the
* circular queue.
*/
last_waiter->next_waiter = first_waiter->next_waiter;
}
/* The waiter is no longer in a wait queue. */
first_waiter->next_waiter = NULL;
queue->queue_length -= 1;
return first_waiter;
}
/**
* vdo_notify_next_waiter() - Notify the next entry waiting in a queue.
* @queue: The wait queue containing the waiter to notify.
* @callback: The function to call to notify the waiter, or NULL to invoke the callback field
* registered in the waiter.
* @context: The context to pass to the callback function.
*
* Notifies the next entry waiting in a queue to continue execution by invoking a callback function
* on it after removing it from the queue.
*
* Return: true if there was a waiter in the queue.
*/
bool vdo_notify_next_waiter(struct wait_queue *queue, waiter_callback_fn callback,
void *context)
{
struct waiter *waiter = vdo_dequeue_next_waiter(queue);
if (waiter == NULL)
return false;
if (callback == NULL)
callback = waiter->callback;
(*callback)(waiter, context);
return true;
}
/**
* vdo_get_next_waiter() - Get the waiter after this one, for debug iteration.
* @queue: The wait queue.
* @waiter: A waiter.
*
* Return: The next waiter, or NULL.
*/
const struct waiter *vdo_get_next_waiter(const struct wait_queue *queue,
const struct waiter *waiter)
{
struct waiter *first_waiter = vdo_get_first_waiter(queue);
if (waiter == NULL)
return first_waiter;
return ((waiter->next_waiter != first_waiter) ? waiter->next_waiter : NULL);
}
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright 2023 Red Hat
*/
#ifndef VDO_WAIT_QUEUE_H
#define VDO_WAIT_QUEUE_H
#include <linux/compiler.h>
#include <linux/types.h>
/**
* DOC: Wait queues.
*
* A wait queue is a circular list of entries waiting to be notified of a change in a condition.
* Keeping a circular list allows the queue structure to simply be a pointer to the tail (newest)
* entry in the queue, supporting constant-time enqueue and dequeue operations. A null pointer is
* an empty queue.
*
* An empty queue:
* queue0.last_waiter -> NULL
*
* A singleton queue:
* queue1.last_waiter -> entry1 -> entry1 -> [...]
*
* A three-element queue:
* queue2.last_waiter -> entry3 -> entry1 -> entry2 -> entry3 -> [...]
*/
struct waiter;
struct wait_queue {
/* The tail of the queue, the last (most recently added) entry */
struct waiter *last_waiter;
/* The number of waiters currently in the queue */
size_t queue_length;
};
/**
* typedef waiter_callback_fn - Callback type for functions which will be called to resume
* processing of a waiter after it has been removed from its wait
* queue.
*/
typedef void (*waiter_callback_fn)(struct waiter *waiter, void *context);
/**
* typedef waiter_match_fn - Method type for waiter matching methods.
*
* A waiter_match_fn method returns false if the waiter does not match.
*/
typedef bool (*waiter_match_fn)(struct waiter *waiter, void *context);
/* The queue entry structure for entries in a wait_queue. */
struct waiter {
/*
* The next waiter in the queue. If this entry is the last waiter, then this is actually a
* pointer back to the head of the queue.
*/
struct waiter *next_waiter;
/* Optional waiter-specific callback to invoke when waking this waiter. */
waiter_callback_fn callback;
};
/**
* is_waiting() - Check whether a waiter is waiting.
* @waiter: The waiter to check.
*
* Return: true if the waiter is on some wait_queue.
*/
static inline bool vdo_is_waiting(struct waiter *waiter)
{
return (waiter->next_waiter != NULL);
}
/**
* initialize_wait_queue() - Initialize a wait queue.
* @queue: The queue to initialize.
*/
static inline void vdo_initialize_wait_queue(struct wait_queue *queue)
{
*queue = (struct wait_queue) {
.last_waiter = NULL,
.queue_length = 0,
};
}
/**
* has_waiters() - Check whether a wait queue has any entries waiting in it.
* @queue: The queue to query.
*
* Return: true if there are any waiters in the queue.
*/
static inline bool __must_check vdo_has_waiters(const struct wait_queue *queue)
{
return (queue->last_waiter != NULL);
}
void vdo_enqueue_waiter(struct wait_queue *queue, struct waiter *waiter);
void vdo_notify_all_waiters(struct wait_queue *queue, waiter_callback_fn callback,
void *context);
bool vdo_notify_next_waiter(struct wait_queue *queue, waiter_callback_fn callback,
void *context);
void vdo_transfer_all_waiters(struct wait_queue *from_queue,
struct wait_queue *to_queue);
struct waiter *vdo_get_first_waiter(const struct wait_queue *queue);
void vdo_dequeue_matching_waiters(struct wait_queue *queue, waiter_match_fn match_method,
void *match_context, struct wait_queue *matched_queue);
struct waiter *vdo_dequeue_next_waiter(struct wait_queue *queue);
/**
* count_waiters() - Count the number of waiters in a wait queue.
* @queue: The wait queue to query.
*
* Return: The number of waiters in the queue.
*/
static inline size_t __must_check vdo_count_waiters(const struct wait_queue *queue)
{
return queue->queue_length;
}
const struct waiter * __must_check vdo_get_next_waiter(const struct wait_queue *queue,
const struct waiter *waiter);
#endif /* VDO_WAIT_QUEUE_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment