Skip to content

Block I/O Requests

include/block/bio.h View source View on GitHub
struct bio_request (19 fields) source

everything WITHOUT the / const / comment next to it can be changed by the scheduler during optimizations

REQUIRED to be set by sender

§ enum bio_request_priority priority

starting priority - can get boosted

§ struct block_device *disk
§ uint64_t lba
§ void *buffer
§ uint64_t size

buffer size in bytes

§ uint64_t sector_count

sectors to read/write

§ bool write

OPTIONALLY set by sender

§ void (*on_complete)(struct bio_request *)
§ void *user_data
§ volatile bool done

set upon completion

§ enum bio_request_status status
§ void *driver_private
§ void *driver_private2
§ struct list_node list
§ bool skip

coalescing

§ bool is_aggregate
§ struct bio_request *next_coalesced
§ uint64_t enqueue_time

priority boosted to URGENT after enough waiting around

§ uint8_t boost_count

boosts are accelerated if it boosts often

enum bio_request_priority (5 variants) source

urgent requests bypass the bio_scheduler, they get submitted immediately

§ BIO_RQ_BACKGROUND = 0
§ BIO_RQ_LOW = 1
§ BIO_RQ_MEDIUM = 2
§ BIO_RQ_HIGH = 3
§ BIO_RQ_URGENT = 4
enum bio_request_status : int32_t (13 variants) source
§ BIO_STATUS_OK = 0
§ BIO_STATUS_INFLIGHT = -1
§ BIO_STATUS_INVAL_ARG = -2
§ BIO_STATUS_INVAL_INTERNAL = -3
§ BIO_STATUS_TIMEOUT = -4
§ BIO_STATUS_DEVICE_FAULT = -5
§ BIO_STATUS_UNCORRECTABLE = -6
§ BIO_STATUS_ABRT = -7
§ BIO_STATUS_MEDIA_CHANGE = -8
§ BIO_STATUS_ID_NOT_FOUND = -9
§ BIO_STATUS_BAD_SECTOR = -10
§ BIO_STATUS_WRITE_PROTECT = -11
§ BIO_STATUS_UNKNOWN_ERR = -12
struct bio_request * bio_create_write(
    struct block_device *d,
    uint64_t lba,
    uint64_t sectors,
    uint64_t size,
    void (*cb)(struct bio_request *),
    void *user,
    void *buf
)
source
struct bio_request * bio_create_read(
    struct block_device *d,
    uint64_t lba,
    uint64_t sectors,
    uint64_t size,
    void (*cb)(struct bio_request *),
    void *user,
    void *buf
)
source
void bio_request_free(struct bio_request *req)
source
#define bio_request_from_list_node(ln)
source
Expansion
#define bio_request_from_list_node(ln) \
    (container_of(ln, struct bio_request, list))