Backward Compatibility
Much has changed with the block device layer, and most of those changes happened between the 2.2 and 2.4 stable releases. Here is a quick summary of what was different before. As always, you can look at the drivers in the sample source, which work on 2.0, 2.2, and 2.4, to see how the portability challenges have been handled.
The block_device_operations structure did not exist
in Linux 2.2. Instead, block drivers used a
file_operations structure just like char drivers.
The check_media_change and
revalidate methods used to be a part of that
structure. The kernel also provided a set of generic
functions—block_read,
block_write, and
block_fsync—which most drivers used in
their file_operations structures. A typical 2.2 or
2.0 file_operations initialization looked like
this:
struct file_operations sbull_bdops = {
read: block_read,
write: block_write,
ioctl: sbull_ioctl,
open: sbull_open,
release: sbull_release,
fsync: block_fsync,
check_media_change: sbull_check_change,
revalidate: sbull_revalidate
};
Note that block drivers are subject to the same changes in the
file_operations prototypes between 2.0 and 2.2 as
char drivers.
In 2.2 and previous kernels, the request function
was stored in the blk_dev global array.
Initialization required a line like
blk_dev[major].request_fn = sbull_request;
Because this method allows for only one queue per major number, the multiqueue capability of 2.4 kernels is not present in earlier releases. Because there was only ...