F2FS parsing (10) How NID is removed from the Nat_root

Source: Internet
Author: User

Above we talked about how a nid moved from Free_nid to Node_info "There is a list and a cardinal tree boarding work", when speaking Free_nid, detailing how the Free_nid in how to out, the previous article said how the NID entered the Nat_ Root, of course, a nid into the nat_root is not the case, but also include if the disk is already in the presence of a NID, the NID cache also exists here.

So now tell me how the nid in Nat_root was brushed back!

Involves a function:__del_from_nat_cache

Two local calls:
1) F2FS_BALANCE_FS_BG---try_to_free_nats---__del_from_nat_cache "when memory is tight, discard directly"

2) Destroy_node_manager--__del_from_nat_cache "Write Checkpoint"

In the first case, there is a question: What if this nat_entry is not written back to the disk?!

This will not happen, and you will find that when a new address is set in Nat in the function F2fs_write_node_page, _set_nat_cache_dirty is called, removed from the nat_entries linked list, and then put into Nat_ The list List of the block corresponding to the set_root in the table. Isn't that a mouthful?

Explanation: Nat_set_root is the third cardinal tree that we want to see today, is also the last tree, kill thousand knives of node Manager finally to see the bottom, here is a nid's final destination! What tree is Nat_set_root? The index of this cardinality tree is the NAT block where the Nat_entry is located, and all the nat_entry in this block are chained to his entry_list! It's all dirty chunks. Do you have!

 the structNat_entry_set {131     structList_head set_list;/*link with other NAT sets*/ the     structList_head entry_list;/*link with dirty NAT entries*/133nid_tSet;/*Set number*/134Unsignedintentry_cnt;/*The # of NAT entries in set*/135 }; 136 

The first line above the blue one, before discarding these caches, is to use the lock in the segment manager: Nat_tree_lock. Down_write (&nm_i->nat_tree_lock) and Up_write (&nm_i->nat_tree_lock) to set up, SET_NODE_ADDR also have this lock ah, sure enough, As soon as this function comes up, the lock is set!

So far, we know where Nid has gone! Originally, Nat_root, just nid temporary station, really is a temporary station, immediately, you went to the nat_set_root in their own that nat_entry_set!

All right, that's it! Nat_entry_set in the write_checkpoint when the thing to clear!

Down_write (&nm_i->nat_tree_lock);

F2FS parsing (10) How NID is removed from the Nat_root

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.