BBB SDK6 Ll_rw_block Analysis

Source: Internet
Author: User

Ll_rw_block is the file system to access the actual block device-driven interface, the application of the actual file (non-device files) operation, and ultimately are

The Ll_rw_block is invoked through the file system to manipulate the actual storage device.

Of course, the actual role of Ll_rw_block is far from an interface so simple, he has maintained a read-write request queue, and read and write requests in the queue

optimization, for example, for the mechanical hard disk, the use of the elevator algorithm, the queue of read and write requests to optimize, sort, merge and other operations, improve the

The efficiency of accessing the hard disk. After optimization, the actual block device driver is finally called to operate the real storage device.

Below, with BBB's TI official Linux source code (SDK6) to probably will ll_rw_block the process to write, lest forget.

void Ll_rw_block (int rw, int nr, struct buffer_head *bhs[])//FS/BUFFER.C

{

RW is a read-write flag, NR is the length of the BHS array, BHS is the information array, source, purpose, length of the actual data to be written.

for (i = 0; i < nr; i++) {
struct Buffer_head *bh = bhs[i];
if (rw = = WRITE) {
SUBMIT_BH (WRITE, BH); Submit Write Request
} else {
SUBMIT_BH (rw, BH); Submit a read request
}
}

}


int submit_bh (int rw, struct buffer_head * bh)//FS/BUFFER.C

{
struct bio *bio;

This omits a series of code that uses BH to construct the bio, and finally commits the bio
Bio_get (bio);
Submit_bio (rw, bio); Submit Bio
}


void Submit_bio (int rw, struct bio *bio)//block/blk-core.c
{
Generic_make_request (bio); Using bio to construct requests
}


void Generic_make_request (struct bio *bio)//block/blk-core.c
{
struct Request_queue *q = Bdev_get_queue (Bio->bi_bdev); Get request queue

Q->MAKE_REQUEST_FN (q, bio); Call the MAKE_REQUEST_FN of the request queue
}


The MAKE_REQUEST_FN function is defined as follows:

void Blk_queue_bio (struct request_queue *q, struct bio *bio)//block/blk-core.c
{
El_ret = Elv_merge (q, &req, bio); Call the elevator algorithm to optimize the processing of read and write operations
__blk_run_queue (q); Look underneath.
}


void __blk_run_queue (struct request_queue *q)//block/blk-core.c
{
Q->REQUEST_FN (q); Here the final call to the REQUEST_FN function of the request queue for real disk operation
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.