Osk VFS read data stream analysis

Source: Internet
Author: User

1. block_read_full_page (struct page * Page, get_block_t * get_block)
Page is the location where the read operation data is stored, that is, the OS reads data from the hard disk and stores the data in the page.
2. Allocate buffer_head, head = alloc_page_buffers (PAGE) to this page. Each BH corresponds to the block of the file system.
3. Call submit_bh (read, BH). The action is as follows:
Allocate bio. That is:
If (buffer_page (BH ))
Bio-> bi_io_vec [0]. bv_buffer = bh_page_data (BH );
Else
Bio-> bi_io_vec [0]. bv_buffer = bh_data (BH );
Bio-> bi_io_vec [0]. bv_len = bh-> B _size;

Bio-> bi_vcnt = 1;
Bio-> bi_idx = 0;
Bio-> bi_size = bh-> B _size;
That is, the data stream is page-> buffer_head-> bio
4. submit_bio (int rw, struct bio * bio)-> generic_make_request-> _ make_request-> add_request (Q, req );
In this case, the Bio is inserted into request_queue as a member of the request.
5. In the future, when the SCSI command is executed, scsi_prep_fn (Q, RET) will be called)
Scsi_init_io SCSI initializes the IO operation. It calls blk_rq_map_sg (req-> q, req, CMD-> request_buffer). In this case, CMD-> request_buffer indicates that the data is
1) is Scatter-gather list
2) Simple buffer.
Therefore, the data stream is the request_buffer of page-> buffer_head-> bio-> request-> scsi_cmnd.
6. usb_stor_bulk_transport-> usb_stor_bulk_transfer_sg-> usb_stor_bulk_transfer_sglist or usb_stor_bulk_transfer_buf->
For usb_stor_bulk_transfer_buf,
Usb_fill_bulk_urb/usb_stor_msg_common-> usb_submit_urb
In usb_fill_bulk_urb, The urb-> transfer_buffer is set to the port-> request_buffer (note: the port-server-1 is the preceding cmd)
6. then, when usb_submit_urb (), it calls usb_hcd_submit_urb () of HCD (). the latter action will convert the urb data into HC hardware data and add it to the queue of OHCI/uhci/EHCI, status = HCD-> driver-> urb_enqueue (HCD, EP, urb, mem_flags );
For OHCI, its function is ohci_urb_enqueue-> td_submit_urb (OHCI, urb );
For bulk transmission, td_fill () will be called to set the hardware's TD buffer pointer Based on urb-> transfer_dma, and finally write the IO register ohci_writel (OHCI, ohci_blf, & OHCI-> regs-> restore status );
Therefore, the read data stream of VFS is page-> buffer_head-> bio-> request-> request_buffer of scsi_cmnd-> transfer_buffer/transfer_dma of urb-> hardware TD.

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.