drivers/block/drbd/drbd_req.h

Source file repositories/reference/linux-study-clean/drivers/block/drbd/drbd_req.h

File Facts

System
Linux kernel
Corpus path
drivers/block/drbd/drbd_req.h
Extension
.h
Size
10577 bytes
Lines
325
Domain
Driver Families
Bucket
drivers/block
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 bio_and_error {
	struct bio *bio;
	int error;
};

extern void start_new_tl_epoch(struct drbd_connection *connection);
extern void drbd_req_destroy(struct kref *kref);
extern int __req_mod(struct drbd_request *req, enum drbd_req_event what,
		struct drbd_peer_device *peer_device,
		struct bio_and_error *m);
extern void complete_master_bio(struct drbd_device *device,
		struct bio_and_error *m);
extern void request_timer_fn(struct timer_list *t);
extern void tl_restart(struct drbd_connection *connection, enum drbd_req_event what);
extern void _tl_restart(struct drbd_connection *connection, enum drbd_req_event what);
extern void tl_abort_disk_io(struct drbd_device *device);

/* this is in drbd_main.c */
extern void drbd_restart_request(struct drbd_request *req);

/* use this if you don't want to deal with calling complete_master_bio()
 * outside the spinlock, e.g. when walking some list on cleanup. */
static inline int _req_mod(struct drbd_request *req, enum drbd_req_event what,
		struct drbd_peer_device *peer_device)
{
	struct drbd_device *device = req->device;
	struct bio_and_error m;
	int rv;

	/* __req_mod possibly frees req, do not touch req after that! */
	rv = __req_mod(req, what, peer_device, &m);
	if (m.bio)
		complete_master_bio(device, &m);

	return rv;
}

/* completion of master bio is outside of our spinlock.
 * We still may or may not be inside some irqs disabled section
 * of the lower level driver completion callback, so we need to
 * spin_lock_irqsave here. */
static inline int req_mod(struct drbd_request *req,
		enum drbd_req_event what,
		struct drbd_peer_device *peer_device)
{
	unsigned long flags;
	struct drbd_device *device = req->device;
	struct bio_and_error m;
	int rv;

	spin_lock_irqsave(&device->resource->req_lock, flags);
	rv = __req_mod(req, what, peer_device, &m);
	spin_unlock_irqrestore(&device->resource->req_lock, flags);

	if (m.bio)
		complete_master_bio(device, &m);

	return rv;
}

extern bool drbd_should_do_remote(union drbd_dev_state);

#endif

Annotation

Implementation Notes