Linux kernel MD Source code interpretation of the process of four command character Run_array

Source: Internet
Author: User
Tags goto

Running the array means that the array goes from scratch, establishes the attributes (such as synchronous reconstruction) that should be used as a raid, and paves the ground for subsequent reads and writes. So what did you do when you ran the array, making the original disk a new Big Mac like a transformer? Now let's look at the array run process:

5158 static int Do_md_run (struct Mddev *mddev)  
5159 {  
5160         int err;  
5161   
5162         err = Md_run (Mddev);  
5163         if (err)  
5164                 goto out;  
5165         err = bitmap_load (Mddev);  
5166         if (err) {  
5167                 Bitmap_destroy (mddev);  
5168                 goto out;  
5169         }  
5170   
5171         md_wakeup_thread (mddev->thread);  
5172         Md_wakeup_thread (mddev->sync_thread);/* Possibly kick off a reshape */5173 5174 set_capacity         ( Mddev->gendisk, mddev->array_sectors);  
5175         Revalidate_disk (mddev->gendisk);  
5176         mddev->changed = 1;  
5177         kobject_uevent (&disk_to_dev (Mddev->gendisk)->kobj, kobj_change);  
5178 out:  
5179 return         err;  
5180}

If the process of running an array is a book, then this function is the directory of the book, each containing a profound story.

5162 lines, Md_run run the array, this function is relatively long, we follow a paragraph to analyze:

4956 int Md_run (struct Mddev *mddev)  
4957 {  
4958         int err;  
4959         struct Md_rdev *rdev;  
4960         struct md_personality *pers;  
4961   
4962         if (List_empty (&mddev->disks))  
4963/                 * cannot run an array with no devices. * *
4964                 return-einval;  
4965   
4966         if (mddev->pers)  
4967                 return-ebusy;  
4968         /* cannot run until previous stop completes properly         /4969 if (mddev->sysfs_active)  
4970< C25/>return-ebusy;  
4971   
4972         /          * 4973 * Analyze all RAID superblock (s) 
4974/
4975         if (!mddev- >raid_disks) {  
4976                 if (!mddev->persistent)  
4977                         return-einval;  
4978                 Analyze_sbs (mddev);  
4979         }

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.