SCSI subsystem initialization and exit on Linux-2.6 Platform

Source: Internet
Author: User

1. SCSI subsystem Initialization

The SCSI subsystem is always compiled to the Linux kernel, and its initialization entry function isInit_scsiIn the drivers/SCSI. c file. It is defined using the macro subsys_initcall.

Static int _ init init_scsi (void)
{
Int error;

Error = scsi_init_queue ();
// Initialize the storage pool required for the aggregation list.
If (error)
Return Error;
Error = scsi_init_procfs (); // initialize the SCSI-related directory in the proc file system
If (error)
Goto cleanup_queue;
Error = scsi_init_devinfo (); // sets the SCSI dynamic device information list.
If (error)
Goto cleanup_procfs;
Error = scsi_init_hosts (); // register the shost_class class. This will create the scsi_host subdirectory in the SYS/class/directory.
If (error)
Goto cleanup_devlist;
Error = scsi_init_sysctl (); // register the SCSI system control table
If (error)
Goto cleanup_hosts;

Error = scsi_sysfs_register ();
// Register the SCSI bus type and sdev_class class
If (error)
Goto cleanup_sysctl;

Scsi_netlink_init ();
// Initialize the SCSI transmission Netlink interface. Netlink is a mechanism for the Linux kernel to communicate with the user space.

Printk (kern_notice "SCSI subsystem initialized \ n ");
Return 0;

Cleanup_sysctl:
Scsi_exit_sysctl ();
Cleanup_hosts:
Scsi_exit_hosts ();
Cleanup_devlist:
Scsi_exit_devinfo ();
Cleanup_procfs:
Scsi_exit_procfs ();
Cleanup_queue:
Scsi_exit_queue ();
Printk (kern_err "SCSI subsystem failed to initialize, error = % d \ n ",
-Error );
Return Error;
}

2. Exit the SCSI subsystem exit_scsi.

Static void _ exit exit_scsi (void)
{
Scsi_netlink_exit ();
Scsi_sysfs_unregister ();
Scsi_exit_sysctl ();
Scsi_exit_hosts ();
Scsi_exit_devinfo ();
Scsi_exit_procfs ();
Scsi_exit_queue ();
}

 

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.