Bitmap source code Analysis in MD--clear process

Source: Internet
Author: User

Bitmap's Qing 0 is implemented by Bitmap_daemon_work (). The RAID1 daemon calls Md_check_recovery when it executes periodically, and Md_check_recovery calls Bitmap_daemon_work to clear the operations based on various states. The implementation of Bitmap_daemon_work is quite complex, and Bitmap cleanup requires two calls to Bitmap_daemon_work. The following mainly in the form of a diagram to gradually analyze the whole process of bitmap clearance.

When you first enter this function, the memory bitmap file's page bitmap_attr is set to Bitmap_page_clean.

Each entry Bitmap_daemon_work first to determine whether the function sleeps enough, if not enough to sleep, then return directly. This sleep is for a certain time to see within the write Disk operation centralized batch processing. To achieve the effect of the asynchronous brush disk, the Bitmap_daemon_work function does two rounds to complete the bit cleanup.

First time The role of bitmap_daemon_work () :

    1. Bitmap_page_clean clears all memory bitmap The Bitmap_attr property of the file page;
    2. Set the Bit page property to Bitmap_page_clean and Bitmap_page_needwrite;
    3. The *BMC value that corresponds to each bit that is processed is set to 1.

second time bitmap_daemon_work () the role of:

    1. Clears all memory bitmap the page bitmap_attr property of file Bitmap_page_clean;
    2. Bit corresponds to the *BMC set to 0;
    3. Bit clear 0;
    4. Clears the bitmap_attr attribute bitmap_page_needwrite;
    5. Bitmap the bitmap file for a page is brushed to disk at a time.

Regardless of which entry bitmap_daemon_work (), the processing process is in page to the bitmap file cache processing, from the first page to the last page, as a cycle traverse all the page. Within the page, each bit and corresponding chunk is processed, and the first chunk is processed to the last chunk.

The specific processing process is shown in the following pictures, note that the meaning of the lastpage may be different, has been in the plot, need to pay attention to the sequence of each step, Bitmap_attr property settings, Bitmap brush the time of the disk, each processing bitmap The different page of file has been marked with a red box.

The advantage of this asynchronous zeroing mechanism is that when it is not clear 0 or the memory bitmap cleared 0 But there is no brush to the disk, and there is a write request to the page, just add the BMC counter or just set the memory bitmap, instead of writing to the external memory bitmap file, thus reducing the IO of a write external memory bitmap. In addition, bit clear 0 does not need to rush to do, asynchronous can make the system resources to deal with more important process.

......

......

......

......

......

......

Reprint Please specify source: http://www.cnblogs.com/fangpei/

Bitmap source code Analysis in MD--clear process

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.