drivers/md/dm-exception-store.h

Source file repositories/reference/linux-study-clean/drivers/md/dm-exception-store.h

File Facts

System
Linux kernel
Corpus path
drivers/md/dm-exception-store.h
Extension
.h
Size
5435 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 dm_exception {
	struct hlist_node hash_list;

	chunk_t old_chunk;
	chunk_t new_chunk;
};

/*
 * Abstraction to handle the meta/layout of exception stores (the
 * COW device).
 */
struct dm_exception_store;
struct dm_exception_store_type {
	const char *name;
	struct module *module;

	int (*ctr)(struct dm_exception_store *store, char *options);

	/*
	 * Destroys this object when you've finished with it.
	 */
	void (*dtr)(struct dm_exception_store *store);

	/*
	 * The target shouldn't read the COW device until this is
	 * called.  As exceptions are read from the COW, they are
	 * reported back via the callback.
	 */
	int (*read_metadata)(struct dm_exception_store *store,
			     int (*callback)(void *callback_context,
					     chunk_t old, chunk_t new),
			     void *callback_context);

	/*
	 * Find somewhere to store the next exception.
	 */
	int (*prepare_exception)(struct dm_exception_store *store,
				 struct dm_exception *e);

	/*
	 * Update the metadata with this exception.
	 */
	void (*commit_exception)(struct dm_exception_store *store,
				 struct dm_exception *e, int valid,
				 void (*callback)(void *, int success),
				 void *callback_context);

	/*
	 * Returns 0 if the exception store is empty.
	 *
	 * If there are exceptions still to be merged, sets
	 * *last_old_chunk and *last_new_chunk to the most recent
	 * still-to-be-merged chunk and returns the number of
	 * consecutive previous ones.
	 */
	int (*prepare_merge)(struct dm_exception_store *store,
			     chunk_t *last_old_chunk, chunk_t *last_new_chunk);

	/*
	 * Clear the last n exceptions.
	 * nr_merged must be <= the value returned by prepare_merge.
	 */
	int (*commit_merge)(struct dm_exception_store *store, int nr_merged);

	/*
	 * The snapshot is invalid, note this in the metadata.
	 */
	void (*drop_snapshot)(struct dm_exception_store *store);

	unsigned int (*status)(struct dm_exception_store *store,
			       status_type_t status, char *result,
			       unsigned int maxlen);

	/*
	 * Return how full the snapshot is.
	 */
	void (*usage)(struct dm_exception_store *store,
		      sector_t *total_sectors, sector_t *sectors_allocated,
		      sector_t *metadata_sectors);

	/* For internal device-mapper use only. */
	struct list_head list;
};

struct dm_snapshot;

struct dm_exception_store {
	struct dm_exception_store_type *type;
	struct dm_snapshot *snap;

Annotation

Implementation Notes