drivers/md/dm-vdo/vdo.h

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

File Facts

System
Linux kernel
Corpus path
drivers/md/dm-vdo/vdo.h
Extension
.h
Size
11646 bytes
Lines
384
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 read_only_listener {
	/* The listener */
	void *listener;
	/* The method to call to notify the listener */
	vdo_read_only_notification_fn notify;
	/* A pointer to the next listener */
	struct read_only_listener *next;
};

struct vdo_thread {
	struct vdo *vdo;
	thread_id_t thread_id;
	struct vdo_work_queue *queue;
	/*
	 * Each thread maintains its own notion of whether the VDO is read-only so that the
	 * read-only state can be checked from any base thread without worrying about
	 * synchronization or thread safety. This does mean that knowledge of the VDO going
	 * read-only does not occur simultaneously across the VDO's threads, but that does not seem
	 * to cause any problems.
	 */
	bool is_read_only;
	/*
	 * A list of objects waiting to be notified on this thread that the VDO has entered
	 * read-only mode.
	 */
	struct read_only_listener *listeners;
	struct registered_thread allocating_thread;
};

/* Keep struct bio statistics atomically */
struct atomic_bio_stats {
	atomic64_t read; /* Number of not REQ_WRITE bios */
	atomic64_t write; /* Number of REQ_WRITE bios */
	atomic64_t discard; /* Number of REQ_DISCARD bios */
	atomic64_t flush; /* Number of REQ_FLUSH bios */
	atomic64_t empty_flush; /* Number of REQ_PREFLUSH bios without data */
	atomic64_t fua; /* Number of REQ_FUA bios */
};

/* Counters are atomic since updates can arrive concurrently from arbitrary threads. */
struct atomic_statistics {
	atomic64_t bios_submitted;
	atomic64_t bios_completed;
	atomic64_t flush_out;
	atomic64_t invalid_advice_pbn_count;
	atomic64_t no_space_error_count;
	atomic64_t read_only_error_count;
	struct atomic_bio_stats bios_in;
	struct atomic_bio_stats bios_in_partial;
	struct atomic_bio_stats bios_out;
	struct atomic_bio_stats bios_out_completed;
	struct atomic_bio_stats bios_acknowledged;
	struct atomic_bio_stats bios_acknowledged_partial;
	struct atomic_bio_stats bios_meta;
	struct atomic_bio_stats bios_meta_completed;
	struct atomic_bio_stats bios_journal;
	struct atomic_bio_stats bios_journal_completed;
	struct atomic_bio_stats bios_page_cache;
	struct atomic_bio_stats bios_page_cache_completed;
};

struct read_only_notifier {
	/* The completion for entering read-only mode */
	struct vdo_completion completion;
	/* A completion waiting for notifications to be drained or enabled */
	struct vdo_completion *waiter;
	/* Lock to protect the next two fields */
	spinlock_t lock;
	/* The code of the error which put the VDO into read-only mode */
	int read_only_error;
	/* The current state of the notifier (values described above) */
	enum notifier_state state;
};

/*
 * 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 ((thread_id_t) -1)

struct thread_config {
	zone_count_t logical_zone_count;
	zone_count_t physical_zone_count;
	zone_count_t hash_zone_count;
	thread_count_t bio_thread_count;
	thread_count_t thread_count;
	thread_id_t admin_thread;
	thread_id_t journal_thread;
	thread_id_t packer_thread;
	thread_id_t dedupe_thread;

Annotation

Implementation Notes