Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 6: Device Drivers


enum rq_cmd_type_bits cmd_type;
...
sector_t sector; /* next sector to submit */
sector_t hard_sector; /* next sector to complete */
unsigned long nr_sectors; /* no. of sectors left to submit */
unsigned long hard_nr_sectors; /* no. of sectors left to complete */
/* no. of sectors left to submit in the current segment */
unsigned int current_nr_sectors;

/* no. of sectors left to complete in the current segment */
unsigned int hard_cur_sectors;

struct bio *bio;
struct bio *biotail;
...
void *elevator_private;
void *elevator_private2;

struct gendisk *rq_disk;
unsigned long start_time;

unsigned short nr_phys_segments;
unsigned short nr_hw_segments;
...
unsigned int cmd_len;
...
};

The very nature of a request is to be kept on a request queue. Such queues are implemented using doubly
linked lists, andqueuelistprovides the required list element.^10 qpoints back to the request queue to
which the request belongs, if any.

Once a request is completed, that is, when all required I/O operations have been performed, it can be
queued on a completed list, anddonelistprovides the necessary list element.

The structure includes three elements to indicate the exact position of the data to be transferred.

❑ sectorspecifies the start sector at which data transfer begins.
❑ current_nr_sectorsindicates the number of sectors to transfer for the current request.
❑ nr_sectorsspecifies the number of sector requests still pending.

hard_sector,hard_cur_sectors,andhard_nr_sectorshave the same meaning but relate to the actual
hardware and not to a virtual device. Usually, both variable collections have the same values, but dif-
ferences may occur when RAID or the Logical Volume Manager is used because these combine several
physical devices into a single virtual device.

When scatter-gather operations are used,nr_phys_segmentsandnr_hw_segmentsspecify, respectively,
the number of segments in a request and the number of segments used after possible re-sorting by an
I/O MMU.

(^10) This is only necessary for asynchronous request completion. Normally the list is not required.

Free download pdf