Difference between revisions of "Documentation/DnodeSync"

Jump to navigation Jump to search
Line 23: Line 23:
''dnode_sync'' starts by handling special cases, some of which use the ''dn_next_'' fields described in the previous paragraph. For example, if this is a newly allocated dnode being synced to disk (i.e. ''dn->dn_allocated_txg == tx->tx_txg'') then the ''dnode_phys_t'' object we'll be writing out must be populated with basic information on the type of the dnode, the number of levels, the blocks it has, etc. There are also special checks for changes in the block size of this dnode, the type, the length of the bonus buffer, or the type of the bonus buffer, among others.
''dnode_sync'' starts by handling special cases, some of which use the ''dn_next_'' fields described in the previous paragraph. For example, if this is a newly allocated dnode being synced to disk (i.e. ''dn->dn_allocated_txg == tx->tx_txg'') then the ''dnode_phys_t'' object we'll be writing out must be populated with basic information on the type of the dnode, the number of levels, the blocks it has, etc. There are also special checks for changes in the block size of this dnode, the type, the length of the bonus buffer, or the type of the bonus buffer, among others.


The core of dnode_sync starts with a loop iterating over the ''dn_ranges'' for the current TXG.
The core of dnode_sync starts with a loop iterating over the ''dn_ranges'' for the current TXG. ''dn_ranges'' stores a AVL tree of the ranges in the file which have been freed in each TXG. These ranges are defined by a ''free_range_t'' object, which stores the block ID of the first block freed, and the number of blocks freed. ''dnode_sync'' calls ''dnode_sync_free_range'' on each of these ranges, which we'll take a look at in more detail later. Once the freeing of that range has completed, it is removed from ''dn_ranges''.
 
After issuing frees for each freed range in a dnode, ''dnode_sync'' checks if this sync is also performing a free of the dnode itself (i.e. ''dn->dn_free_txg <= tx->tx_txg''). If so, ''dnode_sync'' immediately calls ''dnode_sync_free" and returns.
 
However, if we aren't freeing the dnode (which is commonly the case) ''dnode_sync'' goes on to finally sync the dirty in-memory buffers for this dnode to disk. It does this with a call to ''dbuf_sync_list'' on a list of dirty records for the current dnode in the current TXG (stored as ''dbuf_dirty_record_t''s).
Editor
90

edits

Navigation menu