Block drivers in linux

Block drivers in linux

LuckyAds поставлен 29.08.2022 —>

Наши партнеры

Библиотека сайта rus-linux.net

Linux Device Drivers, 2nd Edition

Chapter 12
Loading Block Drivers

Contents:

Registering the Driver

Figure 12-1. Registering a Block Device Driver

The Header File blk.h

Handling Requests: A Simple Introduction

The Request Queue

Performing the Actual Data Transfer

Handling Requests: The Detailed View

The sbull driver as described earlier works very well. In simple situations (as with sbull), the macros from can be used to easily set up a request function and get a working driver. As has already been mentioned, however, block drivers are often a performance-critical part of the kernel. Drivers based on the simple code shown earlier will likely not perform very well in many situations, and can also be a drag on the system as a whole. In this section we get into the details of how the I/O request queue works with an eye toward writing a faster, more efficient driver.

Читайте также:  Диск read only linux

The I/O Request Queue

The request structure and the buffer cache

Figure 12-2. Buffers in the I/O Request Queue

Request queue manipulation

The I/O request lock

How the blk.h macros and functions work

Clustered Requests

The active queue head

Multiqueue Block Drivers

Doing Without the Request Queue

How Mounting and Unmounting Works

The ioctl Method

Removable Devices

check_media_change

Revalidation

Extra Care

Partitionable Devices

The Generic Hard Disk

Partition Detection

 int spull_revalidate(kdev_t i_rdev) < /* first partition, # of partitions */ int part1 = (DEVICE_NR(i_rdev) 

Partition Detection Using initrd

The Device Methods for spull

 ptr = device->data + (spull_partitions[minor].start_sect + req->sector)*SPULL_HARDSECT; size = req->current_nr_sectors*SPULL_HARDSECT; /* * Make sure that the transfer fits within the device. */ if (req->sector + req->current_nr_sectors > spull_partitions[minor].nr_sects)

Interrupt-Driven Block Drivers

Backward Compatibility

Quick Reference

The most important functions and macros used in writing block drivers are summarized here. To save space, however, we do not list the fields of struct request , struct buffer_head , or struct genhd , and we omit the predefined ioctl commands.

#include int register_blkdev(unsigned int major, const char *name, struct block_device_operations *bdops); int unregister_blkdev(unsigned int major, const char *name);

Источник

Оцените статью
Adblock
detector