drivers/md/dm-pcache/backing_dev.h

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

File Facts

System
Linux kernel
Corpus path
drivers/md/dm-pcache/backing_dev.h
Extension
.h
Size
2950 bytes
Lines
128
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 pcache_backing_dev_req {
	u8				type;
	struct bio			bio;
	struct pcache_backing_dev	*backing_dev;

	void				*priv_data;
	backing_req_end_fn_t		end_req;

	struct list_head		node;
	int				ret;

	union {
		struct {
			struct pcache_request		*upper_req;
			u32				bio_off;
		} req;
		struct {
			struct bio_vec	inline_bvecs[BACKING_DEV_REQ_INLINE_BVECS];
			struct bio_vec	*bvecs;
			u32		n_vecs;
		} kmem;
	};
};

struct pcache_backing_dev {
	struct pcache_cache		*cache;

	struct dm_dev			*dm_dev;
	mempool_t			req_pool;
	mempool_t			bvec_pool;

	struct list_head		submit_list;
	spinlock_t			submit_lock;
	struct work_struct		req_submit_work;

	struct list_head		complete_list;
	spinlock_t			complete_lock;
	struct work_struct		req_complete_work;

	atomic_t			inflight_reqs;
	wait_queue_head_t		inflight_wq;

	u64				dev_size;
};

struct dm_pcache;
int backing_dev_start(struct dm_pcache *pcache);
void backing_dev_stop(struct dm_pcache *pcache);

struct pcache_backing_dev_req_opts {
	u32 type;
	union {
		struct {
			struct pcache_request *upper_req;
			u32 req_off;
			u32 len;
		} req;
		struct {
			void *data;
			blk_opf_t opf;
			u32 len;
			u64 backing_off;
		} kmem;
	};

	gfp_t gfp_mask;
	backing_req_end_fn_t	end_fn;
	void			*priv_data;
};

static inline u32 backing_dev_req_coalesced_max_len(const void *data, u32 len)
{
	const void *p = data;
	u32 done = 0, in_page, to_advance;
	struct page *first_page, *next_page;

	if (!is_vmalloc_addr(data))
		return len;

	first_page = vmalloc_to_page(p);
advance:
	in_page = PAGE_SIZE - offset_in_page(p);
	to_advance = min_t(u32, in_page, len - done);

	done += to_advance;
	p += to_advance;

	if (done == len)
		return done;

Annotation

Implementation Notes