drivers/md/dm-vdo/vio.h

Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/vio.h

File Facts

System
Linux kernel
Corpus path
drivers/md/dm-vdo/vio.h
Extension
.h
Size
6490 bytes
Lines
207
Domain
Driver Families
Bucket
drivers/md
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct pooled_vio {
	/* The underlying vio */
	struct vio vio;
	/* The list entry for chaining pooled vios together */
	struct list_head list_entry;
	/* The context set by the pool */
	void *context;
	/* The list entry used by the pool */
	struct list_head pool_entry;
	/* The pool this vio is allocated from */
	struct vio_pool *pool;
};

/**
 * as_vio() - Convert a generic vdo_completion to a vio.
 * @completion: The completion to convert.
 *
 * Return: The completion as a vio.
 */
static inline struct vio *as_vio(struct vdo_completion *completion)
{
	vdo_assert_completion_type(completion, VIO_COMPLETION);
	return container_of(completion, struct vio, completion);
}

/**
 * get_vio_bio_zone_thread_id() - Get the thread id of the bio zone in which a vio should submit
 *                                its I/O.
 * @vio: The vio.
 *
 * Return: The id of the bio zone thread the vio should use.
 */
static inline thread_id_t __must_check get_vio_bio_zone_thread_id(struct vio *vio)
{
	return vio->completion.vdo->thread_config.bio_threads[vio->bio_zone];
}

physical_block_number_t __must_check pbn_from_vio_bio(struct bio *bio);

/**
 * assert_vio_in_bio_zone() - Check that a vio is running on the correct thread for its bio zone.
 * @vio: The vio to check.
 */
static inline void assert_vio_in_bio_zone(struct vio *vio)
{
	thread_id_t expected = get_vio_bio_zone_thread_id(vio);
	thread_id_t thread_id = vdo_get_callback_thread_id();

	VDO_ASSERT_LOG_ONLY((expected == thread_id),
			    "vio I/O for physical block %llu on thread %u, should be on bio zone thread %u",
			    (unsigned long long) pbn_from_vio_bio(vio->bio), thread_id,
			    expected);
}

int vdo_create_bio(struct bio **bio_ptr);
void vdo_free_bio(struct bio *bio);
int allocate_vio_components(struct vdo *vdo, enum vio_type vio_type,
			    enum vio_priority priority, void *parent,
			    unsigned int block_count, char *data, struct vio *vio);
int __must_check create_multi_block_metadata_vio(struct vdo *vdo, enum vio_type vio_type,
						 enum vio_priority priority,
						 void *parent, unsigned int block_count,
						 char *data, struct vio **vio_ptr);

static inline int __must_check create_metadata_vio(struct vdo *vdo, enum vio_type vio_type,
						   enum vio_priority priority,
						   void *parent, char *data,
						   struct vio **vio_ptr)
{
	return create_multi_block_metadata_vio(vdo, vio_type, priority, parent, 1, data,
					       vio_ptr);
}

void free_vio_components(struct vio *vio);
void free_vio(struct vio *vio);

/**
 * initialize_vio() - Initialize a vio.
 * @vio: The vio to initialize.
 * @bio: The bio this vio should use for its I/O.
 * @block_count: The size of this vio in vdo blocks.
 * @vio_type: The vio type.
 * @priority: The relative priority of the vio.
 * @vdo: The vdo for this vio.
 */
static inline void initialize_vio(struct vio *vio, struct bio *bio,
				  unsigned int block_count, enum vio_type vio_type,
				  enum vio_priority priority, struct vdo *vdo)
{
	/* data_vio's may not span multiple blocks */

Annotation

Implementation Notes