Bitmap source code Analysis in MD--state machine instance

Source: Internet
Author: User

1. The state transition relationship of Page_attrs

Previously said, bitmap optimization core is: Bitmap set after the batch write; bitmap delay cleanup. Write bit with bitmap_statrwrite () + bitmap_unplug () two functions, to Achieve the bitmap set after the batch write; Bitmap_endwrite () + Two-wheel bitmap_deamon_work () enables bitmap delay cleanup.

2. An example analysis

The following is a write request instance for analysis. Assuming that the previous chunk data are consistent, or to write 3*4096*8 (3 page) chunk data, the entire disk array only 1 write requests, the analysis example is as follows 5 steps:

1. RAID1 make_request () receives this write request, executes Bitmap_startwrite (), and then activates the daemon after the write bio is hung on the pending_list. Bitmap_startwrite () Set Bitmap File of this 3 a page the page property is Bitmap_page_dirty, each bit corresponds to the *BMC set to 2, immediately *bmc++, at this time these *BMC = 3.

2. After activating the daemon, execute bitmap_unplug ()and traverse all the page of the bitmap file cache before the daemon sends a write request, because only these 3 page properties are bitmap_page_dirty. So just manipulate these 3 page. In page, swipe the 3 - page bit to disk Bitmap file, clears page Property bitmap_page_dirtyfor each page. wait bit after the brush disk is completely finished, write Bio issued .

3, when the last write bio successful callback, execute bitmap_endwrite (), for the 3 page corresponding to each bit of *BMC decrement, at this time these *BMC = 2. will be 3 a page the page property is set to Bitmap_page_clean.

4. When the daemon executes, call bitmap_daemon_work ()and traverse the entire bitmap file cache. Set the *bmc for each bit of the 3 page to 1, and then add bitmap_page_needwrite to the 3 page. Page Properties .

5. When the daemon executes again, call bitmap_daemon_work ()again to traverse the entire bitmap file cache. For these 3 page properties bitmap_page_clean cleared , the corresponding *BMC for each bit is set to 0,bit Clear 0 , 3 page Properties bitmap_page_ needwrite erase , BITMAP to disk for 3-page bit .

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

Bitmap source code Analysis in MD--state machine instance

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.