Disk scan process description in Linux

Source: Internet
Author: User
Article Title: Description of the disk scan process in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Usually, SCSI bus adapters exist as PCI devices. The locations in the computer architecture are shown in:


Location of scis host and device in Computer Architecture

During system initialization, the system PCI bus is scanned. Because the scsi host adapter is attached to the pci bus, it is scanned by the pci scanning software and a pci device (PDO) is generated ). Then the scanning software needs to load the corresponding driver for the pci device. In linux, traverse all the drivers on the pci bus and check whether there are qualified drivers. If the scsi host is a marwell device, if the scsi host driver provided by marwell exists, it will be called successfully. When the scsi host driver is loaded, the pci scanner calls the probe function provided by the scsi host driver, the probe function is registered on the pci-driver when the scsi host driver initializes the driver (this approach is used for Linux bus drivers ). In the specific probe function of the scsi host, the scsi host is initialized, the interrupt processing function is registered, and a scsi host is generated by calling the scsi_host_alloc function, and then added to the scsi middle level, finally, call the scsi_scan_host function to scan all scsi buses managed by the scsi host adapter.

A scsi host adapter may have multiple channels, and each channel has a scsi bus. The traditional scsi bus is a parallel shared bus. The existing P2P interfaces such as SATA and SAS can be understood as a special case of the bus logically. Therefore, the scsi middle level driver is common. Because a scsi host may have multiple channels, each channel is scanned in sequence. According to the spec, a traditional scsi bus can connect up to 16 scsi targets. Therefore, the scsi scanner will detect the targets in sequence. A scsi target can have multiple functions. Each function is called LUN. For a single-Function Device (such as a disk), its LUN is usually 0.

The following pseudo code can be used to describe the Scsi host scan process:

For (channel = 0; channel <max_channel; channel ++ ){

/* Identify the devices in each channel of an adapter */

...

For (id = 0; id

/* Identify the device corresponding to each ID in a channel */

...

For (lun = 1; lun

/* Identify each LUN of the device corresponding to an ID */

...

}

}

}

The preceding scan process shows that a scsi device can be described as follows in the system: host_id: channel_id: target_id: lun_id

The host_id is dynamically allocated by the system, which is related to the scanning sequence of the PCI bus. The scanning results of the system host_id of the fixed hardware will not change. However, if a scsi host (PCI device) is added dynamically, The host_id of the system may change.

Related Article

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.