Skip to content

Block Devices

include/block/block.h View source View on GitHub
struct partition (8 fields) source
§ struct block_device *disk
§ uint64_t start_lba
§ uint64_t sector_count
§ enum fs_type fs_type
§ void *fs_data
§ char name[16]
§ bool mounted
§ struct vfs_node *(*mount)(struct partition *)
struct block_device (17 fields) source
§ enum bdev_flags flags
§ enum bdev_type type
§ enum fs_type fs_type
§ void *fs_data
§ char name[16]
§ uint64_t total_sectors
§ bool is_removable
§ void *driver_data
§ uint32_t sector_size
§ bool (*read_sector)(struct block_device *disk, uint64_t lba, uint8_t *buffer, uint64_t sector_count)

both of these take full priority over the async operations. do not pass go, do not collect two hundred dollars, submit instantly.

these are sync and blocking

these are not used in many areas though, and such, we can get away with instant submission for the most part

§ bool (*write_sector)(struct block_device *disk, uint64_t lba, const uint8_t *buffer, uint64_t sector_count)
§ bool (*submit_bio_async)(struct block_device *disk, struct bio_request *bio)

immediate asynchronous submission

§ struct bio_scheduler_ops *ops
§ struct bio_scheduler *scheduler
§ struct bcache *cache
§ uint64_t partition_count
§ struct partition *partitions cc_counted_by(partition_count)
enum bdev_type (4 variants) source
§ BDEV_IDE_DRIVE
§ BDEV_NVME_DRIVE
§ BDEV_AHCI_DRIVE
§ BDEV_ATAPI_DRIVE
enum bdev_flags (3 variants) source
§ BDEV_FLAG_NO_REORDER = 1

queue reordering is skipped

§ BDEV_FLAG_NO_COALESCE = 1 << 1

coalescing is skipped

§ BDEV_FLAG_NO_SCHED = 1 << 2

scheduling doesn’t happen. this will just call sync requests, and immediately trigger the callback - used in things like RAMdisk.

const char * get_block_device_str(enum bdev_type type)
source
bool bdev_skip_coalesce(struct block_device *disk)
source
bool bdev_skip_sched(struct block_device *disk)
source
bool bdev_skip_reorder(struct block_device *disk)
source